From 79985f94e043bd4de3f3652a19f4b7698291cdd7 Mon Sep 17 00:00:00 2001 From: dpapad Date: Fri, 4 May 2018 01:09:23 +0000 Subject: [PATCH] WebUI: Simplify cr-toggle case of finishing drag gesture outside element. Previous code was working around crbug.com/689158 and crbug.com/768555. New code still works around them, but without requiring JS logic to do so, achieved by wrapping the cr-toggle contents with a diff --git a/ui/webui/resources/cr_elements/cr_toggle/cr_toggle.js b/ui/webui/resources/cr_elements/cr_toggle/cr_toggle.js index d4d38a789a0c43..25c6441b81cac2 100644 --- a/ui/webui/resources/cr_elements/cr_toggle/cr_toggle.js +++ b/ui/webui/resources/cr_elements/cr_toggle/cr_toggle.js @@ -63,9 +63,6 @@ Polymer({ */ handledInPointerMove_: false, - /** @private {number} */ - lastPointerUpTime_: 0, - /** @override */ attached: function() { let direction = this.matches(':host-context([dir=rtl]) cr-toggle') ? -1 : 1; @@ -113,7 +110,6 @@ Polymer({ /** @private */ onPointerUp_: function(e) { - this.lastPointerUpTime_ = e.timeStamp; this.removeEventListener('pointermove', this.boundPointerMove_); }, @@ -151,23 +147,6 @@ Polymer({ this.toggleState_(false); }, - /** - * Whether the host of this element should handle a 'click' event it received, - * 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 - * in cr-toggle, but pointerup happens outside the bounds of cr-toggle, which - * ends up firing a 'click' event on the parent (see context at - * crbug.com/689158 and crbug.com/768555). - * @param {!Event} e - * @return {boolean} - */ - shouldIgnoreHostTap: function(e) { - let timeStamp = - e.detail.sourceEvent ? e.detail.sourceEvent.timeStamp : e.timeStamp; - return timeStamp == this.lastPointerUpTime_; - }, - /** * @param {boolean} fromKeyboard * @private @@ -196,7 +175,7 @@ Polymer({ // customize the element's ripple _createRipple: function() { - this._rippleContainer = this.$.button; + this._rippleContainer = this.$.knob; let ripple = Polymer.PaperRippleBehavior._createRipple(); ripple.id = 'ink'; ripple.setAttribute('recenters', '');