Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: Source/web/TextFinder.h

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use STACK_ALLOCATED() + incorporate ager's overview of macros in this area. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
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 #ifndef TextFinder_h 31 #ifndef TextFinder_h
32 #define TextFinder_h 32 #define TextFinder_h
33 33
34 #include "WebFindOptions.h" 34 #include "WebFindOptions.h"
35 #include "core/editing/FindOptions.h" 35 #include "core/editing/FindOptions.h"
36 #include "platform/geometry/FloatRect.h" 36 #include "platform/geometry/FloatRect.h"
37 #include "platform/heap/Handle.h"
37 #include "public/platform/WebFloatPoint.h" 38 #include "public/platform/WebFloatPoint.h"
38 #include "public/platform/WebFloatRect.h" 39 #include "public/platform/WebFloatRect.h"
39 #include "public/platform/WebRect.h" 40 #include "public/platform/WebRect.h"
40 #include "wtf/PassOwnPtr.h" 41 #include "wtf/PassOwnPtr.h"
41 #include "wtf/PassRefPtr.h" 42 #include "wtf/PassRefPtr.h"
42 #include "wtf/Vector.h" 43 #include "wtf/Vector.h"
43 #include "wtf/text/WTFString.h" 44 #include "wtf/text/WTFString.h"
44 45
45 namespace WebCore { 46 namespace WebCore {
46 class Range; 47 class Range;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 void flushCurrentScoping(); 83 void flushCurrentScoping();
83 84
84 void resetActiveMatch() { m_activeMatch = nullptr; } 85 void resetActiveMatch() { m_activeMatch = nullptr; }
85 86
86 int totalMatchCount() const { return m_totalMatchCount; } 87 int totalMatchCount() const { return m_totalMatchCount; }
87 bool scopingInProgress() const { return m_scopingInProgress; } 88 bool scopingInProgress() const { return m_scopingInProgress; }
88 void increaseMarkerVersion() { ++m_findMatchMarkersVersion; } 89 void increaseMarkerVersion() { ++m_findMatchMarkersVersion; }
89 90
90 ~TextFinder(); 91 ~TextFinder();
91 92
92 private: 93 class FindMatch {
93 class DeferredScopeStringMatches; 94 ALLOW_ONLY_INLINE_ALLOCATION();
94 friend class DeferredScopeStringMatches; 95 public:
95 96 RefPtrWillBeMember<WebCore::Range> m_range;
96 struct FindMatch {
97 RefPtr<WebCore::Range> m_range;
98 97
99 // 1-based index within this frame. 98 // 1-based index within this frame.
100 int m_ordinal; 99 int m_ordinal;
101 100
102 // In find-in-page coordinates. 101 // In find-in-page coordinates.
103 // Lazily calculated by updateFindMatchRects. 102 // Lazily calculated by updateFindMatchRects.
104 WebCore::FloatRect m_rect; 103 WebCore::FloatRect m_rect;
105 104
106 FindMatch(PassRefPtr<WebCore::Range>, int ordinal); 105 FindMatch(PassRefPtrWillBeRawPtr<WebCore::Range>, int ordinal);
106
107 void trace(WebCore::Visitor*);
107 }; 108 };
108 109
110 private:
111 class DeferredScopeStringMatches;
112 friend class DeferredScopeStringMatches;
113
109 explicit TextFinder(WebFrameImpl& ownerFrame); 114 explicit TextFinder(WebFrameImpl& ownerFrame);
110 115
111 // Notifies the delegate about a new selection rect. 116 // Notifies the delegate about a new selection rect.
112 void reportFindInPageSelection( 117 void reportFindInPageSelection(
113 const WebRect& selectionRect, int activeMatchOrdinal, int identifier); 118 const WebRect& selectionRect, int activeMatchOrdinal, int identifier);
114 119
115 // Clear the find-in-page matches cache forcing rects to be fully 120 // Clear the find-in-page matches cache forcing rects to be fully
116 // calculated again next time updateFindMatchRects is called. 121 // calculated again next time updateFindMatchRects is called.
117 void clearFindMatchesCache(); 122 void clearFindMatchesCache();
118 123
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // Returns the ordinal of the first match in the owner frame. 190 // Returns the ordinal of the first match in the owner frame.
186 int ordinalOfFirstMatch() const; 191 int ordinalOfFirstMatch() const;
187 192
188 WebFrameImpl& m_ownerFrame; 193 WebFrameImpl& m_ownerFrame;
189 194
190 // A way for the main frame to keep track of which frame has an active 195 // A way for the main frame to keep track of which frame has an active
191 // match. Should be 0 for all other frames. 196 // match. Should be 0 for all other frames.
192 WebFrameImpl* m_currentActiveMatchFrame; 197 WebFrameImpl* m_currentActiveMatchFrame;
193 198
194 // The range of the active match for the current frame. 199 // The range of the active match for the current frame.
195 RefPtr<WebCore::Range> m_activeMatch; 200 RefPtrWillBePersistent<WebCore::Range> m_activeMatch;
196 201
197 // The index of the active match for the current frame. 202 // The index of the active match for the current frame.
198 int m_activeMatchIndexInCurrentFrame; 203 int m_activeMatchIndexInCurrentFrame;
199 204
200 // The scoping effort can time out and we need to keep track of where we 205 // The scoping effort can time out and we need to keep track of where we
201 // ended our last search so we can continue from where we left of. 206 // ended our last search so we can continue from where we left of.
202 RefPtr<WebCore::Range> m_resumeScopingFromRange; 207 RefPtrWillBePersistent<WebCore::Range> m_resumeScopingFromRange;
203 208
204 // Keeps track of the last string this frame searched for. This is used for 209 // Keeps track of the last string this frame searched for. This is used for
205 // short-circuiting searches in the following scenarios: When a frame has 210 // short-circuiting searches in the following scenarios: When a frame has
206 // been searched and returned 0 results, we don't need to search that frame 211 // been searched and returned 0 results, we don't need to search that frame
207 // again if the user is just adding to the search (making it more specific). 212 // again if the user is just adding to the search (making it more specific).
208 WTF::String m_lastSearchString; 213 WTF::String m_lastSearchString;
209 214
210 // Keeps track of how many matches this frame has found so far, so that we 215 // Keeps track of how many matches this frame has found so far, so that we
211 // don't loose count between scoping efforts, and is also used (in conjuncti on 216 // don't loose count between scoping efforts, and is also used (in conjuncti on
212 // with m_lastSearchString) to figure out if we need to search the frame aga in. 217 // with m_lastSearchString) to figure out if we need to search the frame aga in.
(...skipping 18 matching lines...) Expand all
231 int m_nextInvalidateAfter; 236 int m_nextInvalidateAfter;
232 237
233 // A list of all of the pending calls to scopeStringMatches. 238 // A list of all of the pending calls to scopeStringMatches.
234 Vector<DeferredScopeStringMatches*> m_deferredScopingWork; 239 Vector<DeferredScopeStringMatches*> m_deferredScopingWork;
235 240
236 // Version number incremented on the main frame only whenever the document 241 // Version number incremented on the main frame only whenever the document
237 // find-in-page match markers change. It should be 0 for all other frames. 242 // find-in-page match markers change. It should be 0 for all other frames.
238 int m_findMatchMarkersVersion; 243 int m_findMatchMarkersVersion;
239 244
240 // Local cache of the find match markers currently displayed for this frame. 245 // Local cache of the find match markers currently displayed for this frame.
241 Vector<FindMatch> m_findMatchesCache; 246 WillBePersistentHeapVector<FindMatch> m_findMatchesCache;
242 247
243 // Contents size when find-in-page match rects were last computed for this 248 // Contents size when find-in-page match rects were last computed for this
244 // frame's cache. 249 // frame's cache.
245 WebCore::IntSize m_contentsSizeForCurrentFindMatchRects; 250 WebCore::IntSize m_contentsSizeForCurrentFindMatchRects;
246 251
247 // This flag is used by the scoping effort to determine if we need to figure 252 // This flag is used by the scoping effort to determine if we need to figure
248 // out which rectangle is the active match. Once we find the active 253 // out which rectangle is the active match. Once we find the active
249 // rectangle we clear this flag. 254 // rectangle we clear this flag.
250 bool m_locatingActiveRect; 255 bool m_locatingActiveRect;
251 256
252 // Keeps track of whether there is an scoping effort ongoing in the frame. 257 // Keeps track of whether there is an scoping effort ongoing in the frame.
253 bool m_scopingInProgress; 258 bool m_scopingInProgress;
254 259
255 // Keeps track of whether the last find request completed its scoping effort 260 // Keeps track of whether the last find request completed its scoping effort
256 // without finding any matches in this frame. 261 // without finding any matches in this frame.
257 bool m_lastFindRequestCompletedWithNoMatches; 262 bool m_lastFindRequestCompletedWithNoMatches;
258 263
259 // Determines if the rects in the find-in-page matches cache of this frame 264 // Determines if the rects in the find-in-page matches cache of this frame
260 // are invalid and should be recomputed. 265 // are invalid and should be recomputed.
261 bool m_findMatchRectsAreValid; 266 bool m_findMatchRectsAreValid;
262 }; 267 };
263 268
264 } // namespace blink 269 } // namespace blink
265 270
271 namespace WTF {
272 template <> struct VectorTraits<blink::TextFinder::FindMatch> : VectorTraitsBase <blink::TextFinder::FindMatch> {
273 static const bool canInitializeWithMemset = true;
274 };
275 }
276
266 #endif 277 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698