Changeset 122428 in webkit


Ignore:
Timestamp:
Jul 12, 2012 1:38:16 AM (12 years ago)
Author:
Carlos Garcia Campos
Message:

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

Patch by Sergio Villar Senin <svillar@igalia.com> 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):

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r122426 r122428  
     12012-07-12  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [WK2] Performance issue in FindController::findString
     4        https://bugs.webkit.org/show_bug.cgi?id=78132
     5
     6        Reviewed by Anders Carlsson.
     7
     8        FindController should not unmark all text matches by default. It
     9        will be done only if the string is not found or if
     10        markAllTextMatches() is called. This will allow clients to look
     11        for the next/previous without having to unmark() + mark() all the
     12        text matches for every single search operation.
     13
     14        * UIProcess/API/gtk/WebKitFindController.cpp:
     15        (webKitFindControllerPerform):
     16        (webkit_find_controller_search_next):
     17        (webkit_find_controller_search_previous):
     18        * WebProcess/WebPage/FindController.cpp:
     19        (WebKit::FindController::updateFindUIAfterPageScroll):
     20        (WebKit::FindController::findString):
     21
    1222012-07-12  Christophe Dumez  <christophe.dumez@intel.com>
    223
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp

    r109881 r122428  
    4949typedef enum {
    5050    FindOperation,
     51    FindNextPrevOperation,
    5152    CountOperation
    5253} WebKitFindControllerOperation;
     
    346347    WKPageRef wkPage = getWKPageFromWebKitWebView(findController->priv->webView);
    347348
    348     if (operation == FindOperation) {
    349         // Unconditionally highlight text matches. WK1 API was forcing
    350         // clients to enable/disable highlighting. Since most of them
    351         // (all?) where using highlighting we decided to simplify the
    352         // WK2 API and unconditionally show highlights.
    353         wkFindOptions = static_cast<WKFindOptions>(findController->priv->findOptions | kWKFindOptionsShowHighlight);
    354         WKPageFindString(wkPage, wkSearchText.get(), wkFindOptions, findController->priv->maxMatchCount);
     349    if (operation == CountOperation) {
     350        WKPageCountStringMatches(wkPage, wkSearchText.get(), wkFindOptions, findController->priv->maxMatchCount);
    355351        return;
    356352    }
    357353
    358     WKPageCountStringMatches(wkPage, wkSearchText.get(), wkFindOptions, findController->priv->maxMatchCount);
     354    if (operation == FindOperation)
     355        // Unconditionally highlight text matches when the search
     356        // starts. WK1 API was forcing clients to enable/disable
     357        // highlighting. Since most of them (all?) where using that
     358        // feature we decided to simplify the WK2 API and
     359        // unconditionally show highlights. Both search_next() and
     360        // search_prev() should not enable highlighting to avoid an
     361        // extra unmarkAllTextMatches() + markAllTextMatches()
     362        wkFindOptions = static_cast<WKFindOptions>(findController->priv->findOptions | kWKFindOptionsShowHighlight);
     363
     364    WKPageFindString(wkPage, wkSearchText.get(), wkFindOptions, findController->priv->maxMatchCount);
    359365}
    360366
     
    416422
    417423    findController->priv->findOptions = findController->priv->findOptions & ~WEBKIT_FIND_OPTIONS_BACKWARDS;
    418     webKitFindControllerPerform(findController, FindOperation);
     424    findController->priv->findOptions = findController->priv->findOptions & ~kWKFindOptionsShowHighlight;
     425    webKitFindControllerPerform(findController, FindNextPrevOperation);
    419426}
    420427
     
    433440
    434441    findController->priv->findOptions = findController->priv->findOptions | WEBKIT_FIND_OPTIONS_BACKWARDS;
    435     webKitFindControllerPerform(findController, FindOperation);
     442    findController->priv->findOptions = findController->priv->findOptions & ~kWKFindOptionsShowHighlight;
     443    webKitFindControllerPerform(findController, FindNextPrevOperation);
    436444}
    437445
  • trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp

    r121015 r122428  
    9898
    9999    if (!found) {
     100        m_webPage->corePage()->unmarkAllTextMatches();
     101
    100102        // Clear the selection.
    101103        if (selectedFrame)
     
    115117                --maxMatchCount;
    116118
     119            m_webPage->corePage()->unmarkAllTextMatches();
    117120            matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), shouldShowHighlight, maxMatchCount + 1);
    118121
     
    153156void FindController::findString(const String& string, FindOptions options, unsigned maxMatchCount)
    154157{
    155     m_webPage->corePage()->unmarkAllTextMatches();
    156 
    157158    bool found = m_webPage->corePage()->findString(string, core(options));
    158159
Note: See TracChangeset for help on using the changeset viewer.