Title: [129758] trunk/Source/WebKit2
Revision
129758
Author
[email protected]
Date
2012-09-27 06:00:12 -0700 (Thu, 27 Sep 2012)

Log Message

[EFL][WK2] Add callback functions for WKPageFindClient
https://bugs.webkit.org/show_bug.cgi?id=97431

Patch by Jinwoo Song <[email protected]> on 2012-09-27
Reviewed by Laszlo Gombos.

Add didFailToFindString() and didCountStringMatches() for WKPageFindClient's callback functions.
The unit test for didFindString() and didFailToFindString() have beend added. The unit test for
didCountStringMatches() needs a API which wraps the WKPageCountStringMatches but it is not exists yet.
Additionaly, I changed the 'unsinged int' to 'unsigned' in the parameter type and removed unnecessary
type conversion.

* UIProcess/API/efl/ewk_view.cpp:
(ewk_view_text_find):
* UIProcess/API/efl/ewk_view.h:
* UIProcess/API/efl/ewk_view_find_client.cpp:
(didFindString):
(didFailToFindString):
(didCountStringMatches):
(ewk_view_find_client_attach):
* UIProcess/API/efl/tests/test_ewk2_view.cpp:
(onTextFound):
(TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (129757 => 129758)


--- trunk/Source/WebKit2/ChangeLog	2012-09-27 12:53:56 UTC (rev 129757)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-27 13:00:12 UTC (rev 129758)
@@ -1,3 +1,28 @@
+2012-09-27  Jinwoo Song  <[email protected]>
+
+        [EFL][WK2] Add callback functions for WKPageFindClient
+        https://bugs.webkit.org/show_bug.cgi?id=97431
+
+        Reviewed by Laszlo Gombos.
+
+        Add didFailToFindString() and didCountStringMatches() for WKPageFindClient's callback functions.
+        The unit test for didFindString() and didFailToFindString() have beend added. The unit test for
+        didCountStringMatches() needs a API which wraps the WKPageCountStringMatches but it is not exists yet.
+        Additionaly, I changed the 'unsinged int' to 'unsigned' in the parameter type and removed unnecessary
+        type conversion.
+
+        * UIProcess/API/efl/ewk_view.cpp:
+        (ewk_view_text_find):
+        * UIProcess/API/efl/ewk_view.h:
+        * UIProcess/API/efl/ewk_view_find_client.cpp:
+        (didFindString):
+        (didFailToFindString):
+        (didCountStringMatches):
+        (ewk_view_find_client_attach):
+        * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+        (onTextFound):
+        (TEST_F):
+
 2012-09-27  Allan Sandfeld Jensen  <[email protected]>
 
         Unify event handling of middle mouse button.

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (129757 => 129758)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-09-27 12:53:56 UTC (rev 129757)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-09-27 13:00:12 UTC (rev 129758)
@@ -1517,7 +1517,7 @@
 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
 
-Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned int maxMatchCount)
+Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (129757 => 129758)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-09-27 12:53:56 UTC (rev 129757)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-09-27 13:00:12 UTC (rev 129758)
@@ -622,7 +622,7 @@
 *
 * @return @c EINA_TRUE on success, @c EINA_FALSE on errors
 */
-EAPI Eina_Bool ewk_view_text_find(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned int max_match_count);
+EAPI Eina_Bool ewk_view_text_find(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned max_match_count);
 
 /**
 * Clears the highlight of searched text.

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp (129757 => 129758)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp	2012-09-27 12:53:56 UTC (rev 129757)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp	2012-09-27 13:00:12 UTC (rev 129758)
@@ -34,11 +34,21 @@
     return static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
 }
 
-static void didFindString(WKPageRef, WKStringRef /*string*/, unsigned matchCount, const void* clientInfo)
+static void didFindString(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo)
 {
-    ewk_view_text_found(toEwkView(clientInfo), static_cast<unsigned int>(matchCount));
+    ewk_view_text_found(toEwkView(clientInfo), matchCount);
 }
 
+static void didFailToFindString(WKPageRef, WKStringRef, const void* clientInfo)
+{
+    ewk_view_text_found(toEwkView(clientInfo), 0);
+}
+
+static void didCountStringMatches(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo)
+{
+    ewk_view_text_found(toEwkView(clientInfo), matchCount);
+}
+
 void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
 {
     WKPageFindClient findClient;
@@ -46,5 +56,7 @@
     findClient.version = kWKPageFindClientCurrentVersion;
     findClient.clientInfo = ewkView;
     findClient.didFindString = didFindString;
+    findClient.didFailToFindString = didFailToFindString;
+    findClient.didCountStringMatches = didCountStringMatches;
     WKPageSetPageFindClient(pageRef, &findClient);
 }

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp (129757 => 129758)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp	2012-09-27 12:53:56 UTC (rev 129757)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp	2012-09-27 13:00:12 UTC (rev 129758)
@@ -787,3 +787,40 @@
 
     eina_list_free(points);
 }
+
+static void onTextFound(void* userData, Evas_Object*, void* eventInfo)
+{
+    int* result = static_cast<int*>(userData);
+    unsigned* matchCount = static_cast<unsigned*>(eventInfo);
+
+    *result = *matchCount;
+}
+
+TEST_F(EWK2UnitTestBase, ewk_view_text_find)
+{
+    const char textFindHTML[] =
+        "<!DOCTYPE html>"
+        "<html>"
+        "<body>"
+        "apple apple apple banana banana coconut"
+        "</body>"
+        "</html>";
+    ewk_view_html_string_load(webView(), textFindHTML, 0, 0);
+    waitUntilLoadFinished();
+
+    int matchCount = -1;
+    evas_object_smart_callback_add(webView(), "text,found", onTextFound, &matchCount);
+
+    ewk_view_text_find(webView(), "apple", EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+    EXPECT_EQ(3, matchCount);
+
+    matchCount = -1;
+    ewk_view_text_find(webView(), "mango", EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+    EXPECT_EQ(0, matchCount);
+
+    evas_object_smart_callback_del(webView(), "text,found", onTextFound);
+}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to