| 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 final : public NoBaseWillBeGarbageCollectedFinalized<TextFinder
> { | 53 class TextFinder final : public GarbageCollectedFinalized<TextFinder> { |
| 54 public: | 54 public: |
| 55 static PassOwnPtrWillBeRawPtr<TextFinder> create(WebLocalFrameImpl& ownerFra
me); | 55 static RawPtr<TextFinder> create(WebLocalFrameImpl& ownerFrame); |
| 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 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 92 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 93 public: | 93 public: |
| 94 FindMatch(PassRefPtrWillBeRawPtr<Range>, int ordinal); | 94 FindMatch(RawPtr<Range>, int ordinal); |
| 95 | 95 |
| 96 DECLARE_TRACE(); | 96 DECLARE_TRACE(); |
| 97 | 97 |
| 98 RefPtrWillBeMember<Range> m_range; | 98 Member<Range> m_range; |
| 99 | 99 |
| 100 // 1-based index within this frame. | 100 // 1-based index within this frame. |
| 101 int m_ordinal; | 101 int m_ordinal; |
| 102 | 102 |
| 103 // In find-in-page coordinates. | 103 // In find-in-page coordinates. |
| 104 // Lazily calculated by updateFindMatchRects. | 104 // Lazily calculated by updateFindMatchRects. |
| 105 FloatRect m_rect; | 105 FloatRect m_rect; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 DECLARE_TRACE(); | 108 DECLARE_TRACE(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 WebLocalFrameImpl& ownerFrame() const | 203 WebLocalFrameImpl& ownerFrame() const |
| 204 { | 204 { |
| 205 ASSERT(m_ownerFrame); | 205 ASSERT(m_ownerFrame); |
| 206 return *m_ownerFrame; | 206 return *m_ownerFrame; |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Returns the ordinal of the first match in the owner frame. | 209 // Returns the ordinal of the first match in the owner frame. |
| 210 int ordinalOfFirstMatch() const; | 210 int ordinalOfFirstMatch() const; |
| 211 | 211 |
| 212 RawPtrWillBeMember<WebLocalFrameImpl> m_ownerFrame; | 212 Member<WebLocalFrameImpl> m_ownerFrame; |
| 213 | 213 |
| 214 // A way for the main frame to keep track of which frame has an active | 214 // A way for the main frame to keep track of which frame has an active |
| 215 // match. Should be 0 for all other frames. | 215 // match. Should be 0 for all other frames. |
| 216 RawPtrWillBeMember<WebLocalFrameImpl> m_currentActiveMatchFrame; | 216 Member<WebLocalFrameImpl> m_currentActiveMatchFrame; |
| 217 | 217 |
| 218 // The range of the active match for the current frame. | 218 // The range of the active match for the current frame. |
| 219 RefPtrWillBeMember<Range> m_activeMatch; | 219 Member<Range> m_activeMatch; |
| 220 | 220 |
| 221 // The index of the active match for the current frame. | 221 // The index of the active match for the current frame. |
| 222 int m_activeMatchIndexInCurrentFrame; | 222 int m_activeMatchIndexInCurrentFrame; |
| 223 | 223 |
| 224 // The scoping effort can time out and we need to keep track of where we | 224 // The scoping effort can time out and we need to keep track of where we |
| 225 // ended our last search so we can continue from where we left of. | 225 // ended our last search so we can continue from where we left of. |
| 226 // | 226 // |
| 227 // This range is collapsed to the end position of the last successful | 227 // This range is collapsed to the end position of the last successful |
| 228 // search; the new search should start from this position. | 228 // search; the new search should start from this position. |
| 229 RefPtrWillBeMember<Range> m_resumeScopingFromRange; | 229 Member<Range> m_resumeScopingFromRange; |
| 230 | 230 |
| 231 // Keeps track of the last string this frame searched for. This is used for | 231 // Keeps track of the last string this frame searched for. This is used for |
| 232 // short-circuiting searches in the following scenarios: When a frame has | 232 // short-circuiting searches in the following scenarios: When a frame has |
| 233 // been searched and returned 0 results, we don't need to search that frame | 233 // been searched and returned 0 results, we don't need to search that frame |
| 234 // again if the user is just adding to the search (making it more specific). | 234 // again if the user is just adding to the search (making it more specific). |
| 235 WTF::String m_lastSearchString; | 235 WTF::String m_lastSearchString; |
| 236 | 236 |
| 237 // Keeps track of how many matches this frame has found so far, so that we | 237 // Keeps track of how many matches this frame has found so far, so that we |
| 238 // don't lose count between scoping efforts, and is also used (in conjunctio
n | 238 // don't lose count between scoping efforts, and is also used (in conjunctio
n |
| 239 // with m_lastSearchString) to figure out if we need to search the frame aga
in. | 239 // with m_lastSearchString) to figure out if we need to search the frame aga
in. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 251 | 251 |
| 252 // Identifier of the latest find-in-page request. Required to be stored in | 252 // Identifier of the latest find-in-page request. Required to be stored in |
| 253 // the frame in order to reply if required in case the frame is detached. | 253 // the frame in order to reply if required in case the frame is detached. |
| 254 int m_findRequestIdentifier; | 254 int m_findRequestIdentifier; |
| 255 | 255 |
| 256 // Keeps track of when the scoping effort should next invalidate the scrollb
ar | 256 // Keeps track of when the scoping effort should next invalidate the scrollb
ar |
| 257 // and the frame area. | 257 // and the frame area. |
| 258 int m_nextInvalidateAfter; | 258 int m_nextInvalidateAfter; |
| 259 | 259 |
| 260 // A list of all of the pending calls to scopeStringMatches. | 260 // A list of all of the pending calls to scopeStringMatches. |
| 261 WillBeHeapVector<OwnPtrWillBeMember<DeferredScopeStringMatches>> m_deferredS
copingWork; | 261 HeapVector<Member<DeferredScopeStringMatches>> m_deferredScopingWork; |
| 262 | 262 |
| 263 // Version number incremented on the main frame only whenever the document | 263 // Version number incremented on the main frame only whenever the document |
| 264 // find-in-page match markers change. It should be 0 for all other frames. | 264 // find-in-page match markers change. It should be 0 for all other frames. |
| 265 int m_findMatchMarkersVersion; | 265 int m_findMatchMarkersVersion; |
| 266 | 266 |
| 267 // Local cache of the find match markers currently displayed for this frame. | 267 // Local cache of the find match markers currently displayed for this frame. |
| 268 WillBeHeapVector<FindMatch> m_findMatchesCache; | 268 HeapVector<FindMatch> m_findMatchesCache; |
| 269 | 269 |
| 270 // Contents size when find-in-page match rects were last computed for this | 270 // Contents size when find-in-page match rects were last computed for this |
| 271 // frame's cache. | 271 // frame's cache. |
| 272 IntSize m_contentsSizeForCurrentFindMatchRects; | 272 IntSize m_contentsSizeForCurrentFindMatchRects; |
| 273 | 273 |
| 274 // This flag is used by the scoping effort to determine if we need to figure | 274 // This flag is used by the scoping effort to determine if we need to figure |
| 275 // out which rectangle is the active match. Once we find the active | 275 // out which rectangle is the active match. Once we find the active |
| 276 // rectangle we clear this flag. | 276 // rectangle we clear this flag. |
| 277 bool m_locatingActiveRect; | 277 bool m_locatingActiveRect; |
| 278 | 278 |
| 279 // Keeps track of whether there is an scoping effort ongoing in the frame. | 279 // Keeps track of whether there is an scoping effort ongoing in the frame. |
| 280 bool m_scopingInProgress; | 280 bool m_scopingInProgress; |
| 281 | 281 |
| 282 // Keeps track of whether the last find request completed its scoping effort | 282 // Keeps track of whether the last find request completed its scoping effort |
| 283 // without finding any matches in this frame. | 283 // without finding any matches in this frame. |
| 284 bool m_lastFindRequestCompletedWithNoMatches; | 284 bool m_lastFindRequestCompletedWithNoMatches; |
| 285 | 285 |
| 286 // Determines if the rects in the find-in-page matches cache of this frame | 286 // Determines if the rects in the find-in-page matches cache of this frame |
| 287 // are invalid and should be recomputed. | 287 // are invalid and should be recomputed. |
| 288 bool m_findMatchRectsAreValid; | 288 bool m_findMatchRectsAreValid; |
| 289 }; | 289 }; |
| 290 | 290 |
| 291 } // namespace blink | 291 } // namespace blink |
| 292 | 292 |
| 293 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TextFinder::FindMatch); | 293 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TextFinder::FindMatch); |
| 294 | 294 |
| 295 #endif // TextFinder_h | 295 #endif // TextFinder_h |
| OLD | NEW |