Commit 6e1cf7c2 authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI cr-toggle: Use native 'click' event instead of synthetic 'tap'.

Bug: 812035
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I3fefd8951f9c28b00e98f1a42edaa9d24e5e5856
Reviewed-on: https://chromium-review.googlesource.com/944045
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542269}
parent 346ac2e2
...@@ -26,7 +26,7 @@ Polymer({ ...@@ -26,7 +26,7 @@ Polymer({
}, },
listeners: { listeners: {
'tap': 'onHostTap_', 'click': 'onHostTap_',
}, },
observers: [ observers: [
...@@ -68,7 +68,7 @@ Polymer({ ...@@ -68,7 +68,7 @@ Polymer({
}, },
/** /**
* Handles non cr-toggle button taps (cr-toggle handles its own tap events * Handles non cr-toggle button clicks (cr-toggle handles its own click events
* which don't bubble). * which don't bubble).
* @param {!Event} e * @param {!Event} e
* @private * @private
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
</div> </div>
</div> </div>
<cr-toggle checked="[[unifiedDesktopMode_]]" <cr-toggle checked="[[unifiedDesktopMode_]]"
on-tap="onUnifiedDesktopTap_" on-click="onUnifiedDesktopTap_"
aria-labelledby="displayUnifiedDesktopCheckboxLabel"> aria-labelledby="displayUnifiedDesktopCheckboxLabel">
</cr-toggle> </cr-toggle>
</div> </div>
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
on-settings-boolean-control-change="onMetricsReportingChange_" on-settings-boolean-control-change="onMetricsReportingChange_"
no-set-pref> no-set-pref>
<template is="dom-if" if="[[showRestart_]]" restamp> <template is="dom-if" if="[[showRestart_]]" restamp>
<paper-button on-tap="onRestartTap_" id="restart" <paper-button on-click="onRestartTap_" id="restart"
slot="more-actions"> slot="more-actions">
$i18n{restart} $i18n{restart}
</paper-button> </paper-button>
......
...@@ -25,8 +25,8 @@ Polymer({ ...@@ -25,8 +25,8 @@ Polymer({
}, },
listeners: { listeners: {
'topMenu.tap': 'onLinkTap_', 'topMenu.click': 'onLinkTap_',
'subMenu.tap': 'onLinkTap_', 'subMenu.click': 'onLinkTap_',
}, },
/** @param {!settings.Route} newRoute */ /** @param {!settings.Route} newRoute */
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
label="$i18n{hardwareAccelerationLabel}"> label="$i18n{hardwareAccelerationLabel}">
<template is="dom-if" if="[[shouldShowRestart_( <template is="dom-if" if="[[shouldShowRestart_(
prefs.hardware_acceleration_mode.enabled.value)]]"> prefs.hardware_acceleration_mode.enabled.value)]]">
<paper-button on-tap="onRestartTap_" slot="more-actions"> <paper-button on-click="onRestartTap_" slot="more-actions">
$i18n{restart} $i18n{restart}
</paper-button> </paper-button>
</template> </template>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/** /**
* @fileoverview 'cr-toggle' is a component for showing an on/off switch. It * @fileoverview 'cr-toggle' is a component for showing an on/off switch. It
* fires a 'change' event *only* when its state changes as a result of a user * fires a 'change' event *only* when its state changes as a result of a user
* interaction. Besides just tapping the element, its state can be changed by * interaction. Besides just clicking the element, its state can be changed by
* dragging (pointerdown+pointermove) the element towards the desired direction. * dragging (pointerdown+pointermove) the element towards the desired direction.
*/ */
Polymer({ Polymer({
...@@ -40,7 +40,7 @@ Polymer({ ...@@ -40,7 +40,7 @@ Polymer({
listeners: { listeners: {
'pointerdown': 'onPointerDown_', 'pointerdown': 'onPointerDown_',
'pointerup': 'onPointerUp_', 'pointerup': 'onPointerUp_',
'tap': 'onTap_', 'click': 'onTap_',
'keypress': 'onKeyPress_', 'keypress': 'onKeyPress_',
'focus': 'onFocus_', 'focus': 'onFocus_',
'blur': 'onBlur_', 'blur': 'onBlur_',
...@@ -58,7 +58,7 @@ Polymer({ ...@@ -58,7 +58,7 @@ Polymer({
/** /**
* Whether the state of the toggle has already taken into account by * Whether the state of the toggle has already taken into account by
* |pointeremove| handlers. Used in the 'tap' handler. * |pointeremove| handlers. Used in the 'click' handler.
* @private {boolean} * @private {boolean}
*/ */
handledInPointerMove_: false, handledInPointerMove_: false,
...@@ -136,28 +136,29 @@ Polymer({ ...@@ -136,28 +136,29 @@ Polymer({
/** @private */ /** @private */
onTap_: function(e) { onTap_: function(e) {
// Prevent |tap| event from bubbling. It can cause parents of this elements // Prevent |click| event from bubbling. It can cause parents of this
// to erroneously re-toggle this control. // elements to erroneously re-toggle this control.
e.stopPropagation(); e.stopPropagation();
e.preventDefault();
// User gesture has already been taken care of inside |pointermove| // User gesture has already been taken care of inside |pointermove|
// handlers, Do nothing here. // handlers, Do nothing here.
if (this.handledInPointerMove_) if (this.handledInPointerMove_)
return; return;
// If no pointermove event fired, then user just tapped on the // If no pointermove event fired, then user just clicked on the
// toggle button and therefore it should be toggled. // toggle button and therefore it should be toggled.
this.toggleState_(false); this.toggleState_(false);
}, },
/** /**
* Whether the host of this element should handle a 'tap' event it received, * Whether the host of this element should handle a 'click' event it received,
* to be used when tapping on the parent is supposed to toggle the cr-toggle. * to be used when clicking on the parent is supposed to toggle the cr-toggle.
* *
* This is necessary to avoid a corner case when pointerdown is initiated * This is necessary to avoid a corner case when pointerdown is initiated
* in cr-toggle, but pointerup happens outside the bounds of cr-toggle, which * in cr-toggle, but pointerup happens outside the bounds of cr-toggle, which
* ends up firing a 'tap' event on the parent (see context at crbug.com/689158 * ends up firing a 'click' event on the parent (see context at
* and crbug.com/768555). * crbug.com/689158 and crbug.com/768555).
* @param {!Event} e * @param {!Event} e
* @return {boolean} * @return {boolean}
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment