Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / WebFrameImpl.h
1 /*
2  * Copyright (C) 2009 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29  */
30
31 #ifndef WebFrameImpl_h
32 #define WebFrameImpl_h
33
34 #include "WebFrame.h"
35
36 #include "FrameLoaderClientImpl.h"
37 #include "core/frame/Frame.h"
38 #include "platform/geometry/FloatRect.h"
39 #include "public/platform/WebFileSystemType.h"
40 #include "wtf/Compiler.h"
41 #include "wtf/OwnPtr.h"
42 #include "wtf/RefCounted.h"
43 #include "wtf/text/WTFString.h"
44
45 namespace WebCore {
46 class GraphicsContext;
47 class HTMLInputElement;
48 class HistoryItem;
49 class IntSize;
50 class KURL;
51 class Node;
52 class Range;
53 class SubstituteData;
54 struct FrameLoadRequest;
55 struct WindowFeatures;
56 }
57
58 namespace blink {
59 class ChromePrintContext;
60 class SharedWorkerRepositoryClientImpl;
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
70 template <typename T> class WebVector;
71
72 // Implementation of WebFrame, note that this is a reference counted object.
73 class WebFrameImpl FINAL
74     : public WebFrame
75     , public RefCounted<WebFrameImpl> {
76 public:
77     // WebFrame methods:
78     virtual void close() OVERRIDE;
79     virtual WebString uniqueName() const OVERRIDE;
80     virtual WebString assignedName() const OVERRIDE;
81     virtual void setName(const WebString&) OVERRIDE;
82     virtual long long embedderIdentifier() const 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(const 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*) OVERRIDE;
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 WebSecurityOrigin&) OVERRIDE;
122     virtual void setIsolatedWorldContentSecurityPolicy(int worldID, const WebString&) 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::Object>,
134         int argc,
135         v8::Handle<v8::Value> argv[]) OVERRIDE;
136     virtual v8::Local<v8::Context> mainWorldScriptContext() const OVERRIDE;
137     virtual v8::Handle<v8::Value> createFileSystem(WebFileSystemType,
138         const WebString& name,
139         const WebString& path) OVERRIDE;
140     virtual v8::Handle<v8::Value> createSerializableFileSystem(WebFileSystemType,
141         const WebString& name,
142         const WebString& path) OVERRIDE;
143     virtual v8::Handle<v8::Value> createFileEntry(WebFileSystemType,
144         const WebString& fileSystemName,
145         const WebString& fileSystemPath,
146         const WebString& filePath,
147         bool isDirectory) OVERRIDE;
148     virtual void reload(bool ignoreCache) OVERRIDE;
149     virtual void reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCache) OVERRIDE;
150     virtual void loadRequest(const WebURLRequest&) OVERRIDE;
151     virtual void loadHistoryItem(const WebHistoryItem&, WebURLRequest::CachePolicy) OVERRIDE;
152     virtual void loadData(
153         const WebData&, const WebString& mimeType, const WebString& textEncoding,
154         const WebURL& baseURL, const WebURL& unreachableURL, bool replace) OVERRIDE;
155     virtual void loadHTMLString(
156         const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL,
157         bool replace) OVERRIDE;
158     virtual bool isLoading() const OVERRIDE;
159     virtual void stopLoading() OVERRIDE;
160     virtual WebDataSource* provisionalDataSource() const OVERRIDE;
161     virtual WebDataSource* dataSource() const OVERRIDE;
162     virtual WebHistoryItem previousHistoryItem() const OVERRIDE;
163     virtual WebHistoryItem currentHistoryItem() const OVERRIDE;
164     virtual void enableViewSourceMode(bool enable) OVERRIDE;
165     virtual bool isViewSourceModeEnabled() const OVERRIDE;
166     virtual void setReferrerForRequest(WebURLRequest&, const WebURL& referrer) OVERRIDE;
167     virtual void dispatchWillSendRequest(WebURLRequest&) OVERRIDE;
168     virtual WebURLLoader* createAssociatedURLLoader(const WebURLLoaderOptions&) OVERRIDE;
169     virtual unsigned unloadListenerCount() const OVERRIDE;
170     virtual void replaceSelection(const WebString&) OVERRIDE;
171     virtual void insertText(const WebString&) OVERRIDE;
172     virtual void setMarkedText(const WebString&, unsigned location, unsigned length) OVERRIDE;
173     virtual void unmarkText() OVERRIDE;
174     virtual bool hasMarkedText() const OVERRIDE;
175     virtual WebRange markedRange() const OVERRIDE;
176     virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const OVERRIDE;
177     virtual size_t characterIndexForPoint(const WebPoint&) const OVERRIDE;
178     virtual bool executeCommand(const WebString&, const WebNode& = WebNode()) OVERRIDE;
179     virtual bool executeCommand(const WebString&, const WebString& value, const WebNode& = WebNode()) OVERRIDE;
180     virtual bool isCommandEnabled(const WebString&) const OVERRIDE;
181     virtual void enableContinuousSpellChecking(bool) OVERRIDE;
182     virtual bool isContinuousSpellCheckingEnabled() const OVERRIDE;
183     virtual void requestTextChecking(const WebElement&) OVERRIDE;
184     virtual void replaceMisspelledRange(const WebString&) OVERRIDE;
185     virtual void removeSpellingMarkers() OVERRIDE;
186     virtual bool hasSelection() const OVERRIDE;
187     virtual WebRange selectionRange() const OVERRIDE;
188     virtual WebString selectionAsText() const OVERRIDE;
189     virtual WebString selectionAsMarkup() const OVERRIDE;
190     virtual bool selectWordAroundCaret() OVERRIDE;
191     virtual void selectRange(const WebPoint& base, const WebPoint& extent) OVERRIDE;
192     virtual void selectRange(const WebRange&) OVERRIDE;
193     virtual void moveRangeSelection(const WebPoint& base, const WebPoint& extent) OVERRIDE;
194     virtual void moveCaretSelection(const WebPoint&) OVERRIDE;
195     virtual void setCaretVisible(bool) OVERRIDE;
196     virtual int printBegin(const WebPrintParams&, const WebNode& constrainToNode) OVERRIDE;
197     virtual float printPage(int pageToPrint, WebCanvas*) OVERRIDE;
198     virtual float getPrintPageShrink(int page) OVERRIDE;
199     virtual void printEnd() OVERRIDE;
200     virtual bool isPrintScalingDisabledForPlugin(const WebNode&) OVERRIDE;
201     virtual bool hasCustomPageSizeStyle(int pageIndex) OVERRIDE;
202     virtual bool isPageBoxVisible(int pageIndex) OVERRIDE;
203     virtual void pageSizeAndMarginsInPixels(int pageIndex,
204                                             WebSize& pageSize,
205                                             int& marginTop,
206                                             int& marginRight,
207                                             int& marginBottom,
208                                             int& marginLeft) OVERRIDE;
209     virtual WebString pageProperty(const WebString& propertyName, int pageIndex) OVERRIDE;
210     virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&) OVERRIDE;
211     virtual bool find(
212         int identifier, const WebString& searchText, const WebFindOptions&,
213         bool wrapWithinFrame, WebRect* selectionRect) OVERRIDE;
214     virtual void stopFinding(bool clearSelection) OVERRIDE;
215     virtual void scopeStringMatches(
216         int identifier, const WebString& searchText, const WebFindOptions&,
217         bool reset) OVERRIDE;
218     virtual void cancelPendingScopingEffort() OVERRIDE;
219     virtual void increaseMatchCount(int count, int identifier) OVERRIDE;
220     virtual void resetMatchCount() OVERRIDE;
221     virtual int findMatchMarkersVersion() const OVERRIDE;
222     virtual WebFloatRect activeFindMatchRect() OVERRIDE;
223     virtual void findMatchRects(WebVector<WebFloatRect>&) OVERRIDE;
224     virtual int selectNearestFindMatch(const WebFloatPoint&, WebRect* selectionRect) OVERRIDE;
225
226     virtual void sendOrientationChangeEvent(int orientation) OVERRIDE;
227
228     virtual void dispatchMessageEventWithOriginCheck(
229         const WebSecurityOrigin& intendedTargetOrigin,
230         const WebDOMEvent&) OVERRIDE;
231
232     virtual WebString contentAsText(size_t maxChars) const OVERRIDE;
233     virtual WebString contentAsMarkup() const OVERRIDE;
234     virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTextNormal) const OVERRIDE;
235     virtual WebString markerTextForListItem(const WebElement&) const OVERRIDE;
236     virtual WebRect selectionBoundsRect() const OVERRIDE;
237
238     virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const OVERRIDE;
239     virtual WebString layerTreeAsText(bool showDebugInfo = false) const OVERRIDE;
240
241     void willDetachParent();
242
243     static WebFrameImpl* create(WebFrameClient*);
244     // FIXME: Move the embedderIdentifier concept fully to the embedder and
245     // remove this factory method.
246     static WebFrameImpl* create(WebFrameClient*, long long embedderIdentifier);
247     virtual ~WebFrameImpl();
248
249     // Called by the WebViewImpl to initialize the main frame for the page.
250     void initializeAsMainFrame(WebCore::Page*);
251
252     PassRefPtr<WebCore::Frame> createChildFrame(
253         const WebCore::FrameLoadRequest&, WebCore::HTMLFrameOwnerElement*);
254
255     void didChangeContentsSize(const WebCore::IntSize&);
256
257     void createFrameView();
258
259     static WebFrameImpl* fromFrame(WebCore::Frame* frame);
260     static WebFrameImpl* fromFrameOwnerElement(WebCore::Element* element);
261
262     // If the frame hosts a PluginDocument, this method returns the WebPluginContainerImpl
263     // that hosts the plugin.
264     static WebPluginContainerImpl* pluginContainerFromFrame(WebCore::Frame*);
265
266     // If the frame hosts a PluginDocument, this method returns the WebPluginContainerImpl
267     // that hosts the plugin. If the provided node is a plugin, then it runs its
268     // WebPluginContainerImpl.
269     static WebPluginContainerImpl* pluginContainerFromNode(WebCore::Frame*, const WebNode&);
270
271     WebViewImpl* viewImpl() const;
272
273     WebCore::FrameView* frameView() const { return frame() ? frame()->view() : 0; }
274
275     // Getters for the impls corresponding to Get(Provisional)DataSource. They
276     // may return 0 if there is no corresponding data source.
277     WebDataSourceImpl* dataSourceImpl() const;
278     WebDataSourceImpl* provisionalDataSourceImpl() const;
279
280     // Returns which frame has an active match. This function should only be
281     // called on the main frame, as it is the only frame keeping track. Returned
282     // value can be 0 if no frame has an active match.
283     WebFrameImpl* activeMatchFrame() const { return m_currentActiveMatchFrame; }
284
285     // Returns the active match in the current frame. Could be a null range if
286     // the local frame has no active match.
287     WebCore::Range* activeMatch() const { return m_activeMatch.get(); }
288
289     // When a Find operation ends, we want to set the selection to what was active
290     // and set focus to the first focusable node we find (starting with the first
291     // node in the matched range and going up the inheritance chain). If we find
292     // nothing to focus we focus the first focusable node in the range. This
293     // allows us to set focus to a link (when we find text inside a link), which
294     // allows us to navigate by pressing Enter after closing the Find box.
295     void setFindEndstateFocusAndSelection();
296
297     void didFail(const WebCore::ResourceError&, bool wasProvisional);
298
299     // Sets whether the WebFrameImpl allows its document to be scrolled.
300     // If the parameter is true, allow the document to be scrolled.
301     // Otherwise, disallow scrolling.
302     virtual void setCanHaveScrollbars(bool) OVERRIDE;
303
304     WebCore::Frame* frame() const { return m_frame.get(); }
305     WebFrameClient* client() const { return m_client; }
306     void setClient(WebFrameClient* client) { m_client = client; }
307
308     WebPermissionClient* permissionClient() { return m_permissionClient; }
309     SharedWorkerRepositoryClientImpl* sharedWorkerRepositoryClient() const { return m_sharedWorkerRepositoryClient.get(); }
310
311     void setInputEventsTransformForEmulation(const WebCore::IntSize&, float);
312
313     static void selectWordAroundPosition(WebCore::Frame*, WebCore::VisiblePosition);
314
315 private:
316     class DeferredScopeStringMatches;
317     friend class DeferredScopeStringMatches;
318     friend class FrameLoaderClientImpl;
319
320     struct FindMatch {
321         RefPtr<WebCore::Range> m_range;
322
323         // 1-based index within this frame.
324         int m_ordinal;
325
326         // In find-in-page coordinates.
327         // Lazily calculated by updateFindMatchRects.
328         WebCore::FloatRect m_rect;
329
330         FindMatch(PassRefPtr<WebCore::Range>, int ordinal);
331     };
332
333     // A bit mask specifying area of the frame to invalidate.
334     enum AreaToInvalidate {
335       InvalidateNothing,
336       InvalidateContentArea,
337       InvalidateScrollbar,   // Vertical scrollbar only.
338       InvalidateAll          // Both content area and the scrollbar.
339     };
340
341     WebFrameImpl(WebFrameClient*, long long frame_identifier);
342
343     // Sets the local WebCore frame and registers destruction observers.
344     void setWebCoreFrame(PassRefPtr<WebCore::Frame>);
345
346     // Notifies the delegate about a new selection rect.
347     void reportFindInPageSelection(
348         const WebRect& selectionRect, int activeMatchOrdinal, int identifier);
349
350     // Clear the find-in-page matches cache forcing rects to be fully
351     // calculated again next time updateFindMatchRects is called.
352     void clearFindMatchesCache();
353
354     // Check if the activeMatchFrame still exists in the frame tree.
355     bool isActiveMatchFrameValid() const;
356
357     // Return the index in the find-in-page cache of the match closest to the
358     // provided point in find-in-page coordinates, or -1 in case of error.
359     // The squared distance to the closest match is returned in the distanceSquared parameter.
360     int nearestFindMatch(const WebCore::FloatPoint&, float& distanceSquared);
361
362     // Select a find-in-page match marker in the current frame using a cache
363     // match index returned by nearestFindMatch. Returns the ordinal of the new
364     // selected match or -1 in case of error. Also provides the bounding box of
365     // the marker in window coordinates if selectionRect is not null.
366     int selectFindMatch(unsigned index, WebRect* selectionRect);
367
368     // Compute and cache the rects for FindMatches if required.
369     // Rects are automatically invalidated in case of content size changes,
370     // propagating the invalidation to child frames.
371     void updateFindMatchRects();
372
373     // Append the find-in-page match rects of the current frame to the provided vector.
374     void appendFindMatchRects(Vector<WebFloatRect>& frameRects);
375
376     // Invalidates a certain area within the frame.
377     void invalidateArea(AreaToInvalidate);
378
379     // Add a WebKit TextMatch-highlight marker to nodes in a range.
380     void addMarker(WebCore::Range*, bool activeMatch);
381
382     // Sets the markers within a range as active or inactive.
383     void setMarkerActive(WebCore::Range*, bool active);
384
385     // Returns the ordinal of the first match in the frame specified. This
386     // function enumerates the frames, starting with the main frame and up to (but
387     // not including) the frame passed in as a parameter and counts how many
388     // matches have been found.
389     int ordinalOfFirstMatchForFrame(WebFrameImpl*) const;
390
391     // Determines whether the scoping effort is required for a particular frame.
392     // It is not necessary if the frame is invisible, for example, or if this
393     // is a repeat search that already returned nothing last time the same prefix
394     // was searched.
395     bool shouldScopeMatches(const WTF::String& searchText);
396
397     // Removes the current frame from the global scoping effort and triggers any
398     // updates if appropriate. This method does not mark the scoping operation
399     // as finished.
400     void flushCurrentScopingEffort(int identifier);
401
402     // Finishes the current scoping effort and triggers any updates if appropriate.
403     void finishCurrentScopingEffort(int identifier);
404
405     // Queue up a deferred call to scopeStringMatches.
406     void scopeStringMatchesSoon(
407         int identifier, const WebString& searchText, const WebFindOptions&,
408         bool reset);
409
410     // Called by a DeferredScopeStringMatches instance.
411     void callScopeStringMatches(
412         DeferredScopeStringMatches*, int identifier, const WebString& searchText,
413         const WebFindOptions&, bool reset);
414
415     // Determines whether to invalidate the content area and scrollbar.
416     void invalidateIfNecessary();
417
418     void loadJavaScriptURL(const WebCore::KURL&);
419
420     // Returns a hit-tested VisiblePosition for the given point
421     WebCore::VisiblePosition visiblePositionForWindowPoint(const WebPoint&);
422
423     class WebFrameInit : public WebCore::FrameInit {
424     public:
425         static PassRefPtr<WebFrameInit> create(WebFrameImpl* webFrameImpl, int64_t frameID)
426         {
427             return adoptRef(new WebFrameInit(webFrameImpl, frameID));
428         }
429
430     private:
431         WebFrameInit(WebFrameImpl* webFrameImpl, int64_t frameID)
432             : WebCore::FrameInit(frameID)
433             , m_frameLoaderClientImpl(webFrameImpl)
434         {
435             setFrameLoaderClient(&m_frameLoaderClientImpl);
436         }
437
438         FrameLoaderClientImpl m_frameLoaderClientImpl;
439     };
440     RefPtr<WebFrameInit> m_frameInit;
441
442     // The embedder retains a reference to the WebCore Frame while it is active in the DOM. This
443     // reference is released when the frame is removed from the DOM or the entire page is closed.
444     RefPtr<WebCore::Frame> m_frame;
445     WebFrameImpl* m_parent;
446     WebFrameImpl* m_previousSibling;
447     WebFrameImpl* m_nextSibling;
448     WebFrameImpl* m_firstChild;
449     WebFrameImpl* m_lastChild;
450
451     // Indicate whether the current Frame is local or remote. Remote frames are
452     // rendered in a different process from their parent frames.
453     bool m_isRemote;
454
455     WebFrameClient* m_client;
456     WebPermissionClient* m_permissionClient;
457     OwnPtr<SharedWorkerRepositoryClientImpl> m_sharedWorkerRepositoryClient;
458
459     // A way for the main frame to keep track of which frame has an active
460     // match. Should be 0 for all other frames.
461     WebFrameImpl* m_currentActiveMatchFrame;
462
463     // The range of the active match for the current frame.
464     RefPtr<WebCore::Range> m_activeMatch;
465
466     // The index of the active match for the current frame.
467     int m_activeMatchIndexInCurrentFrame;
468
469     // This flag is used by the scoping effort to determine if we need to figure
470     // out which rectangle is the active match. Once we find the active
471     // rectangle we clear this flag.
472     bool m_locatingActiveRect;
473
474     // The scoping effort can time out and we need to keep track of where we
475     // ended our last search so we can continue from where we left of.
476     RefPtr<WebCore::Range> m_resumeScopingFromRange;
477
478     // Keeps track of the last string this frame searched for. This is used for
479     // short-circuiting searches in the following scenarios: When a frame has
480     // been searched and returned 0 results, we don't need to search that frame
481     // again if the user is just adding to the search (making it more specific).
482     WTF::String m_lastSearchString;
483
484     // Keeps track of how many matches this frame has found so far, so that we
485     // don't loose count between scoping efforts, and is also used (in conjunction
486     // with m_lastSearchString) to figure out if we need to search the frame again.
487     int m_lastMatchCount;
488
489     // This variable keeps a cumulative total of matches found so far for ALL the
490     // frames on the page, and is only incremented by calling IncreaseMatchCount
491     // (on the main frame only). It should be -1 for all other frames.
492     int m_totalMatchCount;
493
494     // This variable keeps a cumulative total of how many frames are currently
495     // scoping, and is incremented/decremented on the main frame only.
496     // It should be -1 for all other frames.
497     int m_framesScopingCount;
498
499     // Identifier of the latest find-in-page request. Required to be stored in
500     // the frame in order to reply if required in case the frame is detached.
501     int m_findRequestIdentifier;
502
503     // Keeps track of whether there is an scoping effort ongoing in the frame.
504     bool m_scopingInProgress;
505
506     // Keeps track of whether the last find request completed its scoping effort
507     // without finding any matches in this frame.
508     bool m_lastFindRequestCompletedWithNoMatches;
509
510     // Keeps track of when the scoping effort should next invalidate the scrollbar
511     // and the frame area.
512     int m_nextInvalidateAfter;
513
514     // A list of all of the pending calls to scopeStringMatches.
515     Vector<DeferredScopeStringMatches*> m_deferredScopingWork;
516
517     // Version number incremented on the main frame only whenever the document
518     // find-in-page match markers change. It should be 0 for all other frames.
519     int m_findMatchMarkersVersion;
520
521     // Local cache of the find match markers currently displayed for this frame.
522     Vector<FindMatch> m_findMatchesCache;
523
524     // Determines if the rects in the find-in-page matches cache of this frame
525     // are invalid and should be recomputed.
526     bool m_findMatchRectsAreValid;
527
528     // Contents size when find-in-page match rects were last computed for this
529     // frame's cache.
530     WebCore::IntSize m_contentsSizeForCurrentFindMatchRects;
531
532     // Valid between calls to BeginPrint() and EndPrint(). Containts the print
533     // information. Is used by PrintPage().
534     OwnPtr<ChromePrintContext> m_printContext;
535
536     // Stores the additional input events offset and scale when device metrics emulation is enabled.
537     WebCore::IntSize m_inputEventsOffsetForEmulation;
538     float m_inputEventsScaleFactorForEmulation;
539 };
540
541 DEFINE_TYPE_CASTS(WebFrameImpl, WebFrame, frame, true, true);
542
543 } // namespace blink
544
545 #endif