Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2394)

Unified Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 2103653004: Revert of MD Settings: make chrome://[md-]settings/clearBrowserData URL work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/settings_page/main_page_behavior.js
diff --git a/chrome/browser/resources/settings/settings_page/main_page_behavior.js b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
index 4b6442c44c82c15ddccf7898de684603d1012755..207870de836c56230eebf82cf9ac933d9fabe641 100644
--- a/chrome/browser/resources/settings/settings_page/main_page_behavior.js
+++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
@@ -7,20 +7,22 @@
var EXPAND_DURATION = 350;
/**
- * Calls |readyTest| repeatedly until it returns true, then calls
- * |readyCallback|.
- * @param {function():boolean} readyTest
- * @param {!Function} readyCallback
+ * Workaround for scrolling an element into view when using Polymer.
+ * @param {function():Element} containerCallback Return parent of element.
+ * @param {function():Element} elementCallback Return element to scroll to.
*/
-function doWhenReady(readyTest, readyCallback) {
- // TODO(dschuyler): Determine whether this hack can be removed.
+function scrollWhenReady(containerCallback, elementCallback) {
+ // TODO(dschuyler): Determine whether this setTimeout can be removed.
// See also: https://github.com/Polymer/polymer/issues/3629
- var intervalId = setInterval(function() {
- if (readyTest()) {
- clearInterval(intervalId);
- readyCallback();
- }
- }, 10);
+ setTimeout(function pollForScrollHeight() {
+ var container = containerCallback();
+ if (!container || container.scrollHeight == 0) {
+ setTimeout(pollForScrollHeight.bind(this), 10);
+ return;
+ }
+
+ elementCallback().scrollIntoView();
+ }.bind(this));
}
/**
@@ -367,14 +369,14 @@
/** @private */
scrollToSection_: function() {
- doWhenReady(
+ scrollWhenReady(
function() {
- return this.scrollHeight > 0;
+ return this;
}.bind(this),
function() {
// If the current section changes while we are waiting for the page to
// be ready, scroll to the newest requested section.
- this.getSection_(this.currentRoute.section).scrollIntoView();
+ return this.getSection_(this.currentRoute.section);
}.bind(this));
},

Powered by Google App Engine
This is Rietveld 408576698