Typing in Safari's unified field causes unnecessary web content repaints.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 May 2013 07:12:19 +0000 (07:12 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 May 2013 07:12:19 +0000 (07:12 +0000)
<http://webkit.org/b/116703>

Reviewed by Andy Estes.

Source/WebCore:

Break out an alternate version of Page::markAllMatchesForText() that only counts the number of times
a string occurs in the page, but doesn't try to mark the occurrences.
This allows Safari to count matches for the 'Find "foo" on This Page' functionality in the unified
location bar without causing tile repaints.

* WebCore.exp.in:
* page/Page.h:
* page/Page.cpp:
(WebCore::Page::findMatchesForText):
(WebCore::Page::markAllMatchesForText):
(WebCore::Page::countFindMatches):

    Renamed markAllMatchesForText() to findMatchesForText() and gave it a boolean parameter to control whether
    matches should be marked or not. countFindMatches() is the new helper that doesn't mark.

Source/WebKit2:

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::countStringMatches):

    Call WebCore::Page::countMatchesForText() instead of markAllMatchesForText(). If the search string
    is found inside the page content, the renderer containing that text will no longer be repainted.

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/FindController.cpp

index 581537b..3947499 100644 (file)
@@ -1,3 +1,25 @@
+2013-05-24  Andreas Kling  <akling@apple.com>
+
+        Typing in Safari's unified field causes unnecessary web content repaints.
+        <http://webkit.org/b/116703>
+
+        Reviewed by Andy Estes.
+
+        Break out an alternate version of Page::markAllMatchesForText() that only counts the number of times
+        a string occurs in the page, but doesn't try to mark the occurrences.
+        This allows Safari to count matches for the 'Find "foo" on This Page' functionality in the unified
+        location bar without causing tile repaints.
+
+        * WebCore.exp.in:
+        * page/Page.h:
+        * page/Page.cpp:
+        (WebCore::Page::findMatchesForText):
+        (WebCore::Page::markAllMatchesForText):
+        (WebCore::Page::countFindMatches):
+
+            Renamed markAllMatchesForText() to findMatchesForText() and gave it a boolean parameter to control whether
+            matches should be marked or not. countFindMatches() is the new helper that doesn't mark.
+
 2013-05-23  Beth Dakin  <bdakin@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=116702
index 004389a..c005090 100644 (file)
@@ -855,6 +855,7 @@ __ZN7WebCore4Page13setPaginationERKNS_10PaginationE
 __ZN7WebCore4Page14setMediaVolumeEf
 __ZN7WebCore4Page15addSchedulePairEN3WTF10PassRefPtrINS1_12SchedulePairEEE
 __ZN7WebCore4Page15didMoveOnscreenEv
+__ZN7WebCore4Page16countFindMatchesERKN3WTF6StringEjj
 __ZN7WebCore4Page16setCanStartMediaEb
 __ZN7WebCore4Page16setDefersLoadingEb
 __ZN7WebCore4Page17willMoveOffscreenEv
index f209e34..ef5d209 100644 (file)
@@ -644,26 +644,32 @@ PassRefPtr<Range> Page::rangeOfString(const String& target, Range* referenceRang
     return 0;
 }
 
-unsigned int Page::markAllMatchesForText(const String& target, TextCaseSensitivity caseSensitivity, bool shouldHighlight, unsigned limit)
-{
-    return markAllMatchesForText(target, caseSensitivity == TextCaseInsensitive ? CaseInsensitive : 0, shouldHighlight, limit);
-}
-
-unsigned int Page::markAllMatchesForText(const String& target, FindOptions options, bool shouldHighlight, unsigned limit)
+unsigned Page::findMatchesForText(const String& target, FindOptions options, unsigned maxMatchCount, bool shouldHighlight, bool markMatches)
 {
     if (target.isEmpty() || !mainFrame())
         return 0;
 
-    unsigned matches = 0;
+    unsigned matchCount = 0;
 
     Frame* frame = mainFrame();
     do {
-        frame->editor().setMarkedTextMatchesAreHighlighted(shouldHighlight);
-        matches += frame->editor().countMatchesForText(target, 0, options, limit ? (limit - matches) : 0, true, 0);
+        if (markMatches)
+            frame->editor().setMarkedTextMatchesAreHighlighted(shouldHighlight);
+        matchCount += frame->editor().countMatchesForText(target, 0, options, maxMatchCount ? (maxMatchCount - matchCount) : 0, markMatches, 0);
         frame = incrementFrame(frame, true, false);
     } while (frame);
 
-    return matches;
+    return matchCount;
+}
+
+unsigned Page::markAllMatchesForText(const String& target, FindOptions options, bool shouldHighlight, unsigned maxMatchCount)
+{
+    return findMatchesForText(target, options, shouldHighlight, maxMatchCount, /*markMatches*/ true);
+}
+
+unsigned Page::countFindMatches(const String& target, FindOptions options, unsigned maxMatchCount)
+{
+    return findMatchesForText(target, options, /*shouldHighlight*/ false, maxMatchCount, /*markMatches*/ false);
 }
 
 void Page::unmarkAllTextMatches()
index 209d4b6..ce70373 100644 (file)
@@ -232,9 +232,9 @@ public:
 
     PassRefPtr<Range> rangeOfString(const String&, Range*, FindOptions);
 
-    unsigned markAllMatchesForText(const String&, FindOptions, bool shouldHighlight, unsigned);
-    // FIXME: Switch callers over to the FindOptions version and retire this one.
-    unsigned markAllMatchesForText(const String&, TextCaseSensitivity, bool shouldHighlight, unsigned);
+    unsigned countFindMatches(const String&, FindOptions, unsigned maxMatchCount);
+    unsigned markAllMatchesForText(const String&, FindOptions, bool shouldHighlight, unsigned maxMatchCount);
+
     void unmarkAllTextMatches();
 
     // find all the Ranges for the matching text.
@@ -411,6 +411,8 @@ private:
     void checkSubframeCountConsistency() const;
 #endif
 
+    unsigned findMatchesForText(const String&, FindOptions, unsigned maxMatchCount, bool shouldHighlight, bool markMatches);
+
     MediaCanStartListener* takeAnyMediaCanStartListener();
 
     void setMinimumTimerInterval(double);
index b014d03..1dfe5b7 100644 (file)
@@ -1,3 +1,16 @@
+2013-05-24  Andreas Kling  <akling@apple.com>
+
+        Typing in Safari's unified field causes unnecessary web content repaints.
+        <http://webkit.org/b/116703>
+
+        Reviewed by Andy Estes.
+
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::countStringMatches):
+
+            Call WebCore::Page::countMatchesForText() instead of markAllMatchesForText(). If the search string
+            is found inside the page content, the renderer containing that text will no longer be repainted.
+
 2013-05-23  Ryuan Choi  <ryuan.choi@samsung.com>
 
         [WK2][EFL][QT] Build break after r150610
index d80d1db..9773cee 100644 (file)
@@ -86,7 +86,7 @@ void FindController::countStringMatches(const String& string, FindOptions option
     if (pluginView)
         matchCount = pluginView->countFindMatches(string, core(options), maxMatchCount + 1);
     else {
-        matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount + 1);
+        matchCount = m_webPage->corePage()->countFindMatches(string, core(options), maxMatchCount + 1);
         m_webPage->corePage()->unmarkAllTextMatches();
     }