Home | History | Annotate | Download | only in web
      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 #if BLINK_IMPLEMENTATION
     49 namespace WebCore { class Frame; }
     50 #endif
     51 
     52 namespace v8 {
     53 class Context;
     54 class Function;
     55 class Object;
     56 class Value;
     57 template <class T> class Handle;
     58 template <class T> class Local;
     59 }
     60 
     61 namespace blink {
     62 
     63 class OpenedFrameTracker;
     64 class WebData;
     65 class WebDataSource;
     66 class WebDocument;
     67 class WebElement;
     68 class WebFormElement;
     69 class WebFrameClient;
     70 class WebInputElement;
     71 class WebLayer;
     72 class WebLocalFrame;
     73 class WebPerformance;
     74 class WebPermissionClient;
     75 class WebRange;
     76 class WebRemoteFrame;
     77 class WebSecurityOrigin;
     78 class WebSharedWorkerRepositoryClient;
     79 class WebString;
     80 class WebURL;
     81 class WebURLLoader;
     82 class WebURLRequest;
     83 class WebView;
     84 struct WebConsoleMessage;
     85 struct WebFindOptions;
     86 struct WebFloatPoint;
     87 struct WebFloatRect;
     88 struct WebPoint;
     89 struct WebPrintParams;
     90 struct WebRect;
     91 struct WebScriptSource;
     92 struct WebSize;
     93 struct WebURLLoaderOptions;
     94 
     95 template <typename T> class WebVector;
     96 
     97 // Frames may be rendered in process ('local') or out of process ('remote').
     98 // A remote frame is always cross-site; a local frame may be either same-site or
     99 // cross-site.
    100 // WebFrame is the base class for both WebLocalFrame and WebRemoteFrame and
    101 // contains methods that are valid on both local and remote frames, such as
    102 // getting a frame's parent or its opener.
    103 class WebFrame {
    104 public:
    105     // Control of renderTreeAsText output
    106     enum RenderAsTextControl {
    107         RenderAsTextNormal = 0,
    108         RenderAsTextDebug = 1 << 0,
    109         RenderAsTextPrinting = 1 << 1
    110     };
    111     typedef unsigned RenderAsTextControls;
    112 
    113     // Returns the number of live WebFrame objects, used for leak checking.
    114     BLINK_EXPORT static int instanceCount();
    115 
    116     virtual bool isWebLocalFrame() const = 0;
    117     virtual WebLocalFrame* toWebLocalFrame() = 0;
    118     virtual bool isWebRemoteFrame() const = 0;
    119     virtual WebRemoteFrame* toWebRemoteFrame() = 0;
    120 
    121     BLINK_EXPORT void swap(WebFrame*);
    122 
    123     // This method closes and deletes the WebFrame.
    124     virtual void close() = 0;
    125 
    126 
    127     // Basic properties ---------------------------------------------------
    128 
    129     // The unique name of this frame.
    130     virtual WebString uniqueName() const = 0;
    131 
    132     // The name of this frame. If no name is given, empty string is returned.
    133     virtual WebString assignedName() const = 0;
    134 
    135     // Sets the name of this frame. For child frames (frames that are not a
    136     // top-most frame) the actual name may have a suffix appended to make the
    137     // frame name unique within the hierarchy.
    138     virtual void setName(const WebString&) = 0;
    139 
    140     // The urls of the given combination types of favicon (if any) specified by
    141     // the document loaded in this frame. The iconTypesMask is a bit-mask of
    142     // WebIconURL::Type values, used to select from the available set of icon
    143     // URLs
    144     virtual WebVector<WebIconURL> iconURLs(int iconTypesMask) const = 0;
    145 
    146     // Notify the WebFrame as to whether its frame will be rendered in a
    147     // separate renderer process.
    148     virtual void setIsRemote(bool) = 0;
    149 
    150     // For a WebFrame with contents being rendered in another process, this
    151     // sets a layer for use by the in-process compositor. WebLayer should be
    152     // null if the content is being rendered in the current process.
    153     virtual void setRemoteWebLayer(blink::WebLayer*) = 0;
    154 
    155     // Initializes the various client interfaces.
    156     virtual void setPermissionClient(WebPermissionClient*) = 0;
    157     virtual void setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClient*) = 0;
    158 
    159 
    160     // Geometry -----------------------------------------------------------
    161 
    162     // NOTE: These routines do not force page layout so their results may
    163     // not be accurate if the page layout is out-of-date.
    164 
    165     // If set to false, do not draw scrollbars on this frame's view.
    166     virtual void setCanHaveScrollbars(bool) = 0;
    167 
    168     // The scroll offset from the top-left corner of the frame in pixels.
    169     virtual WebSize scrollOffset() const = 0;
    170     virtual void setScrollOffset(const WebSize&) = 0;
    171 
    172     // The minimum and maxium scroll positions in pixels.
    173     virtual WebSize minimumScrollOffset() const = 0;
    174     virtual WebSize maximumScrollOffset() const = 0;
    175 
    176     // The size of the contents area.
    177     virtual WebSize contentsSize() const = 0;
    178 
    179     // Returns true if the contents (minus scrollbars) has non-zero area.
    180     virtual bool hasVisibleContent() const = 0;
    181 
    182     // Returns the visible content rect (minus scrollbars, in absolute coordinate)
    183     virtual WebRect visibleContentRect() const = 0;
    184 
    185     virtual bool hasHorizontalScrollbar() const = 0;
    186     virtual bool hasVerticalScrollbar() const = 0;
    187 
    188 
    189     // Hierarchy ----------------------------------------------------------
    190 
    191     // Returns the containing view.
    192     virtual WebView* view() const = 0;
    193 
    194     // Returns the frame that opened this frame or 0 if there is none.
    195     BLINK_EXPORT WebFrame* opener() const;
    196 
    197     // Sets the frame that opened this one or 0 if there is none.
    198     virtual void setOpener(WebFrame*);
    199 
    200     // Reset the frame that opened this frame to 0.
    201     // This is executed between layout tests runs
    202     void clearOpener() { setOpener(0); }
    203 
    204     // Adds the given frame as a child of this frame.
    205     BLINK_EXPORT void appendChild(WebFrame*);
    206 
    207     // Removes the given child from this frame.
    208     virtual void removeChild(WebFrame*);
    209 
    210     // Returns the parent frame or 0 if this is a top-most frame.
    211     BLINK_EXPORT WebFrame* parent() const;
    212 
    213     // Returns the top-most frame in the hierarchy containing this frame.
    214     BLINK_EXPORT WebFrame* top() const;
    215 
    216     // Returns the first/last child frame.
    217     BLINK_EXPORT WebFrame* firstChild() const;
    218     BLINK_EXPORT WebFrame* lastChild() const;
    219 
    220     // Returns the previous/next sibling frame.
    221     BLINK_EXPORT WebFrame* previousSibling() const;
    222     BLINK_EXPORT WebFrame* nextSibling() const;
    223 
    224     // Returns the previous/next frame in "frame traversal order",
    225     // optionally wrapping around.
    226     BLINK_EXPORT WebFrame* traversePrevious(bool wrap) const;
    227     BLINK_EXPORT WebFrame* traverseNext(bool wrap) const;
    228 
    229     // Returns the child frame identified by the given name.
    230     BLINK_EXPORT WebFrame* findChildByName(const WebString& name) const;
    231 
    232 
    233     // Content ------------------------------------------------------------
    234 
    235     virtual WebDocument document() const = 0;
    236 
    237     virtual WebPerformance performance() const = 0;
    238 
    239 
    240     // Closing -------------------------------------------------------------
    241 
    242     // Runs beforeunload handlers for this frame, returning false if a
    243     // handler suppressed unloading.
    244     virtual bool dispatchBeforeUnloadEvent() = 0;
    245 
    246     // Runs unload handlers for this frame.
    247     virtual void dispatchUnloadEvent() = 0;
    248 
    249 
    250     // Scripting ----------------------------------------------------------
    251 
    252     // Returns a NPObject corresponding to this frame's DOMWindow.
    253     virtual NPObject* windowObject() const = 0;
    254 
    255     // Binds a NPObject as a property of this frame's DOMWindow.
    256     virtual void bindToWindowObject(const WebString& name, NPObject*) = 0;
    257     virtual void bindToWindowObject(
    258         const WebString& name, NPObject*, void*) = 0;
    259 
    260     // Executes script in the context of the current page.
    261     virtual void executeScript(const WebScriptSource&) = 0;
    262 
    263     // Executes JavaScript in a new world associated with the web frame.
    264     // The script gets its own global scope and its own prototypes for
    265     // intrinsic JavaScript objects (String, Array, and so-on). It also
    266     // gets its own wrappers for all DOM nodes and DOM constructors.
    267     // extensionGroup is an embedder-provided specifier that controls which
    268     // v8 extensions are loaded into the new context - see
    269     // blink::registerExtension for the corresponding specifier.
    270     //
    271     // worldID must be > 0 (as 0 represents the main world).
    272     // worldID must be < EmbedderWorldIdLimit, high number used internally.
    273     virtual void executeScriptInIsolatedWorld(
    274         int worldID, const WebScriptSource* sources, unsigned numSources,
    275         int extensionGroup) = 0;
    276 
    277     // Associates an isolated world (see above for description) with a security
    278     // origin. XMLHttpRequest instances used in that world will be considered
    279     // to come from that origin, not the frame's.
    280     virtual void setIsolatedWorldSecurityOrigin(
    281         int worldID, const WebSecurityOrigin&) = 0;
    282 
    283     // Associates a content security policy with an isolated world. This policy
    284     // should be used when evaluating script in the isolated world, and should
    285     // also replace a protected resource's CSP when evaluating resources
    286     // injected into the DOM.
    287     //
    288     // FIXME: Setting this simply bypasses the protected resource's CSP. It
    289     //     doesn't yet restrict the isolated world to the provided policy.
    290     virtual void setIsolatedWorldContentSecurityPolicy(
    291         int worldID, const WebString&) = 0;
    292 
    293     // Logs to the console associated with this frame.
    294     virtual void addMessageToConsole(const WebConsoleMessage&) = 0;
    295 
    296     // Calls window.gc() if it is defined.
    297     virtual void collectGarbage() = 0;
    298 
    299     // Check if the scripting URL represents a mixed content condition relative
    300     // to this frame.
    301     virtual bool checkIfRunInsecureContent(const WebURL&) const = 0;
    302 
    303     // Executes script in the context of the current page and returns the value
    304     // that the script evaluated to.
    305     virtual v8::Handle<v8::Value> executeScriptAndReturnValue(
    306         const WebScriptSource&) = 0;
    307 
    308     // worldID must be > 0 (as 0 represents the main world).
    309     // worldID must be < EmbedderWorldIdLimit, high number used internally.
    310     virtual void executeScriptInIsolatedWorld(
    311         int worldID, const WebScriptSource* sourcesIn, unsigned numSources,
    312         int extensionGroup, WebVector<v8::Local<v8::Value> >* results) = 0;
    313 
    314     // Call the function with the given receiver and arguments, bypassing
    315     // canExecute().
    316     virtual v8::Handle<v8::Value> callFunctionEvenIfScriptDisabled(
    317         v8::Handle<v8::Function>,
    318         v8::Handle<v8::Value>,
    319         int argc,
    320         v8::Handle<v8::Value> argv[]) = 0;
    321 
    322     // Returns the V8 context for associated with the main world and this
    323     // frame. There can be many V8 contexts associated with this frame, one for
    324     // each isolated world and one for the main world. If you don't know what
    325     // the "main world" or an "isolated world" is, then you probably shouldn't
    326     // be calling this API.
    327     virtual v8::Local<v8::Context> mainWorldScriptContext() const = 0;
    328 
    329     // Navigation ----------------------------------------------------------
    330 
    331     // Reload the current document.
    332     // True |ignoreCache| explicitly bypasses caches.
    333     // False |ignoreCache| revalidates any existing cache entries.
    334     virtual void reload(bool ignoreCache = false) = 0;
    335 
    336     // This is used for situations where we want to reload a different URL because of a redirect.
    337     virtual void reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCache = false) = 0;
    338 
    339     // Load the given URL.
    340     virtual void loadRequest(const WebURLRequest&) = 0;
    341 
    342     // Load the given history state, corresponding to a back/forward
    343     // navigation of a frame. Multiple frames may be navigated via separate calls.
    344     virtual void loadHistoryItem(
    345         const WebHistoryItem&,
    346         WebHistoryLoadType,
    347         WebURLRequest::CachePolicy = WebURLRequest::UseProtocolCachePolicy) = 0;
    348 
    349     // Loads the given data with specific mime type and optional text
    350     // encoding.  For HTML data, baseURL indicates the security origin of
    351     // the document and is used to resolve links.  If specified,
    352     // unreachableURL is reported via WebDataSource::unreachableURL.  If
    353     // replace is false, then this data will be loaded as a normal
    354     // navigation.  Otherwise, the current history item will be replaced.
    355     virtual void loadData(const WebData& data,
    356                           const WebString& mimeType,
    357                           const WebString& textEncoding,
    358                           const WebURL& baseURL,
    359                           const WebURL& unreachableURL = WebURL(),
    360                           bool replace = false) = 0;
    361 
    362     // This method is short-hand for calling LoadData, where mime_type is
    363     // "text/html" and text_encoding is "UTF-8".
    364     virtual void loadHTMLString(const WebData& html,
    365                                 const WebURL& baseURL,
    366                                 const WebURL& unreachableURL = WebURL(),
    367                                 bool replace = false) = 0;
    368 
    369     // Returns true if the current frame is busy loading content.
    370     virtual bool isLoading() const = 0;
    371 
    372     // Stops any pending loads on the frame and its children.
    373     virtual void stopLoading() = 0;
    374 
    375     // Returns the data source that is currently loading.  May be null.
    376     virtual WebDataSource* provisionalDataSource() const = 0;
    377 
    378     // Returns the data source that is currently loaded.
    379     virtual WebDataSource* dataSource() const = 0;
    380 
    381     // View-source rendering mode.  Set this before loading an URL to cause
    382     // it to be rendered in view-source mode.
    383     virtual void enableViewSourceMode(bool) = 0;
    384     virtual bool isViewSourceModeEnabled() const = 0;
    385 
    386     // Sets the referrer for the given request to be the specified URL or
    387     // if that is null, then it sets the referrer to the referrer that the
    388     // frame would use for subresources.  NOTE: This method also filters
    389     // out invalid referrers (e.g., it is invalid to send a HTTPS URL as
    390     // the referrer for a HTTP request).
    391     virtual void setReferrerForRequest(WebURLRequest&, const WebURL&) = 0;
    392 
    393     // Called to associate the WebURLRequest with this frame.  The request
    394     // will be modified to inherit parameters that allow it to be loaded.
    395     // This method ends up triggering WebFrameClient::willSendRequest.
    396     // DEPRECATED: Please use createAssociatedURLLoader instead.
    397     virtual void dispatchWillSendRequest(WebURLRequest&) = 0;
    398 
    399     // Returns a WebURLLoader that is associated with this frame.  The loader
    400     // will, for example, be cancelled when WebFrame::stopLoading is called.
    401     // FIXME: stopLoading does not yet cancel an associated loader!!
    402     virtual WebURLLoader* createAssociatedURLLoader(const WebURLLoaderOptions& = WebURLLoaderOptions()) = 0;
    403 
    404     // Returns the number of registered unload listeners.
    405     virtual unsigned unloadListenerCount() const = 0;
    406 
    407 
    408     // Editing -------------------------------------------------------------
    409 
    410     // Replaces the selection with the given text.
    411     virtual void replaceSelection(const WebString& text) = 0;
    412 
    413     virtual void insertText(const WebString& text) = 0;
    414 
    415     virtual void setMarkedText(const WebString& text, unsigned location, unsigned length) = 0;
    416     virtual void unmarkText() = 0;
    417     virtual bool hasMarkedText() const = 0;
    418 
    419     virtual WebRange markedRange() const = 0;
    420 
    421     // Returns the frame rectangle in window coordinate space of the given text
    422     // range.
    423     virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const = 0;
    424 
    425     // Returns the index of a character in the Frame's text stream at the given
    426     // point. The point is in the window coordinate space. Will return
    427     // WTF::notFound if the point is invalid.
    428     virtual size_t characterIndexForPoint(const WebPoint&) const = 0;
    429 
    430     // Supports commands like Undo, Redo, Cut, Copy, Paste, SelectAll,
    431     // Unselect, etc. See EditorCommand.cpp for the full list of supported
    432     // commands.
    433     virtual bool executeCommand(const WebString&, const WebNode& = WebNode()) = 0;
    434     virtual bool executeCommand(const WebString&, const WebString& value, const WebNode& = WebNode()) = 0;
    435     virtual bool isCommandEnabled(const WebString&) const = 0;
    436 
    437     // Spell-checking support.
    438     virtual void enableContinuousSpellChecking(bool) = 0;
    439     virtual bool isContinuousSpellCheckingEnabled() const = 0;
    440     virtual void requestTextChecking(const WebElement&) = 0;
    441     virtual void replaceMisspelledRange(const WebString&) = 0;
    442     virtual void removeSpellingMarkers() = 0;
    443 
    444     // Selection -----------------------------------------------------------
    445 
    446     virtual bool hasSelection() const = 0;
    447 
    448     virtual WebRange selectionRange() const = 0;
    449 
    450     virtual WebString selectionAsText() const = 0;
    451     virtual WebString selectionAsMarkup() const = 0;
    452 
    453     // Expands the selection to a word around the caret and returns
    454     // true. Does nothing and returns false if there is no caret or
    455     // there is ranged selection.
    456     virtual bool selectWordAroundCaret() = 0;
    457 
    458     // DEPRECATED: Use moveRangeSelection.
    459     virtual void selectRange(const WebPoint& base, const WebPoint& extent) = 0;
    460 
    461     virtual void selectRange(const WebRange&) = 0;
    462 
    463     // Move the current selection to the provided window point/points. If the
    464     // current selection is editable, the new selection will be restricted to
    465     // the root editable element.
    466     virtual void moveRangeSelection(const WebPoint& base, const WebPoint& extent) = 0;
    467     virtual void moveCaretSelection(const WebPoint&) = 0;
    468 
    469     virtual bool setEditableSelectionOffsets(int start, int end) = 0;
    470     virtual bool setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines) = 0;
    471     virtual void extendSelectionAndDelete(int before, int after) = 0;
    472 
    473     virtual void setCaretVisible(bool) = 0;
    474 
    475     // Printing ------------------------------------------------------------
    476 
    477     // Reformats the WebFrame for printing. WebPrintParams specifies the printable
    478     // content size, paper size, printable area size, printer DPI and print
    479     // scaling option. If constrainToNode node is specified, then only the given node
    480     // is printed (for now only plugins are supported), instead of the entire frame.
    481     // Returns the number of pages that can be printed at the given
    482     // page size.
    483     virtual int printBegin(const WebPrintParams&, const WebNode& constrainToNode = WebNode()) = 0;
    484 
    485     // Returns the page shrinking factor calculated by webkit (usually
    486     // between 1/1.25 and 1/2). Returns 0 if the page number is invalid or
    487     // not in printing mode.
    488     virtual float getPrintPageShrink(int page) = 0;
    489 
    490     // Prints one page, and returns the calculated page shrinking factor
    491     // (usually between 1/1.25 and 1/2).  Returns 0 if the page number is
    492     // invalid or not in printing mode.
    493     virtual float printPage(int pageToPrint, WebCanvas*) = 0;
    494 
    495     // Reformats the WebFrame for screen display.
    496     virtual void printEnd() = 0;
    497 
    498     // If the frame contains a full-frame plugin or the given node refers to a
    499     // plugin whose content indicates that printed output should not be scaled,
    500     // return true, otherwise return false.
    501     virtual bool isPrintScalingDisabledForPlugin(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(WebCore::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 WebCore::Frame* toWebCoreFrame(const WebFrame*);
    699 #endif
    700 
    701 } // namespace blink
    702 
    703 #endif
    704