From 9997409a1d70d0f44936ce49227520406b543c6d Mon Sep 17 00:00:00 2001 From: "arv@chromium.org" Date: Wed, 7 Oct 2009 16:40:31 +0000 Subject: NTP: Add a workaround for the case where we reopen a window and a tooltip is shown in the background window. BUG=23967 TEST=Open two windows with at least two tabs. Open one more window and go to the NTP. Close the first two windows. Now click on the first link in the Recently closed section. This reopens a window. Now move the mouse so you can see the NTP again. There should be no tooltip for the Recently closed item Review URL: http://codereview.chromium.org/263002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28261 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/resources/new_new_tab.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js index add6213..7bf6a61 100644 --- a/chrome/browser/resources/new_new_tab.js +++ b/chrome/browser/resources/new_new_tab.js @@ -1149,16 +1149,6 @@ function handleIfEnterKey(f) { }; } -function maybeOpenFile(e) { - var el = findAncestor(e.target, function(el) { - return el.fileId !== undefined; - }); - if (el) { - chrome.send('openFile', [String(el.fileId)]); - e.preventDefault(); - } -} - function maybeReopenTab(e) { var el = findAncestor(e.target, function(el) { return el.sessionId !== undefined; @@ -1166,6 +1156,13 @@ function maybeReopenTab(e) { if (el) { chrome.send('reopenTab', [String(el.sessionId)]); e.preventDefault(); + + // HACK(arv): After the window onblur event happens we get a mouseover event + // on the next item and we want to make sure that we do not show a tooltip + // for that. + window.setTimeout(function() { + windowTooltip.hide(); + }, 2 * WindowTooltip.DELAY); } } @@ -1182,9 +1179,6 @@ function maybeShowWindowTooltip(e) { var recentlyClosedElement = $('recently-closed'); -recentlyClosedElement.addEventListener('click', maybeOpenFile); -recentlyClosedElement.addEventListener('keydown', - handleIfEnterKey(maybeOpenFile)); recentlyClosedElement.addEventListener('click', maybeReopenTab); recentlyClosedElement.addEventListener('keydown', @@ -1211,6 +1205,12 @@ WindowTooltip.trackMouseMove_ = function(e) { WindowTooltip.clientY = e.clientY; }; +/** + * Time in ms to delay before the tooltip is shown. + * @type {number} + */ +WindowTooltip.DELAY = 300; + WindowTooltip.prototype = { timer: 0, handleMouseOver: function(e, linkEl, tabs) { @@ -1222,13 +1222,13 @@ WindowTooltip.prototype = { this.linkEl_.addEventListener('blur', this.boundHide_); } this.timer = window.setTimeout(bind(this.show, this, e.type, linkEl, tabs), - 300); + WindowTooltip.DELAY); }, show: function(type, linkEl, tabs) { window.addEventListener('blur', this.boundHide_); this.linkEl_.removeEventListener('mousemove', WindowTooltip.trackMouseMove_); - clearTimeout(this.timer); + window.clearTimeout(this.timer); this.renderItems(tabs); var rect = linkEl.getBoundingClientRect(); -- cgit v1.1