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 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 #include "web/TextFinder.h" | 33 #include "web/TextFinder.h" |
34 | 34 |
| 35 #include "core/accessibility/AXObject.h" |
| 36 #include "core/accessibility/AXObjectCache.h" |
35 #include "core/dom/DocumentMarker.h" | 37 #include "core/dom/DocumentMarker.h" |
36 #include "core/dom/DocumentMarkerController.h" | 38 #include "core/dom/DocumentMarkerController.h" |
37 #include "core/dom/Range.h" | 39 #include "core/dom/Range.h" |
38 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
39 #include "core/editing/Editor.h" | 41 #include "core/editing/Editor.h" |
40 #include "core/editing/TextIterator.h" | 42 #include "core/editing/TextIterator.h" |
41 #include "core/editing/VisibleSelection.h" | 43 #include "core/editing/VisibleSelection.h" |
42 #include "core/frame/FrameView.h" | 44 #include "core/frame/FrameView.h" |
43 #include "core/page/Page.h" | 45 #include "core/page/Page.h" |
44 #include "core/rendering/RenderObject.h" | 46 #include "core/rendering/RenderObject.h" |
45 #include "platform/Timer.h" | 47 #include "platform/Timer.h" |
46 #include "public/platform/WebVector.h" | 48 #include "public/platform/WebVector.h" |
| 49 #include "public/web/WebAXObject.h" |
47 #include "public/web/WebFindOptions.h" | 50 #include "public/web/WebFindOptions.h" |
48 #include "public/web/WebFrameClient.h" | 51 #include "public/web/WebFrameClient.h" |
49 #include "public/web/WebViewClient.h" | 52 #include "public/web/WebViewClient.h" |
50 #include "web/FindInPageCoordinates.h" | 53 #include "web/FindInPageCoordinates.h" |
51 #include "web/WebLocalFrameImpl.h" | 54 #include "web/WebLocalFrameImpl.h" |
52 #include "web/WebViewImpl.h" | 55 #include "web/WebViewImpl.h" |
53 #include "wtf/CurrentTime.h" | 56 #include "wtf/CurrentTime.h" |
54 | 57 |
55 namespace blink { | 58 namespace blink { |
56 | 59 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 --m_activeMatchIndexInCurrentFrame; | 184 --m_activeMatchIndexInCurrentFrame; |
182 | 185 |
183 if (m_activeMatchIndexInCurrentFrame + 1 > m_lastMatchCount) | 186 if (m_activeMatchIndexInCurrentFrame + 1 > m_lastMatchCount) |
184 m_activeMatchIndexInCurrentFrame = 0; | 187 m_activeMatchIndexInCurrentFrame = 0; |
185 if (m_activeMatchIndexInCurrentFrame == -1) | 188 if (m_activeMatchIndexInCurrentFrame == -1) |
186 m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1; | 189 m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1; |
187 } | 190 } |
188 if (selectionRect) { | 191 if (selectionRect) { |
189 *selectionRect = ownerFrame().frameView()->contentsToWindow(m_active
Match->boundingBox()); | 192 *selectionRect = ownerFrame().frameView()->contentsToWindow(m_active
Match->boundingBox()); |
190 reportFindInPageSelection(*selectionRect, m_activeMatchIndexInCurren
tFrame + 1, identifier); | 193 reportFindInPageSelection(*selectionRect, m_activeMatchIndexInCurren
tFrame + 1, identifier); |
| 194 reportFindInPageResultToAccessibility(identifier); |
191 } | 195 } |
192 } | 196 } |
193 | 197 |
194 return true; | 198 return true; |
195 } | 199 } |
196 | 200 |
197 void TextFinder::stopFindingAndClearSelection() | 201 void TextFinder::stopFindingAndClearSelection() |
198 { | 202 { |
199 cancelPendingScopingEffort(); | 203 cancelPendingScopingEffort(); |
200 | 204 |
201 // Remove all markers for matches found and turn off the highlighting. | 205 // Remove all markers for matches found and turn off the highlighting. |
202 ownerFrame().frame()->document()->markers().removeMarkers(DocumentMarker::Te
xtMatch); | 206 ownerFrame().frame()->document()->markers().removeMarkers(DocumentMarker::Te
xtMatch); |
203 ownerFrame().frame()->editor().setMarkedTextMatchesAreHighlighted(false); | 207 ownerFrame().frame()->editor().setMarkedTextMatchesAreHighlighted(false); |
204 clearFindMatchesCache(); | 208 clearFindMatchesCache(); |
205 | 209 |
206 // Let the frame know that we don't want tickmarks or highlighting anymore. | 210 // Let the frame know that we don't want tickmarks or highlighting anymore. |
207 ownerFrame().invalidateAll(); | 211 ownerFrame().invalidateAll(); |
208 } | 212 } |
209 | 213 |
| 214 void TextFinder::reportFindInPageResultToAccessibility(int identifier) |
| 215 { |
| 216 AXObjectCache* axObjectCache = ownerFrame().frame()->document()->existingAXO
bjectCache(); |
| 217 if (!axObjectCache) |
| 218 return; |
| 219 |
| 220 AXObject* startObject = axObjectCache->get(m_activeMatch->startContainer()); |
| 221 AXObject* endObject = axObjectCache->get(m_activeMatch->endContainer()); |
| 222 if (!startObject || !endObject) |
| 223 return; |
| 224 |
| 225 WebLocalFrameImpl* mainFrameImpl = ownerFrame().viewImpl()->mainFrameImpl(); |
| 226 if (mainFrameImpl && mainFrameImpl->client()) { |
| 227 mainFrameImpl->client()->handleAccessibilityFindInPageResult( |
| 228 identifier, m_activeMatchIndexInCurrentFrame + 1, |
| 229 WebAXObject(startObject), m_activeMatch->startOffset(), |
| 230 WebAXObject(endObject), m_activeMatch->endOffset()); |
| 231 } |
| 232 } |
| 233 |
210 void TextFinder::scopeStringMatches(int identifier, const WebString& searchText,
const WebFindOptions& options, bool reset) | 234 void TextFinder::scopeStringMatches(int identifier, const WebString& searchText,
const WebFindOptions& options, bool reset) |
211 { | 235 { |
212 if (reset) { | 236 if (reset) { |
213 // This is a brand new search, so we need to reset everything. | 237 // This is a brand new search, so we need to reset everything. |
214 // Scoping is just about to begin. | 238 // Scoping is just about to begin. |
215 m_scopingInProgress = true; | 239 m_scopingInProgress = true; |
216 | 240 |
217 // Need to keep the current identifier locally in order to finish the | 241 // Need to keep the current identifier locally in order to finish the |
218 // request in case the frame is detached during the process. | 242 // request in case the frame is detached during the process. |
219 m_findRequestIdentifier = identifier; | 243 m_findRequestIdentifier = identifier; |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 { | 787 { |
764 visitor->trace(m_ownerFrame); | 788 visitor->trace(m_ownerFrame); |
765 visitor->trace(m_currentActiveMatchFrame); | 789 visitor->trace(m_currentActiveMatchFrame); |
766 visitor->trace(m_activeMatch); | 790 visitor->trace(m_activeMatch); |
767 visitor->trace(m_resumeScopingFromRange); | 791 visitor->trace(m_resumeScopingFromRange); |
768 visitor->trace(m_deferredScopingWork); | 792 visitor->trace(m_deferredScopingWork); |
769 visitor->trace(m_findMatchesCache); | 793 visitor->trace(m_findMatchesCache); |
770 } | 794 } |
771 | 795 |
772 } // namespace blink | 796 } // namespace blink |
OLD | NEW |