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