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