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