Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: Source/web/TextFinder.cpp

Issue 424803002: Revert of Fix incorrect number of matches and misleading highlighting in "Find on Page" results (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/web/tests/TextFinderTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 WebLocalFrameImpl* mainFrameImpl = m_ownerFrame.viewImpl()->mainFrameImpl(); 236 WebLocalFrameImpl* mainFrameImpl = m_ownerFrame.viewImpl()->mainFrameImpl();
237 Position searchStart = firstPositionInNode(m_ownerFrame.frame()->document()) ; 237 Position searchStart = firstPositionInNode(m_ownerFrame.frame()->document()) ;
238 Position searchEnd = lastPositionInNode(m_ownerFrame.frame()->document()); 238 Position searchEnd = lastPositionInNode(m_ownerFrame.frame()->document());
239 ASSERT(searchStart.document() == searchEnd.document()); 239 ASSERT(searchStart.document() == searchEnd.document());
240 240
241 if (m_resumeScopingFromRange) { 241 if (m_resumeScopingFromRange) {
242 // This is a continuation of a scoping operation that timed out and didn 't 242 // This is a continuation of a scoping operation that timed out and didn 't
243 // complete last time around, so we should start from where we left off. 243 // complete last time around, so we should start from where we left off.
244 ASSERT(m_resumeScopingFromRange->collapsed()); 244 ASSERT(m_resumeScopingFromRange->collapsed());
245 searchStart = m_resumeScopingFromRange->startPosition(); 245 searchStart = m_resumeScopingFromRange->startPosition().next();
246 if (searchStart.document() != searchEnd.document()) 246 if (searchStart.document() != searchEnd.document())
247 return; 247 return;
248 } 248 }
249 249
250 // This timeout controls how long we scope before releasing control. This 250 // This timeout controls how long we scope before releasing control. This
251 // value does not prevent us from running for longer than this, but it is 251 // value does not prevent us from running for longer than this, but it is
252 // periodically checked to see if we have exceeded our allocated time. 252 // periodically checked to see if we have exceeded our allocated time.
253 const double maxScopingDuration = 0.1; // seconds 253 const double maxScopingDuration = 0.1; // seconds
254 254
255 int matchCount = 0; 255 int matchCount = 0;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 311 }
312 312
313 addMarker(resultRange.get(), foundActiveMatch); 313 addMarker(resultRange.get(), foundActiveMatch);
314 314
315 m_findMatchesCache.append(FindMatch(resultRange.get(), m_lastMatchCount + matchCount)); 315 m_findMatchesCache.append(FindMatch(resultRange.get(), m_lastMatchCount + matchCount));
316 316
317 // Set the new start for the search range to be the end of the previous 317 // Set the new start for the search range to be the end of the previous
318 // result range. There is no need to use a VisiblePosition here, 318 // result range. There is no need to use a VisiblePosition here,
319 // since findPlainText will use a TextIterator to go over the visible 319 // since findPlainText will use a TextIterator to go over the visible
320 // text nodes. 320 // text nodes.
321 searchStart = resultEnd; 321 searchStart = resultStart.next();
322 322
323 m_resumeScopingFromRange = Range::create(*resultStart.document(), result Start, resultStart); 323 m_resumeScopingFromRange = Range::create(*resultStart.document(), result Start, resultStart);
324 timedOut = (currentTime() - startTime) >= maxScopingDuration; 324 timedOut = (currentTime() - startTime) >= maxScopingDuration;
325 } while (!timedOut); 325 } while (!timedOut);
326 326
327 // Remember what we search for last time, so we can skip searching if more 327 // Remember what we search for last time, so we can skip searching if more
328 // letters are added to the search string (and last outcome was 0). 328 // letters are added to the search string (and last outcome was 0).
329 m_lastSearchString = searchText; 329 m_lastSearchString = searchText;
330 330
331 if (matchCount > 0) { 331 if (matchCount > 0) {
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 if (!m_framesScopingCount) 730 if (!m_framesScopingCount)
731 m_ownerFrame.increaseMatchCount(0, identifier); 731 m_ownerFrame.increaseMatchCount(0, identifier);
732 } 732 }
733 733
734 int TextFinder::ordinalOfFirstMatch() const 734 int TextFinder::ordinalOfFirstMatch() const
735 { 735 {
736 return ordinalOfFirstMatchForFrame(&m_ownerFrame); 736 return ordinalOfFirstMatchForFrame(&m_ownerFrame);
737 } 737 }
738 738
739 } // namespace blink 739 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/TextFinderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698