Commit e7d01a94 authored by Mike West's avatar Mike West Committed by Commit Bot

Revert "MD Settings: Migrate settings-toggle-button to use cr-toggle."

This reverts commit 4981992a.

Reason for revert: 

It appears that this patch caused `browser_test` failures on 'Linux
ChromiumOS Tests (dbg)', starting at [build 30664][1]. The [errors][2]
read `[8882:8882:0928/213724.538975:ERROR:CONSOLE(48)] "Uncaught TypeError: Cannot read property '_createRipple' of undefined", source: chrome://resources/cr_elements/cr_link_row/cr_link_row.js (48)`, which
this patch alters.

[1]: https://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%281%29/builds/30664
[2]: https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.chromiumos%2FLinux_ChromiumOS_Tests__dbg__1_%2F30664%2F%2B%2Frecipes%2Fsteps%2Fbrowser_tests%2F0%2Flogs%2FPasswordsAndFormsBrowserTest.uiTests%2F0

Original change's description:
> MD Settings: Migrate settings-toggle-button to use cr-toggle.
> 
> Bug: 768073
> Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
> Change-Id: If3efa3993d9ff75cce73eb48d583adb0ea5db543
> Reviewed-on: https://chromium-review.googlesource.com/686041
> Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
> Reviewed-by: Scott Chen <scottchen@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#505269}

TBR=dpapad@chromium.org,scottchen@chromium.org

Change-Id: I6e7e68d3a2989898df9aac3364de489fd5b05cd3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 768073
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Reviewed-on: https://chromium-review.googlesource.com/691794Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505321}
parent 78b426d0
......@@ -101,7 +101,6 @@
{
'target_name': 'settings_toggle_button',
'dependencies': [
'<(DEPTH)/ui/webui/resources/cr_elements/cr_toggle/compiled_resources2.gyp:cr_toggle',
'settings_boolean_control_behavior',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="settings_boolean_control_behavior.html">
<link rel="import" href="../settings_shared_css.html">
......@@ -62,12 +62,13 @@
<cr-policy-pref-indicator pref="[[pref]]" icon-aria-label="[[label]]">
</cr-policy-pref-indicator>
</template>
<cr-toggle id="control" checked="{{checked}}"
on-change="onChange_"
<paper-toggle-button id="control" checked="{{checked}}"
on-change="notifyChangedByUserInteraction"
aria-label$="[[getAriaLabel_(label, ariaLabel)]]"
aria-describedby="subLabel"
disabled="[[controlDisabled_(disabled, pref)]]">
</cr-toggle>
aria-describedby="subLabel" on-up="resetTrackLock_"
disabled="[[controlDisabled_(disabled, pref)]]"
on-tap="onToggleTap_">
</paper-toggle-button>
</div>
</template>
<script src="settings_toggle_button.js"></script>
......
......@@ -58,6 +58,17 @@ Polymer({
return this.label || this.ariaLabel;
},
/**
* Handle taps directly on the toggle (see: onLabelWrapperTap_ for non-toggle
* taps).
* @param {!Event} e
* @private
*/
onToggleTap_: function(e) {
// Stop the event from propagating to avoid firing two 'changed' events.
e.stopPropagation();
},
/** @private */
onDisableOrPrefChange_: function() {
if (this.controlDisabled_()) {
......@@ -68,34 +79,28 @@ Polymer({
},
/**
* Handles non cr-toggle button taps (cr-toggle handles its own tap events
* which don't bubble).
* Handle non-toggle button taps (see: onToggleTap_ for toggle taps).
* @param {!Event} e
* @private
*/
onHostTap_: function(e) {
// Stop the event from propagating to avoid firing two 'changed' events.
e.stopPropagation();
if (this.controlDisabled_())
return;
// Ignore this |tap| event, if the interaction sequence
// (pointerdown+pointerup) began within the cr-toggle itself.
if (/** @type {!CrToggleElement} */ (this.$.control)
.shouldIgnoreHostTap(e)) {
return;
}
this.checked = !this.checked;
this.notifyChangedByUserInteraction();
this.fire('change');
},
/**
* @param {!CustomEvent} e
* TODO(scottchen): temporary fix until polymer gesture bug resolved. See:
* https://github.com/PolymerElements/paper-slider/issues/186
* @private
*/
onChange_: function(e) {
this.checked = /** @type {boolean} */ (e.detail);
this.notifyChangedByUserInteraction();
resetTrackLock_: function() {
// Run tap.reset in next run-loop to avoid reversing the current tap event.
setTimeout(() => Polymer.Gestures.gestures.tap.reset());
},
});
......@@ -55,9 +55,6 @@ Polymer({
/** @private {boolean} */
pointerMoveFired_: false,
/** @private {number} */
lastPointerUpTime_: 0,
/** @override */
attached: function() {
// Note: Doing the same in ready instead of attached produces incorrect
......@@ -104,8 +101,7 @@ Polymer({
},
/** @private */
onPointerUp_: function(e) {
this.lastPointerUpTime_ = e.timeStamp;
onPointerUp_: function() {
this.removeEventListener('pointermove', this.boundPointerMove_);
},
......@@ -118,7 +114,7 @@ Polymer({
if (e.button != 0)
return;
// This is necessary to have follow up pointer events fire on |this|, even
// This is necessary to have follow up events fire on |this|, even
// if they occur outside of its bounds.
this.setPointerCapture(e.pointerId);
this.pointerDownX_ = e.clientX;
......@@ -127,11 +123,7 @@ Polymer({
},
/** @private */
onTap_: function(e) {
// Prevent |tap| event from bubbling. It can cause parents of this elements
// to erroneously re-toggle this control.
e.stopPropagation();
onTap_: function() {
// If pointermove fired it means that user tried to drag the toggle button,
// and therefore its state has already been handled within the pointermove
// handler. Do nothing here.
......@@ -143,21 +135,6 @@ Polymer({
this.toggleState_(false);
},
/**
* Whether the host of this element should handle a 'tap' event it received,
* to be used when tapping 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 'tap' event on the parent (see context at crbug.com/689158
* and crbug.com/768555).
* @param {!Event} e
* @return {boolean}
*/
shouldIgnoreHostTap: function(e) {
return e.detail.sourceEvent.timeStamp == this.lastPointerUpTime_;
},
/**
* @param {boolean} fromKeyboard
* @private
......
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