Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / public / web / WebFrame.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 WebFrame_h
32 #define WebFrame_h
33
34 #include "WebCompositionUnderline.h"
35 #include "WebHistoryItem.h"
36 #include "WebIconURL.h"
37 #include "WebNode.h"
38 #include "WebURLLoaderOptions.h"
39 #include "public/platform/WebCanvas.h"
40 #include "public/platform/WebMessagePortChannel.h"
41 #include "public/platform/WebPrivateOwnPtr.h"
42 #include "public/platform/WebReferrerPolicy.h"
43 #include "public/platform/WebURL.h"
44 #include "public/platform/WebURLRequest.h"
45
46 struct NPObject;
47
48 namespace v8 {
49 class Context;
50 class Function;
51 class Object;
52 class Value;
53 template <class T> class Handle;
54 template <class T> class Local;
55 }
56
57 namespace blink {
58
59 class Frame;
60 class OpenedFrameTracker;
61 class WebData;
62 class WebDataSource;
63 class WebDocument;
64 class WebElement;
65 class WebFormElement;
66 class WebFrameClient;
67 class WebInputElement;
68 class WebLayer;
69 class WebLocalFrame;
70 class WebPerformance;
71 class WebPermissionClient;
72 class WebRange;
73 class WebRemoteFrame;
74 class WebSecurityOrigin;
75 class WebSharedWorkerRepositoryClient;
76 class WebString;
77 class WebURL;
78 class WebURLLoader;
79 class WebURLRequest;
80 class WebView;
81 struct WebConsoleMessage;
82 struct WebFindOptions;
83 struct WebFloatPoint;
84 struct WebFloatRect;
85 struct WebPoint;
86 struct WebPrintParams;
87 struct WebRect;
88 struct WebScriptSource;
89 struct WebSize;
90 struct WebURLLoaderOptions;
91
92 template <typename T> class WebVector;
93
94 // Frames may be rendered in process ('local') or out of process ('remote').
95 // A remote frame is always cross-site; a local frame may be either same-site or
96 // cross-site.
97 // WebFrame is the base class for both WebLocalFrame and WebRemoteFrame and
98 // contains methods that are valid on both local and remote frames, such as
99 // getting a frame's parent or its opener.
100 class WebFrame {
101 public:
102     // Control of renderTreeAsText output
103     enum RenderAsTextControl {
104         RenderAsTextNormal = 0,
105         RenderAsTextDebug = 1 << 0,
106         RenderAsTextPrinting = 1 << 1
107     };
108     typedef unsigned RenderAsTextControls;
109
110     // Returns the number of live WebFrame objects, used for leak checking.
111     BLINK_EXPORT static int instanceCount();
112
113     virtual bool isWebLocalFrame() const = 0;
114     virtual WebLocalFrame* toWebLocalFrame() = 0;
115     virtual bool isWebRemoteFrame() const = 0;
116     virtual WebRemoteFrame* toWebRemoteFrame() = 0;
117
118     BLINK_EXPORT void swap(WebFrame*);
119
120     // This method closes and deletes the WebFrame.
121     virtual void close() = 0;
122
123
124     // Basic properties ---------------------------------------------------
125
126     // The unique name of this frame.
127     virtual WebString uniqueName() const = 0;
128
129     // The name of this frame. If no name is given, empty string is returned.
130     virtual WebString assignedName() const = 0;
131
132     // Sets the name of this frame. For child frames (frames that are not a
133     // top-most frame) the actual name may have a suffix appended to make the
134     // frame name unique within the hierarchy.
135     virtual void setName(const WebString&) = 0;
136
137     // The urls of the given combination types of favicon (if any) specified by
138     // the document loaded in this frame. The iconTypesMask is a bit-mask of
139     // WebIconURL::Type values, used to select from the available set of icon
140     // URLs
141     virtual WebVector<WebIconURL> iconURLs(int iconTypesMask) const = 0;
142
143     // Notify the WebFrame as to whether its frame will be rendered in a
144     // separate renderer process.
145     virtual void setIsRemote(bool) = 0;
146
147     // For a WebFrame with contents being rendered in another process, this
148     // sets a layer for use by the in-process compositor. WebLayer should be
149     // null if the content is being rendered in the current process.
150     virtual void setRemoteWebLayer(WebLayer*) = 0;
151
152     // Initializes the various client interfaces.
153     virtual void setPermissionClient(WebPermissionClient*) = 0;
154     virtual void setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClient*) = 0;
155
156
157     // Geometry -----------------------------------------------------------
158
159     // NOTE: These routines do not force page layout so their results may
160     // not be accurate if the page layout is out-of-date.
161
162     // If set to false, do not draw scrollbars on this frame's view.
163     virtual void setCanHaveScrollbars(bool) = 0;
164
165     // The scroll offset from the top-left corner of the frame in pixels.
166     virtual WebSize scrollOffset() const = 0;
167     virtual void setScrollOffset(const WebSize&) = 0;
168
169     // The minimum and maxium scroll positions in pixels.
170     virtual WebSize minimumScrollOffset() const = 0;
171     virtual WebSize maximumScrollOffset() const = 0;
172
173     // The size of the contents area.
174     virtual WebSize contentsSize() const = 0;
175
176     // Returns true if the contents (minus scrollbars) has non-zero area.
177     virtual bool hasVisibleContent() const = 0;
178
179     // Returns the visible content rect (minus scrollbars, in absolute coordinate)
180     virtual WebRect visibleContentRect() const = 0;
181
182     virtual bool hasHorizontalScrollbar() const = 0;
183     virtual bool hasVerticalScrollbar() const = 0;
184
185
186     // Hierarchy ----------------------------------------------------------
187
188     // Returns the containing view.
189     virtual WebView* view() const = 0;
190
191     // Returns the frame that opened this frame or 0 if there is none.
192     BLINK_EXPORT WebFrame* opener() const;
193
194     // Sets the frame that opened this one or 0 if there is none.
195     virtual void setOpener(WebFrame*);
196
197     // Reset the frame that opened this frame to 0.
198     // This is executed between layout tests runs
199     void clearOpener() { setOpener(0); }
200
201     // Adds the given frame as a child of this frame.
202     BLINK_EXPORT void appendChild(WebFrame*);
203
204     // Removes the given child from this frame.
205     virtual void removeChild(WebFrame*);
206
207     // Returns the parent frame or 0 if this is a top-most frame.
208     BLINK_EXPORT WebFrame* parent() const;
209
210     // Returns the top-most frame in the hierarchy containing this frame.
211     BLINK_EXPORT WebFrame* top() const;
212
213     // Returns the first/last child frame.
214     BLINK_EXPORT WebFrame* firstChild() const;
215     BLINK_EXPORT WebFrame* lastChild() const;
216
217     // Returns the previous/next sibling frame.
218     BLINK_EXPORT WebFrame* previousSibling() const;
219     BLINK_EXPORT WebFrame* nextSibling() const;
220
221     // Returns the previous/next frame in "frame traversal order",
222     // optionally wrapping around.
223     BLINK_EXPORT WebFrame* traversePrevious(bool wrap) const;
224     BLINK_EXPORT WebFrame* traverseNext(bool wrap) const;
225
226     // Returns the child frame identified by the given name.
227     BLINK_EXPORT WebFrame* findChildByName(const WebString& name) const;
228
229
230     // Content ------------------------------------------------------------
231
232     virtual WebDocument document() const = 0;
233
234     virtual WebPerformance performance() const = 0;
235
236
237     // Closing -------------------------------------------------------------
238
239     // Runs beforeunload handlers for this frame, returning false if a
240     // handler suppressed unloading.
241     virtual bool dispatchBeforeUnloadEvent() = 0;
242
243     // Runs unload handlers for this frame.
244     virtual void dispatchUnloadEvent() = 0;
245
246
247     // Scripting ----------------------------------------------------------
248
249     // Returns a NPObject corresponding to this frame's DOMWindow.
250     virtual NPObject* windowObject() const = 0;
251
252     // Binds a NPObject as a property of this frame's DOMWindow.
253     virtual void bindToWindowObject(const WebString& name, NPObject*) = 0;
254     virtual void bindToWindowObject(
255         const WebString& name, NPObject*, void*) = 0;
256
257     // Executes script in the context of the current page.
258     virtual void executeScript(const WebScriptSource&) = 0;
259
260     // Executes JavaScript in a new world associated with the web frame.
261     // The script gets its own global scope and its own prototypes for
262     // intrinsic JavaScript objects (String, Array, and so-on). It also
263     // gets its own wrappers for all DOM nodes and DOM constructors.
264     // extensionGroup is an embedder-provided specifier that controls which
265     // v8 extensions are loaded into the new context - see
266     // blink::registerExtension for the corresponding specifier.
267     //
268     // worldID must be > 0 (as 0 represents the main world).
269     // worldID must be < EmbedderWorldIdLimit, high number used internally.
270     virtual void executeScriptInIsolatedWorld(
271         int worldID, const WebScriptSource* sources, unsigned numSources,
272         int extensionGroup) = 0;
273
274     // Associates an isolated world (see above for description) with a security
275     // origin. XMLHttpRequest instances used in that world will be considered
276     // to come from that origin, not the frame's.
277     virtual void setIsolatedWorldSecurityOrigin(
278         int worldID, const WebSecurityOrigin&) = 0;
279
280     // Associates a content security policy with an isolated world. This policy
281     // should be used when evaluating script in the isolated world, and should
282     // also replace a protected resource's CSP when evaluating resources
283     // injected into the DOM.
284     //
285     // FIXME: Setting this simply bypasses the protected resource's CSP. It
286     //     doesn't yet restrict the isolated world to the provided policy.
287     virtual void setIsolatedWorldContentSecurityPolicy(
288         int worldID, const WebString&) = 0;
289
290     // Logs to the console associated with this frame.
291     virtual void addMessageToConsole(const WebConsoleMessage&) = 0;
292
293     // Calls window.gc() if it is defined.
294     virtual void collectGarbage() = 0;
295
296     // Check if the scripting URL represents a mixed content condition relative
297     // to this frame.
298     virtual bool checkIfRunInsecureContent(const WebURL&) const = 0;
299
300     // Executes script in the context of the current page and returns the value
301     // that the script evaluated to.
302     virtual v8::Handle<v8::Value> executeScriptAndReturnValue(
303         const WebScriptSource&) = 0;
304
305     // worldID must be > 0 (as 0 represents the main world).
306     // worldID must be < EmbedderWorldIdLimit, high number used internally.
307     virtual void executeScriptInIsolatedWorld(
308         int worldID, const WebScriptSource* sourcesIn, unsigned numSources,
309         int extensionGroup, WebVector<v8::Local<v8::Value> >* results) = 0;
310
311     // Call the function with the given receiver and arguments, bypassing
312     // canExecute().
313     virtual v8::Handle<v8::Value> callFunctionEvenIfScriptDisabled(
314         v8::Handle<v8::Function>,
315         v8::Handle<v8::Value>,
316         int argc,
317         v8::Handle<v8::Value> argv[]) = 0;
318
319     // Returns the V8 context for associated with the main world and this
320     // frame. There can be many V8 contexts associated with this frame, one for
321     // each isolated world and one for the main world. If you don't know what
322     // the "main world" or an "isolated world" is, then you probably shouldn't
323     // be calling this API.
324     virtual v8::Local<v8::Context> mainWorldScriptContext() const = 0;
325
326     // Navigation ----------------------------------------------------------
327
328     // Reload the current document.
329     // True |ignoreCache| explicitly bypasses caches.
330     // False |ignoreCache| revalidates any existing cache entries.
331     virtual void reload(bool ignoreCache = false) = 0;
332
333     // This is used for situations where we want to reload a different URL because of a redirect.
334     virtual void reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCache = false) = 0;
335
336     // Load the given URL.
337     virtual void loadRequest(const WebURLRequest&) = 0;
338
339     // Load the given history state, corresponding to a back/forward
340     // navigation of a frame. Multiple frames may be navigated via separate calls.
341     virtual void loadHistoryItem(
342         const WebHistoryItem&,
343         WebHistoryLoadType,
344         WebURLRequest::CachePolicy = WebURLRequest::UseProtocolCachePolicy) = 0;
345
346     // Loads the given data with specific mime type and optional text
347     // encoding.  For HTML data, baseURL indicates the security origin of
348     // the document and is used to resolve links.  If specified,
349     // unreachableURL is reported via WebDataSource::unreachableURL.  If
350     // replace is false, then this data will be loaded as a normal
351     // navigation.  Otherwise, the current history item will be replaced.
352     virtual void loadData(const WebData& data,
353                           const WebString& mimeType,
354                           const WebString& textEncoding,
355                           const WebURL& baseURL,
356                           const WebURL& unreachableURL = WebURL(),
357                           bool replace = false) = 0;
358
359     // This method is short-hand for calling LoadData, where mime_type is
360     // "text/html" and text_encoding is "UTF-8".
361     virtual void loadHTMLString(const WebData& html,
362                                 const WebURL& baseURL,
363                                 const WebURL& unreachableURL = WebURL(),
364                                 bool replace = false) = 0;
365
366     // Returns true if the current frame is busy loading content.
367     virtual bool isLoading() const = 0;
368
369     // Stops any pending loads on the frame and its children.
370     virtual void stopLoading() = 0;
371
372     // Returns the data source that is currently loading.  May be null.
373     virtual WebDataSource* provisionalDataSource() const = 0;
374
375     // Returns the data source that is currently loaded.
376     virtual WebDataSource* dataSource() const = 0;
377
378     // View-source rendering mode.  Set this before loading an URL to cause
379     // it to be rendered in view-source mode.
380     virtual void enableViewSourceMode(bool) = 0;
381     virtual bool isViewSourceModeEnabled() const = 0;
382
383     // Sets the referrer for the given request to be the specified URL or
384     // if that is null, then it sets the referrer to the referrer that the
385     // frame would use for subresources.  NOTE: This method also filters
386     // out invalid referrers (e.g., it is invalid to send a HTTPS URL as
387     // the referrer for a HTTP request).
388     virtual void setReferrerForRequest(WebURLRequest&, const WebURL&) = 0;
389
390     // Called to associate the WebURLRequest with this frame.  The request
391     // will be modified to inherit parameters that allow it to be loaded.
392     // This method ends up triggering WebFrameClient::willSendRequest.
393     // DEPRECATED: Please use createAssociatedURLLoader instead.
394     virtual void dispatchWillSendRequest(WebURLRequest&) = 0;
395
396     // Returns a WebURLLoader that is associated with this frame.  The loader
397     // will, for example, be cancelled when WebFrame::stopLoading is called.
398     // FIXME: stopLoading does not yet cancel an associated loader!!
399     virtual WebURLLoader* createAssociatedURLLoader(const WebURLLoaderOptions& = WebURLLoaderOptions()) = 0;
400
401     // Returns the number of registered unload listeners.
402     virtual unsigned unloadListenerCount() const = 0;
403
404
405     // Editing -------------------------------------------------------------
406
407     // Replaces the selection with the given text.
408     virtual void replaceSelection(const WebString& text) = 0;
409
410     virtual void insertText(const WebString& text) = 0;
411
412     virtual void setMarkedText(const WebString& text, unsigned location, unsigned length) = 0;
413     virtual void unmarkText() = 0;
414     virtual bool hasMarkedText() const = 0;
415
416     virtual WebRange markedRange() const = 0;
417
418     // Returns the frame rectangle in window coordinate space of the given text
419     // range.
420     virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const = 0;
421
422     // Returns the index of a character in the Frame's text stream at the given
423     // point. The point is in the window coordinate space. Will return
424     // WTF::notFound if the point is invalid.
425     virtual size_t characterIndexForPoint(const WebPoint&) const = 0;
426
427     // Supports commands like Undo, Redo, Cut, Copy, Paste, SelectAll,
428     // Unselect, etc. See EditorCommand.cpp for the full list of supported
429     // commands.
430     virtual bool executeCommand(const WebString&, const WebNode& = WebNode()) = 0;
431     virtual bool executeCommand(const WebString&, const WebString& value, const WebNode& = WebNode()) = 0;
432     virtual bool isCommandEnabled(const WebString&) const = 0;
433
434     // Spell-checking support.
435     virtual void enableContinuousSpellChecking(bool) = 0;
436     virtual bool isContinuousSpellCheckingEnabled() const = 0;
437     virtual void requestTextChecking(const WebElement&) = 0;
438     virtual void replaceMisspelledRange(const WebString&) = 0;
439     virtual void removeSpellingMarkers() = 0;
440
441     // Selection -----------------------------------------------------------
442
443     virtual bool hasSelection() const = 0;
444
445     virtual WebRange selectionRange() const = 0;
446
447     virtual WebString selectionAsText() const = 0;
448     virtual WebString selectionAsMarkup() const = 0;
449
450     // Expands the selection to a word around the caret and returns
451     // true. Does nothing and returns false if there is no caret or
452     // there is ranged selection.
453     virtual bool selectWordAroundCaret() = 0;
454
455     // DEPRECATED: Use moveRangeSelection.
456     virtual void selectRange(const WebPoint& base, const WebPoint& extent) = 0;
457
458     virtual void selectRange(const WebRange&) = 0;
459
460     // Move the current selection to the provided window point/points. If the
461     // current selection is editable, the new selection will be restricted to
462     // the root editable element.
463     virtual void moveRangeSelection(const WebPoint& base, const WebPoint& extent) = 0;
464     virtual void moveCaretSelection(const WebPoint&) = 0;
465
466     virtual bool setEditableSelectionOffsets(int start, int end) = 0;
467     virtual bool setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines) = 0;
468     virtual void extendSelectionAndDelete(int before, int after) = 0;
469
470     virtual void setCaretVisible(bool) = 0;
471
472     // Printing ------------------------------------------------------------
473
474     // Reformats the WebFrame for printing. WebPrintParams specifies the printable
475     // content size, paper size, printable area size, printer DPI and print
476     // scaling option. If constrainToNode node is specified, then only the given node
477     // is printed (for now only plugins are supported), instead of the entire frame.
478     // Returns the number of pages that can be printed at the given
479     // page size.
480     virtual int printBegin(const WebPrintParams&, const WebNode& constrainToNode = WebNode()) = 0;
481
482     // Returns the page shrinking factor calculated by webkit (usually
483     // between 1/1.25 and 1/2). Returns 0 if the page number is invalid or
484     // not in printing mode.
485     virtual float getPrintPageShrink(int page) = 0;
486
487     // Prints one page, and returns the calculated page shrinking factor
488     // (usually between 1/1.25 and 1/2).  Returns 0 if the page number is
489     // invalid or not in printing mode.
490     virtual float printPage(int pageToPrint, WebCanvas*) = 0;
491
492     // Reformats the WebFrame for screen display.
493     virtual void printEnd() = 0;
494
495     // If the frame contains a full-frame plugin or the given node refers to a
496     // plugin whose content indicates that printed output should not be scaled,
497     // return true, otherwise return false.
498     virtual bool isPrintScalingDisabledForPlugin(const WebNode& = WebNode()) = 0;
499
500     // Returns the number of copies to be printed.
501     virtual int getPrintCopiesForPlugin(const WebNode& = WebNode()) = 0;
502
503     // CSS3 Paged Media ----------------------------------------------------
504
505     // Returns true if page box (margin boxes and page borders) is visible.
506     virtual bool isPageBoxVisible(int pageIndex) = 0;
507
508     // Returns true if the page style has custom size information.
509     virtual bool hasCustomPageSizeStyle(int pageIndex) = 0;
510
511     // Returns the preferred page size and margins in pixels, assuming 96
512     // pixels per inch. pageSize, marginTop, marginRight, marginBottom,
513     // marginLeft must be initialized to the default values that are used if
514     // auto is specified.
515     virtual void pageSizeAndMarginsInPixels(int pageIndex,
516                                             WebSize& pageSize,
517                                             int& marginTop,
518                                             int& marginRight,
519                                             int& marginBottom,
520                                             int& marginLeft) = 0;
521
522     // Returns the value for a page property that is only defined when printing.
523     // printBegin must have been called before this method.
524     virtual WebString pageProperty(const WebString& propertyName, int pageIndex) = 0;
525
526     // Find-in-page --------------------------------------------------------
527
528     // Searches a frame for a given string.
529     //
530     // If a match is found, this function will select it (scrolling down to
531     // make it visible if needed) and fill in selectionRect with the
532     // location of where the match was found (in window coordinates).
533     //
534     // If no match is found, this function clears all tickmarks and
535     // highlighting.
536     //
537     // Returns true if the search string was found, false otherwise.
538     virtual bool find(int identifier,
539                       const WebString& searchText,
540                       const WebFindOptions& options,
541                       bool wrapWithinFrame,
542                       WebRect* selectionRect) = 0;
543
544     // Notifies the frame that we are no longer interested in searching.
545     // This will abort any asynchronous scoping effort already under way
546     // (see the function scopeStringMatches for details) and erase all
547     // tick-marks and highlighting from the previous search.  If
548     // clearSelection is true, it will also make sure the end state for the
549     // find operation does not leave a selection.  This can occur when the
550     // user clears the search string but does not close the find box.
551     virtual void stopFinding(bool clearSelection) = 0;
552
553     // Counts how many times a particular string occurs within the frame.
554     // It also retrieves the location of the string and updates a vector in
555     // the frame so that tick-marks and highlighting can be drawn.  This
556     // function does its work asynchronously, by running for a certain
557     // time-slice and then scheduling itself (co-operative multitasking) to
558     // be invoked later (repeating the process until all matches have been
559     // found).  This allows multiple frames to be searched at the same time
560     // and provides a way to cancel at any time (see
561     // cancelPendingScopingEffort).  The parameter searchText specifies
562     // what to look for and |reset| signals whether this is a brand new
563     // request or a continuation of the last scoping effort.
564     virtual void scopeStringMatches(int identifier,
565                                     const WebString& searchText,
566                                     const WebFindOptions& options,
567                                     bool reset) = 0;
568
569     // Cancels any outstanding requests for scoping string matches on a frame.
570     virtual void cancelPendingScopingEffort() = 0;
571
572     // This function is called on the main frame during the scoping effort
573     // to keep a running tally of the accumulated total match-count for all
574     // frames.  After updating the count it will notify the WebViewClient
575     // about the new count.
576     virtual void increaseMatchCount(int count, int identifier) = 0;
577
578     // This function is called on the main frame to reset the total number
579     // of matches found during the scoping effort.
580     virtual void resetMatchCount() = 0;
581
582     // Returns a counter that is incremented when the find-in-page markers are
583     // changed on any frame. Switching the active marker doesn't change the
584     // current version. Should be called only on the main frame.
585     virtual int findMatchMarkersVersion() const = 0;
586
587     // Returns the bounding box of the active find-in-page match marker or an
588     // empty rect if no such marker exists. The rect is returned in find-in-page
589     // coordinates whatever frame the active marker is.
590     // Should be called only on the main frame.
591     virtual WebFloatRect activeFindMatchRect() = 0;
592
593     // Swaps the contents of the provided vector with the bounding boxes of the
594     // find-in-page match markers from all frames. The bounding boxes are returned
595     // in find-in-page coordinates. This method should be called only on the main frame.
596     virtual void findMatchRects(WebVector<WebFloatRect>&) = 0;
597
598     // Selects the find-in-page match in the appropriate frame closest to the
599     // provided point in find-in-page coordinates. Returns the ordinal of such
600     // match or -1 if none could be found. If not null, selectionRect is set to
601     // the bounding box of the selected match in window coordinates.
602     // This method should be called only on the main frame.
603     virtual int selectNearestFindMatch(const WebFloatPoint&,
604                                        WebRect* selectionRect) = 0;
605
606
607     // Set the tickmarks for the frame. This will override the default tickmarks
608     // generated by find results. If this is called with an empty array, the
609     // default behavior will be restored.
610     virtual void setTickmarks(const WebVector<WebRect>&) = 0;
611
612     // OrientationChange event ---------------------------------------------
613
614     // Notify the frame that the screen orientation has changed.
615     virtual void sendOrientationChangeEvent() = 0;
616
617     // FIXME: this is only there for backward compatibility, it will be removed.
618     // Orientation is the interface orientation in degrees.
619     // Some examples are:
620     //  0 is straight up; -90 is when the device is rotated 90 clockwise;
621     //  90 is when rotated counter clockwise.
622     void sendOrientationChangeEvent(int orientation)
623     {
624         sendOrientationChangeEvent();
625     }
626
627     // Events --------------------------------------------------------------
628
629     // Dispatches a message event on the current DOMWindow in this WebFrame.
630     virtual void dispatchMessageEventWithOriginCheck(
631         const WebSecurityOrigin& intendedTargetOrigin,
632         const WebDOMEvent&) = 0;
633
634
635     // Utility -------------------------------------------------------------
636
637     // Returns the contents of this frame as a string.  If the text is
638     // longer than maxChars, it will be clipped to that length.  WARNING:
639     // This function may be slow depending on the number of characters
640     // retrieved and page complexity.  For a typically sized page, expect
641     // it to take on the order of milliseconds.
642     //
643     // If there is room, subframe text will be recursively appended. Each
644     // frame will be separated by an empty line.
645     virtual WebString contentAsText(size_t maxChars) const = 0;
646
647     // Returns HTML text for the contents of this frame.  This is generated
648     // from the DOM.
649     virtual WebString contentAsMarkup() const = 0;
650
651     // Returns a text representation of the render tree.  This method is used
652     // to support layout tests.
653     virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTextNormal) const = 0;
654
655     // Calls markerTextForListItem() defined in WebCore/rendering/RenderTreeAsText.h.
656     virtual WebString markerTextForListItem(const WebElement&) const = 0;
657
658     // Prints all of the pages into the canvas, with page boundaries drawn as
659     // one pixel wide blue lines. This method exists to support layout tests.
660     virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&) = 0;
661
662     // Returns the bounds rect for current selection. If selection is performed
663     // on transformed text, the rect will still bound the selection but will
664     // not be transformed itself. If no selection is present, the rect will be
665     // empty ((0,0), (0,0)).
666     virtual WebRect selectionBoundsRect() const = 0;
667
668     // Only for testing purpose:
669     // Returns true if selection.anchorNode has a marker on range from |from| with |length|.
670     virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const = 0;
671
672     // Dumps the layer tree, used by the accelerated compositor, in
673     // text form. This is used only by layout tests.
674     virtual WebString layerTreeAsText(bool showDebugInfo = false) const = 0;
675
676 #if BLINK_IMPLEMENTATION
677     static WebFrame* fromFrame(Frame*);
678 #endif
679
680 protected:
681     explicit WebFrame();
682     virtual ~WebFrame();
683
684 private:
685     friend class OpenedFrameTracker;
686
687     WebFrame* m_parent;
688     WebFrame* m_previousSibling;
689     WebFrame* m_nextSibling;
690     WebFrame* m_firstChild;
691     WebFrame* m_lastChild;
692
693     WebFrame* m_opener;
694     WebPrivateOwnPtr<OpenedFrameTracker> m_openedFrameTracker;
695 };
696
697 #if BLINK_IMPLEMENTATION
698 Frame* toCoreFrame(const WebFrame*);
699 #endif
700
701 } // namespace blink
702
703 #endif