| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebFrame_h | 31 #ifndef WebFrame_h |
| 32 #define WebFrame_h | 32 #define WebFrame_h |
| 33 | 33 |
| 34 #error "This header file is still a work in progress; do not include!" | 34 #include "WebCanvas.h" |
| 35 #include "WebURL.h" |
| 35 | 36 |
| 36 #include "WebCommon.h" | 37 class WebView; // FIXME: Move into the WebKit namespace. |
| 38 struct NPObject; |
| 37 | 39 |
| 38 struct NPObject; | 40 #if WEBKIT_USING_V8 |
| 41 namespace v8 { |
| 42 class Context; |
| 43 template <class T> class Local; |
| 44 } |
| 45 #endif |
| 39 | 46 |
| 40 namespace WebKit { | 47 namespace WebKit { |
| 41 class WebData; | 48 class WebData; |
| 42 class WebDataSource; | 49 class WebDataSource; |
| 50 class WebForm; |
| 43 class WebHistoryItem; | 51 class WebHistoryItem; |
| 52 class WebRange; |
| 44 class WebString; | 53 class WebString; |
| 45 class WebURL; | 54 class WebURL; |
| 46 class WebURLRequest; | 55 class WebURLRequest; |
| 47 class WebView; | 56 struct WebConsoleMessage; |
| 57 struct WebFindOptions; |
| 58 struct WebRect; |
| 59 struct WebScriptSource; |
| 60 struct WebSize; |
| 61 template <typename T> class WebVector; |
| 48 | 62 |
| 49 class WebFrame { | 63 class WebFrame { |
| 50 public: | 64 public: |
| 51 // Returns the frame that is currently executing script or 0 if there | 65 // The two functions below retrieve the WebFrame instances relating the |
| 52 // is none. | 66 // currently executing JavaScript. Since JavaScript can make function |
| 53 WEBKIT_API static WebFrame* activeFrame(); | 67 // calls across frames, though, we need to be more precise. |
| 68 // |
| 69 // For example, imagine that a JS function in frame A calls a function |
| 70 // in frame B, which calls native code, which wants to know what the |
| 71 // 'active' frame is. |
| 72 // |
| 73 // The 'entered context' is the context where execution first entered |
| 74 // the script engine; the context that is at the bottom of the JS |
| 75 // function stack. frameForEnteredContext() would return frame A in |
| 76 // our example. |
| 77 // |
| 78 // The 'current context' is the context the JS engine is currently |
| 79 // inside of; the context that is at the top of the JS function stack. |
| 80 // frameForCurrentContext() would return frame B in our example. |
| 81 WEBKIT_API static WebFrame* frameForEnteredContext(); |
| 82 WEBKIT_API static WebFrame* frameForCurrentContext(); |
| 54 | 83 |
| 55 | 84 |
| 56 // Basic properties --------------------------------------------------- | 85 // Basic properties --------------------------------------------------- |
| 57 | 86 |
| 58 // The name of this frame. | 87 // The name of this frame. |
| 59 virtual WebString name() = 0; | 88 virtual WebString name() const = 0; |
| 60 | 89 |
| 61 // The url of the document loaded in this frame. This is equivalent to | 90 // The url of the document loaded in this frame. This is equivalent to |
| 62 // dataSource()->request().url(). | 91 // dataSource()->request().url(). |
| 63 virtual WebURL url() = 0; | 92 virtual WebURL url() const = 0; |
| 64 | 93 |
| 65 // The url of the favicon (if any) specified by the document loaded in | 94 // The url of the favicon (if any) specified by the document loaded in |
| 66 // this frame. | 95 // this frame. |
| 67 virtual WebURL favIconURL() = 0; | 96 virtual WebURL favIconURL() const = 0; |
| 68 | 97 |
| 69 // The url of the OpenSearch Desription Document (if any) specified by | 98 // The url of the OpenSearch Desription Document (if any) specified by |
| 70 // the document loaded in this frame. | 99 // the document loaded in this frame. |
| 71 virtual WebURL openSearchDescriptionURL() = 0; | 100 virtual WebURL openSearchDescriptionURL() const = 0; |
| 72 | |
| 73 // Returns the security origin of the current document. | |
| 74 virtual WebString securityOrigin() = 0; | |
| 75 | 101 |
| 76 | 102 |
| 77 // Geometry ----------------------------------------------------------- | 103 // Geometry ----------------------------------------------------------- |
| 78 | 104 |
| 79 // NOTE: These routines do not force page layout so their results may | 105 // NOTE: These routines do not force page layout so their results may |
| 80 // not be accurate if the page layout is out-of-date. | 106 // not be accurate if the page layout is out-of-date. |
| 81 | 107 |
| 82 // The scroll offset from the top-left corner of the frame in pixels. | 108 // The scroll offset from the top-left corner of the frame in pixels. |
| 83 virtual WebSize scrollOffset() = 0; | 109 virtual WebSize scrollOffset() const = 0; |
| 84 | 110 |
| 85 // The size of the contents area. | 111 // The size of the contents area. |
| 86 virtual WebSize contentsSize() = 0; | 112 virtual WebSize contentsSize() const = 0; |
| 87 | 113 |
| 88 // Returns the minimum preferred width of the content contained in the | 114 // Returns the minimum preferred width of the content contained in the |
| 89 // current document. | 115 // current document. |
| 90 virtual int contentsPreferredWidth() = 0; | 116 virtual int contentsPreferredWidth() const = 0; |
| 91 | 117 |
| 92 // Returns true if the contents (minus scrollbars) has non-zero area. | 118 // Returns true if the contents (minus scrollbars) has non-zero area. |
| 93 virtual bool hasVisibleContent() = 0; | 119 virtual bool hasVisibleContent() const = 0; |
| 94 | 120 |
| 95 | 121 |
| 96 // Hierarchy ---------------------------------------------------------- | 122 // Hierarchy ---------------------------------------------------------- |
| 97 | 123 |
| 98 // Returns the containing view. | 124 // Returns the containing view. |
| 99 virtual WebView* view() = 0; | 125 virtual WebView* view() const = 0; |
| 100 | 126 |
| 101 // Returns the parent frame. | 127 // Returns the frame that opened this frame or 0 if there is none. |
| 102 virtual WebFrame* parent() = 0; | 128 virtual WebFrame* opener() const = 0; |
| 129 |
| 130 // Returns the parent frame or 0 if this is a top-most frame. |
| 131 virtual WebFrame* parent() const = 0; |
| 103 | 132 |
| 104 // Returns the top-most frame in the hierarchy containing this frame. | 133 // Returns the top-most frame in the hierarchy containing this frame. |
| 105 virtual WebFrame* top() = 0; | 134 virtual WebFrame* top() const = 0; |
| 106 | 135 |
| 107 // Returns the first/last child frame. | 136 // Returns the first/last child frame. |
| 108 virtual WebFrame* firstChild() = 0; | 137 virtual WebFrame* firstChild() const = 0; |
| 109 virtual WebFrame* lastChild() = 0; | 138 virtual WebFrame* lastChild() const = 0; |
| 110 | 139 |
| 111 // Returns the next/previous sibling frame. | 140 // Returns the next/previous sibling frame. |
| 112 virtual WebFrame* nextSibling() = 0; | 141 virtual WebFrame* nextSibling() const = 0; |
| 113 virtual WebFrame* previousSibling() = 0; | 142 virtual WebFrame* previousSibling() const = 0; |
| 114 | 143 |
| 115 // Returns the next/previous frame in "frame traversal order" | 144 // Returns the next/previous frame in "frame traversal order" |
| 116 // optionally wrapping around. | 145 // optionally wrapping around. |
| 117 virtual WebFrame* traverseNext(bool wrap) = 0; | 146 virtual WebFrame* traverseNext(bool wrap) const = 0; |
| 118 virtual WebFrame* traversePrevious(bool wrap) = 0; | 147 virtual WebFrame* traversePrevious(bool wrap) const = 0; |
| 119 | 148 |
| 120 // Returns the child frame identified by the given name. | 149 // Returns the child frame identified by the given name. |
| 121 virtual WebFrame* findChildByName(const WebString& name) = 0; | 150 virtual WebFrame* findChildByName(const WebString& name) const = 0; |
| 122 | 151 |
| 123 // Returns the child frame identified by the given xpath expression. | 152 // Returns the child frame identified by the given xpath expression. |
| 124 virtual WebFrame* findChildByExpression(const WebString& xpath) = 0; | 153 virtual WebFrame* findChildByExpression(const WebString& xpath) const = 0; |
| 154 |
| 155 |
| 156 // Content ------------------------------------------------------------ |
| 157 |
| 158 virtual void forms(WebVector<WebForm>&) const = 0; |
| 125 | 159 |
| 126 | 160 |
| 127 // Scripting ---------------------------------------------------------- | 161 // Scripting ---------------------------------------------------------- |
| 128 | 162 |
| 129 // Calls window.gc() if it is defined. | 163 // Returns the security origin of the current document. |
| 130 virtual void collectGarbage() = 0; | 164 virtual WebString securityOrigin() const = 0; |
| 165 |
| 166 // This grants the currently loaded document access to all security |
| 167 // origins (including file URLs). Use with care. The access is |
| 168 // revoked when a new document is loaded into this frame. |
| 169 virtual void grantUniversalAccess() = 0; |
| 131 | 170 |
| 132 // Returns a NPObject corresponding to this frame's DOMWindow. | 171 // Returns a NPObject corresponding to this frame's DOMWindow. |
| 133 virtual NPObject* windowObject() = 0; | 172 virtual NPObject* windowObject() const = 0; |
| 134 | 173 |
| 135 // Binds a NPObject as a property of this frame's DOMWindow. | 174 // Binds a NPObject as a property of this frame's DOMWindow. |
| 136 virtual void bindToWindowObject(const WebString& name, NPObject*) = 0; | 175 virtual void bindToWindowObject(const WebString& name, NPObject*) = 0; |
| 137 | 176 |
| 138 // Executes script in the context of the current page. | 177 // Executes script in the context of the current page. |
| 139 virtual void executeScript(const WebScriptSource&) = 0; | 178 virtual void executeScript(const WebScriptSource&) = 0; |
| 140 | 179 |
| 141 // Executes script in a new context associated with the frame. The | 180 // Executes script in a new context associated with the frame. The |
| 142 // script gets its own global scope and its own prototypes for | 181 // script gets its own global scope and its own prototypes for |
| 143 // intrinsic JS objects (String, Array, and so-on). It shares the | 182 // intrinsic JS objects (String, Array, and so-on). It shares the |
| 144 // wrappers for all DOM nodes and DOM constructors. | 183 // wrappers for all DOM nodes and DOM constructors. extensionGroup is |
| 184 // an embedder-provided specifier that controls which v8 extensions are |
| 185 // loaded into the new context - see WebKit::registerExtension for the |
| 186 // corresponding specifier. |
| 145 virtual void executeScriptInNewContext(const WebScriptSource* sources, | 187 virtual void executeScriptInNewContext(const WebScriptSource* sources, |
| 146 unsigned numSources) = 0; | 188 unsigned numSources, |
| 189 int extensionGroup) = 0; |
| 147 | 190 |
| 148 // Executes JavaScript in a new world associated with the web frame. | 191 // Executes JavaScript in a new world associated with the web frame. |
| 149 // The script gets its own global scope and its own prototypes for | 192 // The script gets its own global scope and its own prototypes for |
| 150 // intrinsic JavaScript objects (String, Array, and so-on). It also | 193 // intrinsic JavaScript objects (String, Array, and so-on). It also |
| 151 // gets its own wrappers for all DOM nodes and DOM constructors. | 194 // gets its own wrappers for all DOM nodes and DOM constructors. |
| 195 // extensionGroup is an embedder-provided specifier that controls which |
| 196 // v8 extensions are loaded into the new context - see |
| 197 // WebKit::registerExtension for the corresponding specifier. |
| 152 virtual void executeScriptInNewWorld(const WebScriptSource* sources, | 198 virtual void executeScriptInNewWorld(const WebScriptSource* sources, |
| 153 unsigned numSources) = 0; | 199 unsigned numSources, |
| 200 int extensionGroup) = 0; |
| 154 | 201 |
| 155 // Logs to the console associated with this frame. | 202 // Logs to the console associated with this frame. |
| 156 virtual void addMessageToConsole(const WebConsoleMessage&) = 0; | 203 virtual void addMessageToConsole(const WebConsoleMessage&) = 0; |
| 157 | 204 |
| 205 // Calls window.gc() if it is defined. |
| 206 virtual void collectGarbage() = 0; |
| 207 |
| 208 #if WEBKIT_USING_V8 |
| 209 // Returns the V8 context for this frame, or an empty handle if there |
| 210 // is none. |
| 211 virtual v8::Local<v8::Context> mainWorldScriptContext() const = 0; |
| 212 #endif |
| 213 |
| 158 | 214 |
| 159 // Styling ------------------------------------------------------------- | 215 // Styling ------------------------------------------------------------- |
| 160 | 216 |
| 161 // Insert the given text as a STYLE element at the beginning of the | 217 // Insert the given text as a STYLE element at the beginning of the |
| 162 // document. | 218 // document. |
| 163 virtual bool insertStyleText(const WebString&) = 0; | 219 virtual bool insertStyleText(const WebString&) = 0; |
| 164 | 220 |
| 165 | 221 |
| 166 // Navigation ---------------------------------------------------------- | 222 // Navigation ---------------------------------------------------------- |
| 167 | 223 |
| 224 // Reload the current document. |
| 168 virtual void reload() = 0; | 225 virtual void reload() = 0; |
| 169 | 226 |
| 227 // Load the given URL. |
| 170 virtual void loadRequest(const WebURLRequest&) = 0; | 228 virtual void loadRequest(const WebURLRequest&) = 0; |
| 171 | 229 |
| 230 // Load the given history state, corresponding to a back/forward |
| 231 // navigation. |
| 172 virtual void loadHistoryItem(const WebHistoryItem&) = 0; | 232 virtual void loadHistoryItem(const WebHistoryItem&) = 0; |
| 173 | 233 |
| 234 // Loads the given data with specific mime type and optional text |
| 235 // encoding. For HTML data, baseURL indicates the security origin of |
| 236 // the document and is used to resolve links. If specified, |
| 237 // unreachableURL is reported via WebDataSource::unreachableURL. If |
| 238 // replace is false, then this data will be loaded as a normal |
| 239 // navigation. Otherwise, the current history item will be replaced. |
| 174 virtual void loadData(const WebData& data, | 240 virtual void loadData(const WebData& data, |
| 175 const WebString& mimeType, | 241 const WebString& mimeType, |
| 176 const WebString& textEncoding, | 242 const WebString& textEncoding, |
| 177 const WebURL& baseURL, | 243 const WebURL& baseURL, |
| 178 const WebURL& unreachableURL = WebURL(), | 244 const WebURL& unreachableURL = WebURL(), |
| 179 bool replace = false) = 0; | 245 bool replace = false) = 0; |
| 180 | 246 |
| 247 // This method is short-hand for calling LoadData, where mime_type is |
| 248 // "text/html" and text_encoding is "UTF-8". |
| 181 virtual void loadHTMLString(const WebData& html, | 249 virtual void loadHTMLString(const WebData& html, |
| 182 const WebURL& baseURL, | 250 const WebURL& baseURL, |
| 183 const WebURL& unreachableURL = WebURL(), | 251 const WebURL& unreachableURL = WebURL(), |
| 184 bool replace = false) = 0; | 252 bool replace = false) = 0; |
| 185 | 253 |
| 186 virtual bool isLoading() = 0; | 254 // Returns true if the current frame is busy loading content. |
| 255 virtual bool isLoading() const = 0; |
| 187 | 256 |
| 188 // Stops any pending loads on the frame and its children. | 257 // Stops any pending loads on the frame and its children. |
| 189 virtual void stopLoading() = 0; | 258 virtual void stopLoading() = 0; |
| 190 | 259 |
| 191 // Returns the data source that is currently loading. May be null. | 260 // Returns the data source that is currently loading. May be null. |
| 192 virtual WebDataSource* provisionalDataSource() = 0; | 261 virtual WebDataSource* provisionalDataSource() const = 0; |
| 193 | 262 |
| 194 // Returns the data source that is currently loaded. | 263 // Returns the data source that is currently loaded. |
| 195 virtual WebDataSource* dataSource() = 0; | 264 virtual WebDataSource* dataSource() const = 0; |
| 196 | 265 |
| 197 // Returns the previous history item. Check WebHistoryItem::isNull() | 266 // Returns the previous history item. Check WebHistoryItem::isNull() |
| 198 // before using. | 267 // before using. |
| 199 virtual WebHistoryItem previousHistoryItem() = 0; | 268 virtual WebHistoryItem previousHistoryItem() const = 0; |
| 200 | 269 |
| 201 // Returns the current history item. Check WebHistoryItem::isNull() | 270 // Returns the current history item. Check WebHistoryItem::isNull() |
| 202 // before using. | 271 // before using. |
| 203 virtual WebHistoryItem currentHistoryItem() = 0; | 272 virtual WebHistoryItem currentHistoryItem() const = 0; |
| 204 | 273 |
| 205 // View-source rendering mode. Set this before loading an URL to cause | 274 // View-source rendering mode. Set this before loading an URL to cause |
| 206 // it to be rendered in view-source mode. | 275 // it to be rendered in view-source mode. |
| 207 virtual void enableViewSourceMode(bool) = 0; | 276 virtual void enableViewSourceMode(bool) = 0; |
| 208 virtual bool isViewSourceModeEnabled() = 0; | 277 virtual bool isViewSourceModeEnabled() const = 0; |
| 209 | 278 |
| 279 // Called to associate the WebURLRequest with this frame. The request |
| 280 // will be modified to inherit parameters that allow it to be loaded. |
| 281 // This method ends up triggering WebFrameClient::willSendRequest. |
| 282 virtual void dispatchWillSendRequest(WebURLRequest&) = 0; |
| 210 | 283 |
| 211 // App-cache ----------------------------------------------------------- | 284 // Called from within WebFrameClient::didReceiveDocumentData to commit |
| 285 // data for the frame that will be used to construct the frame's |
| 286 // document. |
| 287 virtual void commitDocumentData(const char* data, size_t length) = 0; |
| 212 | 288 |
| 213 virtual void selectAppCacheWithoutManifest() = 0; | 289 // Returns the number of registered unload listeners. |
| 214 virtual void selectAppCacheWithManifest(const WebURL& manifest) = 0; | 290 virtual unsigned unloadListenerCount() const = 0; |
| 215 | |
| 216 // Will be null if an app cache has not been selected. | |
| 217 virtual WebAppCacheContext* appCacheContext() = 0; | |
| 218 | 291 |
| 219 | 292 |
| 220 // Editing ------------------------------------------------------------- | 293 // Editing ------------------------------------------------------------- |
| 221 | 294 |
| 222 // Replaces the selection with the given text. | 295 // Replaces the selection with the given text. |
| 223 virtual void replaceSelection(const WebString& text) = 0; | 296 virtual void replaceSelection(const WebString& text) = 0; |
| 224 | 297 |
| 298 virtual void insertText(const WebString& text) = 0; |
| 299 |
| 300 virtual void setMarkedText(const WebString& text, unsigned location, unsigned length) = 0; |
| 301 virtual void unmarkText() = 0; |
| 302 virtual bool hasMarkedText() const = 0; |
| 303 |
| 304 virtual WebRange markedRange() const = 0; |
| 305 |
| 225 // See EditorCommand.cpp for the list of supported commands. | 306 // See EditorCommand.cpp for the list of supported commands. |
| 226 virtual void executeCommand(const WebString&) = 0; | 307 virtual bool executeCommand(const WebString&) = 0; |
| 227 virtual void executeCommand(const WebString&, const WebString& value) = 0; | 308 virtual bool executeCommand(const WebString&, const WebString& value) = 0; |
| 228 virtual bool isCommandEnabled(const WebString&); | 309 virtual bool isCommandEnabled(const WebString&) const = 0; |
| 229 | 310 |
| 230 // Spell-checking support. | 311 // Spell-checking support. |
| 231 virtual void enableContinuousSpellChecking(bool) = 0; | 312 virtual void enableContinuousSpellChecking(bool) = 0; |
| 232 virtual bool isContinuousSpellCheckingEnabled() = 0; | 313 virtual bool isContinuousSpellCheckingEnabled() const = 0; |
| 233 | 314 |
| 234 | 315 |
| 235 // Selection ----------------------------------------------------------- | 316 // Selection ----------------------------------------------------------- |
| 236 | 317 |
| 237 virtual void selectAll() = 0; | 318 virtual void selectAll() = 0; |
| 238 virtual void selectNone() = 0; | 319 virtual void clearSelection() = 0; |
| 320 virtual bool hasSelection() const = 0; |
| 239 | 321 |
| 240 virtual WebString selectionAsText() = 0; | 322 virtual WebRange selectionRange() const = 0; |
| 241 virtual WebString selectionAsHTML() = 0; | 323 |
| 324 virtual WebString selectionAsText() const = 0; |
| 325 virtual WebString selectionAsMarkup() const = 0; |
| 242 | 326 |
| 243 | 327 |
| 244 // Printing ------------------------------------------------------------ | 328 // Printing ------------------------------------------------------------ |
| 245 | 329 |
| 246 // Reformats the WebFrame for printing. pageSize is the page size in | 330 // Reformats the WebFrame for printing. pageSize is the page size in |
| 247 // pixels. Returns the number of pages that can be printed at the | 331 // pixels. Returns the number of pages that can be printed at the |
| 248 // given page size. | 332 // given page size. |
| 249 virtual int printBegin(const WebSize& pageSize); | 333 virtual int printBegin(const WebSize& pageSize) = 0; |
| 250 | 334 |
| 251 // Prints one page, and returns the calculated page shrinking factor | 335 // Prints one page, and returns the calculated page shrinking factor |
| 252 // (usually between 1/1.25 and 1/2). Returns 0 if the page number is | 336 // (usually between 1/1.25 and 1/2). Returns 0 if the page number is |
| 253 // invalid or not in printing mode. | 337 // invalid or not in printing mode. |
| 254 virtual float printPage(int pageToPrint, const WebCanvas&); | 338 virtual float printPage(int pageToPrint, WebCanvas*) = 0; |
| 255 | 339 |
| 256 // Reformats the WebFrame for screen display. | 340 // Reformats the WebFrame for screen display. |
| 257 virtual void printEnd(); | 341 virtual void printEnd() = 0; |
| 258 | 342 |
| 259 | 343 |
| 260 // Find-in-page -------------------------------------------------------- | 344 // Find-in-page -------------------------------------------------------- |
| 261 | 345 |
| 262 // FIXME | 346 // Searches a frame for a given string. |
| 347 // |
| 348 // If a match is found, this function will select it (scrolling down to |
| 349 // make it visible if needed) and fill in selectionRect with the |
| 350 // location of where the match was found (in window coordinates). |
| 351 // |
| 352 // If no match is found, this function clears all tickmarks and |
| 353 // highlighting. |
| 354 // |
| 355 // Returns true if the search string was found, false otherwise. |
| 356 virtual bool find(int identifier, |
| 357 const WebString& searchText, |
| 358 const WebFindOptions& options, |
| 359 bool wrapWithinFrame, |
| 360 WebRect* selectionRect) = 0; |
| 361 |
| 362 // Notifies the frame that we are no longer interested in searching. |
| 363 // This will abort any asynchronous scoping effort already under way |
| 364 // (see the function scopeStringMatches for details) and erase all |
| 365 // tick-marks and highlighting from the previous search. If |
| 366 // clearSelection is true, it will also make sure the end state for the |
| 367 // find operation does not leave a selection. This can occur when the |
| 368 // user clears the search string but does not close the find box. |
| 369 virtual void stopFinding(bool clearSelection) = 0; |
| 370 |
| 371 // Counts how many times a particular string occurs within the frame. |
| 372 // It also retrieves the location of the string and updates a vector in |
| 373 // the frame so that tick-marks and highlighting can be drawn. This |
| 374 // function does its work asynchronously, by running for a certain |
| 375 // time-slice and then scheduling itself (co-operative multitasking) to |
| 376 // be invoked later (repeating the process until all matches have been |
| 377 // found). This allows multiple frames to be searched at the same time |
| 378 // and provides a way to cancel at any time (see |
| 379 // cancelPendingScopingEffort). The parameter searchText specifies |
| 380 // what to look for and |reset| signals whether this is a brand new |
| 381 // request or a continuation of the last scoping effort. |
| 382 virtual void scopeStringMatches(int identifier, |
| 383 const WebString& searchText, |
| 384 const WebFindOptions& options, |
| 385 bool reset) = 0; |
| 386 |
| 387 // Cancels any outstanding requests for scoping string matches on a frame. |
| 388 virtual void cancelPendingScopingEffort() = 0; |
| 389 |
| 390 // This function is called on the main frame during the scoping effort |
| 391 // to keep a running tally of the accumulated total match-count for all |
| 392 // frames. After updating the count it will notify the WebViewClient |
| 393 // about the new count. |
| 394 virtual void increaseMatchCount(int count, int identifier) = 0; |
| 395 |
| 396 // Notifies the WebViewClient about a new selection rect. This will |
| 397 // result in the browser getting notified. For more information see |
| 398 // WebViewClient. |
| 399 virtual void reportFindInPageSelection(const WebRect& selectionRect, |
| 400 int activeMatchOrdinal, |
| 401 int identifier) = 0; |
| 402 |
| 403 // This function is called on the main frame to reset the total number |
| 404 // of matches found during the scoping effort. |
| 405 virtual void resetMatchCount() = 0; |
| 406 |
| 407 |
| 408 // Utility ------------------------------------------------------------- |
| 409 |
| 410 // Returns the contents of this frame as a string. If the text is |
| 411 // longer than maxChars, it will be clipped to that length. WARNING: |
| 412 // This function may be slow depending on the number of characters |
| 413 // retrieved and page complexity. For a typically sized page, expect |
| 414 // it to take on the order of milliseconds. |
| 415 // |
| 416 // If there is room, subframe text will be recursively appended. Each |
| 417 // frame will be separated by an empty line. |
| 418 virtual WebString contentAsText(size_t maxChars) const = 0; |
| 419 |
| 420 // Returns HTML text for the contents of this frame. This is generated |
| 421 // from the DOM. |
| 422 virtual WebString contentAsMarkup() const = 0; |
| 263 }; | 423 }; |
| 264 | 424 |
| 265 } // namespace WebKit | 425 } // namespace WebKit |
| 266 | 426 |
| 267 #endif | 427 #endif |
| OLD | NEW |