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

Unified Diff: third_party/WebKit/Source/core/page/ChromeClient.cpp

Issue 2592263003: Send an empty tooltip text when hovering over a different node (Closed)
Patch Set: Send an empty tooltip text when hoverring over a different node Created 4 years 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: third_party/WebKit/Source/core/page/ChromeClient.cpp
diff --git a/third_party/WebKit/Source/core/page/ChromeClient.cpp b/third_party/WebKit/Source/core/page/ChromeClient.cpp
index 05238fe1cbbfb262c462aad2cbaf99cee8da6f50..34782641ad47786a8d7fa548ca16eb33ebc3cc19 100644
--- a/third_party/WebKit/Source/core/page/ChromeClient.cpp
+++ b/third_party/WebKit/Source/core/page/ChromeClient.cpp
@@ -38,6 +38,11 @@
namespace blink {
+DEFINE_TRACE(ChromeClient) {
+ visitor->trace(m_lastMouseOverNode);
+ HostWindow::trace(visitor);
+}
+
void ChromeClient::setWindowRectWithAdjustment(const IntRect& pendingRect,
LocalFrame& frame) {
IntRect screen = screenInfo().availableRect;
@@ -188,8 +193,18 @@ void ChromeClient::setToolTip(LocalFrame& frame, const HitTestResult& result) {
if (m_lastToolTipPoint == result.hitTestLocation().point() &&
m_lastToolTipText == toolTip)
return;
+
+ // If a tooltip was displayed earlier, and the user has moved the mouse
+ // cursor over a different node, make sure the previous tooltip is unset.
+ // If the newly hovered node has a tooltip, then ::setToolTip will be called
+ // later with the new text.
+ if (result.innerNodeOrImageMapImage() != m_lastMouseOverNode &&
+ !m_lastToolTipText.isEmpty() && toolTip == m_lastToolTipText)
+ clearToolTip(frame);
+
m_lastToolTipPoint = result.hitTestLocation().point();
m_lastToolTipText = toolTip;
+ m_lastMouseOverNode = result.innerNodeOrImageMapImage();
setToolTip(frame, toolTip, toolTipDirection);
}

Powered by Google App Engine
This is Rietveld 408576698