Title: [128784] trunk/Source/WebKit/chromium
Revision
128784
Author
[email protected]
Date
2012-09-17 11:36:07 -0700 (Mon, 17 Sep 2012)

Log Message

[Chromium] Fix cases where find-in-page doesn't send a final update
https://bugs.webkit.org/show_bug.cgi?id=96402

Fix some issues in the WebKit implementation that prevented to send a final
reportFindInPageMatchCount message.

Reviewed by Adam Barth.

* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::scopeStringMatches):
(WebKit):
(WebKit::WebFrameImpl::finishCurrentScopingEffort):
(WebKit::WebFrameImpl::cancelPendingScopingEffort):
(WebKit::WebFrameImpl::WebFrameImpl):
(WebKit::WebFrameImpl::shouldScopeMatches):
* src/WebFrameImpl.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (128783 => 128784)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-09-17 18:28:18 UTC (rev 128783)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-09-17 18:36:07 UTC (rev 128784)
@@ -1,3 +1,22 @@
+2012-09-17  Leandro Gracia Gil  <[email protected]>
+
+        [Chromium] Fix cases where find-in-page doesn't send a final update
+        https://bugs.webkit.org/show_bug.cgi?id=96402
+
+        Fix some issues in the WebKit implementation that prevented to send a final
+        reportFindInPageMatchCount message.
+
+        Reviewed by Adam Barth.
+
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::scopeStringMatches):
+        (WebKit):
+        (WebKit::WebFrameImpl::finishCurrentScopingEffort):
+        (WebKit::WebFrameImpl::cancelPendingScopingEffort):
+        (WebKit::WebFrameImpl::WebFrameImpl):
+        (WebKit::WebFrameImpl::shouldScopeMatches):
+        * src/WebFrameImpl.h:
+
 2012-09-17  Joshua Bell  <[email protected]>
 
         [Chromium] IndexedDB: Remove legacy two-phase open() API members

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (128783 => 128784)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-09-17 18:28:18 UTC (rev 128783)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-09-17 18:36:07 UTC (rev 128784)
@@ -1779,17 +1779,15 @@
                                       const WebFindOptions& options,
                                       bool reset)
 {
-    if (!shouldScopeMatches(searchText))
-        return;
-
     WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
 
     if (reset) {
         // This is a brand new search, so we need to reset everything.
         // Scoping is just about to begin.
         m_scopingComplete = false;
+
         // Clear highlighting for this frame.
-        if (frame()->editor()->markedTextMatchesAreHighlighted())
+        if (frame() && frame()->editor()->markedTextMatchesAreHighlighted())
             frame()->page()->unmarkAllTextMatches();
 
         // Clear the tickmarks and results cache.
@@ -1812,6 +1810,14 @@
         return;
     }
 
+    if (!shouldScopeMatches(searchText)) {
+        // Note that we want to defer the final update when resetting even if shouldScopeMatches returns false.
+        // This is done in order to prevent sending a final message based only on the results of the first frame
+        // since m_framesScopingCount would be 0 as other frames have yet to reset.
+        finishCurrentScopingEffort(identifier);
+        return;
+    }
+
     RefPtr<Range> searchRange(rangeOfContents(frame()->document()));
 
     Node* originalEndContainer = searchRange->endContainer();
@@ -1938,10 +1944,18 @@
         return; // Done for now, resume work later.
     }
 
+    finishCurrentScopingEffort(identifier);
+}
+
+void WebFrameImpl::finishCurrentScopingEffort(int identifier)
+{
+    WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+
     // This frame has no further scoping left, so it is done. Other frames might,
     // of course, continue to scope matches.
     m_scopingComplete = true;
     mainFrameImpl->m_framesScopingCount--;
+    m_lastFindRequestCompletedWithNoMatches = !m_lastMatchCount;
 
     // If this is the last frame to finish scoping we need to trigger the final
     // update to be sent.
@@ -1958,6 +1972,9 @@
     m_deferredScopingWork.clear();
 
     m_activeMatchIndexInCurrentFrame = -1;
+
+    if (!m_scopingComplete)
+        m_lastFindRequestCompletedWithNoMatches = false;
 }
 
 void WebFrameImpl::increaseMatchCount(int count, int identifier)
@@ -2330,6 +2347,7 @@
     , m_totalMatchCount(-1)
     , m_framesScopingCount(-1)
     , m_scopingComplete(false)
+    , m_lastFindRequestCompletedWithNoMatches(false)
     , m_nextInvalidateAfter(0)
     , m_findMatchMarkersVersion(0)
     , m_findMatchRectsAreValid(false)
@@ -2612,9 +2630,9 @@
 
 bool WebFrameImpl::shouldScopeMatches(const String& searchText)
 {
-    // Don't scope if we can't find a frame or a view or if the frame is not visible.
+    // Don't scope if we can't find a frame or a view.
     // The user may have closed the tab/application, so abort.
-    if (!frame() || !frame()->view() || !hasVisibleContent())
+    if (!frame() || !frame()->view())
         return false;
 
     ASSERT(frame()->document() && frame()->view());
@@ -2622,7 +2640,7 @@
     // If the frame completed the scoping operation and found 0 matches the last
     // time it was searched, then we don't have to search it again if the user is
     // just adding to the search string or sending the same search string again.
-    if (m_scopingComplete && !m_lastSearchString.isEmpty() && !m_lastMatchCount) {
+    if (m_lastFindRequestCompletedWithNoMatches && !m_lastSearchString.isEmpty()) {
         // Check to see if the search string prefixes match.
         String previousSearchPrefix =
             searchText.substring(0, m_lastSearchString.length());

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.h (128783 => 128784)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2012-09-17 18:28:18 UTC (rev 128783)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2012-09-17 18:36:07 UTC (rev 128784)
@@ -385,6 +385,9 @@
     // was searched.
     bool shouldScopeMatches(const WTF::String& searchText);
 
+    // Finishes the current scoping effort and triggers any updates if appropriate.
+    void finishCurrentScopingEffort(int identifier);
+
     // Queue up a deferred call to scopeStringMatches.
     void scopeStringMatchesSoon(
         int identifier, const WebString& searchText, const WebFindOptions&,
@@ -456,6 +459,10 @@
     // interrupt it before it completes by submitting a new search).
     bool m_scopingComplete;
 
+    // Keeps track of whether the last find request completed its scoping effort
+    // without finding any matches in this frame.
+    bool m_lastFindRequestCompletedWithNoMatches;
+
     // Keeps track of when the scoping effort should next invalidate the scrollbar
     // and the frame area.
     int m_nextInvalidateAfter;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to