diff options
| author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
| commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
| tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp | |
| parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
| download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz | |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp')
| -rw-r--r-- | Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp b/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp index e673b1a0c..ed70fac09 100644 --- a/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp @@ -84,12 +84,13 @@ InPageSearchManager::~InPageSearchManager() cancelPendingScopingEffort(); } -bool InPageSearchManager::findNextString(const String& text, FindOptions findOptions, bool wrap, bool highlightAllMatches) +bool InPageSearchManager::findNextString(const String& text, FindOptions findOptions, bool wrap, bool highlightAllMatches, bool selectActiveMatchOnClear) { + bool highlightAllMatchesStateChanged = m_highlightAllMatches != highlightAllMatches; m_highlightAllMatches = highlightAllMatches; if (!text.length()) { - clearTextMatches(); + clearTextMatches(selectActiveMatchOnClear); cancelPendingScopingEffort(); m_activeSearchString = String(); m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); @@ -108,7 +109,7 @@ bool InPageSearchManager::findNextString(const String& text, FindOptions findOpt ExceptionCode ec = 0; RefPtr<Range> searchStartingPoint = m_activeMatch ? m_activeMatch->cloneRange(ec) : 0; - bool newSearch = m_activeSearchString != text; + bool newSearch = highlightAllMatchesStateChanged || (m_activeSearchString != text); bool forward = !(findOptions & WebCore::Backwards); if (newSearch) { // Start a new search. m_activeSearchString = text; @@ -179,11 +180,18 @@ bool InPageSearchManager::shouldSearchForText(const String& text) 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)) { + 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) { @@ -215,7 +223,7 @@ bool InPageSearchManager::findAndMarkText(const String& text, Range* range, Fram // all matches but count them. m_webPage->m_page->unmarkAllTextMatches(); m_activeMatch->ownerDocument()->markers()->addTextMatchMarker(m_activeMatch.get(), true); - frame->editor()->setMarkedTextMatchesAreHighlighted(true /* highlight */); + frame->editor().setMarkedTextMatchesAreHighlighted(true /* highlight */); } return true; @@ -223,8 +231,12 @@ bool InPageSearchManager::findAndMarkText(const String& text, Range* range, Fram return false; } -void InPageSearchManager::clearTextMatches() +void InPageSearchManager::clearTextMatches(bool selectActiveMatchOnClear) { + if (selectActiveMatchOnClear && m_activeMatch.get()) { + VisibleSelection selection(m_activeMatch.get()); + m_activeMatch->ownerDocument()->frame()->selection()->setSelection(selection); + } m_webPage->m_page->unmarkAllTextMatches(); m_activeMatch = 0; m_activeMatchCount = 0; @@ -313,7 +325,7 @@ void InPageSearchManager::scopeStringMatches(const String& text, bool reset, boo if (resultRange->collapsed(ec)) { if (!resultRange->startContainer()->isInShadowTree()) break; - searchRange->setStartAfter(resultRange->startContainer()->shadowAncestorNode(), ec); + searchRange->setStartAfter(resultRange->startContainer()->deprecatedShadowAncestorNode(), ec); searchRange->setEnd(originalEndContainer, originalEndOffset, ec); continue; } @@ -348,7 +360,7 @@ void InPageSearchManager::scopeStringMatches(const String& text, bool reset, boo m_activeMatchIndex += matchCount; } else { if (m_highlightAllMatches) - scopingFrame->editor()->setMarkedTextMatchesAreHighlighted(true /* highlight */); + scopingFrame->editor().setMarkedTextMatchesAreHighlighted(true /* highlight */); m_activeMatchCount += matchCount; m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); } |
