| 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); | |
| 167 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr
entActiveMatchFrame; | 166 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr
entActiveMatchFrame; |
| 168 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); | 167 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); |
| 169 | 168 |
| 170 // Make sure no node is focused. See http://crbug.com/38700. | 169 // Make sure no node is focused. See http://crbug.com/38700. |
| 171 ownerFrame().frame()->document()->clearFocusedElement(); | 170 ownerFrame().frame()->document()->clearFocusedElement(); |
| 172 | 171 |
| 173 if (!options.findNext || activeSelection) { | 172 bool isActive = setMarkerActive(m_activeMatch.get(), true); |
| 174 // This is either a Find operation or a Find-next from a new start point | 173 if (activeNow) |
| 175 // due to a selection, so we set the flag to ask the scoping effort | 174 *activeNow = isActive; |
| 176 // to find the active rect for us and report it back to the UI. | 175 |
| 176 if (!options.findNext || activeSelection || !isActive) { |
| 177 // This is either a Find operation, a Find-next from a new start point |
| 178 // due to a selection, or new matches were found during Find-next due |
| 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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 #if !ENABLE(OILPAN) | 678 #if !ENABLE(OILPAN) |
| 674 cancelPendingScopingEffort(); | 679 cancelPendingScopingEffort(); |
| 675 #endif | 680 #endif |
| 676 } | 681 } |
| 677 | 682 |
| 678 void TextFinder::addMarker(Range* range, bool activeMatch) | 683 void TextFinder::addMarker(Range* range, bool activeMatch) |
| 679 { | 684 { |
| 680 ownerFrame().frame()->document()->markers().addTextMatchMarker(range, active
Match); | 685 ownerFrame().frame()->document()->markers().addTextMatchMarker(range, active
Match); |
| 681 } | 686 } |
| 682 | 687 |
| 683 void TextFinder::setMarkerActive(Range* range, bool active) | 688 bool TextFinder::setMarkerActive(Range* range, bool active) |
| 684 { | 689 { |
| 685 if (!range || range->collapsed()) | 690 if (!range || range->collapsed()) |
| 686 return; | 691 return false; |
| 687 ownerFrame().frame()->document()->markers().setMarkersActive(range, active); | 692 return ownerFrame().frame()->document()->markers().setMarkersActive(range, a
ctive); |
| 688 } | 693 } |
| 689 | 694 |
| 690 void TextFinder::unmarkAllTextMatches() | 695 void TextFinder::unmarkAllTextMatches() |
| 691 { | 696 { |
| 692 LocalFrame* frame = ownerFrame().frame(); | 697 LocalFrame* frame = ownerFrame().frame(); |
| 693 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte
d()) { | 698 if (frame && frame->page() && frame->editor().markedTextMatchesAreHighlighte
d()) { |
| 694 if (ownerFrame().client() && ownerFrame().client()->shouldSearchSingleFr
ame()) | 699 if (ownerFrame().client() && ownerFrame().client()->shouldSearchSingleFr
ame()) |
| 695 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch
); | 700 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch
); |
| 696 else | 701 else |
| 697 frame->page()->unmarkAllTextMatches(); | 702 frame->page()->unmarkAllTextMatches(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 visitor->trace(m_ownerFrame); | 813 visitor->trace(m_ownerFrame); |
| 809 visitor->trace(m_currentActiveMatchFrame); | 814 visitor->trace(m_currentActiveMatchFrame); |
| 810 visitor->trace(m_activeMatch); | 815 visitor->trace(m_activeMatch); |
| 811 visitor->trace(m_resumeScopingFromRange); | 816 visitor->trace(m_resumeScopingFromRange); |
| 812 visitor->trace(m_deferredScopingWork); | 817 visitor->trace(m_deferredScopingWork); |
| 813 visitor->trace(m_findMatchesCache); | 818 visitor->trace(m_findMatchesCache); |
| 814 #endif | 819 #endif |
| 815 } | 820 } |
| 816 | 821 |
| 817 } // namespace blink | 822 } // namespace blink |
| OLD | NEW |