Title: [137192] trunk/Source/WebKit2
Revision
137192
Author
[email protected]
Date
2012-12-10 11:42:20 -0800 (Mon, 10 Dec 2012)

Log Message

[GTK] Expose HitTestResult::scrollbar() condition in API
https://bugs.webkit.org/show_bug.cgi?id=104369

Patch by Eduardo Lima Mitev <[email protected]> on 2012-12-10
Reviewed by Carlos Garcia Campos.

This patch populates WebCore::HitTestResult::scrollbar() condition
in WebKitHitTestResult public API, and includes a corresponding unit
test.

* Shared/WebHitTestResult.cpp: Adds new isScrollbar member to
encoding and decoding methods to carry the scrollbar condition
from Web process to UI process.
(WebKit::WebHitTestResult::Data::encode):
(WebKit::WebHitTestResult::Data::decode):
* Shared/WebHitTestResult.h:
(Data): Adds new bool member isScrollbar.
(WebKit::WebHitTestResult::Data::Data): Initializes isScrollbar from
WebCore::HitTestResult::scrollbar().
(WebKit::WebHitTestResult::isScrollbar): Method that returns value
of isScrollbar member.
(WebHitTestResult):
* UIProcess/API/gtk/WebKitHitTestResult.cpp:
(webkitHitTestResultCreate): Adds scrollbar condition to context upon
initialization.
(webkitHitTestResultCompare): Adds comparison of scrollbar condition.
(webkit_hit_test_result_context_is_scrollbar): Public accessor for
scrollbar presence in context.
* UIProcess/API/gtk/WebKitHitTestResult.h: Adds new flag
WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR to
WebKitHitTestResultContext enum.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Adds new API symbol
to the corresponding documentation sections.
* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(testWebViewMouseTarget): Updates mouse-target
test to include assertions for hitting scrollbar condition, and
an new HTML to privide a positive case.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (137191 => 137192)


--- trunk/Source/WebKit2/ChangeLog	2012-12-10 19:33:51 UTC (rev 137191)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-10 19:42:20 UTC (rev 137192)
@@ -1,3 +1,42 @@
+2012-12-10  Eduardo Lima Mitev  <[email protected]>
+
+        [GTK] Expose HitTestResult::scrollbar() condition in API
+        https://bugs.webkit.org/show_bug.cgi?id=104369
+
+        Reviewed by Carlos Garcia Campos.
+
+        This patch populates WebCore::HitTestResult::scrollbar() condition
+        in WebKitHitTestResult public API, and includes a corresponding unit
+        test.
+
+        * Shared/WebHitTestResult.cpp: Adds new isScrollbar member to
+        encoding and decoding methods to carry the scrollbar condition
+        from Web process to UI process.
+        (WebKit::WebHitTestResult::Data::encode):
+        (WebKit::WebHitTestResult::Data::decode):
+        * Shared/WebHitTestResult.h:
+        (Data): Adds new bool member isScrollbar.
+        (WebKit::WebHitTestResult::Data::Data): Initializes isScrollbar from
+        WebCore::HitTestResult::scrollbar().
+        (WebKit::WebHitTestResult::isScrollbar): Method that returns value
+        of isScrollbar member.
+        (WebHitTestResult):
+        * UIProcess/API/gtk/WebKitHitTestResult.cpp:
+        (webkitHitTestResultCreate): Adds scrollbar condition to context upon
+        initialization.
+        (webkitHitTestResultCompare): Adds comparison of scrollbar condition.
+        (webkit_hit_test_result_context_is_scrollbar): Public accessor for
+        scrollbar presence in context.
+        * UIProcess/API/gtk/WebKitHitTestResult.h: Adds new flag
+        WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR to
+        WebKitHitTestResultContext enum.
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Adds new API symbol
+        to the corresponding documentation sections.
+        * UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
+        (testWebViewMouseTarget): Updates mouse-target
+        test to include assertions for hitting scrollbar condition, and
+        an new HTML to privide a positive case.
+
 2012-12-10  Alexis Menard  <[email protected]>
 
         [CSS3 Backgrounds and Borders] Remove CSS3_BACKGROUND feature flag.

Modified: trunk/Source/WebKit2/Shared/WebHitTestResult.cpp (137191 => 137192)


--- trunk/Source/WebKit2/Shared/WebHitTestResult.cpp	2012-12-10 19:33:51 UTC (rev 137191)
+++ trunk/Source/WebKit2/Shared/WebHitTestResult.cpp	2012-12-10 19:42:20 UTC (rev 137192)
@@ -44,6 +44,7 @@
     encoder << linkTitle;
     encoder << isContentEditable;
     encoder << elementBoundingBox;
+    encoder << isScrollbar;
 }
 
 bool WebHitTestResult::Data::decode(CoreIPC::ArgumentDecoder* decoder, WebHitTestResult::Data& hitTestResultData)
@@ -55,7 +56,8 @@
         || !decoder->decode(hitTestResultData.linkLabel)
         || !decoder->decode(hitTestResultData.linkTitle)
         || !decoder->decode(hitTestResultData.isContentEditable)
-        || !decoder->decode(hitTestResultData.elementBoundingBox))
+        || !decoder->decode(hitTestResultData.elementBoundingBox)
+        || !decoder->decode(hitTestResultData.isScrollbar))
         return false;
 
     return true;

Modified: trunk/Source/WebKit2/Shared/WebHitTestResult.h (137191 => 137192)


--- trunk/Source/WebKit2/Shared/WebHitTestResult.h	2012-12-10 19:33:51 UTC (rev 137191)
+++ trunk/Source/WebKit2/Shared/WebHitTestResult.h	2012-12-10 19:42:20 UTC (rev 137192)
@@ -52,6 +52,7 @@
         String linkTitle;
         bool isContentEditable;
         WebCore::IntRect elementBoundingBox;
+        bool isScrollbar;
 
         Data()
         {
@@ -83,6 +84,7 @@
             , linkTitle(hitTestResult.titleDisplayString())
             , isContentEditable(hitTestResult.isContentEditable())
             , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
+            , isScrollbar(hitTestResult.scrollbar())
         {
         }
 
@@ -104,6 +106,8 @@
 
     WebCore::IntRect elementBoundingBox() const { return m_data.elementBoundingBox; }
 
+    bool isScrollbar() const { return m_data.isScrollbar; }
+
 private:
     explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData)
         : m_data(hitTestResultData)

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp (137191 => 137192)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp	2012-12-10 19:33:51 UTC (rev 137191)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp	2012-12-10 19:42:20 UTC (rev 137192)
@@ -240,6 +240,9 @@
     if (hitTestResult->isContentEditable())
         context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
 
+    if (hitTestResult->isScrollbar())
+        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR;
+
     const String& linkTitle = hitTestResult->linkTitle();
     const String& linkLabel = hitTestResult->linkLabel();
 
@@ -262,6 +265,7 @@
 {
     WebKitHitTestResultPrivate* priv = hitTestResult->priv;
     return webHitTestResult->isContentEditable() == webkit_hit_test_result_context_is_editable(hitTestResult)
+        && webHitTestResult->isScrollbar() == webkit_hit_test_result_context_is_scrollbar(hitTestResult)
         && stringIsEqualToCString(webHitTestResult->absoluteLinkURL(), priv->linkURI)
         && stringIsEqualToCString(webHitTestResult->linkTitle(), priv->linkTitle)
         && stringIsEqualToCString(webHitTestResult->linkLabel(), priv->linkLabel)
@@ -433,3 +437,20 @@
 
     return hitTestResult->priv->mediaURI.data();
 }
+
+/**
+ * webkit_hit_test_result_context_is_scrollbar:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR flag is present in
+ * #WebKitHitTestResult:context.
+ *
+ * Returns: %TRUE if there's a scrollbar element at the coordinates of the @hit_test_result,
+ *    or %FALSE otherwise
+ */
+gboolean webkit_hit_test_result_context_is_scrollbar(WebKitHitTestResult* hitTestResult)
+{
+    g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE);
+
+    return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR;
+}

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h (137191 => 137192)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h	2012-12-10 19:33:51 UTC (rev 137191)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h	2012-12-10 19:42:20 UTC (rev 137192)
@@ -47,16 +47,18 @@
  * @WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE: an image element.
  * @WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA: a video or audio element.
  * @WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE: an editable element
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR: a scrollbar element.
  *
  * Enum values with flags representing the context of a #WebKitHitTestResult.
  */
 typedef enum
 {
-    WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT = 1 << 1,
-    WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK     = 1 << 2,
-    WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE    = 1 << 3,
-    WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA    = 1 << 4,
-    WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE = 1 << 5
+    WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT  = 1 << 1,
+    WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK      = 1 << 2,
+    WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE     = 1 << 3,
+    WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA     = 1 << 4,
+    WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE  = 1 << 5,
+    WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR = 1 << 6
 } WebKitHitTestResultContext;
 
 struct _WebKitHitTestResult {
@@ -102,6 +104,9 @@
 WEBKIT_API const gchar *
 webkit_hit_test_result_get_media_uri        (WebKitHitTestResult *hit_test_result);
 
+WEBKIT_API gboolean
+webkit_hit_test_result_context_is_scrollbar (WebKitHitTestResult *hit_test_result);
+
 G_END_DECLS
 
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (137191 => 137192)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-12-10 19:33:51 UTC (rev 137191)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-12-10 19:42:20 UTC (rev 137192)
@@ -526,6 +526,7 @@
 webkit_hit_test_result_get_link_label
 webkit_hit_test_result_get_image_uri
 webkit_hit_test_result_get_media_uri
+webkit_hit_test_result_context_is_scrollbar
 
 <SUBSECTION Standard>
 WebKitHitTestResultClass

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp (137191 => 137192)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp	2012-12-10 19:33:51 UTC (rev 137191)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp	2012-12-10 19:42:20 UTC (rev 137192)
@@ -481,6 +481,7 @@
         " <a style='position:absolute; left:1; top:20' href='' title='WebKitGTK+ Logo'><img src='' width=5 height=5></img></a>"
         " <video style='position:absolute; left:1; top:30' width=10 height=10 controls='controls'><source src='' type='video/ogg' /></video>"
         " <input style='position:absolute; left:1; top:50' size='10'></input>"
+        " <div style='position:absolute; left:1; top:70; width:30; height:30; overflow:scroll'>&nbsp;</div>"
         "</body></html>";
 
     test->loadHtml(linksHoveredHTML, "file:///");
@@ -511,6 +512,7 @@
     g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
     g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
     g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
     g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
     g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK);
 
@@ -520,6 +522,7 @@
     g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
     g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
     g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
     g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo");
     g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
     g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo");
@@ -532,6 +535,7 @@
     g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
     g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
     g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
     g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg");
     g_assert(!test->m_mouseTargetModifiers);
 
@@ -540,8 +544,18 @@
     g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
     g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
     g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
     g_assert(webkit_hit_test_result_context_is_editable(hitTestResult));
     g_assert(!test->m_mouseTargetModifiers);
+
+    // Move over scrollbar.
+    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 95);
+    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+    g_assert(!test->m_mouseTargetModifiers);
 }
 
 static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to