diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-03 05:01:26 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-03 05:01:26 +0000 |
commit | 8922e1ff7ac33a3f88079e1e6d3ae8671602a952 (patch) | |
tree | a842ba34b909f84e7f3db6d60235504ad7887db2 /webkit | |
parent | 4b7d9b47a1adac0daa198761c01fc42ff1d9b394 (diff) | |
download | chromium_src-8922e1ff7ac33a3f88079e1e6d3ae8671602a952.zip chromium_src-8922e1ff7ac33a3f88079e1e6d3ae8671602a952.tar.gz chromium_src-8922e1ff7ac33a3f88079e1e6d3ae8671602a952.tar.bz2 |
More WebView / WebViewDelegate cleanup.
Moves a bunch of methods from glue to the WebKit API.
R=dglazkov
BUG=10033
TEST=none
Review URL: http://codereview.chromium.org/246079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebFrameClient.h | 19 | ||||
-rw-r--r-- | webkit/api/public/WebView.h | 9 | ||||
-rw-r--r-- | webkit/api/public/WebViewClient.h | 12 | ||||
-rw-r--r-- | webkit/glue/editor_client_impl.cc | 8 | ||||
-rw-r--r-- | webkit/glue/empty_webframeclient.h | 4 | ||||
-rw-r--r-- | webkit/glue/inspector_client_impl.cc | 10 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 18 | ||||
-rw-r--r-- | webkit/glue/webpreferences.cc | 3 | ||||
-rw-r--r-- | webkit/glue/webpreferences.h | 3 | ||||
-rw-r--r-- | webkit/glue/webview.h | 7 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 21 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 24 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 13 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 6 |
14 files changed, 74 insertions, 83 deletions
diff --git a/webkit/api/public/WebFrameClient.h b/webkit/api/public/WebFrameClient.h index 4d42965..6ef6e2d 100644 --- a/webkit/api/public/WebFrameClient.h +++ b/webkit/api/public/WebFrameClient.h @@ -50,6 +50,7 @@ namespace WebKit { class WebWorker; class WebWorkerClient; struct WebPluginParams; + struct WebRect; struct WebSize; struct WebURLError; @@ -221,8 +222,22 @@ namespace WebKit { virtual void didChangeContentsSize(WebFrame*, const WebSize&) = 0; - // FIXME need to add: - // find-in-page + // Find-in-page notifications ------------------------------------------ + + // Notifies how many matches have been found so far, for a given + // identifier. |finalUpdate| specifies whether this is the last update + // (all frames have completed scoping). + virtual void reportFindInPageMatchCount( + int identifier, int count, bool finalUpdate) = 0; + + // Notifies what tick-mark rect is currently selected. The given + // identifier lets the client know which request this message belongs + // to, so that it can choose to ignore the message if it has moved on + // to other things. The selection rect is expected to have coordinates + // relative to the top left corner of the web page area and represent + // where on the screen the selection rect is currently located. + virtual void reportFindInPageSelection( + int identifier, int activeMatchOrdinal, const WebRect& selection) = 0; protected: ~WebFrameClient() { } diff --git a/webkit/api/public/WebView.h b/webkit/api/public/WebView.h index 7904f95e..bf7896d 100644 --- a/webkit/api/public/WebView.h +++ b/webkit/api/public/WebView.h @@ -188,12 +188,13 @@ namespace WebKit { // point. virtual void inspectElementAt(const WebPoint&) = 0; + // Settings used by the inspector. + virtual WebString inspectorSettings() const = 0; + virtual void setInspectorSettings(const WebString&) = 0; + // FIXME what about: - // StoreFocusForFrame - // DownloadImage - // Get/SetDelegate - // InsertText -> should move to WebTextInput + // GetDelegate // AutofillSuggestionsForNode // HideAutofillPopup diff --git a/webkit/api/public/WebViewClient.h b/webkit/api/public/WebViewClient.h index b4e8a47..60691fa 100644 --- a/webkit/api/public/WebViewClient.h +++ b/webkit/api/public/WebViewClient.h @@ -144,6 +144,9 @@ namespace WebKit { // Show or hide the spelling UI. virtual void showSpellingUI(bool show) = 0; + // Returns true if the spelling UI is showing. + virtual bool isShowingSpellingUI() = 0; + // Update the spelling UI with the given word. virtual void updateSpellingUIWithMisspelledWord(const WebString& word) = 0; @@ -215,7 +218,7 @@ namespace WebKit { virtual void focusPrevious() = 0; - // Session History ----------------------------------------------------- + // Session history ----------------------------------------------------- // Tells the embedder to navigate back or forward in session history by // the given offset (relative to the current position in session @@ -231,6 +234,13 @@ namespace WebKit { virtual void didAddHistoryItem() = 0; + // Developer tools ----------------------------------------------------- + + // Called to notify the client that the inspector's settings were + // changed and should be saved. See WebView::inspectorSettings. + virtual void didUpdateInspectorSettings() = 0; + + // FIXME need to something for: // OnPasswordFormsSeen // OnAutofillFormSubmitted diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index 6a6af6c..7f57528 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -893,11 +893,9 @@ void EditorClientImpl::showSpellingUI(bool show) { } bool EditorClientImpl::spellingUIIsShowing() { - // SpellingPanel visibility is stored in the webview_ every time a toggle - // message is sent from the browser. If we were to send a message to the - // browser and ask for the visibility, then we run into problems accessing - // cocoa methods on the UI thread. - return webview_->GetSpellingPanelVisibility(); + if (webview_->client()) + return webview_->client()->isShowingSpellingUI(); + return false; } void EditorClientImpl::getGuessesForWord(const WebCore::String&, diff --git a/webkit/glue/empty_webframeclient.h b/webkit/glue/empty_webframeclient.h index 014ac8e..70c266d 100644 --- a/webkit/glue/empty_webframeclient.h +++ b/webkit/glue/empty_webframeclient.h @@ -86,6 +86,10 @@ class EmptyWebFrameClient : public WebKit::WebFrameClient { virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame) {} virtual void didChangeContentsSize( WebKit::WebFrame* frame, const WebKit::WebSize& size) {} + virtual void reportFindInPageMatchCount( + int identifier, int count, bool final_update) {} + virtual void reportFindInPageSelection( + int identifier, int ordinal, const WebKit::WebRect& selection) {} }; } // namespace webkit_glue diff --git a/webkit/glue/inspector_client_impl.cc b/webkit/glue/inspector_client_impl.cc index 694bf30..c2e5e53 100644 --- a/webkit/glue/inspector_client_impl.cc +++ b/webkit/glue/inspector_client_impl.cc @@ -157,8 +157,8 @@ void InspectorClientImpl::LoadSettings() { return; settings_.set(new SettingsMap); - String data = webkit_glue::StdWStringToString( - inspected_web_view_->GetInspectorSettings()); + String data = webkit_glue::WebStringToString( + inspected_web_view_->inspectorSettings()); if (data.isEmpty()) return; @@ -232,6 +232,8 @@ void InspectorClientImpl::SaveSettings() { data.append(entry); data.append("\n"); } - inspected_web_view_->delegate()->UpdateInspectorSettings( - webkit_glue::StringToStdWString(data)); + inspected_web_view_->setInspectorSettings( + webkit_glue::StringToWebString(data)); + if (inspected_web_view_->client()) + inspected_web_view_->client()->didUpdateInspectorSettings(); } diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 5b175c7..092bfc0 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -1434,23 +1434,19 @@ void WebFrameImpl::increaseMatchCount(int count, int request_id) { total_matchcount_ += count; // Update the UI with the latest findings. - WebViewDelegate* webview_delegate = GetWebViewImpl()->delegate(); - DCHECK(webview_delegate); - if (webview_delegate) - webview_delegate->ReportFindInPageMatchCount(total_matchcount_, request_id, - frames_scoping_count_ == 0); + if (client_) { + client_->reportFindInPageMatchCount( + request_id, total_matchcount_, frames_scoping_count_ == 0); + } } void WebFrameImpl::ReportFindInPageSelection(const WebRect& selection_rect, int active_match_ordinal, int request_id) { // Update the UI with the latest selection rect. - WebViewDelegate* webview_delegate = GetWebViewImpl()->delegate(); - DCHECK(webview_delegate); - if (webview_delegate) { - webview_delegate->ReportFindInPageSelection( - request_id, - OrdinalOfFirstMatchForFrame(this) + active_match_ordinal, + if (client_) { + client_->reportFindInPageSelection( + request_id, OrdinalOfFirstMatchForFrame(this) + active_match_ordinal, selection_rect); } } diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc index df437e6..07a0d77 100644 --- a/webkit/glue/webpreferences.cc +++ b/webkit/glue/webpreferences.cc @@ -13,6 +13,7 @@ #include "webkit/glue/webview.h" using WebKit::WebSettings; +using WebKit::WebString; using WebKit::WebURL; void WebPreferences::Apply(WebView* web_view) const { @@ -80,7 +81,7 @@ void WebPreferences::Apply(WebView* web_view) const { settings->setExperimentalWebGLEnabled(experimental_webgl_enabled); // Web inspector settings need to be passed in differently. - web_view->SetInspectorSettings(inspector_settings); + web_view->setInspectorSettings(WebString::fromUTF8(inspector_settings)); // Tabs to link is not part of the settings. WebCore calls // ChromeClient::tabsToLinks which is part of the glue code. diff --git a/webkit/glue/webpreferences.h b/webkit/glue/webpreferences.h index c626e27..1608d9d 100644 --- a/webkit/glue/webpreferences.h +++ b/webkit/glue/webpreferences.h @@ -35,7 +35,7 @@ struct WebPreferences { bool plugins_enabled; bool dom_paste_enabled; bool developer_extras_enabled; - std::wstring inspector_settings; + std::string inspector_settings; bool shrinks_standalone_images_to_fit; bool uses_universal_detector; bool text_areas_are_resizable; @@ -81,7 +81,6 @@ struct WebPreferences { plugins_enabled(true), dom_paste_enabled(false), // enables execCommand("paste") developer_extras_enabled(false), // Requires extra work by embedder - inspector_settings(L""), shrinks_standalone_images_to_fit(true), uses_universal_detector(false), // Disabled: page cycler regression text_areas_are_resizable(true), diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index a6fa6fe..cf290cb 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -69,10 +69,6 @@ class WebView : public WebKit::WebView { // using it, it will be NULL during closing of the view. virtual WebViewDelegate* GetDelegate() = 0; - // Settings used by inspector. - virtual const std::wstring& GetInspectorSettings() const = 0; - virtual void SetInspectorSettings(const std::wstring& settings) = 0; - // Notifies the webview that autofill suggestions are available for a node. virtual void AutofillSuggestionsForNode( int64 node_id, @@ -85,9 +81,6 @@ class WebView : public WebKit::WebView { // Returns development tools agent instance belonging to this view. virtual WebDevToolsAgent* GetWebDevToolsAgent() = 0; - virtual void SetSpellingPanelVisibility(bool is_visible) = 0; - virtual bool GetSpellingPanelVisibility() = 0; - // Performs an action from a context menu for the node at the given // location. virtual void MediaPlayerActionAt(int x, diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 1acf4ac..72e1997 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -70,24 +70,6 @@ class WebViewDelegate : public WebKit::WebViewClient { public: // WebView additions ------------------------------------------------------- - // Notifies how many matches have been found so far, for a given request_id. - // |final_update| specifies whether this is the last update (all frames have - // completed scoping). - virtual void ReportFindInPageMatchCount(int count, int request_id, - bool final_update) { - } - - // Notifies the browser what tick-mark rect is currently selected. Parameter - // |request_id| lets the recipient know which request this message belongs to, - // so that it can choose to ignore the message if it has moved on to other - // things. |selection_rect| is expected to have coordinates relative to the - // top left corner of the web page area and represent where on the screen the - // selection rect is currently located. - virtual void ReportFindInPageSelection(int request_id, - int active_match_ordinal, - const WebKit::WebRect& selection) { - } - // Returns whether this WebView was opened by a user gesture. virtual bool WasOpenedByUserGesture() const { return true; @@ -183,9 +165,6 @@ class WebViewDelegate : public WebKit::WebViewClient { const std::string& frame_charset) { } - // InspectorClient --------------------------------------------------------- - - virtual void UpdateInspectorSettings(const std::wstring& raw_settings) { } // DevTools ---------------------------------------------------------------- diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index fdc3f7a..8774069 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -1605,20 +1605,20 @@ void WebViewImpl::inspectElementAt(const WebPoint& point) { } } -// WebView -------------------------------------------------------------------- - -WebViewDelegate* WebViewImpl::GetDelegate() { - return delegate_; -} - -const std::wstring& WebViewImpl::GetInspectorSettings() const { +WebString WebViewImpl::inspectorSettings() const { return inspector_settings_; } -void WebViewImpl::SetInspectorSettings(const std::wstring& settings) { +void WebViewImpl::setInspectorSettings(const WebString& settings) { inspector_settings_ = settings; } +// WebView -------------------------------------------------------------------- + +WebViewDelegate* WebViewImpl::GetDelegate() { + return delegate_; +} + bool WebViewImpl::setDropEffect(bool accept) { if (drag_target_dispatch_) { drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE; @@ -1895,14 +1895,6 @@ HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { hitTestResultAtPoint(doc_point, false); } -void WebViewImpl::SetSpellingPanelVisibility(bool is_visible) { - spelling_panel_is_visible_ = is_visible; -} - -bool WebViewImpl::GetSpellingPanelVisibility() { - return spelling_panel_is_visible_; -} - void WebViewImpl::setTabsToLinks(bool enable) { tabs_to_links_ = enable; } diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index c8d64ae..dee9900 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -16,6 +16,7 @@ #include "skia/ext/platform_canvas.h" #include "webkit/api/public/WebPoint.h" #include "webkit/api/public/WebSize.h" +#include "webkit/api/public/WebString.h" #include "webkit/api/src/NotificationPresenterImpl.h" #include "webkit/glue/back_forward_list_client_impl.h" #include "webkit/glue/chrome_client_impl.h" @@ -130,11 +131,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual int dragIdentity(); virtual bool setDropEffect(bool accept); virtual void inspectElementAt(const WebKit::WebPoint& point); + virtual WebKit::WebString inspectorSettings() const; + virtual void setInspectorSettings(const WebKit::WebString& settings); // WebView methods: virtual WebViewDelegate* GetDelegate(); - virtual const std::wstring& GetInspectorSettings() const; - virtual void SetInspectorSettings(const std::wstring& settings); virtual void AutofillSuggestionsForNode( int64 node_id, const std::vector<std::wstring>& suggestions, @@ -249,9 +250,6 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // the underlying Node for them. WebCore::Node* GetNodeForWindowPos(int x, int y); - virtual void SetSpellingPanelVisibility(bool is_visible); - virtual bool GetSpellingPanelVisibility(); - #if ENABLE(NOTIFICATIONS) // Returns the provider of desktop notifications. WebKit::NotificationPresenterImpl* GetNotificationPresenter(); @@ -397,14 +395,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // Whether the webview is rendering transparently. bool is_transparent_; - // Whether the spelling panel is currently being displayed or not. - bool spelling_panel_is_visible_; - // Whether the user can press tab to focus links. bool tabs_to_links_; // Inspector settings. - std::wstring inspector_settings_; + WebKit::WebString inspector_settings_; #if ENABLE(NOTIFICATIONS) // The provider of desktop notifications; diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index f23b600..ccf4404 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -123,6 +123,7 @@ class TestWebViewDelegate : public WebViewDelegate, virtual WebKit::WebString autoCorrectWord( const WebKit::WebString& misspelled_word); virtual void showSpellingUI(bool show) {} + virtual bool isShowingSpellingUI() { return false; } virtual void updateSpellingUIWithMisspelledWord( const WebKit::WebString& word) {} virtual void runModalAlertDialog( @@ -148,6 +149,7 @@ class TestWebViewDelegate : public WebViewDelegate, virtual int historyBackListCount(); virtual int historyForwardListCount(); virtual void didAddHistoryItem() {} + virtual void didUpdateInspectorSettings() {} // WebKit::WebWidgetClient virtual void didInvalidateRect(const WebKit::WebRect& rect); @@ -230,6 +232,10 @@ class TestWebViewDelegate : public WebViewDelegate, virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame*) {} virtual void didChangeContentsSize( WebKit::WebFrame*, const WebKit::WebSize&) {} + virtual void reportFindInPageMatchCount( + int identifier, int count, bool final_update) {} + virtual void reportFindInPageSelection( + int identifier, int ordinal, const WebKit::WebRect& selection) {} // webkit_glue::WebPluginPageDelegate virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( |