diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-18 22:13:03 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-18 22:13:03 +0000 |
commit | 04fc948392b6fba1e640bd97eeea2293d9ed9b7e (patch) | |
tree | 3c413c4bf8d139cdf932fdfc4b8a7e3cc812313f /chrome/renderer | |
parent | e0d0014eb45448bf6bc59d905707d242f7517ba6 (diff) | |
download | chromium_src-04fc948392b6fba1e640bd97eeea2293d9ed9b7e.zip chromium_src-04fc948392b6fba1e640bd97eeea2293d9ed9b7e.tar.gz chromium_src-04fc948392b6fba1e640bd97eeea2293d9ed9b7e.tar.bz2 |
Fold WebEditingClient into WebViewClient.
R=dglazkov
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/211032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/print_web_view_helper.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper.h | 30 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 182 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 48 |
4 files changed, 143 insertions, 119 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index c5733c6..a019e8b 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -96,7 +96,7 @@ bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, prefs.javascript_enabled = false; prefs.java_enabled = false; - print_web_view_.reset(WebView::Create(this, NULL)); + print_web_view_.reset(WebView::Create(this)); prefs.Apply(print_web_view_.get()); print_web_view_->InitializeMainFrame(NULL); diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index 7100ae9..1566c50 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -127,6 +127,36 @@ class PrintWebViewHelper : public WebViewDelegate { virtual void printPage(WebKit::WebFrame* frame) {} virtual void didStartLoading() {} virtual void didStopLoading(); + virtual bool shouldBeginEditing(const WebKit::WebRange& range) { + return false; + } + virtual bool shouldEndEditing(const WebKit::WebRange& range) { + return false; + } + virtual bool shouldInsertNode( + const WebKit::WebNode& node, const WebKit::WebRange& range, + WebKit::WebEditingAction action) { return false; } + virtual bool shouldInsertText( + const WebKit::WebString& text, const WebKit::WebRange& range, + WebKit::WebEditingAction action) { return false; } + virtual bool shouldChangeSelectedRange( + const WebKit::WebRange& from, const WebKit::WebRange& to, + WebKit::WebTextAffinity affinity, bool still_selecting) { return false; } + virtual bool shouldDeleteRange(const WebKit::WebRange& range) { + return false; + } + virtual bool shouldApplyStyle( + const WebKit::WebString& style, const WebKit::WebRange& range) { + return false; + } + virtual bool isSmartInsertDeleteEnabled() { return false; } + virtual bool isSelectTrailingWhitespaceEnabled() { return false; } + virtual void setInputMethodEnabled(bool enabled) {} + virtual void didBeginEditing() {} + virtual void didChangeSelection(bool is_selection_empty) {} + virtual void didChangeContents() {} + virtual void didExecuteCommand(const WebKit::WebString& command_name) {} + virtual void didEndEditing() {} virtual void runModalAlertDialog( WebKit::WebFrame* frame, const WebKit::WebString& message) {} virtual bool runModalConfirmDialog( diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index d2c9eec..2e68db7 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -301,7 +301,7 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd, devtools_agent_.reset(new DevToolsAgent(routing_id, this)); - webwidget_ = WebView::Create(this, this); + webwidget_ = WebView::Create(this); webkit_preferences_.Apply(webview()); webview()->InitializeMainFrame(this); @@ -1422,6 +1422,95 @@ void RenderView::didStopLoading() { ResetPendingUpload(); } +bool RenderView::shouldBeginEditing(const WebRange& range) { + return true; +} + +bool RenderView::shouldEndEditing(const WebRange& range) { + return true; +} + +bool RenderView::shouldInsertNode(const WebNode& node, const WebRange& range, + WebEditingAction action) { + return true; +} + +bool RenderView::shouldInsertText(const WebString& text, const WebRange& range, + WebEditingAction action) { + return true; +} + +bool RenderView::shouldChangeSelectedRange(const WebRange& from_range, + const WebRange& to_range, + WebTextAffinity affinity, + bool still_selecting) { + return true; +} + +bool RenderView::shouldDeleteRange(const WebRange& range) { + return true; +} + +bool RenderView::shouldApplyStyle(const WebString& style, + const WebRange& range) { + return true; +} + +bool RenderView::isSmartInsertDeleteEnabled() { + return true; +} + +bool RenderView::isSelectTrailingWhitespaceEnabled() { +#if defined(OS_WIN) + return true; +#else + return false; +#endif +} + +void RenderView::setInputMethodEnabled(bool enabled) { + // Save the updated IME status and mark the input focus has been updated. + // The IME status is to be sent to a browser process next time when + // the input caret is rendered. + if (!ime_control_busy_) { + ime_control_updated_ = true; + ime_control_new_state_ = enabled; + } +} + +void RenderView::didChangeSelection(bool is_empty_selection) { +#if defined(OS_LINUX) + if (!handling_input_event_) + return; + // TODO(estade): investigate incremental updates to the selection so that we + // don't send the entire selection over IPC every time. + if (!is_empty_selection) { + // Sometimes we get repeated didChangeSelection calls from webkit when + // the selection hasn't actually changed. We don't want to report these + // because it will cause us to continually claim the X clipboard. + const std::string& this_selection = + webview()->GetFocusedFrame()->selectionAsText().utf8(); + if (this_selection == last_selection_) + return; + + Send(new ViewHostMsg_SelectionChanged(routing_id_, + this_selection)); + last_selection_ = this_selection; + } else { + last_selection_.clear(); + } +#endif +} + +void RenderView::didExecuteCommand(const WebString& command_name) { + const std::wstring& name = UTF16ToWideHack(command_name); + if (StartsWith(name, L"Move", true) || + StartsWith(name, L"Insert", true) || + StartsWith(name, L"Delete", true)) + return; + UserMetricsRecordAction(name); +} + void RenderView::runModalAlertDialog( WebFrame* frame, const WebString& message) { RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptAlert, @@ -1585,97 +1674,6 @@ void RenderView::runModal() { Send(msg); } -// WebKit::WebEditingClient --------------------------------------------------- - -bool RenderView::shouldBeginEditing(const WebRange& range) { - return true; -} - -bool RenderView::shouldEndEditing(const WebRange& range) { - return true; -} - -bool RenderView::shouldInsertNode(const WebNode& node, const WebRange& range, - WebEditingAction action) { - return true; -} - -bool RenderView::shouldInsertText(const WebString& text, const WebRange& range, - WebEditingAction action) { - return true; -} - -bool RenderView::shouldChangeSelectedRange(const WebRange& from_range, - const WebRange& to_range, - WebTextAffinity affinity, - bool still_selecting) { - return true; -} - -bool RenderView::shouldDeleteRange(const WebRange& range) { - return true; -} - -bool RenderView::shouldApplyStyle(const WebString& style, - const WebRange& range) { - return true; -} - -bool RenderView::isSmartInsertDeleteEnabled() { - return true; -} - -bool RenderView::isSelectTrailingWhitespaceEnabled() { -#if defined(OS_WIN) - return true; -#else - return false; -#endif -} - -void RenderView::setInputMethodEnabled(bool enabled) { - // Save the updated IME status and mark the input focus has been updated. - // The IME status is to be sent to a browser process next time when - // the input caret is rendered. - if (!ime_control_busy_) { - ime_control_updated_ = true; - ime_control_new_state_ = enabled; - } -} - -void RenderView::didChangeSelection(bool is_empty_selection) { -#if defined(OS_LINUX) - if (!handling_input_event_) - return; - // TODO(estade): investigate incremental updates to the selection so that we - // don't send the entire selection over IPC every time. - if (!is_empty_selection) { - // Sometimes we get repeated didChangeSelection calls from webkit when - // the selection hasn't actually changed. We don't want to report these - // because it will cause us to continually claim the X clipboard. - const std::string& this_selection = - webview()->GetFocusedFrame()->selectionAsText().utf8(); - if (this_selection == last_selection_) - return; - - Send(new ViewHostMsg_SelectionChanged(routing_id_, - this_selection)); - last_selection_ = this_selection; - } else { - last_selection_.clear(); - } -#endif -} - -void RenderView::didExecuteCommand(const WebString& command_name) { - const std::wstring& name = UTF16ToWideHack(command_name); - if (StartsWith(name, L"Move", true) || - StartsWith(name, L"Insert", true) || - StartsWith(name, L"Delete", true)) - return; - UserMetricsRecordAction(name); -} - // WebKit::WebFrameClient ----------------------------------------------------- WebPlugin* RenderView::createPlugin( diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 4b35260..b2b71a95 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -33,7 +33,6 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "testing/gtest/include/gtest/gtest_prod.h" #include "webkit/api/public/WebConsoleMessage.h" -#include "webkit/api/public/WebEditingClient.h" #include "webkit/api/public/WebFrameClient.h" #include "webkit/api/public/WebTextDirection.h" #include "webkit/glue/dom_serializer_delegate.h" @@ -105,7 +104,6 @@ typedef base::RefCountedData<int> SharedRenderViewCounter; // class RenderView : public RenderWidget, public WebViewDelegate, - public WebKit::WebEditingClient, public WebKit::WebFrameClient, public webkit_glue::WebPluginPageDelegate, public webkit_glue::DomSerializerDelegate, @@ -235,6 +233,28 @@ class RenderView : public RenderWidget, virtual void printPage(WebKit::WebFrame* frame); virtual void didStartLoading(); virtual void didStopLoading(); + virtual bool shouldBeginEditing(const WebKit::WebRange& range); + virtual bool shouldEndEditing(const WebKit::WebRange& range); + virtual bool shouldInsertNode( + const WebKit::WebNode& node, const WebKit::WebRange& range, + WebKit::WebEditingAction action); + virtual bool shouldInsertText( + const WebKit::WebString& text, const WebKit::WebRange& range, + WebKit::WebEditingAction action); + virtual bool shouldChangeSelectedRange( + const WebKit::WebRange& from, const WebKit::WebRange& to, + WebKit::WebTextAffinity affinity, bool still_selecting); + virtual bool shouldDeleteRange(const WebKit::WebRange& range); + virtual bool shouldApplyStyle( + const WebKit::WebString& style, const WebKit::WebRange& range); + virtual bool isSmartInsertDeleteEnabled(); + virtual bool isSelectTrailingWhitespaceEnabled(); + virtual void setInputMethodEnabled(bool enabled); + virtual void didBeginEditing() {} + virtual void didChangeSelection(bool is_selection_empty); + virtual void didChangeContents() {} + virtual void didExecuteCommand(const WebKit::WebString& command_name); + virtual void didEndEditing() {} virtual void runModalAlertDialog( WebKit::WebFrame* frame, const WebKit::WebString& message); virtual bool runModalConfirmDialog( @@ -264,30 +284,6 @@ class RenderView : public RenderWidget, virtual void closeWidgetSoon(); virtual void runModal(); - // WebKit::WebEditingClient - virtual bool shouldBeginEditing(const WebKit::WebRange& range); - virtual bool shouldEndEditing(const WebKit::WebRange& range); - virtual bool shouldInsertNode( - const WebKit::WebNode& node, const WebKit::WebRange& range, - WebKit::WebEditingAction action); - virtual bool shouldInsertText( - const WebKit::WebString& text, const WebKit::WebRange& range, - WebKit::WebEditingAction action); - virtual bool shouldChangeSelectedRange( - const WebKit::WebRange& from, const WebKit::WebRange& to, - WebKit::WebTextAffinity affinity, bool still_selecting); - virtual bool shouldDeleteRange(const WebKit::WebRange& range); - virtual bool shouldApplyStyle( - const WebKit::WebString& style, const WebKit::WebRange& range); - virtual bool isSmartInsertDeleteEnabled(); - virtual bool isSelectTrailingWhitespaceEnabled(); - virtual void setInputMethodEnabled(bool enabled); - virtual void didBeginEditing() {} - virtual void didChangeSelection(bool is_selection_empty); - virtual void didChangeContents() {} - virtual void didExecuteCommand(const WebKit::WebString& command_name); - virtual void didEndEditing() {} - // WebKit::WebFrameClient virtual WebKit::WebPlugin* createPlugin( WebKit::WebFrame* frame, const WebKit::WebPluginParams& params); |