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; |
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); |
210 resetActiveMatch(); | |
211 } | 211 } |
212 | 212 |
213 void TextFinder::stopFindingAndClearSelection() | 213 void TextFinder::stopFindingAndClearSelection() |
214 { | 214 { |
215 cancelPendingScopingEffort(); | 215 cancelPendingScopingEffort(); |
216 | 216 |
217 // Remove all markers for matches found and turn off the highlighting. | 217 // Remove all markers for matches found and turn off the highlighting. |
218 ownerFrame().frame()->document()->markers().removeMarkers(DocumentMarker::Te
xtMatch); | 218 ownerFrame().frame()->document()->markers().removeMarkers(DocumentMarker::Te
xtMatch); |
219 ownerFrame().frame()->editor().setMarkedTextMatchesAreHighlighted(false); | 219 ownerFrame().frame()->editor().setMarkedTextMatchesAreHighlighted(false); |
220 clearFindMatchesCache(); | 220 clearFindMatchesCache(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // The view might be null on detached frames. | 278 // The view might be null on detached frames. |
279 LocalFrame* frame = ownerFrame().frame(); | 279 LocalFrame* frame = ownerFrame().frame(); |
280 if (frame && frame->page()) | 280 if (frame && frame->page()) |
281 m_frameScoping = true; | 281 m_frameScoping = true; |
282 | 282 |
283 // Now, defer scoping until later to allow find operation to finish quic
kly. | 283 // Now, defer scoping until later to allow find operation to finish quic
kly. |
284 scopeStringMatchesSoon(identifier, searchText, options, false); // false
means just reset, so don't do it again. | 284 scopeStringMatchesSoon(identifier, searchText, options, false); // false
means just reset, so don't do it again. |
285 return; | 285 return; |
286 } | 286 } |
287 | 287 |
288 if (!shouldScopeMatches(searchText, options)) { | 288 if (!shouldScopeMatches(searchText)) { |
289 finishCurrentScopingEffort(identifier); | 289 finishCurrentScopingEffort(identifier); |
290 return; | 290 return; |
291 } | 291 } |
292 | 292 |
293 PositionInFlatTree searchStart = PositionInFlatTree::firstPositionInNode(own
erFrame().frame()->document()); | 293 PositionInFlatTree searchStart = PositionInFlatTree::firstPositionInNode(own
erFrame().frame()->document()); |
294 PositionInFlatTree searchEnd = PositionInFlatTree::lastPositionInNode(ownerF
rame().frame()->document()); | 294 PositionInFlatTree searchEnd = PositionInFlatTree::lastPositionInNode(ownerF
rame().frame()->document()); |
295 DCHECK_EQ(searchStart.document(), searchEnd.document()); | 295 DCHECK_EQ(searchStart.document(), searchEnd.document()); |
296 | 296 |
297 if (m_resumeScopingFromRange) { | 297 if (m_resumeScopingFromRange) { |
298 // This is a continuation of a scoping operation that timed out and didn
't | 298 // 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... |
666 return ownerFrame().frame()->document()->markers().setMarkersActive(Ephemera
lRange(range), active); | 666 return ownerFrame().frame()->document()->markers().setMarkersActive(Ephemera
lRange(range), active); |
667 } | 667 } |
668 | 668 |
669 void TextFinder::unmarkAllTextMatches() | 669 void TextFinder::unmarkAllTextMatches() |
670 { | 670 { |
671 LocalFrame* frame = ownerFrame().frame(); | 671 LocalFrame* frame = ownerFrame().frame(); |
672 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte
d()) | 672 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte
d()) |
673 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch); | 673 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch); |
674 } | 674 } |
675 | 675 |
676 bool TextFinder::shouldScopeMatches(const String& searchText, const WebFindOptio
ns& options) | 676 bool TextFinder::shouldScopeMatches(const String& searchText) |
677 { | 677 { |
678 // Don't scope if we can't find a frame or a view. | 678 // Don't scope if we can't find a frame or a view. |
679 // The user may have closed the tab/application, so abort. | 679 // The user may have closed the tab/application, so abort. |
680 LocalFrame* frame = ownerFrame().frame(); | 680 LocalFrame* frame = ownerFrame().frame(); |
681 if (!frame || !frame->view() || !frame->page()) | 681 if (!frame || !frame->view() || !frame->page() || !ownerFrame().hasVisibleCo
ntent()) |
682 return false; | 682 return false; |
683 | 683 |
684 DCHECK(frame->document()); | 684 DCHECK(frame->document()); |
685 DCHECK(frame->view()); | 685 DCHECK(frame->view()); |
686 | 686 |
687 if (options.force) | |
688 return true; | |
689 | |
690 if (!ownerFrame().hasVisibleContent()) | |
691 return false; | |
692 | |
693 // If the frame completed the scoping operation and found 0 matches the last | 687 // If the frame completed the scoping operation and found 0 matches the last |
694 // time it was searched, then we don't have to search it again if the user i
s | 688 // time it was searched, then we don't have to search it again if the user i
s |
695 // just adding to the search string or sending the same search string again. | 689 // just adding to the search string or sending the same search string again. |
696 if (m_lastFindRequestCompletedWithNoMatches && !m_lastSearchString.isEmpty()
) { | 690 if (m_lastFindRequestCompletedWithNoMatches && !m_lastSearchString.isEmpty()
) { |
697 // Check to see if the search string prefixes match. | 691 // Check to see if the search string prefixes match. |
698 String previousSearchPrefix = | 692 String previousSearchPrefix = |
699 searchText.substring(0, m_lastSearchString.length()); | 693 searchText.substring(0, m_lastSearchString.length()); |
700 | 694 |
701 if (previousSearchPrefix == m_lastSearchString) | 695 if (previousSearchPrefix == m_lastSearchString) |
702 return false; // Don't search this frame, it will be fruitless. | 696 return false; // Don't search this frame, it will be fruitless. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 DEFINE_TRACE(TextFinder) | 740 DEFINE_TRACE(TextFinder) |
747 { | 741 { |
748 visitor->trace(m_ownerFrame); | 742 visitor->trace(m_ownerFrame); |
749 visitor->trace(m_activeMatch); | 743 visitor->trace(m_activeMatch); |
750 visitor->trace(m_resumeScopingFromRange); | 744 visitor->trace(m_resumeScopingFromRange); |
751 visitor->trace(m_deferredScopingWork); | 745 visitor->trace(m_deferredScopingWork); |
752 visitor->trace(m_findMatchesCache); | 746 visitor->trace(m_findMatchesCache); |
753 } | 747 } |
754 | 748 |
755 } // namespace blink | 749 } // namespace blink |
OLD | NEW |