| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, 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 | 5 * modification, are permitted provided that the following conditions are |
| 6 * are met: | 6 * met: |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | 7 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 8 * * Redistributions of source code must retain the above copyright |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 9 * notice, this list of conditions and the following disclaimer. |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 10 * * Redistributions in binary form must reproduce the above |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 11 * copyright notice, this list of conditions and the following disclaimer |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 12 * in the documentation and/or other materials provided with the |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 13 * distribution. |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 14 * * Neither the name of Google Inc. nor the names of its |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 15 * contributors may be used to endorse or promote products derived from |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 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 |
| 22 * (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 |
| 23 * 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. |
| 24 */ | 29 */ |
| 25 | 30 |
| 26 #ifndef WEBKIT_GLUE_WEBFRAME_IMPL_H_ | 31 #ifndef WebFrameImpl_h |
| 27 #define WEBKIT_GLUE_WEBFRAME_IMPL_H_ | 32 #define WebFrameImpl_h |
| 28 | 33 |
| 29 #include "Frame.h" | 34 #include "Frame.h" |
| 35 #include "FrameLoaderClientImpl.h" |
| 30 #include "PlatformString.h" | 36 #include "PlatformString.h" |
| 37 // FIXME: remove this relative path once consumers from glue are removed. |
| 38 #include "../public/WebFrame.h" |
| 31 #include <wtf/OwnPtr.h> | 39 #include <wtf/OwnPtr.h> |
| 32 #include <wtf/RefCounted.h> | 40 #include <wtf/RefCounted.h> |
| 33 | 41 |
| 34 #include "webkit/api/public/WebFrame.h" | |
| 35 #include "webkit/glue/webframeloaderclient_impl.h" | |
| 36 | |
| 37 class ChromePrintContext; | |
| 38 class WebViewImpl; | |
| 39 | |
| 40 namespace gfx { | |
| 41 class BitmapPlatformDevice; | |
| 42 } | |
| 43 | |
| 44 namespace WebCore { | 42 namespace WebCore { |
| 45 class HistoryItem; | 43 class HistoryItem; |
| 46 class KURL; | 44 class KURL; |
| 47 class Node; | 45 class Node; |
| 48 class Range; | 46 class Range; |
| 49 class SubstituteData; | 47 class SubstituteData; |
| 50 struct WindowFeatures; | 48 struct WindowFeatures; |
| 51 } | 49 } |
| 52 | 50 |
| 53 namespace WebKit { | 51 namespace WebKit { |
| 52 class ChromePrintContext; |
| 54 class PasswordAutocompleteListener; | 53 class PasswordAutocompleteListener; |
| 55 class WebDataSourceImpl; | 54 class WebDataSourceImpl; |
| 56 class WebFrameClient; | 55 class WebFrameClient; |
| 57 class WebView; | 56 class WebView; |
| 58 } | 57 class WebViewImpl; |
| 59 | 58 |
| 60 // Implementation of WebFrame, note that this is a reference counted object. | 59 // Implementation of WebFrame, note that this is a reference counted object. |
| 61 class WebFrameImpl : public WebKit::WebFrame, public RefCounted<WebFrameImpl> { | 60 class WebFrameImpl : public WebFrame, public RefCounted<WebFrameImpl> { |
| 62 public: | 61 public: |
| 63 // WebFrame methods: | 62 // WebFrame methods: |
| 64 virtual WebKit::WebString name() const; | 63 virtual WebString name() const; |
| 65 virtual WebKit::WebURL url() const; | 64 virtual WebURL url() const; |
| 66 virtual WebKit::WebURL favIconURL() const; | 65 virtual WebURL favIconURL() const; |
| 67 virtual WebKit::WebURL openSearchDescriptionURL() const; | 66 virtual WebURL openSearchDescriptionURL() const; |
| 68 virtual WebKit::WebSize scrollOffset() const; | 67 virtual WebSize scrollOffset() const; |
| 69 virtual WebKit::WebSize contentsSize() const; | 68 virtual WebSize contentsSize() const; |
| 70 virtual int contentsPreferredWidth() const; | 69 virtual int contentsPreferredWidth() const; |
| 71 virtual bool hasVisibleContent() const; | 70 virtual bool hasVisibleContent() const; |
| 72 virtual WebKit::WebView* view() const; | 71 virtual WebView* view() const; |
| 73 virtual WebKit::WebFrame* opener() const; | 72 virtual WebFrame* opener() const; |
| 74 virtual WebKit::WebFrame* parent() const; | 73 virtual WebFrame* parent() const; |
| 75 virtual WebKit::WebFrame* top() const; | 74 virtual WebFrame* top() const; |
| 76 virtual WebKit::WebFrame* firstChild() const; | 75 virtual WebFrame* firstChild() const; |
| 77 virtual WebKit::WebFrame* lastChild() const; | 76 virtual WebFrame* lastChild() const; |
| 78 virtual WebKit::WebFrame* nextSibling() const; | 77 virtual WebFrame* nextSibling() const; |
| 79 virtual WebKit::WebFrame* previousSibling() const; | 78 virtual WebFrame* previousSibling() const; |
| 80 virtual WebKit::WebFrame* traverseNext(bool wrap) const; | 79 virtual WebFrame* traverseNext(bool wrap) const; |
| 81 virtual WebKit::WebFrame* traversePrevious(bool wrap) const; | 80 virtual WebFrame* traversePrevious(bool wrap) const; |
| 82 virtual WebKit::WebFrame* findChildByName(const WebKit::WebString& name) const; | 81 virtual WebFrame* findChildByName(const WebString&) const; |
| 83 virtual WebKit::WebFrame* findChildByExpression( | 82 virtual WebFrame* findChildByExpression(const WebString&) const; |
| 84 const WebKit::WebString& xpath) const; | 83 virtual void forms(WebVector<WebForm>&) const; |
| 85 virtual void forms(WebKit::WebVector<WebKit::WebForm>&) const; | 84 virtual WebSecurityOrigin securityOrigin() const; |
| 86 virtual WebKit::WebSecurityOrigin securityOrigin() const; | 85 virtual void grantUniversalAccess(); |
| 87 virtual void grantUniversalAccess(); | 86 virtual NPObject* windowObject() const; |
| 88 virtual NPObject* windowObject() const; | 87 virtual void bindToWindowObject(const WebString& name, NPObject*); |
| 89 virtual void bindToWindowObject( | 88 virtual void executeScript(const WebScriptSource&); |
| 90 const WebKit::WebString& name, NPObject* object); | 89 virtual void executeScriptInNewContext( |
| 91 virtual void executeScript(const WebKit::WebScriptSource&); | 90 const WebScriptSource* sources, unsigned numSources, int extensionGroup); |
| 92 virtual void executeScriptInNewContext( | 91 virtual void executeScriptInIsolatedWorld( |
| 93 const WebKit::WebScriptSource* sources, unsigned num_sources, | 92 int worldId, const WebScriptSource* sources, unsigned numSources, |
| 94 int extension_group); | 93 int extensionGroup); |
| 95 virtual void executeScriptInIsolatedWorld( | 94 virtual void addMessageToConsole(const WebConsoleMessage&); |
| 96 int world_id, const WebKit::WebScriptSource* sources, | 95 virtual void collectGarbage(); |
| 97 unsigned num_sources, int extension_group); | |
| 98 virtual void addMessageToConsole(const WebKit::WebConsoleMessage&); | |
| 99 virtual void collectGarbage(); | |
| 100 #if WEBKIT_USING_V8 | 96 #if WEBKIT_USING_V8 |
| 101 virtual v8::Local<v8::Context> mainWorldScriptContext() const; | 97 virtual v8::Local<v8::Context> mainWorldScriptContext() const; |
| 102 #endif | 98 #endif |
| 103 virtual bool insertStyleText( | 99 virtual bool insertStyleText(const WebString& css, const WebString& id); |
| 104 const WebKit::WebString& css, const WebKit::WebString& id); | 100 virtual void reload(); |
| 105 virtual void reload(); | 101 virtual void loadRequest(const WebURLRequest&); |
| 106 virtual void loadRequest(const WebKit::WebURLRequest& request); | 102 virtual void loadHistoryItem(const WebHistoryItem&); |
| 107 virtual void loadHistoryItem(const WebKit::WebHistoryItem& history_item); | 103 virtual void loadData( |
| 108 virtual void loadData( | 104 const WebData&, const WebString& mimeType, const WebString& textEncoding, |
| 109 const WebKit::WebData& data, const WebKit::WebString& mime_type, | 105 const WebURL& baseURL, const WebURL& unreachableURL, bool replace); |
| 110 const WebKit::WebString& text_encoding, const WebKit::WebURL& base_url, | 106 virtual void loadHTMLString( |
| 111 const WebKit::WebURL& unreachable_url, bool replace); | 107 const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL, |
| 112 virtual void loadHTMLString( | 108 bool replace); |
| 113 const WebKit::WebData& html, const WebKit::WebURL& base_url, | 109 virtual bool isLoading() const; |
| 114 const WebKit::WebURL& unreachable_url, bool replace); | 110 virtual void stopLoading(); |
| 115 virtual bool isLoading() const; | 111 virtual WebDataSource* provisionalDataSource() const; |
| 116 virtual void stopLoading(); | 112 virtual WebDataSource* dataSource() const; |
| 117 virtual WebKit::WebDataSource* provisionalDataSource() const; | 113 virtual WebHistoryItem previousHistoryItem() const; |
| 118 virtual WebKit::WebDataSource* dataSource() const; | 114 virtual WebHistoryItem currentHistoryItem() const; |
| 119 virtual WebKit::WebHistoryItem previousHistoryItem() const; | 115 virtual void enableViewSourceMode(bool enable); |
| 120 virtual WebKit::WebHistoryItem currentHistoryItem() const; | 116 virtual bool isViewSourceModeEnabled() const; |
| 121 virtual void enableViewSourceMode(bool enable); | 117 virtual void setReferrerForRequest(WebURLRequest&, const WebURL& referrer); |
| 122 virtual bool isViewSourceModeEnabled() const; | 118 virtual void dispatchWillSendRequest(WebURLRequest&); |
| 123 virtual void setReferrerForRequest( | 119 virtual void commitDocumentData(const char* data, size_t length); |
| 124 WebKit::WebURLRequest& request, const WebKit::WebURL& referrer); | 120 virtual unsigned unloadListenerCount() const; |
| 125 virtual void dispatchWillSendRequest(WebKit::WebURLRequest& request); | 121 virtual bool isProcessingUserGesture() const; |
| 126 virtual void commitDocumentData(const char* data, size_t length); | 122 virtual bool willSuppressOpenerInNewFrame() const; |
| 127 virtual unsigned unloadListenerCount() const; | 123 virtual void replaceSelection(const WebString&); |
| 128 virtual bool isProcessingUserGesture() const; | 124 virtual void insertText(const WebString&); |
| 129 virtual bool willSuppressOpenerInNewFrame() const; | 125 virtual void setMarkedText(const WebString&, unsigned location, unsigned length); |
| 130 virtual void replaceSelection(const WebKit::WebString& text); | 126 virtual void unmarkText(); |
| 131 virtual void insertText(const WebKit::WebString& text); | 127 virtual bool hasMarkedText() const; |
| 132 virtual void setMarkedText( | 128 virtual WebRange markedRange() const; |
| 133 const WebKit::WebString& text, unsigned location, unsigned length); | 129 virtual bool executeCommand(const WebString&); |
| 134 virtual void unmarkText(); | 130 virtual bool executeCommand(const WebString&, const WebString& value); |
| 135 virtual bool hasMarkedText() const; | 131 virtual bool isCommandEnabled(const WebString&) const; |
| 136 virtual WebKit::WebRange markedRange() const; | 132 virtual void enableContinuousSpellChecking(bool); |
| 137 virtual bool executeCommand(const WebKit::WebString& command); | 133 virtual bool isContinuousSpellCheckingEnabled() const; |
| 138 virtual bool executeCommand( | 134 virtual bool hasSelection() const; |
| 139 const WebKit::WebString& command, const WebKit::WebString& value); | 135 virtual WebRange selectionRange() const; |
| 140 virtual bool isCommandEnabled(const WebKit::WebString& command) const; | 136 virtual WebString selectionAsText() const; |
| 141 virtual void enableContinuousSpellChecking(bool enable); | 137 virtual WebString selectionAsMarkup() const; |
| 142 virtual bool isContinuousSpellCheckingEnabled() const; | 138 virtual int printBegin(const WebSize& pageSize); |
| 143 virtual bool hasSelection() const; | 139 virtual float printPage(int pageToPrint, WebCanvas*); |
| 144 virtual WebKit::WebRange selectionRange() const; | 140 virtual float getPrintPageShrink(int page); |
| 145 virtual WebKit::WebString selectionAsText() const; | 141 virtual void printEnd(); |
| 146 virtual WebKit::WebString selectionAsMarkup() const; | 142 virtual bool find( |
| 147 virtual int printBegin(const WebKit::WebSize& page_size); | 143 int identifier, const WebString& searchText, const WebFindOptions&, |
| 148 virtual float printPage(int page_to_print, WebKit::WebCanvas* canvas); | 144 bool wrapWithinFrame, WebRect* selectionRect); |
| 149 virtual float getPrintPageShrink(int page); | 145 virtual void stopFinding(bool clearSelection); |
| 150 virtual void printEnd(); | 146 virtual void scopeStringMatches( |
| 151 virtual bool find( | 147 int identifier, const WebString& searchText, const WebFindOptions&, |
| 152 int identifier, const WebKit::WebString& search_text, | 148 bool reset); |
| 153 const WebKit::WebFindOptions& options, bool wrap_within_frame, | 149 virtual void cancelPendingScopingEffort(); |
| 154 WebKit::WebRect* selection_rect); | 150 virtual void increaseMatchCount(int count, int identifier); |
| 155 virtual void stopFinding(bool clear_selection); | 151 virtual void resetMatchCount(); |
| 156 virtual void scopeStringMatches( | 152 virtual WebURL completeURL(const WebString& url) const; |
| 157 int identifier, const WebKit::WebString& search_text, | 153 virtual WebString contentAsText(size_t maxChars) const; |
| 158 const WebKit::WebFindOptions& options, bool reset); | 154 virtual WebString contentAsMarkup() const; |
| 159 virtual void cancelPendingScopingEffort(); | 155 |
| 160 virtual void increaseMatchCount(int count, int identifier); | 156 static PassRefPtr<WebFrameImpl> create(WebFrameClient* client); |
| 161 virtual void resetMatchCount(); | 157 ~WebFrameImpl(); |
| 162 virtual WebKit::WebURL completeURL(const WebKit::WebString& url) const; | 158 |
| 163 virtual WebKit::WebString contentAsText(size_t max_chars) const; | 159 static int liveObjectCount() { |
| 164 virtual WebKit::WebString contentAsMarkup() const; | 160 return m_liveObjectCount; |
| 165 | |
| 166 static PassRefPtr<WebFrameImpl> create(WebKit::WebFrameClient* client); | |
| 167 ~WebFrameImpl(); | |
| 168 | |
| 169 static int live_object_count() { | |
| 170 return live_object_count_; | |
| 171 } | |
| 172 | |
| 173 // Called by the WebViewImpl to initialize its main frame: | |
| 174 void InitMainFrame(WebViewImpl* webview_impl); | |
| 175 | |
| 176 PassRefPtr<WebCore::Frame> CreateChildFrame( | |
| 177 const WebCore::FrameLoadRequest&, | |
| 178 WebCore::HTMLFrameOwnerElement* owner_element); | |
| 179 | |
| 180 void Layout(); | |
| 181 void Paint(WebKit::WebCanvas* canvas, const WebKit::WebRect& rect); | |
| 182 | |
| 183 void CreateFrameView(); | |
| 184 | |
| 185 WebCore::Frame* frame() const { | |
| 186 return frame_; | |
| 187 } | |
| 188 | |
| 189 static WebFrameImpl* FromFrame(WebCore::Frame* frame); | |
| 190 | |
| 191 WebViewImpl* GetWebViewImpl() const; | |
| 192 | |
| 193 WebCore::FrameView* frameview() const { | |
| 194 return frame_ ? frame_->view() : NULL; | |
| 195 } | |
| 196 | |
| 197 // Getters for the impls corresponding to Get(Provisional)DataSource. They | |
| 198 // may return NULL if there is no corresponding data source. | |
| 199 WebKit::WebDataSourceImpl* GetDataSourceImpl() const; | |
| 200 WebKit::WebDataSourceImpl* GetProvisionalDataSourceImpl() const; | |
| 201 | |
| 202 // Returns which frame has an active match. This function should only be | |
| 203 // called on the main frame, as it is the only frame keeping track. Returned | |
| 204 // value can be NULL if no frame has an active match. | |
| 205 const WebFrameImpl* active_match_frame() const { | |
| 206 return active_match_frame_; | |
| 207 } | |
| 208 | |
| 209 // When a Find operation ends, we want to set the selection to what was active | |
| 210 // and set focus to the first focusable node we find (starting with the first | |
| 211 // node in the matched range and going up the inheritance chain). If we find | |
| 212 // nothing to focus we focus the first focusable node in the range. This | |
| 213 // allows us to set focus to a link (when we find text inside a link), which | |
| 214 // allows us to navigate by pressing Enter after closing the Find box. | |
| 215 void SetFindEndstateFocusAndSelection(); | |
| 216 | |
| 217 void DidFail(const WebCore::ResourceError& error, bool was_provisional); | |
| 218 | |
| 219 // Sets whether the WebFrameImpl allows its document to be scrolled. | |
| 220 // If the parameter is true, allow the document to be scrolled. | |
| 221 // Otherwise, disallow scrolling. | |
| 222 void SetAllowsScrolling(bool flag); | |
| 223 | |
| 224 // Registers a listener for the specified user name input element. The | |
| 225 // listener will receive notifications for blur and when autocomplete should | |
| 226 // be triggered. | |
| 227 // The WebFrameImpl becomes the owner of the passed listener. | |
| 228 void RegisterPasswordListener( | |
| 229 PassRefPtr<WebCore::HTMLInputElement> user_name_input_element, | |
| 230 WebKit::PasswordAutocompleteListener* listener); | |
| 231 | |
| 232 // Returns the password autocomplete listener associated with the passed | |
| 233 // user name input element, or NULL if none available. | |
| 234 // Note that the returned listener is owner by the WebFrameImpl and should not | |
| 235 // be kept around as it is deleted when the page goes away. | |
| 236 WebKit::PasswordAutocompleteListener* GetPasswordListener( | |
| 237 WebCore::HTMLInputElement* user_name_input_element); | |
| 238 | |
| 239 WebKit::WebFrameClient* client() const { return client_handle_->client(); } | |
| 240 void drop_client() { client_handle_->drop_client(); } | |
| 241 | |
| 242 protected: | |
| 243 friend class WebFrameLoaderClient; | |
| 244 | |
| 245 // A weak reference to the WebFrameClient. Each WebFrame in the hierarchy | |
| 246 // owns a reference to a ClientHandle. When the main frame is destroyed, it | |
| 247 // clears the WebFrameClient. | |
| 248 class ClientHandle : public RefCounted<ClientHandle> { | |
| 249 public: | |
| 250 static PassRefPtr<ClientHandle> create(WebKit::WebFrameClient* client) { | |
| 251 return adoptRef(new ClientHandle(client)); | |
| 252 } | 161 } |
| 253 WebKit::WebFrameClient* client() { return client_; } | 162 |
| 254 void drop_client() { client_ = NULL; } | 163 // Called by the WebViewImpl to initialize its main frame: |
| 255 private: | 164 void initializeAsMainFrame(WebViewImpl*); |
| 256 ClientHandle(WebKit::WebFrameClient* client) : client_(client) {} | 165 |
| 257 WebKit::WebFrameClient* client_; | 166 PassRefPtr<WebCore::Frame> createChildFrame( |
| 258 }; | 167 const WebCore::FrameLoadRequest&, WebCore::HTMLFrameOwnerElement*); |
| 259 | 168 |
| 260 WebFrameImpl(PassRefPtr<ClientHandle> client_handle); | 169 void layout(); |
| 261 | 170 void paint(WebCanvas*, const WebRect&); |
| 262 // Informs the WebFrame that the Frame is being closed, called by the | 171 void createFrameView(); |
| 263 // WebFrameLoaderClient | 172 |
| 264 void Closing(); | 173 static WebFrameImpl* fromFrame(WebCore::Frame* frame); |
| 265 | 174 |
| 266 // Used to check for leaks of this object. | 175 WebViewImpl* viewImpl() const; |
| 267 static int live_object_count_; | 176 |
| 268 | 177 WebCore::Frame* frame() const { return m_frame; } |
| 269 WebFrameLoaderClient frame_loader_client_; | 178 WebCore::FrameView* frameView() const { return m_frame ? m_frame->view() : 0; } |
| 270 | 179 |
| 271 RefPtr<ClientHandle> client_handle_; | 180 // Getters for the impls corresponding to Get(Provisional)DataSource. They |
| 272 | 181 // may return NULL if there is no corresponding data source. |
| 273 // This is a weak pointer to our corresponding WebCore frame. A reference to | 182 WebDataSourceImpl* dataSourceImpl() const; |
| 274 // ourselves is held while frame_ is valid. See our Closing method. | 183 WebDataSourceImpl* provisionalDataSourceImpl() const; |
| 275 WebCore::Frame* frame_; | 184 |
| 276 | 185 // Returns which frame has an active match. This function should only be |
| 277 // A way for the main frame to keep track of which frame has an active | 186 // called on the main frame, as it is the only frame keeping track. Returned |
| 278 // match. Should be NULL for all other frames. | 187 // value can be NULL if no frame has an active match. |
| 279 WebFrameImpl* active_match_frame_; | 188 const WebFrameImpl* activeMatchFrame() const { return m_activeMatchFrame; } |
| 280 | 189 |
| 281 // The range of the active match for the current frame. | 190 // When a Find operation ends, we want to set the selection to what was active |
| 282 RefPtr<WebCore::Range> active_match_; | 191 // and set focus to the first focusable node we find (starting with the first |
| 283 | 192 // node in the matched range and going up the inheritance chain). If we find |
| 284 // The index of the active match. | 193 // nothing to focus we focus the first focusable node in the range. This |
| 285 int active_match_index_; | 194 // allows us to set focus to a link (when we find text inside a link), which |
| 286 | 195 // allows us to navigate by pressing Enter after closing the Find box. |
| 287 // This flag is used by the scoping effort to determine if we need to figure | 196 void setFindEndstateFocusAndSelection(); |
| 288 // out which rectangle is the active match. Once we find the active | 197 |
| 289 // rectangle we clear this flag. | 198 void didFail(const WebCore::ResourceError&, bool wasProvisional); |
| 290 bool locating_active_rect_; | 199 |
| 291 | 200 // Sets whether the WebFrameImpl allows its document to be scrolled. |
| 292 // The scoping effort can time out and we need to keep track of where we | 201 // If the parameter is true, allow the document to be scrolled. |
| 293 // ended our last search so we can continue from where we left of. | 202 // Otherwise, disallow scrolling. |
| 294 RefPtr<WebCore::Range> resume_scoping_from_range_; | 203 void setAllowsScrolling(bool); |
| 295 | 204 |
| 296 // Keeps track of the last string this frame searched for. This is used for | 205 // Registers a listener for the specified user name input element. The |
| 297 // short-circuiting searches in the following scenarios: When a frame has | 206 // listener will receive notifications for blur and when autocomplete should |
| 298 // been searched and returned 0 results, we don't need to search that frame | 207 // be triggered. |
| 299 // again if the user is just adding to the search (making it more specific). | 208 // The WebFrameImpl becomes the owner of the passed listener. |
| 300 string16 last_search_string_; | 209 void registerPasswordListener( |
| 301 | 210 PassRefPtr<WebCore::HTMLInputElement>, |
| 302 // Keeps track of how many matches this frame has found so far, so that we | 211 PasswordAutocompleteListener*); |
| 303 // don't loose count between scoping efforts, and is also used (in conjunction | 212 |
| 304 // with last_search_string_ and scoping_complete_) to figure out if we need to | 213 // Returns the password autocomplete listener associated with the passed |
| 305 // search the frame again. | 214 // user name input element, or NULL if none available. |
| 306 int last_match_count_; | 215 // Note that the returned listener is owner by the WebFrameImpl and should not |
| 307 | 216 // be kept around as it is deleted when the page goes away. |
| 308 // This variable keeps a cumulative total of matches found so far for ALL the | 217 PasswordAutocompleteListener* getPasswordListener(WebCore::HTMLInputElement*); |
| 309 // frames on the page, and is only incremented by calling IncreaseMatchCount | 218 |
| 310 // (on the main frame only). It should be -1 for all other frames. | 219 WebFrameClient* client() const { return m_clientHandle->client(); } |
| 311 size_t total_matchcount_; | 220 void dropClient() { m_clientHandle->dropClient(); } |
| 312 | 221 |
| 313 // This variable keeps a cumulative total of how many frames are currently | 222 private: |
| 314 // scoping, and is incremented/decremented on the main frame only. | 223 class DeferredScopeStringMatches; |
| 315 // It should be -1 for all other frames. | 224 friend class DeferredScopeStringMatches; |
| 316 int frames_scoping_count_; | 225 friend class FrameLoaderClientImpl; |
| 317 | 226 |
| 318 // Keeps track of whether the scoping effort was completed (the user may | 227 // A weak reference to the WebFrameClient. Each WebFrame in the hierarchy |
| 319 // interrupt it before it completes by submitting a new search). | 228 // owns a reference to a ClientHandle. When the main frame is destroyed, it |
| 320 bool scoping_complete_; | 229 // clears the WebFrameClient. |
| 321 | 230 class ClientHandle : public RefCounted<ClientHandle> { |
| 322 // Keeps track of when the scoping effort should next invalidate the scrollbar | 231 public: |
| 323 // and the frame area. | 232 static PassRefPtr<ClientHandle> create(WebFrameClient* client) |
| 324 int next_invalidate_after_; | 233 { |
| 325 | 234 return adoptRef(new ClientHandle(client)); |
| 326 private: | 235 } |
| 327 class DeferredScopeStringMatches; | 236 WebFrameClient* client() { return m_client; } |
| 328 friend class DeferredScopeStringMatches; | 237 void dropClient() { m_client = NULL; } |
| 329 | 238 private: |
| 330 // A bit mask specifying area of the frame to invalidate. | 239 ClientHandle(WebFrameClient* client) : m_client(client) {} |
| 331 enum AreaToInvalidate { | 240 WebFrameClient* m_client; |
| 332 INVALIDATE_NOTHING = 0, | 241 }; |
| 333 INVALIDATE_CONTENT_AREA = 1, | 242 |
| 334 INVALIDATE_SCROLLBAR = 2, // vertical scrollbar only. | 243 // A bit mask specifying area of the frame to invalidate. |
| 335 INVALIDATE_ALL = 3 // both content area and the scrollbar. | 244 enum AreaToInvalidate { |
| 336 }; | 245 InvalidateNothing, |
| 337 | 246 InvalidateContentArea, |
| 338 // Notifies the delegate about a new selection rect. | 247 InvalidateScrollbar, // Vertical scrollbar only. |
| 339 void ReportFindInPageSelection( | 248 InvalidateAll // Both content area and the scrollbar. |
| 340 const WebKit::WebRect& selection_rect, int active_match_ordinal, | 249 }; |
| 341 int identifier); | 250 |
| 342 | 251 WebFrameImpl(PassRefPtr<ClientHandle>); |
| 343 // Invalidates a certain area within the frame. | 252 |
| 344 void InvalidateArea(AreaToInvalidate area); | 253 // Informs the WebFrame that the Frame is being closed, called by the |
| 345 | 254 // WebFrameLoaderClient |
| 346 // Add a WebKit TextMatch-highlight marker to nodes in a range. | 255 void closing(); |
| 347 void AddMarker(WebCore::Range* range, bool active_match); | 256 |
| 348 | 257 // Notifies the delegate about a new selection rect. |
| 349 // Sets the markers within a range as active or inactive. | 258 void reportFindInPageSelection( |
| 350 void SetMarkerActive(WebCore::Range* range, bool active); | 259 const WebRect& selectionRect, int activeMatchOrdinal, int identifier); |
| 351 | 260 |
| 352 // Returns the ordinal of the first match in the frame specified. This | 261 // Invalidates a certain area within the frame. |
| 353 // function enumerates the frames, starting with the main frame and up to (but | 262 void invalidateArea(AreaToInvalidate); |
| 354 // not including) the frame passed in as a parameter and counts how many | 263 |
| 355 // matches have been found. | 264 // Add a WebKit TextMatch-highlight marker to nodes in a range. |
| 356 int OrdinalOfFirstMatchForFrame(WebFrameImpl* frame) const; | 265 void addMarker(WebCore::Range*, bool activeMatch); |
| 357 | 266 |
| 358 // Determines whether the scoping effort is required for a particular frame. | 267 // Sets the markers within a range as active or inactive. |
| 359 // It is not necessary if the frame is invisible, for example, or if this | 268 void setMarkerActive(WebCore::Range*, bool active); |
| 360 // is a repeat search that already returned nothing last time the same prefix | 269 |
| 361 // was searched. | 270 // Returns the ordinal of the first match in the frame specified. This |
| 362 bool ShouldScopeMatches(const string16& search_text); | 271 // function enumerates the frames, starting with the main frame and up to (but |
| 363 | 272 // not including) the frame passed in as a parameter and counts how many |
| 364 // Queue up a deferred call to scopeStringMatches. | 273 // matches have been found. |
| 365 void ScopeStringMatchesSoon( | 274 int ordinalOfFirstMatchForFrame(WebFrameImpl*) const; |
| 366 int identifier, const WebKit::WebString& search_text, | 275 |
| 367 const WebKit::WebFindOptions& options, bool reset); | 276 // Determines whether the scoping effort is required for a particular frame. |
| 368 | 277 // It is not necessary if the frame is invisible, for example, or if this |
| 369 // Called by a DeferredScopeStringMatches instance. | 278 // is a repeat search that already returned nothing last time the same prefix |
| 370 void CallScopeStringMatches( | 279 // was searched. |
| 371 DeferredScopeStringMatches* deferred, | 280 bool shouldScopeMatches(const WebCore::String& searchText); |
| 372 int identifier, const WebKit::WebString& search_text, | 281 |
| 373 const WebKit::WebFindOptions& options, bool reset); | 282 // Queue up a deferred call to scopeStringMatches. |
| 374 | 283 void scopeStringMatchesSoon( |
| 375 // Determines whether to invalidate the content area and scrollbar. | 284 int identifier, const WebString& searchText, const WebFindOptions&, |
| 376 void InvalidateIfNecessary(); | 285 bool reset); |
| 377 | 286 |
| 378 // Clears the map of password listeners. | 287 // Called by a DeferredScopeStringMatches instance. |
| 379 void ClearPasswordListeners(); | 288 void callScopeStringMatches( |
| 380 | 289 DeferredScopeStringMatches*, int identifier, const WebString& searchText, |
| 381 void LoadJavaScriptURL(const WebCore::KURL& url); | 290 const WebFindOptions&, bool reset); |
| 382 | 291 |
| 383 // A list of all of the pending calls to scopeStringMatches. | 292 // Determines whether to invalidate the content area and scrollbar. |
| 384 Vector<DeferredScopeStringMatches*> deferred_scoping_work_; | 293 void invalidateIfNecessary(); |
| 385 | 294 |
| 386 // Valid between calls to BeginPrint() and EndPrint(). Containts the print | 295 // Clears the map of password listeners. |
| 387 // information. Is used by PrintPage(). | 296 void clearPasswordListeners(); |
| 388 OwnPtr<ChromePrintContext> print_context_; | 297 |
| 389 | 298 void loadJavaScriptURL(const WebCore::KURL&); |
| 390 // The input fields that are interested in edit events and their associated | 299 |
| 391 // listeners. | 300 // Used to check for leaks of this object. |
| 392 typedef HashMap<RefPtr<WebCore::HTMLInputElement>, | 301 static int m_liveObjectCount; |
| 393 WebKit::PasswordAutocompleteListener*> PasswordListenerMap; | 302 |
| 394 PasswordListenerMap password_listeners_; | 303 FrameLoaderClientImpl m_frameLoaderClient; |
| 304 |
| 305 RefPtr<ClientHandle> m_clientHandle; |
| 306 |
| 307 // This is a weak pointer to our corresponding WebCore frame. A reference to |
| 308 // ourselves is held while frame_ is valid. See our Closing method. |
| 309 WebCore::Frame* m_frame; |
| 310 |
| 311 // A way for the main frame to keep track of which frame has an active |
| 312 // match. Should be NULL for all other frames. |
| 313 WebFrameImpl* m_activeMatchFrame; |
| 314 |
| 315 // The range of the active match for the current frame. |
| 316 RefPtr<WebCore::Range> m_activeMatch; |
| 317 |
| 318 // The index of the active match. |
| 319 int m_activeMatchIndex; |
| 320 |
| 321 // This flag is used by the scoping effort to determine if we need to figure |
| 322 // out which rectangle is the active match. Once we find the active |
| 323 // rectangle we clear this flag. |
| 324 bool m_locatingActiveRect; |
| 325 |
| 326 // The scoping effort can time out and we need to keep track of where we |
| 327 // ended our last search so we can continue from where we left of. |
| 328 RefPtr<WebCore::Range> m_resumeScopingFromRange; |
| 329 |
| 330 // Keeps track of the last string this frame searched for. This is used for |
| 331 // short-circuiting searches in the following scenarios: When a frame has |
| 332 // been searched and returned 0 results, we don't need to search that frame |
| 333 // again if the user is just adding to the search (making it more specific). |
| 334 WebCore::String m_lastSearchString; |
| 335 |
| 336 // Keeps track of how many matches this frame has found so far, so that we |
| 337 // don't loose count between scoping efforts, and is also used (in conjunction |
| 338 // with m_lastSearchString and m_scopingComplete) to figure out if we need to |
| 339 // search the frame again. |
| 340 int m_lastMatchCount; |
| 341 |
| 342 // This variable keeps a cumulative total of matches found so far for ALL the |
| 343 // frames on the page, and is only incremented by calling IncreaseMatchCount |
| 344 // (on the main frame only). It should be -1 for all other frames. |
| 345 size_t m_totalMatchCount; |
| 346 |
| 347 // This variable keeps a cumulative total of how many frames are currently |
| 348 // scoping, and is incremented/decremented on the main frame only. |
| 349 // It should be -1 for all other frames. |
| 350 int m_framesScopingCount; |
| 351 |
| 352 // Keeps track of whether the scoping effort was completed (the user may |
| 353 // interrupt it before it completes by submitting a new search). |
| 354 bool m_scopingComplete; |
| 355 |
| 356 // Keeps track of when the scoping effort should next invalidate the scrollbar |
| 357 // and the frame area. |
| 358 int m_nextInvalidateAfter; |
| 359 |
| 360 // A list of all of the pending calls to scopeStringMatches. |
| 361 Vector<DeferredScopeStringMatches*> m_deferredScopingWork; |
| 362 |
| 363 // Valid between calls to BeginPrint() and EndPrint(). Containts the print |
| 364 // information. Is used by PrintPage(). |
| 365 OwnPtr<ChromePrintContext> m_printContext; |
| 366 |
| 367 // The input fields that are interested in edit events and their associated |
| 368 // listeners. |
| 369 typedef HashMap<RefPtr<WebCore::HTMLInputElement>, |
| 370 PasswordAutocompleteListener*> PasswordListenerMap; |
| 371 PasswordListenerMap m_passwordListeners; |
| 395 }; | 372 }; |
| 396 | 373 |
| 397 #endif // WEBKIT_GLUE_WEBFRAME_IMPL_H_ | 374 } // namespace WebKit |
| 375 |
| 376 #endif |
| OLD | NEW |