Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / web / WebFrame.h
blobee3a1b42d12eff522d8215da2f6f4b6c8d6d71c3
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
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.
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.
31 #ifndef WebFrame_h
32 #define WebFrame_h
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 #include "public/web/WebTreeScopeType.h"
47 struct NPObject;
49 namespace v8 {
50 class Context;
51 class Function;
52 class Object;
53 class Value;
54 template <class T> class Local;
57 namespace blink {
59 class Frame;
60 class OpenedFrameTracker;
61 class Visitor;
62 class WebData;
63 class WebDataSource;
64 class WebDocument;
65 class WebElement;
66 class WebLayer;
67 class WebLocalFrame;
68 class WebPerformance;
69 class WebRange;
70 class WebRemoteFrame;
71 class WebSecurityOrigin;
72 class WebSharedWorkerRepositoryClient;
73 class WebString;
74 class WebURL;
75 class WebURLLoader;
76 class WebURLRequest;
77 class WebView;
78 enum class WebSandboxFlags;
79 struct WebConsoleMessage;
80 struct WebFindOptions;
81 struct WebFloatPoint;
82 struct WebFloatRect;
83 struct WebPoint;
84 struct WebPrintParams;
85 struct WebRect;
86 struct WebScriptSource;
87 struct WebSize;
88 struct WebURLLoaderOptions;
90 template <typename T> class WebVector;
92 // Frames may be rendered in process ('local') or out of process ('remote').
93 // A remote frame is always cross-site; a local frame may be either same-site or
94 // cross-site.
95 // WebFrame is the base class for both WebLocalFrame and WebRemoteFrame and
96 // contains methods that are valid on both local and remote frames, such as
97 // getting a frame's parent or its opener.
98 class WebFrame {
99 public:
100 // Control of layoutTreeAsText output
101 enum LayoutAsTextControl {
102 LayoutAsTextNormal = 0,
103 LayoutAsTextDebug = 1 << 0,
104 LayoutAsTextPrinting = 1 << 1,
105 LayoutAsTextWithLineTrees = 1 << 2
107 typedef unsigned LayoutAsTextControls;
109 // FIXME: We already have blink::TextGranularity. For now we support only
110 // a part of blink::TextGranularity.
111 // Ideally it seems blink::TextGranularity should be broken up into
112 // blink::TextGranularity and perhaps blink::TextBoundary and then
113 // TextGranularity enum could be moved somewhere to public/, and we could
114 // just use it here directly without introducing a new enum.
115 enum TextGranularity {
116 CharacterGranularity = 0,
117 WordGranularity,
118 TextGranularityLast = WordGranularity,
121 // Returns the number of live WebFrame objects, used for leak checking.
122 BLINK_EXPORT static int instanceCount();
124 virtual bool isWebLocalFrame() const = 0;
125 virtual WebLocalFrame* toWebLocalFrame() = 0;
126 virtual bool isWebRemoteFrame() const = 0;
127 virtual WebRemoteFrame* toWebRemoteFrame() = 0;
129 BLINK_EXPORT bool swap(WebFrame*);
131 // This method closes and deletes the WebFrame. This is typically called by
132 // the embedder in response to a frame detached callback to the WebFrame
133 // client.
134 virtual void close() = 0;
136 // Called by the embedder when it needs to detach the subtree rooted at this
137 // frame.
138 BLINK_EXPORT void detach();
140 // Basic properties ---------------------------------------------------
142 // The unique name of this frame.
143 virtual WebString uniqueName() const = 0;
145 // The name of this frame. If no name is given, empty string is returned.
146 virtual WebString assignedName() const = 0;
148 // Sets the name of this frame. For child frames (frames that are not a
149 // top-most frame) the actual name may have a suffix appended to make the
150 // frame name unique within the hierarchy.
151 virtual void setName(const WebString&) = 0;
153 // The urls of the given combination types of favicon (if any) specified by
154 // the document loaded in this frame. The iconTypesMask is a bit-mask of
155 // WebIconURL::Type values, used to select from the available set of icon
156 // URLs
157 virtual WebVector<WebIconURL> iconURLs(int iconTypesMask) const = 0;
159 // For a WebFrame with contents being rendered in another process, this
160 // sets a layer for use by the in-process compositor. WebLayer should be
161 // null if the content is being rendered in the current process.
162 virtual void setRemoteWebLayer(WebLayer*) = 0;
164 // Initializes the various client interfaces.
165 virtual void setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClient*) = 0;
167 // The security origin of this frame.
168 BLINK_EXPORT WebSecurityOrigin securityOrigin() const;
170 // Updates the sandbox flags in the frame's FrameOwner. This is used when
171 // this frame's parent is in another process and it dynamically updates
172 // this frame's sandbox flags. The flags won't take effect until the next
173 // navigation.
174 BLINK_EXPORT void setFrameOwnerSandboxFlags(WebSandboxFlags);
176 // Geometry -----------------------------------------------------------
178 // NOTE: These routines do not force page layout so their results may
179 // not be accurate if the page layout is out-of-date.
181 // If set to false, do not draw scrollbars on this frame's view.
182 virtual void setCanHaveScrollbars(bool) = 0;
184 // The scroll offset from the top-left corner of the frame in pixels.
185 virtual WebSize scrollOffset() const = 0;
186 virtual void setScrollOffset(const WebSize&) = 0;
188 // The size of the contents area.
189 virtual WebSize contentsSize() const = 0;
191 // Returns true if the contents (minus scrollbars) has non-zero area.
192 virtual bool hasVisibleContent() const = 0;
194 // Returns the visible content rect (minus scrollbars, in absolute coordinate)
195 virtual WebRect visibleContentRect() const = 0;
197 virtual bool hasHorizontalScrollbar() const = 0;
198 virtual bool hasVerticalScrollbar() const = 0;
200 // Hierarchy ----------------------------------------------------------
202 // Returns the containing view.
203 virtual WebView* view() const = 0;
205 // Returns the frame that opened this frame or 0 if there is none.
206 BLINK_EXPORT WebFrame* opener() const;
208 // Sets the frame that opened this one or 0 if there is none.
209 virtual void setOpener(WebFrame*);
211 // Reset the frame that opened this frame to 0.
212 // This is executed between layout tests runs
213 void clearOpener() { setOpener(0); }
215 // Inserts the given frame as a child of this frame, so that it is the next
216 // child after |previousSibling|, or first child if |previousSibling| is null.
217 BLINK_EXPORT void insertAfter(WebFrame* child, WebFrame* previousSibling);
219 // Adds the given frame as a child of this frame.
220 BLINK_EXPORT void appendChild(WebFrame*);
222 // Removes the given child from this frame.
223 virtual void removeChild(WebFrame*);
225 // Returns the parent frame or 0 if this is a top-most frame.
226 BLINK_EXPORT WebFrame* parent() const;
228 // Returns the top-most frame in the hierarchy containing this frame.
229 BLINK_EXPORT WebFrame* top() const;
231 // Returns the first/last child frame.
232 BLINK_EXPORT WebFrame* firstChild() const;
233 BLINK_EXPORT WebFrame* lastChild() const;
235 // Returns the previous/next sibling frame.
236 BLINK_EXPORT WebFrame* previousSibling() const;
237 BLINK_EXPORT WebFrame* nextSibling() const;
239 // Returns the previous/next frame in "frame traversal order",
240 // optionally wrapping around.
241 BLINK_EXPORT WebFrame* traversePrevious(bool wrap) const;
242 BLINK_EXPORT WebFrame* traverseNext(bool wrap) const;
244 // Returns the child frame identified by the given name.
245 BLINK_EXPORT WebFrame* findChildByName(const WebString& name) const;
248 // Content ------------------------------------------------------------
250 virtual WebDocument document() const = 0;
252 virtual WebPerformance performance() const = 0;
255 // Closing -------------------------------------------------------------
257 // Runs beforeunload handlers for this frame, returning false if a
258 // handler suppressed unloading.
259 virtual bool dispatchBeforeUnloadEvent() = 0;
261 // Runs unload handlers for this frame.
262 virtual void dispatchUnloadEvent() = 0;
265 // Scripting ----------------------------------------------------------
267 // Returns a NPObject corresponding to this frame's DOMWindow.
268 virtual NPObject* windowObject() const = 0;
270 // Binds a NPObject as a property of this frame's DOMWindow.
271 virtual void bindToWindowObject(const WebString& name, NPObject*) = 0;
272 virtual void bindToWindowObject(
273 const WebString& name, NPObject*, void*) = 0;
275 // Executes script in the context of the current page.
276 virtual void executeScript(const WebScriptSource&) = 0;
278 // Executes JavaScript in a new world associated with the web frame.
279 // The script gets its own global scope and its own prototypes for
280 // intrinsic JavaScript objects (String, Array, and so-on). It also
281 // gets its own wrappers for all DOM nodes and DOM constructors.
282 // extensionGroup is an embedder-provided specifier that controls which
283 // v8 extensions are loaded into the new context - see
284 // blink::registerExtension for the corresponding specifier.
286 // worldID must be > 0 (as 0 represents the main world).
287 // worldID must be < EmbedderWorldIdLimit, high number used internally.
288 virtual void executeScriptInIsolatedWorld(
289 int worldID, const WebScriptSource* sources, unsigned numSources,
290 int extensionGroup) = 0;
292 // Associates an isolated world (see above for description) with a security
293 // origin. XMLHttpRequest instances used in that world will be considered
294 // to come from that origin, not the frame's.
295 virtual void setIsolatedWorldSecurityOrigin(
296 int worldID, const WebSecurityOrigin&) = 0;
298 // Associates a content security policy with an isolated world. This policy
299 // should be used when evaluating script in the isolated world, and should
300 // also replace a protected resource's CSP when evaluating resources
301 // injected into the DOM.
303 // FIXME: Setting this simply bypasses the protected resource's CSP. It
304 // doesn't yet restrict the isolated world to the provided policy.
305 virtual void setIsolatedWorldContentSecurityPolicy(
306 int worldID, const WebString&) = 0;
308 // Logs to the console associated with this frame.
309 virtual void addMessageToConsole(const WebConsoleMessage&) = 0;
311 // Calls window.gc() if it is defined.
312 virtual void collectGarbage() = 0;
314 // Check if the scripting URL represents a mixed content condition relative
315 // to this frame.
316 virtual bool checkIfRunInsecureContent(const WebURL&) const = 0;
318 // Executes script in the context of the current page and returns the value
319 // that the script evaluated to.
320 // DEPRECATED: Use WebLocalFrame::requestExecuteScriptAndReturnValue.
321 virtual v8::Local<v8::Value> executeScriptAndReturnValue(
322 const WebScriptSource&) = 0;
324 // worldID must be > 0 (as 0 represents the main world).
325 // worldID must be < EmbedderWorldIdLimit, high number used internally.
326 // DEPRECATED: Use WebLocalFrame::requestExecuteScriptInIsolatedWorld.
327 virtual void executeScriptInIsolatedWorld(
328 int worldID, const WebScriptSource* sourcesIn, unsigned numSources,
329 int extensionGroup, WebVector<v8::Local<v8::Value> >* results) = 0;
331 // Call the function with the given receiver and arguments, bypassing
332 // canExecute().
333 virtual v8::Local<v8::Value> callFunctionEvenIfScriptDisabled(
334 v8::Local<v8::Function>,
335 v8::Local<v8::Value>,
336 int argc,
337 v8::Local<v8::Value> argv[]) = 0;
339 // Returns the V8 context for associated with the main world and this
340 // frame. There can be many V8 contexts associated with this frame, one for
341 // each isolated world and one for the main world. If you don't know what
342 // the "main world" or an "isolated world" is, then you probably shouldn't
343 // be calling this API.
344 virtual v8::Local<v8::Context> mainWorldScriptContext() const = 0;
347 // Returns true if the WebFrame currently executing JavaScript has access
348 // to the given WebFrame, or false otherwise.
349 BLINK_EXPORT static bool scriptCanAccess(WebFrame*);
352 // Navigation ----------------------------------------------------------
354 // Reload the current document.
355 // True |ignoreCache| explicitly bypasses caches.
356 // False |ignoreCache| revalidates any existing cache entries.
357 virtual void reload(bool ignoreCache = false) = 0;
359 // This is used for situations where we want to reload a different URL because of a redirect.
360 virtual void reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCache = false) = 0;
362 // Load the given URL.
363 virtual void loadRequest(const WebURLRequest&) = 0;
365 // Load the given history state, corresponding to a back/forward
366 // navigation of a frame. Multiple frames may be navigated via separate calls.
367 virtual void loadHistoryItem(
368 const WebHistoryItem&,
369 WebHistoryLoadType,
370 WebURLRequest::CachePolicy = WebURLRequest::UseProtocolCachePolicy) = 0;
372 // Loads the given data with specific mime type and optional text
373 // encoding. For HTML data, baseURL indicates the security origin of
374 // the document and is used to resolve links. If specified,
375 // unreachableURL is reported via WebDataSource::unreachableURL. If
376 // replace is false, then this data will be loaded as a normal
377 // navigation. Otherwise, the current history item will be replaced.
378 virtual void loadData(const WebData& data,
379 const WebString& mimeType,
380 const WebString& textEncoding,
381 const WebURL& baseURL,
382 const WebURL& unreachableURL = WebURL(),
383 bool replace = false) = 0;
385 // This method is short-hand for calling LoadData, where mime_type is
386 // "text/html" and text_encoding is "UTF-8".
387 virtual void loadHTMLString(const WebData& html,
388 const WebURL& baseURL,
389 const WebURL& unreachableURL = WebURL(),
390 bool replace = false) = 0;
392 // Stops any pending loads on the frame and its children.
393 virtual void stopLoading() = 0;
395 // Returns the data source that is currently loading. May be null.
396 virtual WebDataSource* provisionalDataSource() const = 0;
398 // Returns the data source that is currently loaded.
399 virtual WebDataSource* dataSource() const = 0;
401 // View-source rendering mode. Set this before loading an URL to cause
402 // it to be rendered in view-source mode.
403 virtual void enableViewSourceMode(bool) = 0;
404 virtual bool isViewSourceModeEnabled() const = 0;
406 // Sets the referrer for the given request to be the specified URL or
407 // if that is null, then it sets the referrer to the referrer that the
408 // frame would use for subresources. NOTE: This method also filters
409 // out invalid referrers (e.g., it is invalid to send a HTTPS URL as
410 // the referrer for a HTTP request).
411 virtual void setReferrerForRequest(WebURLRequest&, const WebURL&) = 0;
413 // Called to associate the WebURLRequest with this frame. The request
414 // will be modified to inherit parameters that allow it to be loaded.
415 // This method ends up triggering WebFrameClient::willSendRequest.
416 // DEPRECATED: Please use createAssociatedURLLoader instead.
417 virtual void dispatchWillSendRequest(WebURLRequest&) = 0;
419 // Returns a WebURLLoader that is associated with this frame. The loader
420 // will, for example, be cancelled when WebFrame::stopLoading is called.
421 // FIXME: stopLoading does not yet cancel an associated loader!!
422 virtual WebURLLoader* createAssociatedURLLoader(const WebURLLoaderOptions& = WebURLLoaderOptions()) = 0;
424 // Returns the number of registered unload listeners.
425 virtual unsigned unloadListenerCount() const = 0;
428 // Editing -------------------------------------------------------------
430 // Replaces the selection with the given text.
431 virtual void replaceSelection(const WebString& text) = 0;
433 virtual void insertText(const WebString& text) = 0;
435 virtual void setMarkedText(const WebString& text, unsigned location, unsigned length) = 0;
436 virtual void unmarkText() = 0;
437 virtual bool hasMarkedText() const = 0;
439 virtual WebRange markedRange() const = 0;
441 // Returns the text range rectangle in the viepwort coordinate space.
442 virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const = 0;
444 // Returns the index of a character in the Frame's text stream at the given
445 // point. The point is in the viewport coordinate space. Will return
446 // WTF::notFound if the point is invalid.
447 virtual size_t characterIndexForPoint(const WebPoint&) const = 0;
449 // Supports commands like Undo, Redo, Cut, Copy, Paste, SelectAll,
450 // Unselect, etc. See EditorCommand.cpp for the full list of supported
451 // commands.
452 virtual bool executeCommand(const WebString&, const WebNode& = WebNode()) = 0;
453 virtual bool executeCommand(const WebString&, const WebString& value, const WebNode& = WebNode()) = 0;
454 virtual bool isCommandEnabled(const WebString&) const = 0;
456 // Spell-checking support.
457 virtual void enableContinuousSpellChecking(bool) = 0;
458 virtual bool isContinuousSpellCheckingEnabled() const = 0;
459 virtual void requestTextChecking(const WebElement&) = 0;
460 virtual void replaceMisspelledRange(const WebString&) = 0;
461 virtual void removeSpellingMarkers() = 0;
463 // Selection -----------------------------------------------------------
465 virtual bool hasSelection() const = 0;
467 virtual WebRange selectionRange() const = 0;
469 virtual WebString selectionAsText() const = 0;
470 virtual WebString selectionAsMarkup() const = 0;
472 // Expands the selection to a word around the caret and returns
473 // true. Does nothing and returns false if there is no caret or
474 // there is ranged selection.
475 virtual bool selectWordAroundCaret() = 0;
477 // DEPRECATED: Use moveRangeSelection.
478 virtual void selectRange(const WebPoint& base, const WebPoint& extent) = 0;
480 virtual void selectRange(const WebRange&) = 0;
482 // Move the current selection to the provided viewport point/points. If the
483 // current selection is editable, the new selection will be restricted to
484 // the root editable element.
485 // |TextGranularity| represents character wrapping granularity. If
486 // WordGranularity is set, WebFrame extends selection to wrap word.
487 virtual void moveRangeSelection(const WebPoint& base, const WebPoint& extent, WebFrame::TextGranularity = CharacterGranularity) = 0;
488 virtual void moveCaretSelection(const WebPoint&) = 0;
490 virtual bool setEditableSelectionOffsets(int start, int end) = 0;
491 virtual bool setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines) = 0;
492 virtual void extendSelectionAndDelete(int before, int after) = 0;
494 virtual void setCaretVisible(bool) = 0;
496 // Printing ------------------------------------------------------------
498 // Reformats the WebFrame for printing. WebPrintParams specifies the printable
499 // content size, paper size, printable area size, printer DPI and print
500 // scaling option. If constrainToNode node is specified, then only the given node
501 // is printed (for now only plugins are supported), instead of the entire frame.
502 // Returns the number of pages that can be printed at the given
503 // page size.
504 virtual int printBegin(const WebPrintParams&, const WebNode& constrainToNode = WebNode()) = 0;
506 // Returns the page shrinking factor calculated by webkit (usually
507 // between 1/1.25 and 1/2). Returns 0 if the page number is invalid or
508 // not in printing mode.
509 virtual float getPrintPageShrink(int page) = 0;
511 // Prints one page, and returns the calculated page shrinking factor
512 // (usually between 1/1.25 and 1/2). Returns 0 if the page number is
513 // invalid or not in printing mode.
514 virtual float printPage(int pageToPrint, WebCanvas*) = 0;
516 // Reformats the WebFrame for screen display.
517 virtual void printEnd() = 0;
519 // If the frame contains a full-frame plugin or the given node refers to a
520 // plugin whose content indicates that printed output should not be scaled,
521 // return true, otherwise return false.
522 virtual bool isPrintScalingDisabledForPlugin(const WebNode& = WebNode()) = 0;
524 // CSS3 Paged Media ----------------------------------------------------
526 // Returns true if page box (margin boxes and page borders) is visible.
527 virtual bool isPageBoxVisible(int pageIndex) = 0;
529 // Returns true if the page style has custom size information.
530 virtual bool hasCustomPageSizeStyle(int pageIndex) = 0;
532 // Returns the preferred page size and margins in pixels, assuming 96
533 // pixels per inch. pageSize, marginTop, marginRight, marginBottom,
534 // marginLeft must be initialized to the default values that are used if
535 // auto is specified.
536 virtual void pageSizeAndMarginsInPixels(int pageIndex,
537 WebSize& pageSize,
538 int& marginTop,
539 int& marginRight,
540 int& marginBottom,
541 int& marginLeft) = 0;
543 // Returns the value for a page property that is only defined when printing.
544 // printBegin must have been called before this method.
545 virtual WebString pageProperty(const WebString& propertyName, int pageIndex) = 0;
547 // Find-in-page --------------------------------------------------------
549 // Searches a frame for a given string.
551 // If a match is found, this function will select it (scrolling down to
552 // make it visible if needed) and fill in selectionRect with the
553 // location of where the match was found (in window coordinates).
555 // If no match is found, this function clears all tickmarks and
556 // highlighting.
558 // Returns true if the search string was found, false otherwise.
559 virtual bool find(int identifier,
560 const WebString& searchText,
561 const WebFindOptions& options,
562 bool wrapWithinFrame,
563 WebRect* selectionRect) = 0;
565 // Notifies the frame that we are no longer interested in searching.
566 // This will abort any asynchronous scoping effort already under way
567 // (see the function scopeStringMatches for details) and erase all
568 // tick-marks and highlighting from the previous search. If
569 // clearSelection is true, it will also make sure the end state for the
570 // find operation does not leave a selection. This can occur when the
571 // user clears the search string but does not close the find box.
572 virtual void stopFinding(bool clearSelection) = 0;
574 // Counts how many times a particular string occurs within the frame.
575 // It also retrieves the location of the string and updates a vector in
576 // the frame so that tick-marks and highlighting can be drawn. This
577 // function does its work asynchronously, by running for a certain
578 // time-slice and then scheduling itself (co-operative multitasking) to
579 // be invoked later (repeating the process until all matches have been
580 // found). This allows multiple frames to be searched at the same time
581 // and provides a way to cancel at any time (see
582 // cancelPendingScopingEffort). The parameter searchText specifies
583 // what to look for and |reset| signals whether this is a brand new
584 // request or a continuation of the last scoping effort.
585 virtual void scopeStringMatches(int identifier,
586 const WebString& searchText,
587 const WebFindOptions& options,
588 bool reset) = 0;
590 // Cancels any outstanding requests for scoping string matches on a frame.
591 virtual void cancelPendingScopingEffort() = 0;
593 // This function is called on the main frame during the scoping effort
594 // to keep a running tally of the accumulated total match-count for all
595 // frames. After updating the count it will notify the WebViewClient
596 // about the new count.
597 virtual void increaseMatchCount(int count, int identifier) = 0;
599 // This function is called on the main frame to reset the total number
600 // of matches found during the scoping effort.
601 virtual void resetMatchCount() = 0;
603 // Returns a counter that is incremented when the find-in-page markers are
604 // changed on any frame. Switching the active marker doesn't change the
605 // current version. Should be called only on the main frame.
606 virtual int findMatchMarkersVersion() const = 0;
608 // Returns the bounding box of the active find-in-page match marker or an
609 // empty rect if no such marker exists. The rect is returned in find-in-page
610 // coordinates whatever frame the active marker is.
611 // Should be called only on the main frame.
612 virtual WebFloatRect activeFindMatchRect() = 0;
614 // Swaps the contents of the provided vector with the bounding boxes of the
615 // find-in-page match markers from all frames. The bounding boxes are returned
616 // in find-in-page coordinates. This method should be called only on the main frame.
617 virtual void findMatchRects(WebVector<WebFloatRect>&) = 0;
619 // Selects the find-in-page match in the appropriate frame closest to the
620 // provided point in find-in-page coordinates. Returns the ordinal of such
621 // match or -1 if none could be found. If not null, selectionRect is set to
622 // the bounding box of the selected match in window coordinates.
623 // This method should be called only on the main frame.
624 virtual int selectNearestFindMatch(const WebFloatPoint&,
625 WebRect* selectionRect) = 0;
628 // Set the tickmarks for the frame. This will override the default tickmarks
629 // generated by find results. If this is called with an empty array, the
630 // default behavior will be restored.
631 virtual void setTickmarks(const WebVector<WebRect>&) = 0;
633 // Events --------------------------------------------------------------
635 // Dispatches a message event on the current DOMWindow in this WebFrame.
636 virtual void dispatchMessageEventWithOriginCheck(
637 const WebSecurityOrigin& intendedTargetOrigin,
638 const WebDOMEvent&) = 0;
641 // Utility -------------------------------------------------------------
643 // Returns the contents of this frame as a string. If the text is
644 // longer than maxChars, it will be clipped to that length. WARNING:
645 // This function may be slow depending on the number of characters
646 // retrieved and page complexity. For a typically sized page, expect
647 // it to take on the order of milliseconds.
649 // If there is room, subframe text will be recursively appended. Each
650 // frame will be separated by an empty line.
651 virtual WebString contentAsText(size_t maxChars) const = 0;
653 // Returns HTML text for the contents of this frame. This is generated
654 // from the DOM.
655 virtual WebString contentAsMarkup() const = 0;
657 // Returns a text representation of the render tree. This method is used
658 // to support layout tests.
659 virtual WebString layoutTreeAsText(LayoutAsTextControls toShow = LayoutAsTextNormal) const = 0;
661 // Calls markerTextForListItem() defined in core/layout/LayoutTreeAsText.h.
662 virtual WebString markerTextForListItem(const WebElement&) const = 0;
664 // Prints all of the pages into the canvas, with page boundaries drawn as
665 // one pixel wide blue lines. This method exists to support layout tests.
666 virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&) = 0;
668 // Returns the bounds rect for current selection. If selection is performed
669 // on transformed text, the rect will still bound the selection but will
670 // not be transformed itself. If no selection is present, the rect will be
671 // empty ((0,0), (0,0)).
672 virtual WebRect selectionBoundsRect() const = 0;
674 // Only for testing purpose:
675 // Returns true if selection.anchorNode has a marker on range from |from| with |length|.
676 virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const = 0;
678 // Dumps the layer tree, used by the accelerated compositor, in
679 // text form. This is used only by layout tests.
680 virtual WebString layerTreeAsText(bool showDebugInfo = false) const = 0;
682 // Returns the frame inside a given frame or iframe element. Returns 0 if
683 // the given element is not a frame, iframe or if the frame is empty.
684 BLINK_EXPORT static WebFrame* fromFrameOwnerElement(const WebElement&);
686 #if BLINK_IMPLEMENTATION
687 static WebFrame* fromFrame(Frame*);
689 bool inShadowTree() const { return m_scope == WebTreeScopeType::Shadow; }
691 #if ENABLE(OILPAN)
692 static void traceFrames(Visitor*, WebFrame*);
693 static void traceFrames(InlinedGlobalMarkingVisitor, WebFrame*);
694 void clearWeakFrames(Visitor*);
695 void clearWeakFrames(InlinedGlobalMarkingVisitor);
696 #endif
697 #endif
699 protected:
700 explicit WebFrame(WebTreeScopeType);
701 virtual ~WebFrame();
703 // Sets the parent WITHOUT fulling adding it to the frame tree.
704 // Used to lie to a local frame that is replacing a remote frame,
705 // so it can properly start a navigation but wait to swap until
706 // commit-time.
707 void setParent(WebFrame*);
709 private:
710 friend class OpenedFrameTracker;
712 #if BLINK_IMPLEMENTATION
713 #if ENABLE(OILPAN)
714 static void traceFrame(Visitor*, WebFrame*);
715 static void traceFrame(InlinedGlobalMarkingVisitor, WebFrame*);
716 static bool isFrameAlive(const WebFrame*);
718 template <typename VisitorDispatcher>
719 static void traceFramesImpl(VisitorDispatcher, WebFrame*);
720 template <typename VisitorDispatcher>
721 void clearWeakFramesImpl(VisitorDispatcher);
722 template <typename VisitorDispatcher>
723 static void traceFrameImpl(VisitorDispatcher, WebFrame*);
724 #endif
725 #endif
727 const WebTreeScopeType m_scope;
729 WebFrame* m_parent;
730 WebFrame* m_previousSibling;
731 WebFrame* m_nextSibling;
732 WebFrame* m_firstChild;
733 WebFrame* m_lastChild;
735 WebFrame* m_opener;
736 WebPrivateOwnPtr<OpenedFrameTracker> m_openedFrameTracker;
739 #if BLINK_IMPLEMENTATION
740 Frame* toCoreFrame(const WebFrame*);
741 #endif
743 } // namespace blink
745 #endif