WebCore:
Move tooltip logic down into WebCore so that it can be shared cross-platform
Reviewed by Sam.
* page/Chrome.cpp:
(WebCore::Chrome::setToolTip): Added.
* page/Chrome.h:
* page/ChromeClient.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::mouseMoved): Call Chrome::setToolTip.
* platform/graphics/svg/SVGImageEmptyClients.h:
Added stubs for Gdk:
* platform/gdk/ChromeClientGdk.h:
* platform/gdk/TemporaryLinkStubs.cpp:
(ChromeClientGdk::setToolTip):
WebKit:
Move tooltip logic down into WebCore so that it can be shared cross-platform
Reviewed by Sam.
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::setToolTip): Added.
* WebView/WebHTMLView.mm: Removed _resetCachedWebPreferences.
(-[WebHTMLView _updateMouseoverWithEvent:]): Removed tooltip code.
(-[WebHTMLView initWithFrame:]): Removed call to
_resetCachedWebPreferences.
(-[WebHTMLView setDataSource:]): Ditto.
* WebView/WebHTMLViewInternal.h: Removed showsURLsInToolTips ivar.
* WebView/WebHTMLViewPrivate.h: Added declaration for _setTooltip so
that WebChromeClient can call it.
WebKit/win:
Added a stub for WebChromeClient::setToolTip
Reviewed by Sam.
* WebChromeClient.cpp:
* WebChromeClient.h:
WebKitQt:
Added a stub for ChromeClientQt::setToolTip
Reviewed by Sam.
* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::setToolTip):
* WebCoreSupport/ChromeClientQt.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24000
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-07-04 Adam Roben <aroben@apple.com>
+
+ Move tooltip logic down into WebCore so that it can be shared cross-platform
+
+ Reviewed by Sam.
+
+ * page/Chrome.cpp:
+ (WebCore::Chrome::setToolTip): Added.
+ * page/Chrome.h:
+ * page/ChromeClient.h:
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::mouseMoved): Call Chrome::setToolTip.
+ * platform/graphics/svg/SVGImageEmptyClients.h:
+
+ Added stubs for Gdk:
+
+ * platform/gdk/ChromeClientGdk.h:
+ * platform/gdk/TemporaryLinkStubs.cpp:
+ (ChromeClientGdk::setToolTip):
+
2007-07-04 Adam Roben <aroben@apple.com>
Add Settings::showsURLsInToolTips
#include "ChromeClient.h"
#include "FloatRect.h"
#include "Frame.h"
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
#include "InspectorController.h"
#include "Page.h"
#include "ResourceHandle.h"
+#include "Settings.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
+using namespace HTMLNames;
+
class PageGroupLoadDeferrer : Noncopyable {
public:
PageGroupLoadDeferrer(Page*, bool deferSelf);
m_client->mouseDidMoveOverElement(result, modifierFlags);
}
+void Chrome::setToolTip(const HitTestResult& result)
+{
+ // First priority is a potential toolTip representing a spelling or grammar error
+ String toolTip = result.spellingToolTip();
+
+ // Next priority is a toolTip from a URL beneath the mouse (if preference is set to show those).
+ if (toolTip.isEmpty() && m_page->settings()->showsURLsInToolTips()) {
+ if (Node* node = result.innerNonSharedNode()) {
+ // Get tooltip representing form action, if relevant
+ if (node->hasTagName(inputTag)) {
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
+ if (input->inputType() == HTMLInputElement::SUBMIT)
+ if (HTMLFormElement* form = input->form())
+ toolTip = form->action();
+ }
+ }
+
+ // Get tooltip representing link's URL
+ if (toolTip.isEmpty())
+ // FIXME: Need to pass this URL through userVisibleString once that's in WebCore
+ toolTip = result.absoluteLinkURL().url();
+ }
+
+ // Lastly we'll consider a tooltip for element with "title" attribute
+ if (toolTip.isEmpty())
+ toolTip = result.title();
+
+ m_client->setToolTip(toolTip);
+}
+
PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
{
if (const HashSet<Page*>* group = page->frameNamespace()) {
void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
+ void setToolTip(const HitTestResult&);
+
#if PLATFORM(MAC)
void focusNSView(NSView*);
#endif
virtual void updateBackingStore() = 0;
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
+
+ virtual void setToolTip(const String&) = 0;
};
}
hoveredNode.setToNonShadowAncestor();
page->chrome()->mouseDidMoveOverElement(hoveredNode, event.modifierFlags());
+ page->chrome()->setToolTip(hoveredNode);
return result;
}
virtual void updateBackingStore();
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
+
+ virtual void setToolTip(const String&);
};
}
notImplemented();
}
+void ChromeClientGdk::setToolTip(const String&)
+{
+ notImplemented();
+}
+
/********************************************************/
/* Completely empty stubs (mostly to allow DRT to run): */
/********************************************************/
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) { }
+ virtual void setToolTip(const String&) { }
};
class SVGEmptyFrameLoaderClient : public FrameLoaderClient {
+2007-07-04 Adam Roben <aroben@apple.com>
+
+ Move tooltip logic down into WebCore so that it can be shared cross-platform
+
+ Reviewed by Sam.
+
+ * WebCoreSupport/WebChromeClient.h:
+ * WebCoreSupport/WebChromeClient.mm:
+ (WebChromeClient::setToolTip): Added.
+ * WebView/WebHTMLView.mm: Removed _resetCachedWebPreferences.
+ (-[WebHTMLView _updateMouseoverWithEvent:]): Removed tooltip code.
+ (-[WebHTMLView initWithFrame:]): Removed call to
+ _resetCachedWebPreferences.
+ (-[WebHTMLView setDataSource:]): Ditto.
+ * WebView/WebHTMLViewInternal.h: Removed showsURLsInToolTips ivar.
+ * WebView/WebHTMLViewPrivate.h: Added declaration for _setTooltip so
+ that WebChromeClient can call it.
+
2007-07-04 Adam Roben <aroben@apple.com>
Initialize Settings::showsURLsInToolTips
virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags);
+ virtual void setToolTip(const WebCore::String&);
+
private:
WebView *m_webView;
};
#import "WebFrameInternal.h"
#import "WebFrameView.h"
#import "WebHTMLView.h"
+#import "WebHTMLViewPrivate.h"
#import "WebNSURLRequestExtras.h"
#import "WebUIDelegate.h"
#import "WebUIDelegatePrivate.h"
[m_webView _mouseDidMoveOverElement:element modifierFlags:modifierFlags];
[element release];
}
+
+void WebChromeClient::setToolTip(const String& toolTip)
+{
+ [(WebHTMLView *)[[[m_webView mainFrame] frameView] documentView] _setToolTip:toolTip];
+}
if (Frame* coreFrame = core([view _frame]))
coreFrame->eventHandler()->mouseMoved(event);
- NSPoint point = [view convertPoint:[event locationInWindow] fromView:nil];
- NSDictionary *element = [view elementAtPoint:point];
-
- // Set a tool tip; it won't show up right away but will if the user pauses.
-
- // First priority is a potential toolTip representing a spelling or grammar error
- NSString *newToolTip = [element objectForKey:WebElementSpellingToolTipKey];
-
- // Next priority is a toolTip from a URL beneath the mouse (if preference is set to show those).
- if ([newToolTip length] == 0 && _private->showsURLsInToolTips) {
- DOMHTMLElement *domElement = [element objectForKey:WebElementDOMNodeKey];
-
- // Get tooltip representing form action, if relevant
- if ([domElement isKindOfClass:[DOMHTMLInputElement class]]) {
- if ([[(DOMHTMLInputElement *)domElement type] isEqualToString:@"submit"])
- newToolTip = [[(DOMHTMLInputElement *) domElement form] action];
- }
-
- // Get tooltip representing link's URL
- if ([newToolTip length] == 0)
- newToolTip = [[element objectForKey:WebElementLinkURLKey] _web_userVisibleString];
- }
-
- // Lastly we'll consider a tooltip for element with "title" attribute
- if ([newToolTip length] == 0)
- newToolTip = [element objectForKey:WebElementTitleKey];
-
- [view _setToolTip:newToolTip];
-
[view release];
}
}
#endif
}
-- (void)_resetCachedWebPreferences:(NSNotification *)ignored
-{
- WebPreferences *preferences = [[self _webView] preferences];
- // Check for nil because we might not yet have an associated webView when this is called
- if (preferences == nil)
- preferences = [WebPreferences standardPreferences];
-
- _private->showsURLsInToolTips = [preferences showsURLsInToolTips];
-}
-
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
_private->pluginController = [[WebPluginController alloc] initWithDocumentView:self];
_private->needsLayout = YES;
- [self _resetCachedWebPreferences:nil];
- [[NSNotificationCenter defaultCenter]
- addObserver:self selector:@selector(_resetCachedWebPreferences:)
- name:WebPreferencesChangedNotification object:nil];
return self;
}
[_private->pluginController setDataSource:dataSource];
[self addMouseMovedObserver];
}
- [self _resetCachedWebPreferences:nil];
}
- (void)dataSourceUpdated:(WebDataSource *)dataSource
BOOL closed;
BOOL needsLayout;
BOOL needsToApplyStyles;
- BOOL showsURLsInToolTips;
BOOL ignoringMouseDraggedEvents;
BOOL printing;
- (BOOL)_transparentBackground;
- (void)_setTransparentBackground:(BOOL)f;
+- (void)_setToolTip:(NSString *)string;
+
// SPI's for Mail.
- (NSImage *)_selectionDraggingImage;
- (NSRect)_selectionDraggingRect;
+2007-07-04 Adam Roben <aroben@apple.com>
+
+ Added a stub for WebChromeClient::setToolTip
+
+ Reviewed by Sam.
+
+ * WebChromeClient.cpp:
+ * WebChromeClient.h:
+
2007-07-04 Adam Roben <aroben@apple.com>
Initialize Settings::showsURLsInToolTips
uiDelegate->mouseDidMoveOverElement(m_webView, element.get(), modifierFlags);
}
+
+void WebChromeClient::setToolTip(const String&)
+{
+}
virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags);
+ virtual void setToolTip(const WebCore::String&);
+
private:
WebView* m_webView;
};
+2007-07-04 Adam Roben <aroben@apple.com>
+
+ Added a stub for ChromeClientQt::setToolTip
+
+ Reviewed by Sam.
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::setToolTip):
+ * WebCoreSupport/ChromeClientQt.h:
+
2007-07-04 Adam Roben <aroben@apple.com>
Added a stub for ChromeClientQt::mouseDidMoveOverElement
notImplemented();
}
+void ChromeClientQt::setToolTip(const String&)
+{
+ notImplemented();
+}
+
}
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
+ virtual void setToolTip(const String&);
+
QWebPage* m_webPage;
};
}