- Revision
- 128871
- Author
- [email protected]
- Date
- 2012-09-18 03:34:40 -0700 (Tue, 18 Sep 2012)
Log Message
[GTK] Set the area of tooltips in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=96618
Reviewed by Martin Robinson.
In GTK+ tooltips are associated to a widget, if the mouse is moved
inside the widget area, the tooltip position doesn't change even
if the tooltip text changes. To support multiple tooltips for the
same widget, we need to set the area of the widget for every
tooltip.
* Shared/WebHitTestResult.cpp:
(WebKit::WebHitTestResult::Data::encode): Encode elementBoundingBox.
(WebKit::WebHitTestResult::Data::decode): Decode elementBoundingBox.
* Shared/WebHitTestResult.h:
(Data): Add elementBoundingBox to WebHitTestResult::Data.
(WebKit::WebHitTestResult::Data::elementBoundingBoxInWindowCoordinates):
Get the bounding box of the inner non shared node of the hit test
result in window coordinates.
(WebKit::WebHitTestResult::Data::Data):
(WebKit::WebHitTestResult::elementBoundingBox):
(WebHitTestResult):
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewMouseTargetChanged): Call webkitWebViewBaseSetTooltipArea.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseQueryTooltip): Use the tooltipArea if it's not empty.
(webkitWebViewBaseSetTooltipArea): Set the tooltipArea.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (128870 => 128871)
--- trunk/Source/WebKit2/ChangeLog 2012-09-18 10:29:02 UTC (rev 128870)
+++ trunk/Source/WebKit2/ChangeLog 2012-09-18 10:34:40 UTC (rev 128871)
@@ -1,3 +1,34 @@
+2012-09-18 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Set the area of tooltips in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=96618
+
+ Reviewed by Martin Robinson.
+
+ In GTK+ tooltips are associated to a widget, if the mouse is moved
+ inside the widget area, the tooltip position doesn't change even
+ if the tooltip text changes. To support multiple tooltips for the
+ same widget, we need to set the area of the widget for every
+ tooltip.
+
+ * Shared/WebHitTestResult.cpp:
+ (WebKit::WebHitTestResult::Data::encode): Encode elementBoundingBox.
+ (WebKit::WebHitTestResult::Data::decode): Decode elementBoundingBox.
+ * Shared/WebHitTestResult.h:
+ (Data): Add elementBoundingBox to WebHitTestResult::Data.
+ (WebKit::WebHitTestResult::Data::elementBoundingBoxInWindowCoordinates):
+ Get the bounding box of the inner non shared node of the hit test
+ result in window coordinates.
+ (WebKit::WebHitTestResult::Data::Data):
+ (WebKit::WebHitTestResult::elementBoundingBox):
+ (WebHitTestResult):
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkitWebViewMouseTargetChanged): Call webkitWebViewBaseSetTooltipArea.
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseQueryTooltip): Use the tooltipArea if it's not empty.
+ (webkitWebViewBaseSetTooltipArea): Set the tooltipArea.
+ * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+
2012-09-18 Tor Arne Vestbø <[email protected]>
[Qt] Fix build without the QtQuick module
Modified: trunk/Source/WebKit2/Shared/WebHitTestResult.cpp (128870 => 128871)
--- trunk/Source/WebKit2/Shared/WebHitTestResult.cpp 2012-09-18 10:29:02 UTC (rev 128870)
+++ trunk/Source/WebKit2/Shared/WebHitTestResult.cpp 2012-09-18 10:34:40 UTC (rev 128871)
@@ -43,6 +43,7 @@
encoder->encode(linkLabel);
encoder->encode(linkTitle);
encoder->encode(isContentEditable);
+ encoder->encode(elementBoundingBox);
}
bool WebHitTestResult::Data::decode(CoreIPC::ArgumentDecoder* decoder, WebHitTestResult::Data& hitTestResultData)
@@ -53,7 +54,8 @@
|| !decoder->decode(hitTestResultData.absoluteMediaURL)
|| !decoder->decode(hitTestResultData.linkLabel)
|| !decoder->decode(hitTestResultData.linkTitle)
- || !decoder->decode(hitTestResultData.isContentEditable))
+ || !decoder->decode(hitTestResultData.isContentEditable)
+ || !decoder->decode(hitTestResultData.elementBoundingBox))
return false;
return true;
Modified: trunk/Source/WebKit2/Shared/WebHitTestResult.h (128870 => 128871)
--- trunk/Source/WebKit2/Shared/WebHitTestResult.h 2012-09-18 10:29:02 UTC (rev 128870)
+++ trunk/Source/WebKit2/Shared/WebHitTestResult.h 2012-09-18 10:34:40 UTC (rev 128871)
@@ -21,8 +21,10 @@
#define WebHitTestResult_h
#include "APIObject.h"
+#include <WebCore/FrameView.h>
#include <WebCore/HitTestResult.h>
#include <WebCore/KURL.h>
+#include <WebCore/Node.h>
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
@@ -49,11 +51,29 @@
String linkLabel;
String linkTitle;
bool isContentEditable;
+ WebCore::IntRect elementBoundingBox;
Data()
{
}
+ WebCore::IntRect elementBoundingBoxInWindowCoordinates(const WebCore::HitTestResult& hitTestResult)
+ {
+ WebCore::Node* node = hitTestResult.innerNonSharedNode();
+ if (!node)
+ return WebCore::IntRect();
+
+ WebCore::Frame* frame = node->document()->frame();
+ if (!frame)
+ return WebCore::IntRect();
+
+ WebCore::FrameView* view = frame->view();
+ if (!view)
+ return WebCore::IntRect();
+
+ return view->contentsToWindow(node->pixelSnappedBoundingBox());
+ }
+
explicit Data(const WebCore::HitTestResult& hitTestResult)
: absoluteImageURL(hitTestResult.absoluteImageURL().string())
, absolutePDFURL(hitTestResult.absolutePDFURL().string())
@@ -62,6 +82,7 @@
, linkLabel(hitTestResult.textContent())
, linkTitle(hitTestResult.titleDisplayString())
, isContentEditable(hitTestResult.isContentEditable())
+ , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
{
}
@@ -81,6 +102,8 @@
bool isContentEditable() const { return m_data.isContentEditable; }
+ WebCore::IntRect elementBoundingBox() const { return m_data.elementBoundingBox; }
+
private:
explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData)
: m_data(hitTestResultData)
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (128870 => 128871)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2012-09-18 10:29:02 UTC (rev 128870)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2012-09-18 10:34:40 UTC (rev 128871)
@@ -1268,6 +1268,8 @@
void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WKHitTestResultRef wkHitTestResult, unsigned modifiers)
{
+ webkitWebViewBaseSetTooltipArea(WEBKIT_WEB_VIEW_BASE(webView), toImpl(wkHitTestResult)->elementBoundingBox());
+
WebKitWebViewPrivate* priv = webView->priv;
if (priv->mouseTargetHitTestResult
&& priv->mouseTargetModifiers == modifiers
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (128870 => 128871)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2012-09-18 10:29:02 UTC (rev 128870)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2012-09-18 10:34:40 UTC (rev 128871)
@@ -84,6 +84,7 @@
GRefPtr<GtkIMContext> imContext;
GtkClickCounter clickCounter;
CString tooltipText;
+ IntRect tooltipArea;
GtkDragAndDropHelper dragAndDropHelper;
DragIcon dragIcon;
IntSize resizerSize;
@@ -502,9 +503,13 @@
if (priv->tooltipText.length() <= 0)
return FALSE;
- // TODO: set the tip area when WKPageMouseDidMoveOverElementCallback
- // receives a hit test result.
+ if (!priv->tooltipArea.isEmpty()) {
+ GdkRectangle area = priv->tooltipArea;
+ gtk_tooltip_set_tip_area(tooltip, &area);
+ } else
+ gtk_tooltip_set_tip_area(tooltip, 0);
gtk_tooltip_set_text(tooltip, priv->tooltipText.data());
+
return TRUE;
}
@@ -691,6 +696,11 @@
gtk_widget_trigger_tooltip_query(GTK_WIDGET(webViewBase));
}
+void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase* webViewBase, const IntRect& tooltipArea)
+{
+ webViewBase->priv->tooltipArea = tooltipArea;
+}
+
void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
{
WebKitWebViewBasePrivate* priv = webViewBase->priv;
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (128870 => 128871)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2012-09-18 10:29:02 UTC (rev 128870)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2012-09-18 10:34:40 UTC (rev 128871)
@@ -40,6 +40,7 @@
WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WKContextRef, WKPageGroupRef);
void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
+void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase*, const WebCore::IntRect&);
void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*);
void webkitWebViewBaseStartDrag(WebKitWebViewBase*, const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
void webkitWebViewBaseChildMoveResize(WebKitWebViewBase*, GtkWidget*, const WebCore::IntRect&);