Title: [122428] trunk/Source/WebKit2
Revision
122428
Author
[email protected]
Date
2012-07-12 01:38:16 -0700 (Thu, 12 Jul 2012)

Log Message

[WK2] Performance issue in FindController::findString
https://bugs.webkit.org/show_bug.cgi?id=78132

Patch by Sergio Villar Senin <[email protected]> on 2012-07-12
Reviewed by Anders Carlsson.

FindController should not unmark all text matches by default. It
will be done only if the string is not found or if
markAllTextMatches() is called. This will allow clients to look
for the next/previous without having to unmark() + mark() all the
text matches for every single search operation.

* UIProcess/API/gtk/WebKitFindController.cpp:
(webKitFindControllerPerform):
(webkit_find_controller_search_next):
(webkit_find_controller_search_previous):
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindUIAfterPageScroll):
(WebKit::FindController::findString):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122427 => 122428)


--- trunk/Source/WebKit2/ChangeLog	2012-07-12 08:38:08 UTC (rev 122427)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-12 08:38:16 UTC (rev 122428)
@@ -1,3 +1,24 @@
+2012-07-12  Sergio Villar Senin  <[email protected]>
+
+        [WK2] Performance issue in FindController::findString
+        https://bugs.webkit.org/show_bug.cgi?id=78132
+
+        Reviewed by Anders Carlsson.
+
+        FindController should not unmark all text matches by default. It
+        will be done only if the string is not found or if
+        markAllTextMatches() is called. This will allow clients to look
+        for the next/previous without having to unmark() + mark() all the
+        text matches for every single search operation.
+
+        * UIProcess/API/gtk/WebKitFindController.cpp:
+        (webKitFindControllerPerform):
+        (webkit_find_controller_search_next):
+        (webkit_find_controller_search_previous):
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::updateFindUIAfterPageScroll):
+        (WebKit::FindController::findString):
+
 2012-07-12  Christophe Dumez  <[email protected]>
 
         [WK2][EFL] Add policy client to Ewk_View

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp (122427 => 122428)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp	2012-07-12 08:38:08 UTC (rev 122427)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp	2012-07-12 08:38:16 UTC (rev 122428)
@@ -48,6 +48,7 @@
 
 typedef enum {
     FindOperation,
+    FindNextPrevOperation,
     CountOperation
 } WebKitFindControllerOperation;
 
@@ -345,17 +346,22 @@
     WKRetainPtr<WKStringRef> wkSearchText(AdoptWK, WKStringCreateWithUTF8CString(findController->priv->searchText.data()));
     WKPageRef wkPage = getWKPageFromWebKitWebView(findController->priv->webView);
 
-    if (operation == FindOperation) {
-        // Unconditionally highlight text matches. WK1 API was forcing
-        // clients to enable/disable highlighting. Since most of them
-        // (all?) where using highlighting we decided to simplify the
-        // WK2 API and unconditionally show highlights.
-        wkFindOptions = static_cast<WKFindOptions>(findController->priv->findOptions | kWKFindOptionsShowHighlight);
-        WKPageFindString(wkPage, wkSearchText.get(), wkFindOptions, findController->priv->maxMatchCount);
+    if (operation == CountOperation) {
+        WKPageCountStringMatches(wkPage, wkSearchText.get(), wkFindOptions, findController->priv->maxMatchCount);
         return;
     }
 
-    WKPageCountStringMatches(wkPage, wkSearchText.get(), wkFindOptions, findController->priv->maxMatchCount);
+    if (operation == FindOperation)
+        // Unconditionally highlight text matches when the search
+        // starts. WK1 API was forcing clients to enable/disable
+        // highlighting. Since most of them (all?) where using that
+        // feature we decided to simplify the WK2 API and
+        // unconditionally show highlights. Both search_next() and
+        // search_prev() should not enable highlighting to avoid an
+        // extra unmarkAllTextMatches() + markAllTextMatches()
+        wkFindOptions = static_cast<WKFindOptions>(findController->priv->findOptions | kWKFindOptionsShowHighlight);
+
+    WKPageFindString(wkPage, wkSearchText.get(), wkFindOptions, findController->priv->maxMatchCount);
 }
 
 static inline void webKitFindControllerSetSearchData(WebKitFindController* findController, const gchar* searchText, guint32 findOptions, guint maxMatchCount)
@@ -415,7 +421,8 @@
     g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController));
 
     findController->priv->findOptions = findController->priv->findOptions & ~WEBKIT_FIND_OPTIONS_BACKWARDS;
-    webKitFindControllerPerform(findController, FindOperation);
+    findController->priv->findOptions = findController->priv->findOptions & ~kWKFindOptionsShowHighlight;
+    webKitFindControllerPerform(findController, FindNextPrevOperation);
 }
 
 /**
@@ -432,7 +439,8 @@
     g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController));
 
     findController->priv->findOptions = findController->priv->findOptions | WEBKIT_FIND_OPTIONS_BACKWARDS;
-    webKitFindControllerPerform(findController, FindOperation);
+    findController->priv->findOptions = findController->priv->findOptions & ~kWKFindOptionsShowHighlight;
+    webKitFindControllerPerform(findController, FindNextPrevOperation);
 }
 
 /**

Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp (122427 => 122428)


--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp	2012-07-12 08:38:08 UTC (rev 122427)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp	2012-07-12 08:38:16 UTC (rev 122428)
@@ -97,6 +97,8 @@
     bool shouldShowOverlay = false;
 
     if (!found) {
+        m_webPage->corePage()->unmarkAllTextMatches();
+
         // Clear the selection.
         if (selectedFrame)
             selectedFrame->selection()->clear();
@@ -114,6 +116,7 @@
             if (maxMatchCount == numeric_limits<unsigned>::max())
                 --maxMatchCount;
 
+            m_webPage->corePage()->unmarkAllTextMatches();
             matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), shouldShowHighlight, maxMatchCount + 1);
 
             // Check if we have more matches than allowed.
@@ -152,8 +155,6 @@
 
 void FindController::findString(const String& string, FindOptions options, unsigned maxMatchCount)
 {
-    m_webPage->corePage()->unmarkAllTextMatches();
-
     bool found = m_webPage->corePage()->findString(string, core(options));
 
     m_webPage->drawingArea()->dispatchAfterEnsuringUpdatedScrollPosition(WTF::bind(&FindController::updateFindUIAfterPageScroll, this, found, string, options, maxMatchCount));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to