Commit 744f0cb4 authored by iceman@yandex-team.ru's avatar iceman@yandex-team.ru

Fix incorrect number of matches and misleading highlighting in "Find on Page" results.

BUG= 397563

Review URL: https://codereview.chromium.org/422443004

git-svn-id: svn://svn.chromium.org/blink/trunk@179000 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 67d6e72b
...@@ -242,7 +242,7 @@ void TextFinder::scopeStringMatches(int identifier, const WebString& searchText, ...@@ -242,7 +242,7 @@ void TextFinder::scopeStringMatches(int identifier, const WebString& searchText,
// This is a continuation of a scoping operation that timed out and didn't // This is a continuation of a scoping operation that timed out and didn't
// complete last time around, so we should start from where we left off. // complete last time around, so we should start from where we left off.
ASSERT(m_resumeScopingFromRange->collapsed()); ASSERT(m_resumeScopingFromRange->collapsed());
searchStart = m_resumeScopingFromRange->startPosition().next(); searchStart = m_resumeScopingFromRange->startPosition();
if (searchStart.document() != searchEnd.document()) if (searchStart.document() != searchEnd.document())
return; return;
} }
...@@ -318,7 +318,7 @@ void TextFinder::scopeStringMatches(int identifier, const WebString& searchText, ...@@ -318,7 +318,7 @@ void TextFinder::scopeStringMatches(int identifier, const WebString& searchText,
// result range. There is no need to use a VisiblePosition here, // result range. There is no need to use a VisiblePosition here,
// since findPlainText will use a TextIterator to go over the visible // since findPlainText will use a TextIterator to go over the visible
// text nodes. // text nodes.
searchStart = resultStart.next(); searchStart = resultEnd;
m_resumeScopingFromRange = Range::create(*resultStart.document(), resultStart, resultStart); m_resumeScopingFromRange = Range::create(*resultStart.document(), resultStart, resultStart);
timedOut = (currentTime() - startTime) >= maxScopingDuration; timedOut = (currentTime() - startTime) >= maxScopingDuration;
......
...@@ -289,4 +289,26 @@ TEST_F(TextFinderTest, ScopeTextMatchesWithShadowDOM) ...@@ -289,4 +289,26 @@ TEST_F(TextFinderTest, ScopeTextMatchesWithShadowDOM)
EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[2]); EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[2]);
} }
TEST_F(TextFinderTest, ScopeRepeatPatternTextMatches)
{
document().body()->setInnerHTML("ab ab ab ab ab", ASSERT_NO_EXCEPTION);
Node* textNode = document().body()->firstChild();
int identifier = 0;
WebString searchText(String("ab ab"));
WebFindOptions findOptions; // Default.
textFinder().resetMatchCount();
textFinder().scopeStringMatches(identifier, searchText, findOptions, true);
while (textFinder().scopingInProgress())
FrameTestHelpers::runPendingTasks();
EXPECT_EQ(2, textFinder().totalMatchCount());
WebVector<WebFloatRect> matchRects;
textFinder().findMatchRects(matchRects);
ASSERT_EQ(2u, matchRects.size());
EXPECT_EQ(findInPageRect(textNode, 0, textNode, 5), matchRects[0]);
EXPECT_EQ(findInPageRect(textNode, 6, textNode, 11), matchRects[1]);
}
} // namespace } // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment