OLD | NEW |
---|---|
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 | 193 |
194 if (m_activeMatchIndex + 1 > m_lastMatchCount) | 194 if (m_activeMatchIndex + 1 > m_lastMatchCount) |
195 m_activeMatchIndex = 0; | 195 m_activeMatchIndex = 0; |
196 else if (m_activeMatchIndex < 0) | 196 else if (m_activeMatchIndex < 0) |
197 m_activeMatchIndex = m_lastMatchCount - 1; | 197 m_activeMatchIndex = m_lastMatchCount - 1; |
198 } | 198 } |
199 WebRect selectionRect = ownerFrame().frameView()->contentsToRootFrame(m_ activeMatch->boundingBox()); | 199 WebRect selectionRect = ownerFrame().frameView()->contentsToRootFrame(m_ activeMatch->boundingBox()); |
200 reportFindInPageSelection(selectionRect, m_activeMatchIndex + 1, identif ier); | 200 reportFindInPageSelection(selectionRect, m_activeMatchIndex + 1, identif ier); |
201 } | 201 } |
202 | 202 |
203 m_lastFindRequestCompletedWithNoMatches = false; | |
dcheng
2016/09/21 07:15:44
Ditto: what is the significance behind these two c
paulmeyer
2016/09/21 15:40:52
First change:
By this point in this function, at
| |
203 return true; | 204 return true; |
204 } | 205 } |
205 | 206 |
206 void TextFinder::clearActiveFindMatch() | 207 void TextFinder::clearActiveFindMatch() |
207 { | 208 { |
208 m_currentActiveMatchFrame = false; | 209 m_currentActiveMatchFrame = false; |
209 setMarkerActive(m_activeMatch.get(), false); | 210 setMarkerActive(m_activeMatch.get(), false); |
211 resetActiveMatch(); | |
210 } | 212 } |
211 | 213 |
212 void TextFinder::stopFindingAndClearSelection() | 214 void TextFinder::stopFindingAndClearSelection() |
213 { | 215 { |
214 cancelPendingScopingEffort(); | 216 cancelPendingScopingEffort(); |
215 | 217 |
216 // Remove all markers for matches found and turn off the highlighting. | 218 // Remove all markers for matches found and turn off the highlighting. |
217 ownerFrame().frame()->document()->markers().removeMarkers(DocumentMarker::Te xtMatch); | 219 ownerFrame().frame()->document()->markers().removeMarkers(DocumentMarker::Te xtMatch); |
218 ownerFrame().frame()->editor().setMarkedTextMatchesAreHighlighted(false); | 220 ownerFrame().frame()->editor().setMarkedTextMatchesAreHighlighted(false); |
219 clearFindMatchesCache(); | 221 clearFindMatchesCache(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 // The view might be null on detached frames. | 279 // The view might be null on detached frames. |
278 LocalFrame* frame = ownerFrame().frame(); | 280 LocalFrame* frame = ownerFrame().frame(); |
279 if (frame && frame->page()) | 281 if (frame && frame->page()) |
280 m_frameScoping = true; | 282 m_frameScoping = true; |
281 | 283 |
282 // Now, defer scoping until later to allow find operation to finish quic kly. | 284 // Now, defer scoping until later to allow find operation to finish quic kly. |
283 scopeStringMatchesSoon(identifier, searchText, options, false); // false means just reset, so don't do it again. | 285 scopeStringMatchesSoon(identifier, searchText, options, false); // false means just reset, so don't do it again. |
284 return; | 286 return; |
285 } | 287 } |
286 | 288 |
287 if (!shouldScopeMatches(searchText)) { | 289 if (!shouldScopeMatches(searchText, options)) { |
288 finishCurrentScopingEffort(identifier); | 290 finishCurrentScopingEffort(identifier); |
289 return; | 291 return; |
290 } | 292 } |
291 | 293 |
292 PositionInFlatTree searchStart = PositionInFlatTree::firstPositionInNode(own erFrame().frame()->document()); | 294 PositionInFlatTree searchStart = PositionInFlatTree::firstPositionInNode(own erFrame().frame()->document()); |
293 PositionInFlatTree searchEnd = PositionInFlatTree::lastPositionInNode(ownerF rame().frame()->document()); | 295 PositionInFlatTree searchEnd = PositionInFlatTree::lastPositionInNode(ownerF rame().frame()->document()); |
294 DCHECK_EQ(searchStart.document(), searchEnd.document()); | 296 DCHECK_EQ(searchStart.document(), searchEnd.document()); |
295 | 297 |
296 if (m_resumeScopingFromRange) { | 298 if (m_resumeScopingFromRange) { |
297 // This is a continuation of a scoping operation that timed out and didn 't | 299 // This is a continuation of a scoping operation that timed out and didn 't |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 return ownerFrame().frame()->document()->markers().setMarkersActive(Ephemera lRange(range), active); | 667 return ownerFrame().frame()->document()->markers().setMarkersActive(Ephemera lRange(range), active); |
666 } | 668 } |
667 | 669 |
668 void TextFinder::unmarkAllTextMatches() | 670 void TextFinder::unmarkAllTextMatches() |
669 { | 671 { |
670 LocalFrame* frame = ownerFrame().frame(); | 672 LocalFrame* frame = ownerFrame().frame(); |
671 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte d()) | 673 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte d()) |
672 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch); | 674 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch); |
673 } | 675 } |
674 | 676 |
675 bool TextFinder::shouldScopeMatches(const String& searchText) | 677 bool TextFinder::shouldScopeMatches(const String& searchText, const WebFindOptio ns& options) |
676 { | 678 { |
677 // Don't scope if we can't find a frame or a view. | 679 // Don't scope if we can't find a frame or a view. |
678 // The user may have closed the tab/application, so abort. | 680 // The user may have closed the tab/application, so abort. |
679 LocalFrame* frame = ownerFrame().frame(); | 681 LocalFrame* frame = ownerFrame().frame(); |
680 if (!frame || !frame->view() || !frame->page() || !ownerFrame().hasVisibleCo ntent()) | 682 if (!frame || !frame->view() || !frame->page()) |
681 return false; | 683 return false; |
682 | 684 |
683 DCHECK(frame->document()); | 685 DCHECK(frame->document()); |
684 DCHECK(frame->view()); | 686 DCHECK(frame->view()); |
685 | 687 |
688 if (options.force) | |
689 return true; | |
690 | |
691 if (!ownerFrame().hasVisibleContent()) | |
692 return false; | |
693 | |
686 // If the frame completed the scoping operation and found 0 matches the last | 694 // If the frame completed the scoping operation and found 0 matches the last |
687 // time it was searched, then we don't have to search it again if the user i s | 695 // time it was searched, then we don't have to search it again if the user i s |
688 // just adding to the search string or sending the same search string again. | 696 // just adding to the search string or sending the same search string again. |
689 if (m_lastFindRequestCompletedWithNoMatches && !m_lastSearchString.isEmpty() ) { | 697 if (m_lastFindRequestCompletedWithNoMatches && !m_lastSearchString.isEmpty() ) { |
690 // Check to see if the search string prefixes match. | 698 // Check to see if the search string prefixes match. |
691 String previousSearchPrefix = | 699 String previousSearchPrefix = |
692 searchText.substring(0, m_lastSearchString.length()); | 700 searchText.substring(0, m_lastSearchString.length()); |
693 | 701 |
694 if (previousSearchPrefix == m_lastSearchString) | 702 if (previousSearchPrefix == m_lastSearchString) |
695 return false; // Don't search this frame, it will be fruitless. | 703 return false; // Don't search this frame, it will be fruitless. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 DEFINE_TRACE(TextFinder) | 747 DEFINE_TRACE(TextFinder) |
740 { | 748 { |
741 visitor->trace(m_ownerFrame); | 749 visitor->trace(m_ownerFrame); |
742 visitor->trace(m_activeMatch); | 750 visitor->trace(m_activeMatch); |
743 visitor->trace(m_resumeScopingFromRange); | 751 visitor->trace(m_resumeScopingFromRange); |
744 visitor->trace(m_deferredScopingWork); | 752 visitor->trace(m_deferredScopingWork); |
745 visitor->trace(m_findMatchesCache); | 753 visitor->trace(m_findMatchesCache); |
746 } | 754 } |
747 | 755 |
748 } // namespace blink | 756 } // namespace blink |
OLD | NEW |