Chromium Code Reviews| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 } | 105 } |
| 106 | 106 |
| 107 Timer<DeferredScopeStringMatches> m_timer; | 107 Timer<DeferredScopeStringMatches> m_timer; |
| 108 RawPtrWillBeMember<TextFinder> m_textFinder; | 108 RawPtrWillBeMember<TextFinder> m_textFinder; |
| 109 const int m_identifier; | 109 const int m_identifier; |
| 110 const WebString m_searchText; | 110 const WebString m_searchText; |
| 111 const WebFindOptions m_options; | 111 const WebFindOptions m_options; |
| 112 const bool m_reset; | 112 const bool m_reset; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 bool TextFinder::find(int identifier, const WebString& searchText, const WebFind Options& options, bool wrapWithinFrame, WebRect* selectionRect) | 115 bool TextFinder::find(int identifier, const WebString& searchText, const WebFind Options& options, bool wrapWithinFrame, WebRect* selectionRect, bool& newTextFou nd) |
| 116 { | 116 { |
| 117 if (!ownerFrame().frame() || !ownerFrame().frame()->page()) | 117 if (!ownerFrame().frame() || !ownerFrame().frame()->page()) |
| 118 return false; | 118 return false; |
| 119 | 119 |
| 120 WebLocalFrameImpl* mainFrameImpl = ownerFrame().viewImpl()->mainFrameImpl(); | 120 WebLocalFrameImpl* mainFrameImpl = ownerFrame().viewImpl()->mainFrameImpl(); |
| 121 | 121 |
| 122 if (!options.findNext) | 122 if (!options.findNext) |
| 123 unmarkAllTextMatches(); | 123 unmarkAllTextMatches(); |
| 124 else | 124 else |
| 125 setMarkerActive(m_activeMatch.get(), false); | 125 setMarkerActive(m_activeMatch.get(), false); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 | 158 |
| 159 // If the user is browsing a page with autosizing, adjust the zoom to the | 159 // If the user is browsing a page with autosizing, adjust the zoom to the |
| 160 // column where the next hit has been found. Doing this when autosizing is | 160 // column where the next hit has been found. Doing this when autosizing is |
| 161 // not set will result in a zoom reset on small devices. | 161 // not set will result in a zoom reset on small devices. |
| 162 if (ownerFrame().frame()->document()->textAutosizer()->pageNeedsAutosizing() ) { | 162 if (ownerFrame().frame()->document()->textAutosizer()->pageNeedsAutosizing() ) { |
| 163 ownerFrame().viewImpl()->zoomToFindInPageRect(ownerFrame().frameView()-> contentsToRootFrame(enclosingIntRect(LayoutObject::absoluteBoundingBoxRectForRan ge(m_activeMatch.get())))); | 163 ownerFrame().viewImpl()->zoomToFindInPageRect(ownerFrame().frameView()-> contentsToRootFrame(enclosingIntRect(LayoutObject::absoluteBoundingBoxRectForRan ge(m_activeMatch.get())))); |
| 164 } | 164 } |
| 165 | 165 |
| 166 setMarkerActive(m_activeMatch.get(), true); | 166 newTextFound = !setMarkerActive(m_activeMatch.get(), true); |
| 167 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr entActiveMatchFrame; | 167 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr entActiveMatchFrame; |
| 168 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); | 168 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); |
| 169 | 169 |
| 170 // Make sure no node is focused. See http://crbug.com/38700. | 170 // Make sure no node is focused. See http://crbug.com/38700. |
| 171 ownerFrame().frame()->document()->clearFocusedElement(); | 171 ownerFrame().frame()->document()->clearFocusedElement(); |
| 172 | 172 |
| 173 if (!options.findNext || activeSelection) { | 173 if (!options.findNext || activeSelection || newTextFound) { |
| 174 // This is either a Find operation or a Find-next from a new start point | 174 // This is either a Find operation or a Find-next from a new start point |
| 175 // due to a selection, so we set the flag to ask the scoping effort | 175 // due to a selection, so we set the flag to ask the scoping effort |
| 176 // to find the active rect for us and report it back to the UI. | 176 // to find the active rect for us and report it back to the UI. |
|
Finnur
2016/01/20 14:14:03
Nit: This comment would now need updating too.
dvadym
2016/01/29 09:44:17
Done.
| |
| 177 m_locatingActiveRect = true; | 177 m_locatingActiveRect = true; |
| 178 } else { | 178 } else { |
| 179 if (oldActiveFrame != &ownerFrame()) { | 179 if (oldActiveFrame != &ownerFrame()) { |
| 180 if (options.forward) | 180 if (options.forward) |
| 181 m_activeMatchIndexInCurrentFrame = 0; | 181 m_activeMatchIndexInCurrentFrame = 0; |
| 182 else | 182 else |
| 183 m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1; | 183 m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1; |
| 184 } else { | 184 } else { |
| 185 if (options.forward) | 185 if (options.forward) |
| 186 ++m_activeMatchIndexInCurrentFrame; | 186 ++m_activeMatchIndexInCurrentFrame; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 680 #if !ENABLE(OILPAN) | 680 #if !ENABLE(OILPAN) |
| 681 cancelPendingScopingEffort(); | 681 cancelPendingScopingEffort(); |
| 682 #endif | 682 #endif |
| 683 } | 683 } |
| 684 | 684 |
| 685 void TextFinder::addMarker(Range* range, bool activeMatch) | 685 void TextFinder::addMarker(Range* range, bool activeMatch) |
| 686 { | 686 { |
| 687 ownerFrame().frame()->document()->markers().addTextMatchMarker(range, active Match); | 687 ownerFrame().frame()->document()->markers().addTextMatchMarker(range, active Match); |
| 688 } | 688 } |
| 689 | 689 |
| 690 void TextFinder::setMarkerActive(Range* range, bool active) | 690 bool TextFinder::setMarkerActive(Range* range, bool active) |
| 691 { | 691 { |
| 692 if (!range || range->collapsed()) | 692 if (!range || range->collapsed()) |
| 693 return; | 693 return true; |
|
Finnur
2016/01/20 14:14:03
Wait... why not return false?
dvadym
2016/01/29 09:44:17
Done.
| |
| 694 ownerFrame().frame()->document()->markers().setMarkersActive(range, active); | 694 return ownerFrame().frame()->document()->markers().setMarkersActive(range, a ctive); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void TextFinder::unmarkAllTextMatches() | 697 void TextFinder::unmarkAllTextMatches() |
| 698 { | 698 { |
| 699 LocalFrame* frame = ownerFrame().frame(); | 699 LocalFrame* frame = ownerFrame().frame(); |
| 700 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte d()) { | 700 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte d()) { |
| 701 if (ownerFrame().client() && ownerFrame().client()->shouldSearchSingleFr ame()) | 701 if (ownerFrame().client() && ownerFrame().client()->shouldSearchSingleFr ame()) |
| 702 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch ); | 702 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch ); |
| 703 else | 703 else |
| 704 frame->page()->unmarkAllTextMatches(); | 704 frame->page()->unmarkAllTextMatches(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 visitor->trace(m_ownerFrame); | 815 visitor->trace(m_ownerFrame); |
| 816 visitor->trace(m_currentActiveMatchFrame); | 816 visitor->trace(m_currentActiveMatchFrame); |
| 817 visitor->trace(m_activeMatch); | 817 visitor->trace(m_activeMatch); |
| 818 visitor->trace(m_resumeScopingFromRange); | 818 visitor->trace(m_resumeScopingFromRange); |
| 819 visitor->trace(m_deferredScopingWork); | 819 visitor->trace(m_deferredScopingWork); |
| 820 visitor->trace(m_findMatchesCache); | 820 visitor->trace(m_findMatchesCache); |
| 821 #endif | 821 #endif |
| 822 } | 822 } |
| 823 | 823 |
| 824 } // namespace blink | 824 } // namespace blink |
| OLD | NEW |