[WK2] Add WKHitTestResultIsContentEditable()
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jun 2012 08:40:42 +0000 (08:40 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jun 2012 08:40:42 +0000 (08:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80597

Reviewed by Martin Robinson.

* Shared/WebHitTestResult.cpp:
(WebKit::WebHitTestResult::Data::encode): Encode isContentEditable.
(WebKit::WebHitTestResult::Data::decode): Decode isContentEditable.
* Shared/WebHitTestResult.h:
(Data): Add isContentEditable.
(WebKit::WebHitTestResult::Data::Data): Initialize
isContentEditable.
(WebKit::WebHitTestResult::isContentEditable): Returns whether
hit test result target is editable content.
* UIProcess/API/C/WKHitTestResult.cpp:
(WKHitTestResultIsContentEditable): C API to get whether hit test
result target is editable content.
* UIProcess/API/C/WKHitTestResult.h:
* UIProcess/API/gtk/WebKitHitTestResult.cpp:
(webkitHitTestResultCreate): Add
WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE flags to the context if
hit test result target is editable content.
(webkit_hit_test_result_context_is_editable): Returns TRUE if
WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE flags is present in
context.
* UIProcess/API/gtk/WebKitHitTestResult.h:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(testWebViewMouseTarget): Add tests for
WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120297 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebHitTestResult.cpp
Source/WebKit2/Shared/WebHitTestResult.h
Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp
Source/WebKit2/UIProcess/API/C/WKHitTestResult.h
Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp

index 34b73de9bb4d54b83cd5aabcc7d7b5c9b682ee24..bdbaafd43c4020cb98b4fbc106e68a77ac4433d0 100644 (file)
@@ -1,3 +1,36 @@
+2012-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [WK2] Add WKHitTestResultIsContentEditable()
+        https://bugs.webkit.org/show_bug.cgi?id=80597
+
+        Reviewed by Martin Robinson.
+
+        * Shared/WebHitTestResult.cpp:
+        (WebKit::WebHitTestResult::Data::encode): Encode isContentEditable.
+        (WebKit::WebHitTestResult::Data::decode): Decode isContentEditable.
+        * Shared/WebHitTestResult.h:
+        (Data): Add isContentEditable.
+        (WebKit::WebHitTestResult::Data::Data): Initialize
+        isContentEditable.
+        (WebKit::WebHitTestResult::isContentEditable): Returns whether
+        hit test result target is editable content.
+        * UIProcess/API/C/WKHitTestResult.cpp:
+        (WKHitTestResultIsContentEditable): C API to get whether hit test
+        result target is editable content.
+        * UIProcess/API/C/WKHitTestResult.h:
+        * UIProcess/API/gtk/WebKitHitTestResult.cpp:
+        (webkitHitTestResultCreate): Add
+        WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE flags to the context if
+        hit test result target is editable content.
+        (webkit_hit_test_result_context_is_editable): Returns TRUE if
+        WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE flags is present in
+        context.
+        * UIProcess/API/gtk/WebKitHitTestResult.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
+        * UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
+        (testWebViewMouseTarget): Add tests for
+        WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE.
+
 2012-06-14  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
 
         [WK2] Fix client interface size for WKPageLoaderClient.
index 6e346e08d00e3f748bbf4cb820bb73d70255db49..26eaf6a0afd30adc542231b1eef36988d3fb1fcd 100644 (file)
@@ -42,6 +42,7 @@ void WebHitTestResult::Data::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(absoluteMediaURL);
     encoder->encode(linkLabel);
     encoder->encode(linkTitle);
+    encoder->encode(isContentEditable);
 }
 
 bool WebHitTestResult::Data::decode(CoreIPC::ArgumentDecoder* decoder, WebHitTestResult::Data& hitTestResultData)
@@ -51,7 +52,8 @@ bool WebHitTestResult::Data::decode(CoreIPC::ArgumentDecoder* decoder, WebHitTes
         || !decoder->decode(hitTestResultData.absoluteLinkURL)
         || !decoder->decode(hitTestResultData.absoluteMediaURL)
         || !decoder->decode(hitTestResultData.linkLabel)
-        || !decoder->decode(hitTestResultData.linkTitle))
+        || !decoder->decode(hitTestResultData.linkTitle)
+        || !decoder->decode(hitTestResultData.isContentEditable))
         return false;
 
     return true;
index d16dcddd4fbd1c7b3d7ba4e57a6151861a34c528..798a2db2bcf75ed68ac75129222488c211d6b8cb 100644 (file)
@@ -48,6 +48,7 @@ public:
         String absoluteMediaURL;
         String linkLabel;
         String linkTitle;
+        bool isContentEditable;
 
         Data()
         {
@@ -60,6 +61,7 @@ public:
             , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
             , linkLabel(hitTestResult.textContent())
             , linkTitle(hitTestResult.titleDisplayString())
+            , isContentEditable(hitTestResult.isContentEditable())
         {
         }
 
@@ -77,6 +79,8 @@ public:
     String linkLabel() const { return m_data.linkLabel; }
     String linkTitle() const { return m_data.linkTitle; }
 
+    bool isContentEditable() const { return m_data.isContentEditable; }
+
 private:
     explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData)
         : m_data(hitTestResultData)
index a87b6e35ba4b6cef697c90a46252362d9e271965..5949091bb5c8ad639f85c7b0257fb5a7159313c4 100644 (file)
@@ -66,3 +66,8 @@ WKStringRef WKHitTestResultCopyLinkTitle(WKHitTestResultRef hitTestResultRef)
 {
     return toCopiedAPI(toImpl(hitTestResultRef)->linkTitle());
 }
+
+bool WKHitTestResultIsContentEditable(WKHitTestResultRef hitTestResultRef)
+{
+    return toImpl(hitTestResultRef)->isContentEditable();
+}
index 0ba23df6ccc0737d77248694ee05bb356cb3ca25..55fd13768edbfe4b44a9032de25f9b2372f2265f 100644 (file)
@@ -43,6 +43,8 @@ WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteMediaURL(WKHitTestResultRef hitTes
 WK_EXPORT WKStringRef WKHitTestResultCopyLinkLabel(WKHitTestResultRef hitTestResult);
 WK_EXPORT WKStringRef WKHitTestResultCopyLinkTitle(WKHitTestResultRef hitTestResult);
 
+WK_EXPORT bool WKHitTestResultIsContentEditable(WKHitTestResultRef hitTestResult);
+
 #ifdef __cplusplus
 }
 #endif
index 928b4dc42a469d5f64260f3647bb54c21f360748..034768cb056b67671bcc5d1b867e42dd23bb4a1d 100644 (file)
@@ -253,6 +253,9 @@ WebKitHitTestResult* webkitHitTestResultCreate(WKHitTestResultRef wkHitTestResul
     if (!mediaURL.isEmpty())
         context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
 
+    if (WKHitTestResultIsContentEditable(wkHitTestResult))
+        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
+
     const String& linkTitle = toImpl(wkHitTestResult)->linkTitle();
     const String& linkLabel = toImpl(wkHitTestResult)->linkLabel();
 
@@ -347,6 +350,23 @@ gboolean webkit_hit_test_result_context_is_media(WebKitHitTestResult* hitTestRes
     return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
 }
 
+/**
+ * webkit_hit_test_result_context_is_editable:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE flag is present in
+ * #WebKitHitTestResult:context.
+ *
+ * Returns: %TRUE if there's an editable element at the coordinates of the @hit_test_result,
+ *    or %FALSE otherwise
+ */
+gboolean webkit_hit_test_result_context_is_editable(WebKitHitTestResult* hitTestResult)
+{
+    g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE);
+
+    return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
+}
+
 /**
  * webkit_hit_test_result_get_link_uri:
  * @hit_test_result: a #WebKitHitTestResult
index d8916e5f3be6741c623e8a816b46e7e69693dc12..01e66c9641cfba5884afa51eb3ea5dd8587a590d 100644 (file)
@@ -46,6 +46,7 @@ typedef struct _WebKitHitTestResultPrivate WebKitHitTestResultPrivate;
  * @WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK: a hyperlink element.
  * @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
  *
  * Enum values with flags representing the context of a #WebKitHitTestResult.
  */
@@ -54,7 +55,8 @@ 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_MEDIA    = 1 << 4,
+    WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE = 1 << 5
 } WebKitHitTestResultContext;
 
 struct _WebKitHitTestResult {
@@ -82,6 +84,9 @@ webkit_hit_test_result_context_is_image     (WebKitHitTestResult *hit_test_resul
 WEBKIT_API gboolean
 webkit_hit_test_result_context_is_media     (WebKitHitTestResult *hit_test_result);
 
+WEBKIT_API gboolean
+webkit_hit_test_result_context_is_editable  (WebKitHitTestResult *hit_test_result);
+
 WEBKIT_API const gchar *
 webkit_hit_test_result_get_link_uri         (WebKitHitTestResult *hit_test_result);
 
index ce693739b6bac95aa2531d0e9e9e873686a32f50..1b97de88f8d1b9e46e10f687542044c6bc56a25b 100644 (file)
@@ -483,6 +483,7 @@ webkit_hit_test_result_get_context
 webkit_hit_test_result_context_is_link
 webkit_hit_test_result_context_is_image
 webkit_hit_test_result_context_is_media
+webkit_hit_test_result_context_is_editable
 webkit_hit_test_result_get_link_uri
 webkit_hit_test_result_get_link_title
 webkit_hit_test_result_get_link_label
index 51006df2b136d94287e857d53a736b7b586739df..646752974e8ff0e3f5d9181b51663ff9a5b10160 100644 (file)
@@ -417,6 +417,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
         " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>"
         " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>"
         " <video style='position:absolute; left:1; top:30' width=10 height=10 controls='controls'><source src='movie.ogg' type='video/ogg' /></video>"
+        " <input style='position:absolute; left:1; top:50' size='10'></input>"
         "</body></html>";
 
     test->loadHtml(linksHoveredHTML, "file:///");
@@ -427,6 +428,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
     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_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/");
     g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title");
     g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website");
@@ -437,6 +439,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
     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(!test->m_mouseTargetModifiers);
 
     // Move over image with GDK_CONTROL_MASK.
@@ -444,6 +447,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
     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_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
     g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK);
 
@@ -452,6 +456,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
     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_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");
@@ -463,8 +468,17 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
     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_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg");
     g_assert(!test->m_mouseTargetModifiers);
+
+    // Mover over input.
+    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 55);
+    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(!test->m_mouseTargetModifiers);
 }
 
 static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer)