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

Side by Side 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 3 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2012, Samsung Electronics. All rights reserved. 4 * Copyright (C) 2012, Samsung Electronics. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 20 matching lines...) Expand all
31 #include "core/page/FrameTree.h" 31 #include "core/page/FrameTree.h"
32 #include "core/page/ScopedPageSuspender.h" 32 #include "core/page/ScopedPageSuspender.h"
33 #include "core/page/WindowFeatures.h" 33 #include "core/page/WindowFeatures.h"
34 #include "platform/geometry/IntRect.h" 34 #include "platform/geometry/IntRect.h"
35 #include "platform/network/NetworkHints.h" 35 #include "platform/network/NetworkHints.h"
36 #include "public/platform/WebScreenInfo.h" 36 #include "public/platform/WebScreenInfo.h"
37 #include <algorithm> 37 #include <algorithm>
38 38
39 namespace blink { 39 namespace blink {
40 40
41 DEFINE_TRACE(ChromeClient) {
42 visitor->trace(m_lastMouseOverNode);
43 HostWindow::trace(visitor);
44 }
45
41 void ChromeClient::setWindowRectWithAdjustment(const IntRect& pendingRect, 46 void ChromeClient::setWindowRectWithAdjustment(const IntRect& pendingRect,
42 LocalFrame& frame) { 47 LocalFrame& frame) {
43 IntRect screen = screenInfo().availableRect; 48 IntRect screen = screenInfo().availableRect;
44 IntRect window = pendingRect; 49 IntRect window = pendingRect;
45 50
46 IntSize minimumSize = minimumWindowSize(); 51 IntSize minimumSize = minimumWindowSize();
47 // Let size 0 pass through, since that indicates default size, not minimum 52 // Let size 0 pass through, since that indicates default size, not minimum
48 // size. 53 // size.
49 if (window.width()) 54 if (window.width())
50 window.setWidth(std::min(std::max(minimumSize.width(), window.width()), 55 window.setWidth(std::min(std::max(minimumSize.width(), window.width()),
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // ChromeClient::setToolTip. We'll work on tooltip text 188 // ChromeClient::setToolTip. We'll work on tooltip text
184 // direction during bidi cleanup in form inputs. 189 // direction during bidi cleanup in form inputs.
185 toolTipDirection = TextDirection::Ltr; 190 toolTipDirection = TextDirection::Ltr;
186 } 191 }
187 } 192 }
188 } 193 }
189 194
190 if (m_lastToolTipPoint == result.hitTestLocation().point() && 195 if (m_lastToolTipPoint == result.hitTestLocation().point() &&
191 m_lastToolTipText == toolTip) 196 m_lastToolTipText == toolTip)
192 return; 197 return;
198
199 // If a tooltip was displayed earlier, and mouse cursor moves over
200 // a different node with the same tooltip text, make sure the previous
201 // tooltip is unset, so that it does not get stuck positioned relative
202 // to the previous node).
203 // The ::setToolTip overload, which is be called down the road,
204 // ensures a new tooltip to be displayed with the new context.
205 if (result.innerNodeOrImageMapImage() != m_lastMouseOverNode &&
206 !m_lastToolTipText.isEmpty() && toolTip == m_lastToolTipText)
207 clearToolTip(frame);
208
193 m_lastToolTipPoint = result.hitTestLocation().point(); 209 m_lastToolTipPoint = result.hitTestLocation().point();
194 m_lastToolTipText = toolTip; 210 m_lastToolTipText = toolTip;
211 m_lastMouseOverNode = result.innerNodeOrImageMapImage();
195 setToolTip(frame, toolTip, toolTipDirection); 212 setToolTip(frame, toolTip, toolTipDirection);
196 } 213 }
197 214
198 void ChromeClient::clearToolTip(LocalFrame& frame) { 215 void ChromeClient::clearToolTip(LocalFrame& frame) {
199 // Do not check m_lastToolTip* and do not update them intentionally. 216 // Do not check m_lastToolTip* and do not update them intentionally.
200 // We don't want to show tooltips with same content after clearToolTip(). 217 // We don't want to show tooltips with same content after clearToolTip().
201 setToolTip(frame, String(), TextDirection::Ltr); 218 setToolTip(frame, String(), TextDirection::Ltr);
202 } 219 }
203 220
204 bool ChromeClient::print(LocalFrame* frame) { 221 bool ChromeClient::print(LocalFrame* frame) {
205 if (frame->document()->isSandboxed(SandboxModals)) { 222 if (frame->document()->isSandboxed(SandboxModals)) {
206 UseCounter::count(frame, UseCounter::DialogInSandboxedContext); 223 UseCounter::count(frame, UseCounter::DialogInSandboxedContext);
207 frame->console().addMessage(ConsoleMessage::create( 224 frame->console().addMessage(ConsoleMessage::create(
208 SecurityMessageSource, ErrorMessageLevel, 225 SecurityMessageSource, ErrorMessageLevel,
209 "Ignored call to 'print()'. The document is sandboxed, and the " 226 "Ignored call to 'print()'. The document is sandboxed, and the "
210 "'allow-modals' keyword is not set.")); 227 "'allow-modals' keyword is not set."));
211 return false; 228 return false;
212 } 229 }
213 230
214 // Suspend pages in case the client method runs a new event loop that would 231 // Suspend pages in case the client method runs a new event loop that would
215 // otherwise cause the load to continue while we're in the middle of 232 // otherwise cause the load to continue while we're in the middle of
216 // executing JavaScript. 233 // executing JavaScript.
217 ScopedPageSuspender suspender; 234 ScopedPageSuspender suspender;
218 235
219 printDelegate(frame); 236 printDelegate(frame);
220 return true; 237 return true;
221 } 238 }
222 239
223 } // namespace blink 240 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/ChromeClient.h ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698