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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
44 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 class Range; | 48 class Range; |
49 class WebLocalFrameImpl; | 49 class WebLocalFrameImpl; |
50 | 50 |
51 template <typename T> class WebVector; | 51 template <typename T> class WebVector; |
52 | 52 |
53 class TextFinder { | 53 class TextFinder final : public NoBaseWillBeGarbageCollectedFinalized<TextFinder
> { |
54 public: | 54 public: |
55 static PassOwnPtr<TextFinder> create(WebLocalFrameImpl& ownerFrame); | 55 static PassOwnPtrWillBeRawPtr<TextFinder> create(WebLocalFrameImpl& ownerFra
me); |
56 | 56 |
57 bool find( | 57 bool find( |
58 int identifier, const WebString& searchText, const WebFindOptions&, | 58 int identifier, const WebString& searchText, const WebFindOptions&, |
59 bool wrapWithinFrame, WebRect* selectionRect); | 59 bool wrapWithinFrame, WebRect* selectionRect); |
60 void stopFindingAndClearSelection(); | 60 void stopFindingAndClearSelection(); |
61 void scopeStringMatches( | 61 void scopeStringMatches( |
62 int identifier, const WebString& searchText, const WebFindOptions&, | 62 int identifier, const WebString& searchText, const WebFindOptions&, |
63 bool reset); | 63 bool reset); |
64 void cancelPendingScopingEffort(); | 64 void cancelPendingScopingEffort(); |
65 void increaseMatchCount(int identifier, int count); | 65 void increaseMatchCount(int identifier, int count); |
(...skipping 18 matching lines...) Expand all Loading... |
84 | 84 |
85 int totalMatchCount() const { return m_totalMatchCount; } | 85 int totalMatchCount() const { return m_totalMatchCount; } |
86 bool scopingInProgress() const { return m_scopingInProgress; } | 86 bool scopingInProgress() const { return m_scopingInProgress; } |
87 void increaseMarkerVersion() { ++m_findMatchMarkersVersion; } | 87 void increaseMarkerVersion() { ++m_findMatchMarkersVersion; } |
88 | 88 |
89 ~TextFinder(); | 89 ~TextFinder(); |
90 | 90 |
91 class FindMatch { | 91 class FindMatch { |
92 ALLOW_ONLY_INLINE_ALLOCATION(); | 92 ALLOW_ONLY_INLINE_ALLOCATION(); |
93 public: | 93 public: |
| 94 FindMatch(PassRefPtrWillBeRawPtr<Range>, int ordinal); |
| 95 |
| 96 void trace(Visitor*); |
| 97 |
94 RefPtrWillBeMember<Range> m_range; | 98 RefPtrWillBeMember<Range> m_range; |
95 | 99 |
96 // 1-based index within this frame. | 100 // 1-based index within this frame. |
97 int m_ordinal; | 101 int m_ordinal; |
98 | 102 |
99 // In find-in-page coordinates. | 103 // In find-in-page coordinates. |
100 // Lazily calculated by updateFindMatchRects. | 104 // Lazily calculated by updateFindMatchRects. |
101 FloatRect m_rect; | 105 FloatRect m_rect; |
| 106 }; |
102 | 107 |
103 FindMatch(PassRefPtrWillBeRawPtr<Range>, int ordinal); | 108 void trace(Visitor*); |
104 | |
105 void trace(Visitor*); | |
106 }; | |
107 | 109 |
108 private: | 110 private: |
109 class DeferredScopeStringMatches; | 111 class DeferredScopeStringMatches; |
110 friend class DeferredScopeStringMatches; | 112 friend class DeferredScopeStringMatches; |
111 | 113 |
112 explicit TextFinder(WebLocalFrameImpl& ownerFrame); | 114 explicit TextFinder(WebLocalFrameImpl& ownerFrame); |
113 | 115 |
114 // Notifies the delegate about a new selection rect. | 116 // Notifies the delegate about a new selection rect. |
115 void reportFindInPageSelection( | 117 void reportFindInPageSelection( |
116 const WebRect& selectionRect, int activeMatchOrdinal, int identifier); | 118 const WebRect& selectionRect, int activeMatchOrdinal, int identifier); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const WebFindOptions&, bool reset); | 180 const WebFindOptions&, bool reset); |
179 | 181 |
180 // Determines whether to invalidate the content area and scrollbar. | 182 // Determines whether to invalidate the content area and scrollbar. |
181 void invalidateIfNecessary(); | 183 void invalidateIfNecessary(); |
182 | 184 |
183 // Sets the markers within a current match range as active or inactive. | 185 // Sets the markers within a current match range as active or inactive. |
184 void setMatchMarkerActive(bool); | 186 void setMatchMarkerActive(bool); |
185 | 187 |
186 void decrementFramesScopingCount(int identifier); | 188 void decrementFramesScopingCount(int identifier); |
187 | 189 |
| 190 WebLocalFrameImpl& ownerFrame() const |
| 191 { |
| 192 ASSERT(m_ownerFrame); |
| 193 return *m_ownerFrame; |
| 194 } |
| 195 |
188 // Returns the ordinal of the first match in the owner frame. | 196 // Returns the ordinal of the first match in the owner frame. |
189 int ordinalOfFirstMatch() const; | 197 int ordinalOfFirstMatch() const; |
190 | 198 |
191 WebLocalFrameImpl& m_ownerFrame; | 199 RawPtrWillBeMember<WebLocalFrameImpl> m_ownerFrame; |
192 | 200 |
193 // A way for the main frame to keep track of which frame has an active | 201 // A way for the main frame to keep track of which frame has an active |
194 // match. Should be 0 for all other frames. | 202 // match. Should be 0 for all other frames. |
195 WebLocalFrameImpl* m_currentActiveMatchFrame; | 203 RawPtrWillBeMember<WebLocalFrameImpl> m_currentActiveMatchFrame; |
196 | 204 |
197 // The range of the active match for the current frame. | 205 // The range of the active match for the current frame. |
198 RefPtrWillBePersistent<Range> m_activeMatch; | 206 RefPtrWillBeMember<Range> m_activeMatch; |
199 | 207 |
200 // The index of the active match for the current frame. | 208 // The index of the active match for the current frame. |
201 int m_activeMatchIndexInCurrentFrame; | 209 int m_activeMatchIndexInCurrentFrame; |
202 | 210 |
203 // The scoping effort can time out and we need to keep track of where we | 211 // The scoping effort can time out and we need to keep track of where we |
204 // ended our last search so we can continue from where we left of. | 212 // ended our last search so we can continue from where we left of. |
205 // | 213 // |
206 // This range is collapsed to the end position of the last successful | 214 // This range is collapsed to the end position of the last successful |
207 // search; the new search should start from this position. | 215 // search; the new search should start from this position. |
208 RefPtrWillBePersistent<Range> m_resumeScopingFromRange; | 216 RefPtrWillBeMember<Range> m_resumeScopingFromRange; |
209 | 217 |
210 // Keeps track of the last string this frame searched for. This is used for | 218 // Keeps track of the last string this frame searched for. This is used for |
211 // short-circuiting searches in the following scenarios: When a frame has | 219 // short-circuiting searches in the following scenarios: When a frame has |
212 // been searched and returned 0 results, we don't need to search that frame | 220 // been searched and returned 0 results, we don't need to search that frame |
213 // again if the user is just adding to the search (making it more specific). | 221 // again if the user is just adding to the search (making it more specific). |
214 WTF::String m_lastSearchString; | 222 WTF::String m_lastSearchString; |
215 | 223 |
216 // Keeps track of how many matches this frame has found so far, so that we | 224 // Keeps track of how many matches this frame has found so far, so that we |
217 // don't lose count between scoping efforts, and is also used (in conjunctio
n | 225 // don't lose count between scoping efforts, and is also used (in conjunctio
n |
218 // with m_lastSearchString) to figure out if we need to search the frame aga
in. | 226 // with m_lastSearchString) to figure out if we need to search the frame aga
in. |
(...skipping 11 matching lines...) Expand all Loading... |
230 | 238 |
231 // Identifier of the latest find-in-page request. Required to be stored in | 239 // Identifier of the latest find-in-page request. Required to be stored in |
232 // the frame in order to reply if required in case the frame is detached. | 240 // the frame in order to reply if required in case the frame is detached. |
233 int m_findRequestIdentifier; | 241 int m_findRequestIdentifier; |
234 | 242 |
235 // Keeps track of when the scoping effort should next invalidate the scrollb
ar | 243 // Keeps track of when the scoping effort should next invalidate the scrollb
ar |
236 // and the frame area. | 244 // and the frame area. |
237 int m_nextInvalidateAfter; | 245 int m_nextInvalidateAfter; |
238 | 246 |
239 // A list of all of the pending calls to scopeStringMatches. | 247 // A list of all of the pending calls to scopeStringMatches. |
240 Vector<DeferredScopeStringMatches*> m_deferredScopingWork; | 248 WillBeHeapVector<OwnPtrWillBeMember<DeferredScopeStringMatches> > m_deferred
ScopingWork; |
241 | 249 |
242 // Version number incremented on the main frame only whenever the document | 250 // Version number incremented on the main frame only whenever the document |
243 // find-in-page match markers change. It should be 0 for all other frames. | 251 // find-in-page match markers change. It should be 0 for all other frames. |
244 int m_findMatchMarkersVersion; | 252 int m_findMatchMarkersVersion; |
245 | 253 |
246 // Local cache of the find match markers currently displayed for this frame. | 254 // Local cache of the find match markers currently displayed for this frame. |
247 WillBePersistentHeapVector<FindMatch> m_findMatchesCache; | 255 WillBeHeapVector<FindMatch> m_findMatchesCache; |
248 | 256 |
249 // Contents size when find-in-page match rects were last computed for this | 257 // Contents size when find-in-page match rects were last computed for this |
250 // frame's cache. | 258 // frame's cache. |
251 IntSize m_contentsSizeForCurrentFindMatchRects; | 259 IntSize m_contentsSizeForCurrentFindMatchRects; |
252 | 260 |
253 // This flag is used by the scoping effort to determine if we need to figure | 261 // This flag is used by the scoping effort to determine if we need to figure |
254 // out which rectangle is the active match. Once we find the active | 262 // out which rectangle is the active match. Once we find the active |
255 // rectangle we clear this flag. | 263 // rectangle we clear this flag. |
256 bool m_locatingActiveRect; | 264 bool m_locatingActiveRect; |
257 | 265 |
258 // Keeps track of whether there is an scoping effort ongoing in the frame. | 266 // Keeps track of whether there is an scoping effort ongoing in the frame. |
259 bool m_scopingInProgress; | 267 bool m_scopingInProgress; |
260 | 268 |
261 // Keeps track of whether the last find request completed its scoping effort | 269 // Keeps track of whether the last find request completed its scoping effort |
262 // without finding any matches in this frame. | 270 // without finding any matches in this frame. |
263 bool m_lastFindRequestCompletedWithNoMatches; | 271 bool m_lastFindRequestCompletedWithNoMatches; |
264 | 272 |
265 // Determines if the rects in the find-in-page matches cache of this frame | 273 // Determines if the rects in the find-in-page matches cache of this frame |
266 // are invalid and should be recomputed. | 274 // are invalid and should be recomputed. |
267 bool m_findMatchRectsAreValid; | 275 bool m_findMatchRectsAreValid; |
268 }; | 276 }; |
269 | 277 |
270 } // namespace blink | 278 } // namespace blink |
271 | 279 |
272 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TextFinder::FindMatch); | 280 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TextFinder::FindMatch); |
273 | 281 |
274 #endif | 282 #endif // TextFinder_h |
OLD | NEW |