Changeset 128784 in webkit


Ignore:
Timestamp:
Sep 17, 2012 11:36:07 AM (12 years ago)
Author:
leandrogracia@chromium.org
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:
Location:
trunk/Source/WebKit/chromium
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r128773 r128784  
     12012-09-17  Leandro Gracia Gil  <leandrogracia@chromium.org>
     2
     3        [Chromium] Fix cases where find-in-page doesn't send a final update
     4        https://bugs.webkit.org/show_bug.cgi?id=96402
     5
     6        Fix some issues in the WebKit implementation that prevented to send a final
     7        reportFindInPageMatchCount message.
     8
     9        Reviewed by Adam Barth.
     10
     11        * src/WebFrameImpl.cpp:
     12        (WebKit::WebFrameImpl::scopeStringMatches):
     13        (WebKit):
     14        (WebKit::WebFrameImpl::finishCurrentScopingEffort):
     15        (WebKit::WebFrameImpl::cancelPendingScopingEffort):
     16        (WebKit::WebFrameImpl::WebFrameImpl):
     17        (WebKit::WebFrameImpl::shouldScopeMatches):
     18        * src/WebFrameImpl.h:
     19
    1202012-09-17  Joshua Bell  <jsbell@chromium.org>
    221
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r128426 r128784  
    17801780                                      bool reset)
    17811781{
    1782     if (!shouldScopeMatches(searchText))
    1783         return;
    1784 
    17851782    WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
    17861783
     
    17891786        // Scoping is just about to begin.
    17901787        m_scopingComplete = false;
     1788
    17911789        // Clear highlighting for this frame.
    1792         if (frame()->editor()->markedTextMatchesAreHighlighted())
     1790        if (frame() && frame()->editor()->markedTextMatchesAreHighlighted())
    17931791            frame()->page()->unmarkAllTextMatches();
    17941792
     
    18101808            options,
    18111809            false); // false=we just reset, so don't do it again.
     1810        return;
     1811    }
     1812
     1813    if (!shouldScopeMatches(searchText)) {
     1814        // Note that we want to defer the final update when resetting even if shouldScopeMatches returns false.
     1815        // This is done in order to prevent sending a final message based only on the results of the first frame
     1816        // since m_framesScopingCount would be 0 as other frames have yet to reset.
     1817        finishCurrentScopingEffort(identifier);
    18121818        return;
    18131819    }
     
    19391945    }
    19401946
     1947    finishCurrentScopingEffort(identifier);
     1948}
     1949
     1950void WebFrameImpl::finishCurrentScopingEffort(int identifier)
     1951{
     1952    WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
     1953
    19411954    // This frame has no further scoping left, so it is done. Other frames might,
    19421955    // of course, continue to scope matches.
    19431956    m_scopingComplete = true;
    19441957    mainFrameImpl->m_framesScopingCount--;
     1958    m_lastFindRequestCompletedWithNoMatches = !m_lastMatchCount;
    19451959
    19461960    // If this is the last frame to finish scoping we need to trigger the final
     
    19591973
    19601974    m_activeMatchIndexInCurrentFrame = -1;
     1975
     1976    if (!m_scopingComplete)
     1977        m_lastFindRequestCompletedWithNoMatches = false;
    19611978}
    19621979
     
    23312348    , m_framesScopingCount(-1)
    23322349    , m_scopingComplete(false)
     2350    , m_lastFindRequestCompletedWithNoMatches(false)
    23332351    , m_nextInvalidateAfter(0)
    23342352    , m_findMatchMarkersVersion(0)
     
    26132631bool WebFrameImpl::shouldScopeMatches(const String& searchText)
    26142632{
    2615     // Don't scope if we can't find a frame or a view or if the frame is not visible.
     2633    // Don't scope if we can't find a frame or a view.
    26162634    // The user may have closed the tab/application, so abort.
    2617     if (!frame() || !frame()->view() || !hasVisibleContent())
     2635    if (!frame() || !frame()->view())
    26182636        return false;
    26192637
     
    26232641    // time it was searched, then we don't have to search it again if the user is
    26242642    // just adding to the search string or sending the same search string again.
    2625     if (m_scopingComplete && !m_lastSearchString.isEmpty() && !m_lastMatchCount) {
     2643    if (m_lastFindRequestCompletedWithNoMatches && !m_lastSearchString.isEmpty()) {
    26262644        // Check to see if the search string prefixes match.
    26272645        String previousSearchPrefix =
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.h

    r127776 r128784  
    386386    bool shouldScopeMatches(const WTF::String& searchText);
    387387
     388    // Finishes the current scoping effort and triggers any updates if appropriate.
     389    void finishCurrentScopingEffort(int identifier);
     390
    388391    // Queue up a deferred call to scopeStringMatches.
    389392    void scopeStringMatchesSoon(
     
    457460    bool m_scopingComplete;
    458461
     462    // Keeps track of whether the last find request completed its scoping effort
     463    // without finding any matches in this frame.
     464    bool m_lastFindRequestCompletedWithNoMatches;
     465
    459466    // Keeps track of when the scoping effort should next invalidate the scrollbar
    460467    // and the frame area.
Note: See TracChangeset for help on using the changeset viewer.