Title: [124864] trunk/Source/WebKit2
Revision
124864
Author
[email protected]
Date
2012-08-07 01:15:43 -0700 (Tue, 07 Aug 2012)

Log Message

[EFL][WK2] Add ewk_view_find_client.h / cpp for wrapping WKPageSetPageFindClient.
https://bugs.webkit.org/show_bug.cgi?id=90927

Patch by Hyerim Bae <[email protected]> on 2012-08-07
Reviewed by Kentaro Hara.

Add ewk_view_find_client.h / files for wrapping WKPageSetPageFindClient,
add didFindString callback member of WKPageSetPageFindClient.

* PlatformEfl.cmake:
* UIProcess/API/efl/ewk_view.cpp:
(ewk_view_base_add):
(ewk_view_text_found):
(ewk_view_text_find):
(ewk_view_text_find_highlight_clear):
* UIProcess/API/efl/ewk_view.h:
* UIProcess/API/efl/ewk_view_find_client.cpp: Added.
(toEwkView):
(didFindString):
(ewk_view_find_client_attach):
* UIProcess/API/efl/ewk_view_find_client_private.h: Added.
* UIProcess/API/efl/ewk_view_private.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (124863 => 124864)


--- trunk/Source/WebKit2/ChangeLog	2012-08-07 07:48:55 UTC (rev 124863)
+++ trunk/Source/WebKit2/ChangeLog	2012-08-07 08:15:43 UTC (rev 124864)
@@ -1,3 +1,27 @@
+2012-08-07  Hyerim Bae  <[email protected]>
+
+        [EFL][WK2] Add ewk_view_find_client.h / cpp for wrapping WKPageSetPageFindClient.
+        https://bugs.webkit.org/show_bug.cgi?id=90927
+
+        Reviewed by Kentaro Hara.
+
+        Add ewk_view_find_client.h / files for wrapping WKPageSetPageFindClient,
+        add didFindString callback member of WKPageSetPageFindClient.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/efl/ewk_view.cpp:
+        (ewk_view_base_add):
+        (ewk_view_text_found):
+        (ewk_view_text_find):
+        (ewk_view_text_find_highlight_clear):
+        * UIProcess/API/efl/ewk_view.h:
+        * UIProcess/API/efl/ewk_view_find_client.cpp: Added.
+        (toEwkView):
+        (didFindString):
+        (ewk_view_find_client_attach):
+        * UIProcess/API/efl/ewk_view_find_client_private.h: Added.
+        * UIProcess/API/efl/ewk_view_private.h:
+
 2012-08-06  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r124816.

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (124863 => 124864)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-08-07 07:48:55 UTC (rev 124863)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-08-07 08:15:43 UTC (rev 124864)
@@ -55,6 +55,7 @@
     UIProcess/API/efl/ewk_url_response.cpp
     UIProcess/API/efl/ewk_url_scheme_request.cpp
     UIProcess/API/efl/ewk_view.cpp
+    UIProcess/API/efl/ewk_view_find_client.cpp
     UIProcess/API/efl/ewk_view_form_client.cpp
     UIProcess/API/efl/ewk_view_loader_client.cpp
     UIProcess/API/efl/ewk_view_policy_client.cpp

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


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-08-07 07:48:55 UTC (rev 124863)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-08-07 08:15:43 UTC (rev 124864)
@@ -26,12 +26,15 @@
 #include "NativeWebWheelEvent.h"
 #include "PageClientImpl.h"
 #include "WKAPICast.h"
+#include "WKFindOptions.h"
 #include "WKRetainPtr.h"
 #include "WKString.h"
 #include "WKURL.h"
 #include "ewk_context.h"
 #include "ewk_context_private.h"
 #include "ewk_intent_private.h"
+#include "ewk_private.h"
+#include "ewk_view_find_client_private.h"
 #include "ewk_view_form_client_private.h"
 #include "ewk_view_loader_client_private.h"
 #include "ewk_view_policy_client_private.h"
@@ -664,6 +667,7 @@
     priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), ewkView);
 
     WKPageRef wkPage = toAPI(priv->pageClient->page());
+    ewk_view_find_client_attach(wkPage, ewkView);
     ewk_view_form_client_attach(wkPage, ewkView);
     ewk_view_loader_client_attach(wkPage, ewkView);
     ewk_view_policy_client_attach(wkPage, ewkView);
@@ -869,6 +873,17 @@
 
 /**
  * @internal
+ * Reports that the requested text was found.
+ *
+ * Emits signal: "text,found" with the number of matches.
+ */
+void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
+{
+    evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
+}
+
+/**
+ * @internal
  * The view title was changed by the frame loader.
  *
  * Emits signal: "title,changed" with pointer to new title string.
@@ -1315,3 +1330,35 @@
 
     return static_cast<WKPageRef>(WKRetain(ewk_view_page_get(newEwkView)));
 }
+
+// EwkFindOptions should be matched up orders with WkFindOptions.
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
+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)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
+
+    WKRetainPtr<WKStringRef> findText(AdoptWK, WKStringCreateWithUTF8CString(text));
+    WKPageFindString(toAPI(priv->pageClient->page()), findText.get(), static_cast<WKFindOptions>(options), maxMatchCount);
+
+    return true;
+}
+
+Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+    WKPageHideFindUI(toAPI(priv->pageClient->page()));
+
+    return true;
+}

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


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-08-07 07:48:55 UTC (rev 124863)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-08-07 08:15:43 UTC (rev 124864)
@@ -61,6 +61,7 @@
  * - "resource,request,new", const Ewk_Web_Resource_Request*: a resource request was initiated.
  * - "resource,request,response", Ewk_Web_Resource_Load_Response*: a response to a resource request was received.
  * - "resource,request,sent", const Ewk_Web_Resource_Request*: a resource request was sent.
+ * - "text,found", unsigned int*: the requested text was found and it gives the number of matches.
  * - "title,changed", const char*: title of the main frame was changed.
  * - "uri,changed", const char*: uri of the main frame was changed.
  */
@@ -218,6 +219,24 @@
 };
 
 /**
+ * Enum values used to specify search options.
+ * @brief   Provides option to find text
+ * @info    Keep this in sync with WKFindOptions.h
+ */
+enum _Ewk_Find_Options {
+    EWK_FIND_OPTIONS_NONE, /**< no search flags, this means a case sensitive, no wrap, forward only search. */
+    EWK_FIND_OPTIONS_CASE_INSENSITIVE = 1 << 0, /**< case insensitive search. */
+    EWK_FIND_OPTIONS_AT_WORD_STARTS = 1 << 1, /**< search text only at the beginning of the words. */
+    EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START = 1 << 2, /**< treat capital letters in the middle of words as word start. */
+    EWK_FIND_OPTIONS_BACKWARDS = 1 << 3, /**< search backwards. */
+    EWK_FIND_OPTIONS_WRAP_AROUND = 1 << 4, /**< if not present search will stop at the end of the document. */
+    EWK_FIND_OPTIONS_SHOW_OVERLAY = 1 << 5, /**< show overlay */
+    EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR = 1 << 6, /**< show indicator */
+    EWK_FIND_OPTIONS_SHOW_HIGHLIGHT = 1 << 7 /**< show highlight */
+};
+typedef enum _Ewk_Find_Options Ewk_Find_Options;
+
+/**
  * Creates a new EFL WebKit view object.
  *
  * @param e canvas object where to create the view object
@@ -496,6 +515,27 @@
  */
 EAPI Eina_Bool    ewk_view_setting_encoding_custom_set(Evas_Object *o, const char *encoding);
 
+/**
+* Searches the given string in the document.
+*
+* @param o view object to find text
+* @param text text to find
+* @param options options to find
+* @param max count to find, unlimited if 0
+*
+* @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);
+
+/**
+* Clears the highlight of searched text.
+*
+* @param o view object to find text
+*
+* @return @c EINA_TRUE on success, @c EINA_FALSE on errors
+*/
+EAPI Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *o);
+
 #ifdef __cplusplus
 }
 #endif

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp (0 => 124864)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp	2012-08-07 08:15:43 UTC (rev 124864)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "WKPage.h"
+#include "ewk_view_find_client_private.h"
+#include "ewk_view_private.h"
+
+static inline Evas_Object* toEwkView(const void* clientInfo)
+{
+    return static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+}
+
+static void didFindString(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo)
+{
+    ewk_view_text_found(toEwkView(clientInfo), static_cast<unsigned int>(matchCount));
+}
+
+void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
+{
+    WKPageFindClient findClient;
+    memset(&findClient, 0, sizeof(WKPageFindClient));
+    findClient.version = kWKPageFindClientCurrentVersion;
+    findClient.clientInfo = ewkView;
+    findClient.didFindString = didFindString;
+    WKPageSetPageFindClient(pageRef, &findClient);
+}

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h (0 => 124864)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h	2012-08-07 08:15:43 UTC (rev 124864)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ewk_view_find_client_private_h
+#define ewk_view_find_client_private_h
+
+#include <Evas.h>
+#include <WebKit2/WKBase.h>
+
+void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView);
+
+#endif // ewk_view_find_client_private_h

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h (124863 => 124864)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h	2012-08-07 07:48:55 UTC (rev 124863)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h	2012-08-07 08:15:43 UTC (rev 124864)
@@ -69,6 +69,7 @@
 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request);
 void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response);
 void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse);
+void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount);
 
 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to