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

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

Issue 181013007: Introduce TextFinder class for decoupling WebFrameImpl and text finder. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@introduce-textfinder-class-new
Patch Set: Fixed Linux build Created 6 years, 9 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
« no previous file with comments | « no previous file | Source/web/TextFinder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 #ifndef TextFinder_h 31 #ifndef TextFinder_h
32 #define TextFinder_h 32 #define TextFinder_h
33 33
34 #include "WebFrame.h" 34 #include "WebFindOptions.h"
35 35 #include "core/editing/FindOptions.h"
36 #include "FrameLoaderClientImpl.h"
37 #include "core/frame/LocalFrame.h"
38 #include "platform/geometry/FloatRect.h" 36 #include "platform/geometry/FloatRect.h"
39 #include "public/platform/WebFileSystemType.h" 37 #include "public/platform/WebFloatPoint.h"
40 #include "wtf/Compiler.h" 38 #include "public/platform/WebFloatRect.h"
41 #include "wtf/HashSet.h" 39 #include "public/platform/WebRect.h"
42 #include "wtf/OwnPtr.h" 40 #include "wtf/PassOwnPtr.h"
43 #include "wtf/RefCounted.h" 41 #include "wtf/PassRefPtr.h"
42 #include "wtf/Vector.h"
44 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
45 44
46 namespace WebCore { 45 namespace WebCore {
47 class GraphicsContext;
48 class HTMLInputElement;
49 class HistoryItem;
50 class IntSize;
51 class KURL;
52 class Node;
53 class Range; 46 class Range;
54 class SubstituteData;
55 struct FrameLoadRequest;
56 struct WindowFeatures;
57 } 47 }
58 48
59 namespace blink { 49 namespace blink {
60 class ChromePrintContext; 50 class WebFrameImpl;
61 class SharedWorkerRepositoryClientImpl;
62 class WebDataSourceImpl;
63 class WebInputElement;
64 class WebFrameClient;
65 class WebPerformance;
66 class WebPluginContainerImpl;
67 class WebView;
68 class WebViewImpl;
69 struct WebPrintParams;
70 51
71 template <typename T> class WebVector; 52 template <typename T> class WebVector;
72 53
73 // Implementation of WebFrame, note that this is a reference counted object. 54 class TextFinder {
74 class WebFrameImpl FINAL
75 : public WebFrame
76 , public RefCounted<WebFrameImpl> {
77 public: 55 public:
78 // WebFrame methods: 56 static PassOwnPtr<TextFinder> create(WebFrameImpl& ownerFrame);
79 virtual void close() OVERRIDE; 57
80 virtual WebString uniqueName() const OVERRIDE; 58 bool find(
81 virtual WebString assignedName() const OVERRIDE;
82 virtual void setName(const WebString&) OVERRIDE;
83 virtual WebVector<WebIconURL> iconURLs(int iconTypesMask) const OVERRIDE;
84 virtual void setIsRemote(bool) OVERRIDE;
85 virtual void setRemoteWebLayer(WebLayer*) OVERRIDE;
86 virtual void setPermissionClient(WebPermissionClient*) OVERRIDE;
87 virtual void setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClient *) OVERRIDE;
88 virtual WebSize scrollOffset() const OVERRIDE;
89 virtual void setScrollOffset(const WebSize&) OVERRIDE;
90 virtual WebSize minimumScrollOffset() const OVERRIDE;
91 virtual WebSize maximumScrollOffset() const OVERRIDE;
92 virtual WebSize contentsSize() const OVERRIDE;
93 virtual bool hasVisibleContent() const OVERRIDE;
94 virtual WebRect visibleContentRect() const OVERRIDE;
95 virtual bool hasHorizontalScrollbar() const OVERRIDE;
96 virtual bool hasVerticalScrollbar() const OVERRIDE;
97 virtual WebView* view() const OVERRIDE;
98 virtual WebFrame* opener() const OVERRIDE;
99 virtual void setOpener(WebFrame*) OVERRIDE;
100 virtual void appendChild(WebFrame*) OVERRIDE;
101 virtual void removeChild(WebFrame*) OVERRIDE;
102 virtual WebFrame* parent() const OVERRIDE;
103 virtual WebFrame* top() const OVERRIDE;
104 virtual WebFrame* previousSibling() const OVERRIDE;
105 virtual WebFrame* nextSibling() const OVERRIDE;
106 virtual WebFrame* firstChild() const OVERRIDE;
107 virtual WebFrame* lastChild() const OVERRIDE;
108 virtual WebFrame* traversePrevious(bool wrap) const OVERRIDE;
109 virtual WebFrame* traverseNext(bool wrap) const OVERRIDE;
110 virtual WebFrame* findChildByName(const WebString&) const OVERRIDE;
111 virtual WebFrame* findChildByExpression(const WebString&) const OVERRIDE;
112 virtual WebDocument document() const OVERRIDE;
113 virtual WebPerformance performance() const OVERRIDE;
114 virtual NPObject* windowObject() const OVERRIDE;
115 virtual void bindToWindowObject(const WebString& name, NPObject*) OVERRIDE;
116 virtual void bindToWindowObject(const WebString& name, NPObject*, void*) OVE RRIDE;
117 virtual void executeScript(const WebScriptSource&) OVERRIDE;
118 virtual void executeScriptInIsolatedWorld(
119 int worldID, const WebScriptSource* sources, unsigned numSources,
120 int extensionGroup) OVERRIDE;
121 virtual void setIsolatedWorldSecurityOrigin(int worldID, const WebSecurityOr igin&) OVERRIDE;
122 virtual void setIsolatedWorldContentSecurityPolicy(int worldID, const WebStr ing&) OVERRIDE;
123 virtual void addMessageToConsole(const WebConsoleMessage&) OVERRIDE;
124 virtual void collectGarbage() OVERRIDE;
125 virtual bool checkIfRunInsecureContent(const WebURL&) const OVERRIDE;
126 virtual v8::Handle<v8::Value> executeScriptAndReturnValue(
127 const WebScriptSource&) OVERRIDE;
128 virtual void executeScriptInIsolatedWorld(
129 int worldID, const WebScriptSource* sourcesIn, unsigned numSources,
130 int extensionGroup, WebVector<v8::Local<v8::Value> >* results) OVERRIDE;
131 virtual v8::Handle<v8::Value> callFunctionEvenIfScriptDisabled(
132 v8::Handle<v8::Function>,
133 v8::Handle<v8::Value>,
134 int argc,
135 v8::Handle<v8::Value> argv[]) OVERRIDE;
136 virtual v8::Local<v8::Context> mainWorldScriptContext() const OVERRIDE;
137 virtual void reload(bool ignoreCache) OVERRIDE;
138 virtual void reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCac he) OVERRIDE;
139 virtual void loadRequest(const WebURLRequest&) OVERRIDE;
140 virtual void loadHistoryItem(const WebHistoryItem&, WebURLRequest::CachePoli cy) OVERRIDE;
141 virtual void loadData(
142 const WebData&, const WebString& mimeType, const WebString& textEncoding ,
143 const WebURL& baseURL, const WebURL& unreachableURL, bool replace) OVERR IDE;
144 virtual void loadHTMLString(
145 const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL ,
146 bool replace) OVERRIDE;
147 virtual bool isLoading() const OVERRIDE;
148 virtual void stopLoading() OVERRIDE;
149 virtual WebDataSource* provisionalDataSource() const OVERRIDE;
150 virtual WebDataSource* dataSource() const OVERRIDE;
151 virtual WebHistoryItem previousHistoryItem() const OVERRIDE;
152 virtual WebHistoryItem currentHistoryItem() const OVERRIDE;
153 virtual void enableViewSourceMode(bool enable) OVERRIDE;
154 virtual bool isViewSourceModeEnabled() const OVERRIDE;
155 virtual void setReferrerForRequest(WebURLRequest&, const WebURL& referrer) O VERRIDE;
156 virtual void dispatchWillSendRequest(WebURLRequest&) OVERRIDE;
157 virtual WebURLLoader* createAssociatedURLLoader(const WebURLLoaderOptions&) OVERRIDE;
158 virtual unsigned unloadListenerCount() const OVERRIDE;
159 virtual void replaceSelection(const WebString&) OVERRIDE;
160 virtual void insertText(const WebString&) OVERRIDE;
161 virtual void setMarkedText(const WebString&, unsigned location, unsigned len gth) OVERRIDE;
162 virtual void unmarkText() OVERRIDE;
163 virtual bool hasMarkedText() const OVERRIDE;
164 virtual WebRange markedRange() const OVERRIDE;
165 virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const OVERRIDE;
166 virtual size_t characterIndexForPoint(const WebPoint&) const OVERRIDE;
167 virtual bool executeCommand(const WebString&, const WebNode& = WebNode()) OV ERRIDE;
168 virtual bool executeCommand(const WebString&, const WebString& value, const WebNode& = WebNode()) OVERRIDE;
169 virtual bool isCommandEnabled(const WebString&) const OVERRIDE;
170 virtual void enableContinuousSpellChecking(bool) OVERRIDE;
171 virtual bool isContinuousSpellCheckingEnabled() const OVERRIDE;
172 virtual void requestTextChecking(const WebElement&) OVERRIDE;
173 virtual void replaceMisspelledRange(const WebString&) OVERRIDE;
174 virtual void removeSpellingMarkers() OVERRIDE;
175 virtual bool hasSelection() const OVERRIDE;
176 virtual WebRange selectionRange() const OVERRIDE;
177 virtual WebString selectionAsText() const OVERRIDE;
178 virtual WebString selectionAsMarkup() const OVERRIDE;
179 virtual bool selectWordAroundCaret() OVERRIDE;
180 virtual void selectRange(const WebPoint& base, const WebPoint& extent) OVERR IDE;
181 virtual void selectRange(const WebRange&) OVERRIDE;
182 virtual void moveRangeSelection(const WebPoint& base, const WebPoint& extent ) OVERRIDE;
183 virtual void moveCaretSelection(const WebPoint&) OVERRIDE;
184 virtual void setCaretVisible(bool) OVERRIDE;
185 virtual int printBegin(const WebPrintParams&, const WebNode& constrainToNode ) OVERRIDE;
186 virtual float printPage(int pageToPrint, WebCanvas*) OVERRIDE;
187 virtual float getPrintPageShrink(int page) OVERRIDE;
188 virtual void printEnd() OVERRIDE;
189 virtual bool isPrintScalingDisabledForPlugin(const WebNode&) OVERRIDE;
190 virtual bool hasCustomPageSizeStyle(int pageIndex) OVERRIDE;
191 virtual bool isPageBoxVisible(int pageIndex) OVERRIDE;
192 virtual void pageSizeAndMarginsInPixels(int pageIndex,
193 WebSize& pageSize,
194 int& marginTop,
195 int& marginRight,
196 int& marginBottom,
197 int& marginLeft) OVERRIDE;
198 virtual WebString pageProperty(const WebString& propertyName, int pageIndex) OVERRIDE;
199 virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&) OVERRIDE;
200 virtual bool find(
201 int identifier, const WebString& searchText, const WebFindOptions&, 59 int identifier, const WebString& searchText, const WebFindOptions&,
202 bool wrapWithinFrame, WebRect* selectionRect) OVERRIDE; 60 bool wrapWithinFrame, WebRect* selectionRect);
203 virtual void stopFinding(bool clearSelection) OVERRIDE; 61 void stopFindingAndClearSelection();
204 virtual void scopeStringMatches( 62 void scopeStringMatches(
205 int identifier, const WebString& searchText, const WebFindOptions&, 63 int identifier, const WebString& searchText, const WebFindOptions&,
206 bool reset) OVERRIDE; 64 bool reset);
207 virtual void cancelPendingScopingEffort() OVERRIDE; 65 void cancelPendingScopingEffort();
208 virtual void increaseMatchCount(int count, int identifier) OVERRIDE; 66 void increaseMatchCount(int identifier, int count);
209 virtual void resetMatchCount() OVERRIDE; 67 void resetMatchCount();
210 virtual int findMatchMarkersVersion() const OVERRIDE; 68 int findMatchMarkersVersion() const { return m_findMatchMarkersVersion; }
211 virtual WebFloatRect activeFindMatchRect() OVERRIDE; 69 WebFloatRect activeFindMatchRect();
212 virtual void findMatchRects(WebVector<WebFloatRect>&) OVERRIDE; 70 void findMatchRects(WebVector<WebFloatRect>&);
213 virtual int selectNearestFindMatch(const WebFloatPoint&, WebRect* selectionR ect) OVERRIDE; 71 int selectNearestFindMatch(const WebFloatPoint&, WebRect* selectionRect);
214
215 virtual void sendOrientationChangeEvent(int orientation) OVERRIDE;
216
217 virtual void dispatchMessageEventWithOriginCheck(
218 const WebSecurityOrigin& intendedTargetOrigin,
219 const WebDOMEvent&) OVERRIDE;
220
221 virtual WebString contentAsText(size_t maxChars) const OVERRIDE;
222 virtual WebString contentAsMarkup() const OVERRIDE;
223 virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTex tNormal) const OVERRIDE;
224 virtual WebString markerTextForListItem(const WebElement&) const OVERRIDE;
225 virtual WebRect selectionBoundsRect() const OVERRIDE;
226
227 virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const OVERRIDE;
228 virtual WebString layerTreeAsText(bool showDebugInfo = false) const OVERRIDE ;
229
230 void willDetachParent();
231
232 static WebFrameImpl* create(WebFrameClient*);
233 virtual ~WebFrameImpl();
234
235 // Called by the WebViewImpl to initialize the main frame for the page.
236 void initializeAsMainFrame(WebCore::Page*);
237
238 PassRefPtr<WebCore::LocalFrame> createChildFrame(
239 const WebCore::FrameLoadRequest&, WebCore::HTMLFrameOwnerElement*);
240
241 void didChangeContentsSize(const WebCore::IntSize&);
242
243 void createFrameView();
244
245 static WebFrameImpl* fromFrame(WebCore::LocalFrame* frame);
246 static WebFrameImpl* fromFrameOwnerElement(WebCore::Element* element);
247
248 // If the frame hosts a PluginDocument, this method returns the WebPluginCon tainerImpl
249 // that hosts the plugin.
250 static WebPluginContainerImpl* pluginContainerFromFrame(WebCore::LocalFrame* );
251
252 // If the frame hosts a PluginDocument, this method returns the WebPluginCon tainerImpl
253 // that hosts the plugin. If the provided node is a plugin, then it runs its
254 // WebPluginContainerImpl.
255 static WebPluginContainerImpl* pluginContainerFromNode(WebCore::LocalFrame*, const WebNode&);
256
257 WebViewImpl* viewImpl() const;
258
259 WebCore::FrameView* frameView() const { return frame() ? frame()->view() : 0 ; }
260
261 // Getters for the impls corresponding to Get(Provisional)DataSource. They
262 // may return 0 if there is no corresponding data source.
263 WebDataSourceImpl* dataSourceImpl() const;
264 WebDataSourceImpl* provisionalDataSourceImpl() const;
265 72
266 // Returns which frame has an active match. This function should only be 73 // Returns which frame has an active match. This function should only be
267 // called on the main frame, as it is the only frame keeping track. Returned 74 // called on the main frame, as it is the only frame keeping track. Returned
268 // value can be 0 if no frame has an active match. 75 // value can be 0 if no frame has an active match.
269 WebFrameImpl* activeMatchFrame() const { return m_currentActiveMatchFrame; } 76 WebFrameImpl* activeMatchFrame() const { return m_currentActiveMatchFrame; }
270 77
271 // Returns the active match in the current frame. Could be a null range if 78 // Returns the active match in the current frame. Could be a null range if
272 // the local frame has no active match. 79 // the local frame has no active match.
273 WebCore::Range* activeMatch() const { return m_activeMatch.get(); } 80 WebCore::Range* activeMatch() const { return m_activeMatch.get(); }
274 81
275 // When a Find operation ends, we want to set the selection to what was acti ve 82 void flushCurrentScoping();
276 // and set focus to the first focusable node we find (starting with the firs t
277 // node in the matched range and going up the inheritance chain). If we find
278 // nothing to focus we focus the first focusable node in the range. This
279 // allows us to set focus to a link (when we find text inside a link), which
280 // allows us to navigate by pressing Enter after closing the Find box.
281 void setFindEndstateFocusAndSelection();
282 83
283 void didFail(const WebCore::ResourceError&, bool wasProvisional); 84 void resetActiveMatch() { m_activeMatch = nullptr; }
284 85
285 // Sets whether the WebFrameImpl allows its document to be scrolled. 86 int totalMatchCount() const { return m_totalMatchCount; }
286 // If the parameter is true, allow the document to be scrolled. 87 bool scopingInProgress() const { return m_scopingInProgress; }
287 // Otherwise, disallow scrolling. 88 void increaseMarkerVersion() { ++m_findMatchMarkersVersion; }
288 virtual void setCanHaveScrollbars(bool) OVERRIDE;
289 89
290 WebCore::LocalFrame* frame() const { return m_frame.get(); } 90 ~TextFinder();
291 WebFrameClient* client() const { return m_client; }
292 void setClient(WebFrameClient* client) { m_client = client; }
293
294 WebPermissionClient* permissionClient() { return m_permissionClient; }
295 SharedWorkerRepositoryClientImpl* sharedWorkerRepositoryClient() const { ret urn m_sharedWorkerRepositoryClient.get(); }
296
297 void setInputEventsTransformForEmulation(const WebCore::IntSize&, float);
298
299 static void selectWordAroundPosition(WebCore::LocalFrame*, WebCore::VisibleP osition);
300 91
301 private: 92 private:
302 class DeferredScopeStringMatches; 93 class DeferredScopeStringMatches;
303 friend class DeferredScopeStringMatches; 94 friend class DeferredScopeStringMatches;
304 friend class FrameLoaderClientImpl;
305 95
306 struct FindMatch { 96 struct FindMatch {
307 RefPtr<WebCore::Range> m_range; 97 RefPtr<WebCore::Range> m_range;
308 98
309 // 1-based index within this frame. 99 // 1-based index within this frame.
310 int m_ordinal; 100 int m_ordinal;
311 101
312 // In find-in-page coordinates. 102 // In find-in-page coordinates.
313 // Lazily calculated by updateFindMatchRects. 103 // Lazily calculated by updateFindMatchRects.
314 WebCore::FloatRect m_rect; 104 WebCore::FloatRect m_rect;
315 105
316 FindMatch(PassRefPtr<WebCore::Range>, int ordinal); 106 FindMatch(PassRefPtr<WebCore::Range>, int ordinal);
317 }; 107 };
318 108
319 // A bit mask specifying area of the frame to invalidate. 109 explicit TextFinder(WebFrameImpl& ownerFrame);
320 enum AreaToInvalidate {
321 InvalidateNothing,
322 InvalidateContentArea,
323 InvalidateScrollbar, // Vertical scrollbar only.
324 InvalidateAll // Both content area and the scrollbar.
325 };
326
327 explicit WebFrameImpl(WebFrameClient*);
328
329 // Sets the local WebCore frame and registers destruction observers.
330 void setWebCoreFrame(PassRefPtr<WebCore::LocalFrame>);
331 110
332 // Notifies the delegate about a new selection rect. 111 // Notifies the delegate about a new selection rect.
333 void reportFindInPageSelection( 112 void reportFindInPageSelection(
334 const WebRect& selectionRect, int activeMatchOrdinal, int identifier); 113 const WebRect& selectionRect, int activeMatchOrdinal, int identifier);
335 114
336 // Clear the find-in-page matches cache forcing rects to be fully 115 // Clear the find-in-page matches cache forcing rects to be fully
337 // calculated again next time updateFindMatchRects is called. 116 // calculated again next time updateFindMatchRects is called.
338 void clearFindMatchesCache(); 117 void clearFindMatchesCache();
339 118
340 // Check if the activeMatchFrame still exists in the frame tree. 119 // Check if the activeMatchFrame still exists in the frame tree.
(...skipping 11 matching lines...) Expand all
352 int selectFindMatch(unsigned index, WebRect* selectionRect); 131 int selectFindMatch(unsigned index, WebRect* selectionRect);
353 132
354 // Compute and cache the rects for FindMatches if required. 133 // Compute and cache the rects for FindMatches if required.
355 // Rects are automatically invalidated in case of content size changes, 134 // Rects are automatically invalidated in case of content size changes,
356 // propagating the invalidation to child frames. 135 // propagating the invalidation to child frames.
357 void updateFindMatchRects(); 136 void updateFindMatchRects();
358 137
359 // Append the find-in-page match rects of the current frame to the provided vector. 138 // Append the find-in-page match rects of the current frame to the provided vector.
360 void appendFindMatchRects(Vector<WebFloatRect>& frameRects); 139 void appendFindMatchRects(Vector<WebFloatRect>& frameRects);
361 140
362 // Invalidates a certain area within the frame.
363 void invalidateArea(AreaToInvalidate);
364
365 // Add a WebKit TextMatch-highlight marker to nodes in a range. 141 // Add a WebKit TextMatch-highlight marker to nodes in a range.
366 void addMarker(WebCore::Range*, bool activeMatch); 142 void addMarker(WebCore::Range*, bool activeMatch);
367 143
368 // Sets the markers within a range as active or inactive. 144 // Sets the markers within a range as active or inactive.
369 void setMarkerActive(WebCore::Range*, bool active); 145 void setMarkerActive(WebCore::Range*, bool active);
370 146
371 // Returns the ordinal of the first match in the frame specified. This 147 // Returns the ordinal of the first match in the frame specified. This
372 // function enumerates the frames, starting with the main frame and up to (b ut 148 // function enumerates the frames, starting with the main frame and up to (b ut
373 // not including) the frame passed in as a parameter and counts how many 149 // not including) the frame passed in as a parameter and counts how many
374 // matches have been found. 150 // matches have been found.
(...skipping 19 matching lines...) Expand all
394 bool reset); 170 bool reset);
395 171
396 // Called by a DeferredScopeStringMatches instance. 172 // Called by a DeferredScopeStringMatches instance.
397 void callScopeStringMatches( 173 void callScopeStringMatches(
398 DeferredScopeStringMatches*, int identifier, const WebString& searchText , 174 DeferredScopeStringMatches*, int identifier, const WebString& searchText ,
399 const WebFindOptions&, bool reset); 175 const WebFindOptions&, bool reset);
400 176
401 // Determines whether to invalidate the content area and scrollbar. 177 // Determines whether to invalidate the content area and scrollbar.
402 void invalidateIfNecessary(); 178 void invalidateIfNecessary();
403 179
404 void loadJavaScriptURL(const WebCore::KURL&); 180 // Sets the markers within a current match range as active or inactive.
181 void setMatchMarkerActive(bool);
405 182
406 // Returns a hit-tested VisiblePosition for the given point 183 void decrementFramesScopingCount(int identifier);
407 WebCore::VisiblePosition visiblePositionForWindowPoint(const WebPoint&);
408 184
409 FrameLoaderClientImpl m_frameLoaderClientImpl; 185 // Returns the ordinal of the first match in the owner frame.
186 int ordinalOfFirstMatch() const;
410 187
411 // The embedder retains a reference to the WebCore LocalFrame while it is ac tive in the DOM. This 188 WebFrameImpl& m_ownerFrame;
412 // reference is released when the frame is removed from the DOM or the entir e page is closed.
413 // FIXME: These will need to change to WebFrame when we introduce WebFramePr oxy.
414 RefPtr<WebCore::LocalFrame> m_frame;
415 WebFrameImpl* m_parent;
416 WebFrameImpl* m_previousSibling;
417 WebFrameImpl* m_nextSibling;
418 WebFrameImpl* m_firstChild;
419 WebFrameImpl* m_lastChild;
420
421 WebFrameImpl* m_opener;
422 WTF::HashSet<WebFrameImpl*> m_openedFrames;
423
424 // Indicate whether the current LocalFrame is local or remote. Remote frames are
425 // rendered in a different process from their parent frames.
426 bool m_isRemote;
427
428 WebFrameClient* m_client;
429 WebPermissionClient* m_permissionClient;
430 OwnPtr<SharedWorkerRepositoryClientImpl> m_sharedWorkerRepositoryClient;
431 189
432 // A way for the main frame to keep track of which frame has an active 190 // A way for the main frame to keep track of which frame has an active
433 // match. Should be 0 for all other frames. 191 // match. Should be 0 for all other frames.
434 WebFrameImpl* m_currentActiveMatchFrame; 192 WebFrameImpl* m_currentActiveMatchFrame;
435 193
436 // The range of the active match for the current frame. 194 // The range of the active match for the current frame.
437 RefPtr<WebCore::Range> m_activeMatch; 195 RefPtr<WebCore::Range> m_activeMatch;
438 196
439 // The index of the active match for the current frame. 197 // The index of the active match for the current frame.
440 int m_activeMatchIndexInCurrentFrame; 198 int m_activeMatchIndexInCurrentFrame;
441 199
442 // This flag is used by the scoping effort to determine if we need to figure
443 // out which rectangle is the active match. Once we find the active
444 // rectangle we clear this flag.
445 bool m_locatingActiveRect;
446
447 // The scoping effort can time out and we need to keep track of where we 200 // The scoping effort can time out and we need to keep track of where we
448 // ended our last search so we can continue from where we left of. 201 // ended our last search so we can continue from where we left of.
449 RefPtr<WebCore::Range> m_resumeScopingFromRange; 202 RefPtr<WebCore::Range> m_resumeScopingFromRange;
450 203
451 // Keeps track of the last string this frame searched for. This is used for 204 // Keeps track of the last string this frame searched for. This is used for
452 // short-circuiting searches in the following scenarios: When a frame has 205 // short-circuiting searches in the following scenarios: When a frame has
453 // been searched and returned 0 results, we don't need to search that frame 206 // been searched and returned 0 results, we don't need to search that frame
454 // again if the user is just adding to the search (making it more specific). 207 // again if the user is just adding to the search (making it more specific).
455 WTF::String m_lastSearchString; 208 WTF::String m_lastSearchString;
456 209
457 // Keeps track of how many matches this frame has found so far, so that we 210 // Keeps track of how many matches this frame has found so far, so that we
458 // don't loose count between scoping efforts, and is also used (in conjuncti on 211 // don't loose count between scoping efforts, and is also used (in conjuncti on
459 // with m_lastSearchString) to figure out if we need to search the frame aga in. 212 // with m_lastSearchString) to figure out if we need to search the frame aga in.
460 int m_lastMatchCount; 213 int m_lastMatchCount;
461 214
462 // This variable keeps a cumulative total of matches found so far for ALL th e 215 // This variable keeps a cumulative total of matches found so far for ALL th e
463 // frames on the page, and is only incremented by calling IncreaseMatchCount 216 // frames on the page, and is only incremented by calling IncreaseMatchCount
464 // (on the main frame only). It should be -1 for all other frames. 217 // (on the main frame only). It should be -1 for all other frames.
465 int m_totalMatchCount; 218 int m_totalMatchCount;
466 219
467 // This variable keeps a cumulative total of how many frames are currently 220 // This variable keeps a cumulative total of how many frames are currently
468 // scoping, and is incremented/decremented on the main frame only. 221 // scoping, and is incremented/decremented on the main frame only.
469 // It should be -1 for all other frames. 222 // It should be -1 for all other frames.
470 int m_framesScopingCount; 223 int m_framesScopingCount;
471 224
472 // Identifier of the latest find-in-page request. Required to be stored in 225 // Identifier of the latest find-in-page request. Required to be stored in
473 // the frame in order to reply if required in case the frame is detached. 226 // the frame in order to reply if required in case the frame is detached.
474 int m_findRequestIdentifier; 227 int m_findRequestIdentifier;
475 228
476 // Keeps track of whether there is an scoping effort ongoing in the frame.
477 bool m_scopingInProgress;
478
479 // Keeps track of whether the last find request completed its scoping effort
480 // without finding any matches in this frame.
481 bool m_lastFindRequestCompletedWithNoMatches;
482
483 // Keeps track of when the scoping effort should next invalidate the scrollb ar 229 // Keeps track of when the scoping effort should next invalidate the scrollb ar
484 // and the frame area. 230 // and the frame area.
485 int m_nextInvalidateAfter; 231 int m_nextInvalidateAfter;
486 232
487 // A list of all of the pending calls to scopeStringMatches. 233 // A list of all of the pending calls to scopeStringMatches.
488 Vector<DeferredScopeStringMatches*> m_deferredScopingWork; 234 Vector<DeferredScopeStringMatches*> m_deferredScopingWork;
489 235
490 // Version number incremented on the main frame only whenever the document 236 // Version number incremented on the main frame only whenever the document
491 // find-in-page match markers change. It should be 0 for all other frames. 237 // find-in-page match markers change. It should be 0 for all other frames.
492 int m_findMatchMarkersVersion; 238 int m_findMatchMarkersVersion;
493 239
494 // Local cache of the find match markers currently displayed for this frame. 240 // Local cache of the find match markers currently displayed for this frame.
495 Vector<FindMatch> m_findMatchesCache; 241 Vector<FindMatch> m_findMatchesCache;
496 242
497 // Determines if the rects in the find-in-page matches cache of this frame
498 // are invalid and should be recomputed.
499 bool m_findMatchRectsAreValid;
500
501 // Contents size when find-in-page match rects were last computed for this 243 // Contents size when find-in-page match rects were last computed for this
502 // frame's cache. 244 // frame's cache.
503 WebCore::IntSize m_contentsSizeForCurrentFindMatchRects; 245 WebCore::IntSize m_contentsSizeForCurrentFindMatchRects;
504 246
505 // Valid between calls to BeginPrint() and EndPrint(). Containts the print 247 // This flag is used by the scoping effort to determine if we need to figure
506 // information. Is used by PrintPage(). 248 // out which rectangle is the active match. Once we find the active
507 OwnPtr<ChromePrintContext> m_printContext; 249 // rectangle we clear this flag.
250 bool m_locatingActiveRect;
508 251
509 // Stores the additional input events offset and scale when device metrics e mulation is enabled. 252 // Keeps track of whether there is an scoping effort ongoing in the frame.
510 WebCore::IntSize m_inputEventsOffsetForEmulation; 253 bool m_scopingInProgress;
511 float m_inputEventsScaleFactorForEmulation; 254
255 // Keeps track of whether the last find request completed its scoping effort
256 // without finding any matches in this frame.
257 bool m_lastFindRequestCompletedWithNoMatches;
258
259 // Determines if the rects in the find-in-page matches cache of this frame
260 // are invalid and should be recomputed.
261 bool m_findMatchRectsAreValid;
512 }; 262 };
513 263
514 DEFINE_TYPE_CASTS(WebFrameImpl, WebFrame, frame, true, true);
515
516 } // namespace blink 264 } // namespace blink
517 265
518 #endif 266 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/web/TextFinder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698