示例#1
0
bool InPageSearchManager::findAndMarkText(const String& text, Range* range, Frame* frame, const FindOptions& options, bool isNewSearch, bool startFromSelection)
{
    if (RefPtr<Range> match = frame->editor().findStringAndScrollToVisible(text, range, options)) {
        // Move the highlight to the new match.
        setActiveMatchAndMarker(match);
        if (isNewSearch) {
            scopeStringMatches(text, true /* reset */, false /* locateActiveMatchOnly */);
            if (!m_highlightAllMatches) {
                // Not highlighting all matches, we need to add the marker here,
                // because scopeStringMatches does not add any markers, it only counts the number.
                // No need to unmarkAllTextMatches, it is already done from the caller because of newSearch
                m_activeMatch->ownerDocument().markers().addTextMatchMarker(m_activeMatch.get(), true);
                frame->editor().setMarkedTextMatchesAreHighlighted(true /* highlight */);
            }
            return true;
        }
        if (startFromSelection || m_locatingActiveMatch) {
            // We are finding next, but
            // - starting from a new node, or
            // - last locating active match effort is not done yet
            if (!m_scopingComplete) {
                // Last scoping is not done yet, let's restart it.
                scopeStringMatches(text, true /* reset */, false /* locateActiveMatchOnly */);
            } else {
                // Last scoping is done, but we are jumping to somewhere instead of
                // searching one by one, or there is another locating active match effort,
                // let's start a scoping effort to locate active match only.
                scopeStringMatches(text, true /* reset */, true /* locateActiveMatchOnly */);
            }
        } else {
            // We are finding next one by one, let's calculate active match index
            // There is at least one match, because otherwise we won't get into this block,
            // so m_activeMatchIndex is at least one.
            ASSERT(m_activeMatchCount);
            if (!(options & WebCore::Backwards))
                m_activeMatchIndex = m_activeMatchIndex + 1 > m_activeMatchCount ? 1 : m_activeMatchIndex + 1;
            else
                m_activeMatchIndex = m_activeMatchIndex - 1 < 1 ? m_activeMatchCount : m_activeMatchIndex - 1;
            m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex);
        }
        if (!m_highlightAllMatches) {
            // When only showing single matches, the scoping effort won't highlight
            // all matches but count them.
            m_webPage->m_page->unmarkAllTextMatches();
            m_activeMatch->ownerDocument().markers().addTextMatchMarker(m_activeMatch.get(), true);
            frame->editor().setMarkedTextMatchesAreHighlighted(true /* highlight */);
        }

        return true;
    }
    return false;
}
示例#2
0
void TextFinder::resumeScopingStringMatches(int identifier,
                                            const WebString& searchText,
                                            const WebFindOptions& options) {
  m_deferredScopingWork.clear();

  scopeStringMatches(identifier, searchText, options);
}
示例#3
0
void TextFinder::callScopeStringMatches(DeferredScopeStringMatches* caller, int identifier, const WebString& searchText, const WebFindOptions& options, bool reset)
{
    m_deferredScopingWork.remove(m_deferredScopingWork.find(caller));
    scopeStringMatches(identifier, searchText, options, reset);

    // This needs to happen last since searchText is passed by reference.
    delete caller;
}
示例#4
0
void TextFinder::callScopeStringMatches(DeferredScopeStringMatches* caller,
                                        int identifier,
                                        const WebString& searchText,
                                        const WebFindOptions& options,
                                        bool reset) {
  size_t index = m_deferredScopingWork.find(caller);
  m_deferredScopingWork.remove(index);

  scopeStringMatches(identifier, searchText, options, reset);
}
void TextFinder::callScopeStringMatches(DeferredScopeStringMatches* caller, int identifier, const WebString& searchText, const WebFindOptions& options, bool reset)
{
    size_t index = m_deferredScopingWork.find(caller);
#if !ENABLE(OILPAN)
    // Finalization needs to be delayed as (m_)searchText is passed by reference.
    OwnPtr<DeferredScopeStringMatches> item = index != kNotFound ? m_deferredScopingWork[index].release() : nullptr;
#endif
    m_deferredScopingWork.remove(index);

    scopeStringMatches(identifier, searchText, options, reset);
}
示例#6
0
bool InPageSearchManager::findAndMarkText(const String& text, Range* range, Frame* frame, const FindOptions& options, bool isNewSearch)
{
    m_activeMatch = frame->editor()->findStringAndScrollToVisible(text, range, options);
    if (m_activeMatch) {
        setMarkerActive(m_activeMatch.get(), true /* active */);
        if (isNewSearch) {
            scopeStringMatches(text, true /* reset */);
            // FIXME: If it is a not new search, we need to calculate activeMatchIndex and notify client.
        }
        return true;
    }
    return false;
}
示例#7
0
void InPageSearchManager::callScopeStringMatches(DeferredScopeStringMatches* caller, Frame* scopingFrame, const String& text, bool reset, bool locateActiveMatchOnly)
{
    m_deferredScopingWork.remove(m_deferredScopingWork.find(caller));
    scopeStringMatches(text, reset, locateActiveMatchOnly, scopingFrame);
    delete caller;
}