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* activeNow) |
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 bool isActive = setMarkerActive(m_activeMatch.get(), true); |
paulmeyer
2016/02/12 13:58:49
nit: Please move this block down to right above th
dvadym
2016/02/12 16:46:06
Done.
| |
167 if (activeNow) | |
168 *activeNow = isActive; | |
169 | |
167 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr entActiveMatchFrame; | 170 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr entActiveMatchFrame; |
168 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); | 171 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); |
169 | 172 |
170 // Make sure no node is focused. See http://crbug.com/38700. | 173 // Make sure no node is focused. See http://crbug.com/38700. |
171 ownerFrame().frame()->document()->clearFocusedElement(); | 174 ownerFrame().frame()->document()->clearFocusedElement(); |
172 | 175 |
173 if (!options.findNext || activeSelection) { | 176 if (!options.findNext || activeSelection || !isActive) { |
174 // This is either a Find operation or a Find-next from a new start point | 177 // This is either a Find operation, a Find-next from a new start point |
175 // due to a selection, so we set the flag to ask the scoping effort | 178 // due to a selection, or new matches were found during Find-next due |
176 // to find the active rect for us and report it back to the UI. | 179 // to DOM alteration (that couldn't be set as active), so we set the |
180 // flag to ask the scoping effort to find the active rect for us and | |
181 // report it back to the UI. | |
177 m_locatingActiveRect = true; | 182 m_locatingActiveRect = true; |
178 } else { | 183 } else { |
179 if (oldActiveFrame != &ownerFrame()) { | 184 if (oldActiveFrame != &ownerFrame()) { |
180 if (options.forward) | 185 if (options.forward) |
181 m_activeMatchIndexInCurrentFrame = 0; | 186 m_activeMatchIndexInCurrentFrame = 0; |
182 else | 187 else |
183 m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1; | 188 m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1; |
184 } else { | 189 } else { |
185 if (options.forward) | 190 if (options.forward) |
186 ++m_activeMatchIndexInCurrentFrame; | 191 ++m_activeMatchIndexInCurrentFrame; |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
680 #if !ENABLE(OILPAN) | 685 #if !ENABLE(OILPAN) |
681 cancelPendingScopingEffort(); | 686 cancelPendingScopingEffort(); |
682 #endif | 687 #endif |
683 } | 688 } |
684 | 689 |
685 void TextFinder::addMarker(Range* range, bool activeMatch) | 690 void TextFinder::addMarker(Range* range, bool activeMatch) |
686 { | 691 { |
687 ownerFrame().frame()->document()->markers().addTextMatchMarker(range, active Match); | 692 ownerFrame().frame()->document()->markers().addTextMatchMarker(range, active Match); |
688 } | 693 } |
689 | 694 |
690 void TextFinder::setMarkerActive(Range* range, bool active) | 695 bool TextFinder::setMarkerActive(Range* range, bool active) |
691 { | 696 { |
692 if (!range || range->collapsed()) | 697 if (!range || range->collapsed()) |
693 return; | 698 return false; |
694 ownerFrame().frame()->document()->markers().setMarkersActive(range, active); | 699 return ownerFrame().frame()->document()->markers().setMarkersActive(range, a ctive); |
695 } | 700 } |
696 | 701 |
697 void TextFinder::unmarkAllTextMatches() | 702 void TextFinder::unmarkAllTextMatches() |
698 { | 703 { |
699 LocalFrame* frame = ownerFrame().frame(); | 704 LocalFrame* frame = ownerFrame().frame(); |
700 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte d()) { | 705 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte d()) { |
701 if (ownerFrame().client() && ownerFrame().client()->shouldSearchSingleFr ame()) | 706 if (ownerFrame().client() && ownerFrame().client()->shouldSearchSingleFr ame()) |
702 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch ); | 707 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch ); |
703 else | 708 else |
704 frame->page()->unmarkAllTextMatches(); | 709 frame->page()->unmarkAllTextMatches(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
815 visitor->trace(m_ownerFrame); | 820 visitor->trace(m_ownerFrame); |
816 visitor->trace(m_currentActiveMatchFrame); | 821 visitor->trace(m_currentActiveMatchFrame); |
817 visitor->trace(m_activeMatch); | 822 visitor->trace(m_activeMatch); |
818 visitor->trace(m_resumeScopingFromRange); | 823 visitor->trace(m_resumeScopingFromRange); |
819 visitor->trace(m_deferredScopingWork); | 824 visitor->trace(m_deferredScopingWork); |
820 visitor->trace(m_findMatchesCache); | 825 visitor->trace(m_findMatchesCache); |
821 #endif | 826 #endif |
822 } | 827 } |
823 | 828 |
824 } // namespace blink | 829 } // namespace blink |
OLD | NEW |