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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // If we're finding next the next active match might not be in the curre
nt frame. | 149 // If we're finding next the next active match might not be in the curre
nt frame. |
150 // In this case we don't want to clear the matches cache. | 150 // In this case we don't want to clear the matches cache. |
151 if (!options.findNext) | 151 if (!options.findNext) |
152 clearFindMatchesCache(); | 152 clearFindMatchesCache(); |
153 | 153 |
154 ownerFrame().invalidateAll(); | 154 ownerFrame().invalidateAll(); |
155 return false; | 155 return false; |
156 } | 156 } |
157 | 157 |
158 #if OS(ANDROID) | 158 #if OS(ANDROID) |
159 ownerFrame().viewImpl()->zoomToFindInPageRect(ownerFrame().frameView()->cont
entsToWindow(enclosingIntRect(LayoutObject::absoluteBoundingBoxRectForRange(m_ac
tiveMatch.get())))); | 159 ownerFrame().viewImpl()->zoomToFindInPageRect(ownerFrame().frameView()->cont
entsToRootFrame(enclosingIntRect(LayoutObject::absoluteBoundingBoxRectForRange(m
_activeMatch.get())))); |
160 #endif | 160 #endif |
161 | 161 |
162 setMarkerActive(m_activeMatch.get(), true); | 162 setMarkerActive(m_activeMatch.get(), true); |
163 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr
entActiveMatchFrame; | 163 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr
entActiveMatchFrame; |
164 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); | 164 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); |
165 | 165 |
166 // Make sure no node is focused. See http://crbug.com/38700. | 166 // Make sure no node is focused. See http://crbug.com/38700. |
167 ownerFrame().frame()->document()->setFocusedElement(nullptr); | 167 ownerFrame().frame()->document()->setFocusedElement(nullptr); |
168 | 168 |
169 if (!options.findNext || activeSelection) { | 169 if (!options.findNext || activeSelection) { |
(...skipping 12 matching lines...) Expand all Loading... |
182 ++m_activeMatchIndexInCurrentFrame; | 182 ++m_activeMatchIndexInCurrentFrame; |
183 else | 183 else |
184 --m_activeMatchIndexInCurrentFrame; | 184 --m_activeMatchIndexInCurrentFrame; |
185 | 185 |
186 if (m_activeMatchIndexInCurrentFrame + 1 > m_lastMatchCount) | 186 if (m_activeMatchIndexInCurrentFrame + 1 > m_lastMatchCount) |
187 m_activeMatchIndexInCurrentFrame = 0; | 187 m_activeMatchIndexInCurrentFrame = 0; |
188 if (m_activeMatchIndexInCurrentFrame == -1) | 188 if (m_activeMatchIndexInCurrentFrame == -1) |
189 m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1; | 189 m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1; |
190 } | 190 } |
191 if (selectionRect) { | 191 if (selectionRect) { |
192 *selectionRect = ownerFrame().frameView()->contentsToWindow(m_active
Match->boundingBox()); | 192 *selectionRect = ownerFrame().frameView()->contentsToRootFrame(m_act
iveMatch->boundingBox()); |
193 reportFindInPageSelection(*selectionRect, m_activeMatchIndexInCurren
tFrame + 1, identifier); | 193 reportFindInPageSelection(*selectionRect, m_activeMatchIndexInCurren
tFrame + 1, identifier); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 return true; | 197 return true; |
198 } | 198 } |
199 | 199 |
200 void TextFinder::stopFindingAndClearSelection() | 200 void TextFinder::stopFindingAndClearSelection() |
201 { | 201 { |
202 cancelPendingScopingEffort(); | 202 cancelPendingScopingEffort(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 // We have found the active tickmark frame. | 336 // We have found the active tickmark frame. |
337 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &owner
Frame(); | 337 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &owner
Frame(); |
338 foundActiveMatch = true; | 338 foundActiveMatch = true; |
339 // We also know which tickmark is active now. | 339 // We also know which tickmark is active now. |
340 m_activeMatchIndexInCurrentFrame = matchCount - 1; | 340 m_activeMatchIndexInCurrentFrame = matchCount - 1; |
341 // To stop looking for the active tickmark, we set this flag. | 341 // To stop looking for the active tickmark, we set this flag. |
342 m_locatingActiveRect = false; | 342 m_locatingActiveRect = false; |
343 | 343 |
344 // Notify browser of new location for the selected rectangle. | 344 // Notify browser of new location for the selected rectangle. |
345 reportFindInPageSelection( | 345 reportFindInPageSelection( |
346 ownerFrame().frameView()->contentsToWindow(resultBounds), | 346 ownerFrame().frameView()->contentsToRootFrame(resultBounds), |
347 m_activeMatchIndexInCurrentFrame + 1, | 347 m_activeMatchIndexInCurrentFrame + 1, |
348 identifier); | 348 identifier); |
349 } | 349 } |
350 | 350 |
351 addMarker(resultRange.get(), foundActiveMatch); | 351 addMarker(resultRange.get(), foundActiveMatch); |
352 | 352 |
353 m_findMatchesCache.append(FindMatch(resultRange.get(), m_lastMatchCount
+ matchCount)); | 353 m_findMatchesCache.append(FindMatch(resultRange.get(), m_lastMatchCount
+ matchCount)); |
354 | 354 |
355 // Set the new start for the search range to be the end of the previous | 355 // Set the new start for the search range to be the end of the previous |
356 // result range. There is no need to use a VisiblePosition here, | 356 // result range. There is no need to use a VisiblePosition here, |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 IntRect activeMatchRect; | 623 IntRect activeMatchRect; |
624 IntRect activeMatchBoundingBox = enclosingIntRect(LayoutObject::absoluteBoun
dingBoxRectForRange(m_activeMatch.get())); | 624 IntRect activeMatchBoundingBox = enclosingIntRect(LayoutObject::absoluteBoun
dingBoxRectForRange(m_activeMatch.get())); |
625 | 625 |
626 if (!activeMatchBoundingBox.isEmpty()) { | 626 if (!activeMatchBoundingBox.isEmpty()) { |
627 if (m_activeMatch->firstNode() && m_activeMatch->firstNode()->layoutObje
ct()) { | 627 if (m_activeMatch->firstNode() && m_activeMatch->firstNode()->layoutObje
ct()) { |
628 m_activeMatch->firstNode()->layoutObject()->scrollRectToVisible( | 628 m_activeMatch->firstNode()->layoutObject()->scrollRectToVisible( |
629 LayoutRect(activeMatchBoundingBox), ScrollAlignment::alignCenter
IfNeeded, ScrollAlignment::alignCenterIfNeeded); | 629 LayoutRect(activeMatchBoundingBox), ScrollAlignment::alignCenter
IfNeeded, ScrollAlignment::alignCenterIfNeeded); |
630 } | 630 } |
631 | 631 |
632 // Zoom to the active match. | 632 // Zoom to the active match. |
633 activeMatchRect = ownerFrame().frameView()->contentsToWindow(activeMatch
BoundingBox); | 633 activeMatchRect = ownerFrame().frameView()->contentsToRootFrame(activeMa
tchBoundingBox); |
634 ownerFrame().viewImpl()->zoomToFindInPageRect(activeMatchRect); | 634 ownerFrame().viewImpl()->zoomToFindInPageRect(activeMatchRect); |
635 } | 635 } |
636 | 636 |
637 if (selectionRect) | 637 if (selectionRect) |
638 *selectionRect = activeMatchRect; | 638 *selectionRect = activeMatchRect; |
639 | 639 |
640 return ordinalOfFirstMatch() + m_activeMatchIndexInCurrentFrame + 1; | 640 return ordinalOfFirstMatch() + m_activeMatchIndexInCurrentFrame + 1; |
641 } | 641 } |
642 | 642 |
643 PassOwnPtrWillBeRawPtr<TextFinder> TextFinder::create(WebLocalFrameImpl& ownerFr
ame) | 643 PassOwnPtrWillBeRawPtr<TextFinder> TextFinder::create(WebLocalFrameImpl& ownerFr
ame) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 { | 790 { |
791 visitor->trace(m_ownerFrame); | 791 visitor->trace(m_ownerFrame); |
792 visitor->trace(m_currentActiveMatchFrame); | 792 visitor->trace(m_currentActiveMatchFrame); |
793 visitor->trace(m_activeMatch); | 793 visitor->trace(m_activeMatch); |
794 visitor->trace(m_resumeScopingFromRange); | 794 visitor->trace(m_resumeScopingFromRange); |
795 visitor->trace(m_deferredScopingWork); | 795 visitor->trace(m_deferredScopingWork); |
796 visitor->trace(m_findMatchesCache); | 796 visitor->trace(m_findMatchesCache); |
797 } | 797 } |
798 | 798 |
799 } // namespace blink | 799 } // namespace blink |
OLD | NEW |