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