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