Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: webkit/api/public/WebFrame.h

Issue 385057: Deleted webkit/api which now lives in webkit.org (Closed)
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webkit/api/public/WebFormElement.h ('k') | webkit/api/public/WebFrameClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 "WebCanvas.h"
35 #include "WebURL.h"
36
37 struct NPObject;
38
39 #if WEBKIT_USING_V8
40 namespace v8 {
41 class Context;
42 template <class T> class Local;
43 }
44 #endif
45
46 namespace WebKit {
47
48 class WebData;
49 class WebDataSource;
50 class WebFormElement;
51 class WebHistoryItem;
52 class WebInputElement;
53 class WebPasswordAutocompleteListener;
54 class WebRange;
55 class WebSecurityOrigin;
56 class WebString;
57 class WebURL;
58 class WebURLRequest;
59 class WebView;
60 struct WebConsoleMessage;
61 struct WebFindOptions;
62 struct WebRect;
63 struct WebScriptSource;
64 struct WebSize;
65 template <typename T> class WebVector;
66
67 class WebFrame {
68 public:
69 // The two functions below retrieve the WebFrame instances relating the
70 // currently executing JavaScript. Since JavaScript can make function
71 // calls across frames, though, we need to be more precise.
72 //
73 // For example, imagine that a JS function in frame A calls a function
74 // in frame B, which calls native code, which wants to know what the
75 // 'active' frame is.
76 //
77 // The 'entered context' is the context where execution first entered
78 // the script engine; the context that is at the bottom of the JS
79 // function stack. frameForEnteredContext() would return frame A in
80 // our example.
81 //
82 // The 'current context' is the context the JS engine is currently
83 // inside of; the context that is at the top of the JS function stack.
84 // frameForCurrentContext() would return frame B in our example.
85 WEBKIT_API static WebFrame* frameForEnteredContext();
86 WEBKIT_API static WebFrame* frameForCurrentContext();
87
88
89 // Basic properties ---------------------------------------------------
90
91 // The name of this frame.
92 virtual WebString name() const = 0;
93
94 // The url of the document loaded in this frame. This is equivalent to
95 // dataSource()->request().url().
96 virtual WebURL url() const = 0;
97
98 // The url of the favicon (if any) specified by the document loaded in
99 // this frame.
100 virtual WebURL favIconURL() const = 0;
101
102 // The url of the OpenSearch Desription Document (if any) specified by
103 // the document loaded in this frame.
104 virtual WebURL openSearchDescriptionURL() const = 0;
105
106
107 // Geometry -----------------------------------------------------------
108
109 // NOTE: These routines do not force page layout so their results may
110 // not be accurate if the page layout is out-of-date.
111
112 // The scroll offset from the top-left corner of the frame in pixels.
113 virtual WebSize scrollOffset() const = 0;
114
115 // The size of the contents area.
116 virtual WebSize contentsSize() const = 0;
117
118 // Returns the minimum preferred width of the content contained in the
119 // current document.
120 virtual int contentsPreferredWidth() const = 0;
121
122 // Returns true if the contents (minus scrollbars) has non-zero area.
123 virtual bool hasVisibleContent() const = 0;
124
125
126 // Hierarchy ----------------------------------------------------------
127
128 // Returns the containing view.
129 virtual WebView* view() const = 0;
130
131 // Returns the frame that opened this frame or 0 if there is none.
132 virtual WebFrame* opener() const = 0;
133
134 // Returns the parent frame or 0 if this is a top-most frame.
135 virtual WebFrame* parent() const = 0;
136
137 // Returns the top-most frame in the hierarchy containing this frame.
138 virtual WebFrame* top() const = 0;
139
140 // Returns the first/last child frame.
141 virtual WebFrame* firstChild() const = 0;
142 virtual WebFrame* lastChild() const = 0;
143
144 // Returns the next/previous sibling frame.
145 virtual WebFrame* nextSibling() const = 0;
146 virtual WebFrame* previousSibling() const = 0;
147
148 // Returns the next/previous frame in "frame traversal order"
149 // optionally wrapping around.
150 virtual WebFrame* traverseNext(bool wrap) const = 0;
151 virtual WebFrame* traversePrevious(bool wrap) const = 0;
152
153 // Returns the child frame identified by the given name.
154 virtual WebFrame* findChildByName(const WebString& name) const = 0;
155
156 // Returns the child frame identified by the given xpath expression.
157 virtual WebFrame* findChildByExpression(const WebString& xpath) const = 0;
158
159
160 // Content ------------------------------------------------------------
161
162 virtual void forms(WebVector<WebFormElement>&) const = 0;
163
164
165 // Scripting ----------------------------------------------------------
166
167 // Returns the security origin of the current document.
168 virtual WebSecurityOrigin securityOrigin() const = 0;
169
170 // This grants the currently loaded document access to all security
171 // origins (including file URLs). Use with care. The access is
172 // revoked when a new document is loaded into this frame.
173 virtual void grantUniversalAccess() = 0;
174
175 // Returns a NPObject corresponding to this frame's DOMWindow.
176 virtual NPObject* windowObject() const = 0;
177
178 // Binds a NPObject as a property of this frame's DOMWindow.
179 virtual void bindToWindowObject(const WebString& name, NPObject*) = 0;
180
181 // Executes script in the context of the current page.
182 virtual void executeScript(const WebScriptSource&) = 0;
183
184 // Executes script in a new context associated with the frame. The
185 // script gets its own global scope and its own prototypes for
186 // intrinsic JS objects (String, Array, and so-on). It shares the
187 // wrappers for all DOM nodes and DOM constructors. extensionGroup is
188 // an embedder-provided specifier that controls which v8 extensions are
189 // loaded into the new context - see WebKit::registerExtension for the
190 // corresponding specifier.
191 virtual void executeScriptInNewContext(const WebScriptSource* sources,
192 unsigned numSources,
193 int extensionGroup) = 0;
194
195 // Executes JavaScript in a new world associated with the web frame.
196 // The script gets its own global scope and its own prototypes for
197 // intrinsic JavaScript objects (String, Array, and so-on). It also
198 // gets its own wrappers for all DOM nodes and DOM constructors.
199 // extensionGroup is an embedder-provided specifier that controls which
200 // v8 extensions are loaded into the new context - see
201 // WebKit::registerExtension for the corresponding specifier.
202 virtual void executeScriptInIsolatedWorld(
203 int worldId, const WebScriptSource* sources, unsigned numSources,
204 int extensionGroup) = 0;
205
206 // Logs to the console associated with this frame.
207 virtual void addMessageToConsole(const WebConsoleMessage&) = 0;
208
209 // Calls window.gc() if it is defined.
210 virtual void collectGarbage() = 0;
211
212 #if WEBKIT_USING_V8
213 // Returns the V8 context for this frame, or an empty handle if there
214 // is none.
215 virtual v8::Local<v8::Context> mainWorldScriptContext() const = 0;
216 #endif
217
218
219 // Styling -------------------------------------------------------------
220
221 // Insert the given text as a STYLE element at the beginning of the
222 // document. |elementId| can be empty, but if specified then it is used
223 // as the id for the newly inserted element (replacing an existing one
224 // with the same id, if any).
225 virtual bool insertStyleText(const WebString& styleText,
226 const WebString& elementId) = 0;
227
228
229 // Navigation ----------------------------------------------------------
230
231 // Reload the current document.
232 virtual void reload() = 0;
233
234 // Load the given URL.
235 virtual void loadRequest(const WebURLRequest&) = 0;
236
237 // Load the given history state, corresponding to a back/forward
238 // navigation.
239 virtual void loadHistoryItem(const WebHistoryItem&) = 0;
240
241 // Loads the given data with specific mime type and optional text
242 // encoding. For HTML data, baseURL indicates the security origin of
243 // the document and is used to resolve links. If specified,
244 // unreachableURL is reported via WebDataSource::unreachableURL. If
245 // replace is false, then this data will be loaded as a normal
246 // navigation. Otherwise, the current history item will be replaced.
247 virtual void loadData(const WebData& data,
248 const WebString& mimeType,
249 const WebString& textEncoding,
250 const WebURL& baseURL,
251 const WebURL& unreachableURL = WebURL(),
252 bool replace = false) = 0;
253
254 // This method is short-hand for calling LoadData, where mime_type is
255 // "text/html" and text_encoding is "UTF-8".
256 virtual void loadHTMLString(const WebData& html,
257 const WebURL& baseURL,
258 const WebURL& unreachableURL = WebURL(),
259 bool replace = false) = 0;
260
261 // Returns true if the current frame is busy loading content.
262 virtual bool isLoading() const = 0;
263
264 // Stops any pending loads on the frame and its children.
265 virtual void stopLoading() = 0;
266
267 // Returns the data source that is currently loading. May be null.
268 virtual WebDataSource* provisionalDataSource() const = 0;
269
270 // Returns the data source that is currently loaded.
271 virtual WebDataSource* dataSource() const = 0;
272
273 // Returns the previous history item. Check WebHistoryItem::isNull()
274 // before using.
275 virtual WebHistoryItem previousHistoryItem() const = 0;
276
277 // Returns the current history item. Check WebHistoryItem::isNull()
278 // before using.
279 virtual WebHistoryItem currentHistoryItem() const = 0;
280
281 // View-source rendering mode. Set this before loading an URL to cause
282 // it to be rendered in view-source mode.
283 virtual void enableViewSourceMode(bool) = 0;
284 virtual bool isViewSourceModeEnabled() const = 0;
285
286 // Sets the referrer for the given request to be the specified URL or
287 // if that is null, then it sets the referrer to the referrer that the
288 // frame would use for subresources. NOTE: This method also filters
289 // out invalid referrers (e.g., it is invalid to send a HTTPS URL as
290 // the referrer for a HTTP request).
291 virtual void setReferrerForRequest(WebURLRequest&, const WebURL&) = 0;
292
293 // Called to associate the WebURLRequest with this frame. The request
294 // will be modified to inherit parameters that allow it to be loaded.
295 // This method ends up triggering WebFrameClient::willSendRequest.
296 virtual void dispatchWillSendRequest(WebURLRequest&) = 0;
297
298 // Called from within WebFrameClient::didReceiveDocumentData to commit
299 // data for the frame that will be used to construct the frame's
300 // document.
301 virtual void commitDocumentData(const char* data, size_t length) = 0;
302
303 // Returns the number of registered unload listeners.
304 virtual unsigned unloadListenerCount() const = 0;
305
306 // Returns true if a user gesture is currently being processed.
307 virtual bool isProcessingUserGesture() const = 0;
308
309 // Returns true if this frame is in the process of opening a new frame
310 // with a suppressed opener.
311 virtual bool willSuppressOpenerInNewFrame() const = 0;
312
313
314 // Editing -------------------------------------------------------------
315
316 // Replaces the selection with the given text.
317 virtual void replaceSelection(const WebString& text) = 0;
318
319 virtual void insertText(const WebString& text) = 0;
320
321 virtual void setMarkedText(const WebString& text, unsigned location, unsigned length) = 0;
322 virtual void unmarkText() = 0;
323 virtual bool hasMarkedText() const = 0;
324
325 virtual WebRange markedRange() const = 0;
326
327 // Supports commands like Undo, Redo, Cut, Copy, Paste, SelectAll,
328 // Unselect, etc. See EditorCommand.cpp for the full list of supported
329 // commands.
330 virtual bool executeCommand(const WebString&) = 0;
331 virtual bool executeCommand(const WebString&, const WebString& value) = 0;
332 virtual bool isCommandEnabled(const WebString&) const = 0;
333
334 // Spell-checking support.
335 virtual void enableContinuousSpellChecking(bool) = 0;
336 virtual bool isContinuousSpellCheckingEnabled() const = 0;
337
338
339 // Selection -----------------------------------------------------------
340
341 virtual bool hasSelection() const = 0;
342
343 virtual WebRange selectionRange() const = 0;
344
345 virtual WebString selectionAsText() const = 0;
346 virtual WebString selectionAsMarkup() const = 0;
347
348
349 // Printing ------------------------------------------------------------
350
351 // Reformats the WebFrame for printing. pageSize is the page size in
352 // pixels. Returns the number of pages that can be printed at the
353 // given page size.
354 virtual int printBegin(const WebSize& pageSize) = 0;
355
356 // Returns the page shrinking factor calculated by webkit (usually
357 // between 1/1.25 and 1/2). Returns 0 if the page number is invalid or
358 // not in printing mode.
359 virtual float getPrintPageShrink(int page) = 0;
360
361 // Prints one page, and returns the calculated page shrinking factor
362 // (usually between 1/1.25 and 1/2). Returns 0 if the page number is
363 // invalid or not in printing mode.
364 virtual float printPage(int pageToPrint, WebCanvas*) = 0;
365
366 // Reformats the WebFrame for screen display.
367 virtual void printEnd() = 0;
368
369
370 // Find-in-page --------------------------------------------------------
371
372 // Searches a frame for a given string.
373 //
374 // If a match is found, this function will select it (scrolling down to
375 // make it visible if needed) and fill in selectionRect with the
376 // location of where the match was found (in window coordinates).
377 //
378 // If no match is found, this function clears all tickmarks and
379 // highlighting.
380 //
381 // Returns true if the search string was found, false otherwise.
382 virtual bool find(int identifier,
383 const WebString& searchText,
384 const WebFindOptions& options,
385 bool wrapWithinFrame,
386 WebRect* selectionRect) = 0;
387
388 // Notifies the frame that we are no longer interested in searching.
389 // This will abort any asynchronous scoping effort already under way
390 // (see the function scopeStringMatches for details) and erase all
391 // tick-marks and highlighting from the previous search. If
392 // clearSelection is true, it will also make sure the end state for the
393 // find operation does not leave a selection. This can occur when the
394 // user clears the search string but does not close the find box.
395 virtual void stopFinding(bool clearSelection) = 0;
396
397 // Counts how many times a particular string occurs within the frame.
398 // It also retrieves the location of the string and updates a vector in
399 // the frame so that tick-marks and highlighting can be drawn. This
400 // function does its work asynchronously, by running for a certain
401 // time-slice and then scheduling itself (co-operative multitasking) to
402 // be invoked later (repeating the process until all matches have been
403 // found). This allows multiple frames to be searched at the same time
404 // and provides a way to cancel at any time (see
405 // cancelPendingScopingEffort). The parameter searchText specifies
406 // what to look for and |reset| signals whether this is a brand new
407 // request or a continuation of the last scoping effort.
408 virtual void scopeStringMatches(int identifier,
409 const WebString& searchText,
410 const WebFindOptions& options,
411 bool reset) = 0;
412
413 // Cancels any outstanding requests for scoping string matches on a frame.
414 virtual void cancelPendingScopingEffort() = 0;
415
416 // This function is called on the main frame during the scoping effort
417 // to keep a running tally of the accumulated total match-count for all
418 // frames. After updating the count it will notify the WebViewClient
419 // about the new count.
420 virtual void increaseMatchCount(int count, int identifier) = 0;
421
422 // This function is called on the main frame to reset the total number
423 // of matches found during the scoping effort.
424 virtual void resetMatchCount() = 0;
425
426 // Password autocompletion ---------------------------------------------
427
428 // Registers a listener for the specified user name input element. The
429 // listener will receive notifications for blur and when autocomplete
430 // should be triggered.
431 // The WebFrame becomes the owner of the passed listener.
432 virtual void registerPasswordListener(
433 WebInputElement,
434 WebPasswordAutocompleteListener*) = 0;
435
436 // Utility -------------------------------------------------------------
437
438 // Given a relative URL, returns an absolute URL by resolving the URL
439 // relative to the base URL of the frame's document. This uses the
440 // same algorithm that WebKit uses to resolve hyperlinks found in a
441 // HTML document.
442 virtual WebURL completeURL(const WebString&) const = 0;
443
444 // Returns the contents of this frame as a string. If the text is
445 // longer than maxChars, it will be clipped to that length. WARNING:
446 // This function may be slow depending on the number of characters
447 // retrieved and page complexity. For a typically sized page, expect
448 // it to take on the order of milliseconds.
449 //
450 // If there is room, subframe text will be recursively appended. Each
451 // frame will be separated by an empty line.
452 virtual WebString contentAsText(size_t maxChars) const = 0;
453
454 // Returns HTML text for the contents of this frame. This is generated
455 // from the DOM.
456 virtual WebString contentAsMarkup() const = 0;
457
458 protected:
459 ~WebFrame() { }
460 };
461
462 } // namespace WebKit
463
464 #endif
OLDNEW
« no previous file with comments | « webkit/api/public/WebFormElement.h ('k') | webkit/api/public/WebFrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698