summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-04 00:52:08 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-04 00:52:08 +0000
commit8b8f32b509c0f9d351a52f90bd2632ce510258bb (patch)
treefad6de71e258ce77fedaf79bf8dd7f678f1b5aef /chrome/browser
parenta56dc5e23c84acb4ca4e3bf990603c680338cba3 (diff)
downloadchromium_src-8b8f32b509c0f9d351a52f90bd2632ce510258bb.zip
chromium_src-8b8f32b509c0f9d351a52f90bd2632ce510258bb.tar.gz
chromium_src-8b8f32b509c0f9d351a52f90bd2632ce510258bb.tar.bz2
Fix race condition in find as you type.
BUG=42953 TEST=manual Review URL: http://codereview.chromium.org/1910001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46308 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/resources/bookmark_manager/main.html22
1 files changed, 16 insertions, 6 deletions
diff --git a/chrome/browser/resources/bookmark_manager/main.html b/chrome/browser/resources/bookmark_manager/main.html
index b025b94..1da1116 100644
--- a/chrome/browser/resources/bookmark_manager/main.html
+++ b/chrome/browser/resources/bookmark_manager/main.html
@@ -188,16 +188,25 @@ tree.addEventListener('change', function() {
/**
* Navigates to a bookmark ID.
* @param {string} id The ID to navigate to.
+ * @param {boolean=} opt_updateHashNow Whether to immediately update the
+ * location.hash. If false then it is updated in a timeout.
*/
-function navigateTo(id) {
- console.info('navigateTo', window.location.hash, id);
+function navigateTo(id, opt_updateHashNow) {
+ console.info('navigateTo', 'from', window.location.hash, 'to', id);
// Update the location hash using a timer to prevent reentrancy. This is how
// often we add history entries and the time here is a bit arbitrary but was
// picked as the smallest time a human perceives as instant.
- clearTimeout(navigateTo.timer_);
- navigateTo.timer_ = setTimeout(function() {
+
+ function f() {
window.location.hash = tree.selectedItem.bookmarkId;
- }, 300);
+ }
+
+ clearTimeout(navigateTo.timer_);
+ if (opt_updateHashNow)
+ f();
+ else
+ navigateTo.timer_ = setTimeout(f, 250);
+
updateParentId(id);
}
@@ -288,7 +297,8 @@ function setSearch(searchText) {
id = tree.selectedItem.bookmarkId;
}
- navigateTo(id);
+ // Navigate now and update hash immediately.
+ navigateTo(id, true);
}
// Handle the logo button UI.