diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 05:42:51 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 05:42:51 +0000 |
commit | 79dbc66fba17d6b4967fe86a577b11d15548cdec (patch) | |
tree | df2853054e47aa76cea79eb6664f4c21cb54bd9e | |
parent | bdc66ceff07dac7b74ddea70fabdf535936d39b1 (diff) | |
download | chromium_src-79dbc66fba17d6b4967fe86a577b11d15548cdec.zip chromium_src-79dbc66fba17d6b4967fe86a577b11d15548cdec.tar.gz chromium_src-79dbc66fba17d6b4967fe86a577b11d15548cdec.tar.bz2 |
Hook up WebEditingClient.
Moves the WebViewDelegate parameter back to WebView::Create and
adds a second parameter for WebEditingClient.
I had hoped to make the WebEditingClient NULL for RenderView on
Windows and Mac, but that turned out to not be an option. I need
a few methods on all platforms.
The Describe* functions from EditorClientImpl are moved into the
TestWebViewDelegate since they are only applicable to layout tests.
R=dglazkov
BUG=
TEST=none
Review URL: http://codereview.chromium.org/195008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25432 0039d316-1c4b-4281-b951-d872f2087c98
25 files changed, 544 insertions, 555 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index fdc1c9a..aa7f78f7 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -93,9 +93,9 @@ bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, prefs.javascript_enabled = false; prefs.java_enabled = false; - print_web_view_.reset(WebView::Create()); + print_web_view_.reset(WebView::Create(this, NULL)); prefs.Apply(print_web_view_.get()); - print_web_view_->InitializeMainFrame(this); + print_web_view_->InitializeMainFrame(); print_pages_params_.reset(new ViewMsg_PrintPages_Params(params)); print_pages_params_->pages.clear(); // Print all pages of selection. diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 2c32e5f..d857123 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -108,17 +108,21 @@ using WebKit::WebConsoleMessage; using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebDragData; +using WebKit::WebEditingAction; using WebKit::WebForm; using WebKit::WebFrame; using WebKit::WebHistoryItem; using WebKit::WebNavigationPolicy; using WebKit::WebNavigationType; +using WebKit::WebNode; using WebKit::WebPopupMenuInfo; +using WebKit::WebRange; using WebKit::WebRect; using WebKit::WebScriptSource; using WebKit::WebSettings; using WebKit::WebSize; using WebKit::WebString; +using WebKit::WebTextAffinity; using WebKit::WebTextDirection; using WebKit::WebURL; using WebKit::WebURLError; @@ -280,18 +284,12 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd, devtools_agent_.reset(new DevToolsAgent(routing_id, this)); - webwidget_ = WebView::Create(); + webwidget_ = WebView::Create(this, this); webkit_preferences_.Apply(webview()); - webview()->InitializeMainFrame(this); + webview()->InitializeMainFrame(); OnSetRendererPrefs(renderer_prefs); -#if defined(OS_LINUX) - // We have to enable ourselves as the editor delegate on linux so we can copy - // text selections to the X clipboard. - webview()->SetUseEditorDelegate(true); -#endif - // Don't let WebCore keep a B/F list - we have our own. // We let it keep 1 entry because FrameLoader::goToItem expects an item in the // backForwardList, which is used only in ASSERTs. @@ -1033,8 +1031,7 @@ void RenderView::UpdateSessionHistory(WebFrame* frame) { routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); } -/////////////////////////////////////////////////////////////////////////////// -// WebViewDelegate +// WebViewDelegate ------------------------------------------------------------ bool RenderView::CanAcceptLoadDrops() const { return renderer_preferences_.can_accept_load_drops; @@ -1977,6 +1974,8 @@ void RenderView::DidContentsSizeChange(WebWidget* webwidget, } } +// WebKit::WebWidgetClient ---------------------------------------------------- + // We are supposed to get a single call to Show for a newly created RenderView // that was created via RenderView::CreateWebView. So, we wait until this // point to dispatch the ShowView message. @@ -2015,6 +2014,99 @@ 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_glue::WebPluginPageDelegate ----------------------------------------- + webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( const GURL& url, const std::string& mime_type, @@ -2444,16 +2536,6 @@ std::wstring RenderView::GetAutoCorrectWord( return autocorrect_word; } -void RenderView::SetInputMethodState(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::ScriptedPrint(WebFrame* frame) { DCHECK(webview()); if (webview()) { @@ -2528,30 +2610,6 @@ void RenderView::SetTooltipText(WebView* webview, text_direction_hint)); } -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::DownloadUrl(const GURL& url, const GURL& referrer) { Send(new ViewHostMsg_DownloadUrl(routing_id_, url, referrer)); } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 83518cd..7318da7 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -29,6 +29,7 @@ #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/WebTextDirection.h" #include "webkit/glue/dom_serializer_delegate.h" #include "webkit/glue/form_data.h" @@ -99,6 +100,7 @@ typedef base::RefCountedData<int> SharedRenderViewCounter; // class RenderView : public RenderWidget, public WebViewDelegate, + public WebKit::WebEditingClient, public webkit_glue::WebPluginPageDelegate, public webkit_glue::DomSerializerDelegate, public base::SupportsWeakPtr<RenderView> { @@ -179,7 +181,6 @@ class RenderView : public RenderWidget, const std::wstring& message, unsigned int line_no, const std::wstring& source_id); - virtual void DidStartLoading(WebView* webview); virtual void DidStopLoading(WebView* webview); virtual void DidCreateDataSource(WebKit::WebFrame* frame, @@ -212,20 +213,23 @@ class RenderView : public RenderWidget, virtual void DidFailLoadWithError(WebView* webview, const WebKit::WebURLError& error, WebKit::WebFrame* forFrame); - virtual void DidFinishDocumentLoadForFrame(WebView* webview, WebKit::WebFrame* frame); + virtual void DidFinishDocumentLoadForFrame( + WebView* webview, + WebKit::WebFrame* frame); virtual bool DidLoadResourceFromMemoryCache( WebView* webview, const WebKit::WebURLRequest& request, const WebKit::WebURLResponse& response, WebKit::WebFrame* frame); - virtual void DidHandleOnloadEventsForFrame(WebView* webview, WebKit::WebFrame* frame); + virtual void DidHandleOnloadEventsForFrame( + WebView* webview, + WebKit::WebFrame* frame); virtual void DidChangeLocationWithinPageForFrame(WebView* webview, WebKit::WebFrame* frame, bool is_new_navigation); virtual void DidContentsSizeChange(WebKit::WebWidget* webwidget, int new_width, int new_height); - virtual void DidCompleteClientRedirect(WebView* webview, WebKit::WebFrame* frame, const GURL& source); @@ -240,13 +244,11 @@ class RenderView : public RenderWidget, uint32 identifier, const WebKit::WebURLResponse& response); virtual void DidFinishLoading(WebKit::WebFrame* webframe, uint32 identifier); - virtual void WindowObjectCleared(WebKit::WebFrame* webframe); virtual void DocumentElementAvailable(WebKit::WebFrame* webframe); virtual void DidCreateScriptContextForFrame(WebKit::WebFrame* webframe); virtual void DidDestroyScriptContextForFrame(WebKit::WebFrame* webframe); virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* webframe); - virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( WebView* webview, WebKit::WebFrame* frame, @@ -254,7 +256,6 @@ class RenderView : public RenderWidget, WebKit::WebNavigationType type, WebKit::WebNavigationPolicy default_policy, bool is_redirect); - virtual WebView* CreateWebView(WebView* webview, bool user_gesture, const GURL& creator_url); @@ -280,7 +281,6 @@ class RenderView : public RenderWidget, const GURL& image_url, bool errored, const SkBitmap& image); - virtual void ShowContextMenu(WebView* webview, ContextNodeType node_type, int x, @@ -297,10 +297,8 @@ class RenderView : public RenderWidget, const std::string& frame_charset); virtual void StartDragging(WebView* webview, const WebKit::WebDragData& drag_data); - virtual void TakeFocus(WebView* webview, bool reverse); virtual void JSOutOfMemory(); - virtual void NavigateBackForwardSoon(int offset); virtual int GetHistoryBackListCount(); virtual int GetHistoryForwardListCount(); @@ -308,18 +306,10 @@ class RenderView : public RenderWidget, virtual void SetTooltipText(WebView* webview, const std::wstring& tooltip_text, WebKit::WebTextDirection text_direction_hint); - // Called when the text selection changed. This is only called on linux since - // on other platforms the RenderView doesn't act as an editor client delegate. - virtual void DidChangeSelection(bool is_empty_selection); - virtual void DownloadUrl(const GURL& url, const GURL& referrer); - virtual void UpdateInspectorSettings(const std::wstring& raw_settings); - virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate(); - virtual void PasteFromSelectionClipboard(); - virtual void ReportFindInPageMatchCount(int count, int request_id, bool final_update); virtual void ReportFindInPageSelection(int request_id, @@ -330,7 +320,6 @@ class RenderView : public RenderWidget, virtual void SpellCheck(const std::wstring& word, int* misspell_location, int* misspell_length); virtual std::wstring GetAutoCorrectWord(const std::wstring& word); - virtual void SetInputMethodState(bool enabled); virtual void ScriptedPrint(WebKit::WebFrame* frame); virtual void UserMetricsRecordAction(const std::wstring& action); virtual void DnsPrefetch(const std::vector<std::string>& host_names); @@ -341,7 +330,31 @@ class RenderView : public RenderWidget, virtual void closeWidgetSoon(); virtual void runModal(); - // WebPluginPageDelegate: + // 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_glue::WebPluginPageDelegate virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( const GURL& url, const std::string& mime_type, diff --git a/webkit/api/public/WebEditingAction.h b/webkit/api/public/WebEditingAction.h index de716ca..4ac6653 100644 --- a/webkit/api/public/WebEditingAction.h +++ b/webkit/api/public/WebEditingAction.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,8 +31,6 @@ #ifndef WebEditingAction_h #define WebEditingAction_h -#error "This header file is still a work in progress; do not include!" - namespace WebKit { enum WebEditingAction { diff --git a/webkit/api/public/WebEditingClient.h b/webkit/api/public/WebEditingClient.h index 8cc0e01..9b20593 100644 --- a/webkit/api/public/WebEditingClient.h +++ b/webkit/api/public/WebEditingClient.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,38 +31,39 @@ #ifndef WebEditingClient_h #define WebEditingClient_h -#error "This header file is still a work in progress; do not include!" +#include "WebEditingAction.h" +#include "WebTextAffinity.h" namespace WebKit { class WebNode; class WebRange; - class WebView; + class WebString; + // This interface allow the client to intercept and overrule editing + // operations. class WebEditingClient { public: - // The following methods allow the client to intercept and overrule - // editing operations. - virtual bool shouldBeginEditing(WebView*, const WebRange&) = 0; - virtual bool shouldEndEditing(WebView*, const WebRange&) = 0; + virtual bool shouldBeginEditing(const WebRange&) = 0; + virtual bool shouldEndEditing(const WebRange&) = 0; virtual bool shouldInsertNode( - WebView*, const WebNode&, const WebRange&, const WebEditingAction&) = 0; + const WebNode&, const WebRange&, WebEditingAction) = 0; virtual bool shouldInsertText( - WebView*, const WebString&, const WebRange&, const WebEditingAction&) = 0; + const WebString&, const WebRange&, WebEditingAction) = 0; virtual bool shouldChangeSelectedRange( - WebView*, const WebRange& from, const WebRange& to, const WebTextAffinity&, + const WebRange& from, const WebRange& to, WebTextAffinity, bool stillSelecting) = 0; - virtual bool shouldDeleteRange(WebView*, const WebRange&) = 0; - virtual bool shouldApplyStyle(WebView*, const WebString& style, const WebRange&) = 0; + virtual bool shouldDeleteRange(const WebRange&) = 0; + virtual bool shouldApplyStyle(const WebString& style, const WebRange&) = 0; - virtual bool isSmartInsertDeleteEnabled(WebView*) = 0; - virtual bool isSelectTrailingWhitespaceEnabled(WebView*) = 0; - virtual void setInputMethodEnabled(WebView*, bool enabled) = 0; + virtual bool isSmartInsertDeleteEnabled() = 0; + virtual bool isSelectTrailingWhitespaceEnabled() = 0; + virtual void setInputMethodEnabled(bool enabled) = 0; - virtual void didBeginEditing(WebView*) = 0; - virtual void didChangeSelection(WebView*, bool isSelectionEmpty) = 0; - virtual void didChangeContents(WebView*) = 0; - virtual void didExecuteCommand(WebView*, const WebString& commandName) = 0; - virtual void didEndEditing(WebView*) = 0; + virtual void didBeginEditing() = 0; + virtual void didChangeSelection(bool isSelectionEmpty) = 0; + virtual void didChangeContents() = 0; + virtual void didExecuteCommand(const WebString& commandName) = 0; + virtual void didEndEditing() = 0; }; } // namespace WebKit diff --git a/webkit/api/public/WebTextAffinity.h b/webkit/api/public/WebTextAffinity.h index 3fcea31..2ca86aa 100644 --- a/webkit/api/public/WebTextAffinity.h +++ b/webkit/api/public/WebTextAffinity.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,8 +31,6 @@ #ifndef WebTextAffinity_h #define WebTextAffinity_h -#error "This header file is still a work in progress; do not include!" - namespace WebKit { // These constants specify the preferred direction of selection. diff --git a/webkit/api/src/AssertMatchingEnums.cpp b/webkit/api/src/AssertMatchingEnums.cpp new file mode 100644 index 0000000..5477d37 --- /dev/null +++ b/webkit/api/src/AssertMatchingEnums.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Use this file to assert that various WebKit API enum values continue +// matching WebCore defined enum values. + +// FIXME: Move all of the COMPILE_ASSERTs for enums into this file. + +#include "EditorInsertAction.h" +#include "TextAffinity.h" +#include "WebEditingAction.h" +#include "WebTextAffinity.h" +#include <wtf/Assertions.h> + +using namespace WebCore; + +namespace WebKit { + +#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \ + COMPILE_ASSERT(int(webkit_name) == int(webcore_name), webkit_name) + +COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionTyped, EditorInsertActionTyped); +COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionPasted, EditorInsertActionPasted); +COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionDropped, EditorInsertActionDropped); + +COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityUpstream, UPSTREAM); +COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityDownstream, DOWNSTREAM); + +} // namespace WebKit diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index 22ab39d..64a1869 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -26,7 +26,12 @@ #undef LOG #include "base/message_loop.h" #include "base/string_util.h" +#include "webkit/api/public/WebEditingAction.h" +#include "webkit/api/public/WebEditingClient.h" #include "webkit/api/public/WebKit.h" +#include "webkit/api/public/WebNode.h" +#include "webkit/api/public/WebRange.h" +#include "webkit/api/public/WebTextAffinity.h" #include "webkit/glue/autofill_form.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/editor_client_impl.h" @@ -36,6 +41,10 @@ #include "webkit/glue/webview_impl.h" using webkit_glue::AutofillForm; +using WebKit::WebEditingAction; +using WebKit::WebEditingClient; +using WebKit::WebString; +using WebKit::WebTextAffinity; // Arbitrary depth limit for the undo stack, to keep it from using // unbounded memory. This is the maximum number of distinct undoable @@ -47,48 +56,21 @@ static const size_t kMaximumUndoStackDepth = 1000; // (so to avoid sending long strings through IPC). static const size_t kMaximumTextSizeForAutofill = 1000; -namespace { - -// Record an editor command from the keyDownEntries[] below. We ignore the -// Move* and Insert* commands because they're not that interesting. -void MaybeRecordCommand(WebViewDelegate* d, const char* command_name) { - if (!d) - return; - - const char* move_prefix = "Move"; - const char* insert_prefix = "Insert"; - const char* delete_prefix = "Delete"; - // Ignore all the Move*, Insert*, and Delete* commands. - if (0 == strncmp(command_name, move_prefix, sizeof(move_prefix)) || - 0 == strncmp(command_name, insert_prefix, sizeof(insert_prefix)) || - 0 == strncmp(command_name, delete_prefix, sizeof(delete_prefix))) { - return; - } - d->UserMetricsRecordComputedAction(UTF8ToWide(command_name)); -} - -} - -EditorClientImpl::EditorClientImpl(WebView* web_view) - : web_view_(static_cast<WebViewImpl*>(web_view)), - use_editor_delegate_(false), +EditorClientImpl::EditorClientImpl(WebViewImpl* web_view, + WebEditingClient* editing_client) + : web_view_(web_view), + editing_client_(editing_client), in_redo_(false), backspace_or_delete_pressed_(false), spell_check_this_field_status_(SPELLCHECK_AUTOMATIC), -// Don't complain about using "this" in initializer list. -MSVC_PUSH_DISABLE_WARNING(4355) - autofill_factory_(this) { -MSVC_POP_WARNING() + ALLOW_THIS_IN_INITIALIZER_LIST(autofill_factory_(this)) { } EditorClientImpl::~EditorClientImpl() { } void EditorClientImpl::pageDestroyed() { - // Called by the Page (which owns the editor client) when the page is going - // away. This should cause us to delete ourselves, which is stupid. The page - // should just delete us when it's going away. Oh well. - delete this; + // Ignored since our lifetime is managed by the WebViewImpl. } bool EditorClientImpl::shouldShowDeleteInterface(WebCore::HTMLElement* elem) { @@ -100,24 +82,18 @@ bool EditorClientImpl::shouldShowDeleteInterface(WebCore::HTMLElement* elem) { } bool EditorClientImpl::smartInsertDeleteEnabled() { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - return d->SmartInsertDeleteEnabled(); - } + if (editing_client_) + return editing_client_->isSmartInsertDeleteEnabled(); return true; } bool EditorClientImpl::isSelectTrailingWhitespaceEnabled() { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - return d->IsSelectTrailingWhitespaceEnabled(); - } + if (editing_client_) + return editing_client_->isSelectTrailingWhitespaceEnabled(); #if defined(OS_WIN) return true; -#elif defined(OS_MACOSX) || defined(OS_LINUX) +#else return false; #endif } @@ -155,10 +131,9 @@ bool EditorClientImpl::ShouldSpellcheckByDefault() { bool EditorClientImpl::isContinuousSpellCheckingEnabled() { if (spell_check_this_field_status_ == SPELLCHECK_FORCED_OFF) return false; - else if (spell_check_this_field_status_ == SPELLCHECK_FORCED_ON) + if (spell_check_this_field_status_ == SPELLCHECK_FORCED_ON) return true; - else - return ShouldSpellcheckByDefault(); + return ShouldSpellcheckByDefault(); } void EditorClientImpl::toggleContinuousSpellChecking() { @@ -186,19 +161,17 @@ bool EditorClientImpl::isEditable() { } bool EditorClientImpl::shouldBeginEditing(WebCore::Range* range) { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - return d->ShouldBeginEditing(web_view_, Describe(range)); + if (editing_client_) { + return editing_client_->shouldBeginEditing( + webkit_glue::RangeToWebRange(range)); } return true; } bool EditorClientImpl::shouldEndEditing(WebCore::Range* range) { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - return d->ShouldEndEditing(web_view_, Describe(range)); + if (editing_client_) { + return editing_client_->shouldEndEditing( + webkit_glue::RangeToWebRange(range)); } return true; } @@ -206,14 +179,11 @@ bool EditorClientImpl::shouldEndEditing(WebCore::Range* range) { bool EditorClientImpl::shouldInsertNode(WebCore::Node* node, WebCore::Range* range, WebCore::EditorInsertAction action) { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) { - return d->ShouldInsertNode(web_view_, - Describe(node), - Describe(range), - Describe(action)); - } + if (editing_client_) { + return editing_client_->shouldInsertNode( + webkit_glue::NodeToWebNode(node), + webkit_glue::RangeToWebRange(range), + static_cast<WebEditingAction>(action)); } return true; } @@ -221,25 +191,20 @@ bool EditorClientImpl::shouldInsertNode(WebCore::Node* node, bool EditorClientImpl::shouldInsertText(const WebCore::String& text, WebCore::Range* range, WebCore::EditorInsertAction action) { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) { - std::wstring wstr = webkit_glue::StringToStdWString(text); - return d->ShouldInsertText(web_view_, - wstr, - Describe(range), - Describe(action)); - } + if (editing_client_) { + return editing_client_->shouldInsertText( + webkit_glue::StringToWebString(text), + webkit_glue::RangeToWebRange(range), + static_cast<WebEditingAction>(action)); } return true; } bool EditorClientImpl::shouldDeleteRange(WebCore::Range* range) { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - return d->ShouldDeleteRange(web_view_, Describe(range)); + if (editing_client_) { + return editing_client_->shouldDeleteRange( + webkit_glue::RangeToWebRange(range)); } return true; } @@ -248,25 +213,23 @@ bool EditorClientImpl::shouldChangeSelectedRange(WebCore::Range* from_range, WebCore::Range* to_range, WebCore::EAffinity affinity, bool still_selecting) { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) { - return d->ShouldChangeSelectedRange(web_view_, - Describe(from_range), - Describe(to_range), - Describe(affinity), - still_selecting); - } + if (editing_client_) { + return editing_client_->shouldChangeSelectedRange( + webkit_glue::RangeToWebRange(from_range), + webkit_glue::RangeToWebRange(to_range), + static_cast<WebTextAffinity>(affinity), + still_selecting); } return true; } bool EditorClientImpl::shouldApplyStyle(WebCore::CSSStyleDeclaration* style, WebCore::Range* range) { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - return d->ShouldApplyStyle(web_view_, Describe(style), Describe(range)); + if (editing_client_) { + // TODO(darin): Pass a reference to the CSSStyleDeclaration somehow. + return editing_client_->shouldApplyStyle( + WebString(), + webkit_glue::RangeToWebRange(range)); } return true; } @@ -278,38 +241,26 @@ bool EditorClientImpl::shouldMoveRangeAfterDelete( } void EditorClientImpl::didBeginEditing() { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - d->DidBeginEditing(); - } + if (editing_client_) + editing_client_->didBeginEditing(); } void EditorClientImpl::respondToChangedSelection() { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) { - WebCore::Frame* frame = web_view_->GetFocusedWebCoreFrame(); - if (frame) - d->DidChangeSelection(!frame->selection()->isRange()); - } + if (editing_client_) { + WebCore::Frame* frame = web_view_->GetFocusedWebCoreFrame(); + if (frame) + editing_client_->didChangeSelection(!frame->selection()->isRange()); } } void EditorClientImpl::respondToChangedContents() { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - d->DidChangeContents(); - } + if (editing_client_) + editing_client_->didChangeContents(); } void EditorClientImpl::didEndEditing() { - if (use_editor_delegate_) { - WebViewDelegate* d = web_view_->delegate(); - if (d) - d->DidEndEditing(); - } + if (editing_client_) + editing_client_->didEndEditing(); } void EditorClientImpl::didWriteSelectionToPasteboard() { @@ -599,7 +550,7 @@ bool EditorClientImpl::handleEditingKeyboardEvent( if (!frame) return false; - const char* command_name = interpretKeyEvent(evt); + WebCore::String command_name = interpretKeyEvent(evt); WebCore::Editor::Command command = frame->editor()->command(command_name); if (keyEvent->type() == WebCore::PlatformKeyboardEvent::RawKeyDown) { @@ -608,19 +559,23 @@ bool EditorClientImpl::handleEditingKeyboardEvent( // so we leave it upon WebCore to either handle them immediately // (e.g. Tab that changes focus) or let a keypress event be generated // (e.g. Tab that inserts a Tab character, or Enter). - if (command.isTextInsertion() || !command_name) + if (command.isTextInsertion() || command_name.isEmpty()) return false; if (command.execute(evt)) { - WebViewDelegate* d = web_view_->delegate(); - MaybeRecordCommand(d, command_name); + if (editing_client_) { + editing_client_->didExecuteCommand( + webkit_glue::StringToWebString(command_name)); + } return true; } return false; } if (command.execute(evt)) { - WebViewDelegate* d = web_view_->delegate(); - MaybeRecordCommand(d, command_name); + if (editing_client_) { + editing_client_->didExecuteCommand( + webkit_glue::StringToWebString(command_name)); + } return true; } @@ -942,91 +897,6 @@ void EditorClientImpl::getGuessesForWord(const WebCore::String&, } void EditorClientImpl::setInputMethodState(bool enabled) { - WebViewDelegate* d = web_view_->delegate(); - if (d) { - d->SetInputMethodState(enabled); - } -} - - -std::wstring EditorClientImpl::DescribeOrError(int number, - WebCore::ExceptionCode ec) { - if (ec) - return L"ERROR"; - - return IntToWString(number); -} - -std::wstring EditorClientImpl::DescribeOrError(WebCore::Node* node, - WebCore::ExceptionCode ec) { - if (ec) - return L"ERROR"; - - return Describe(node); -} - -// These Describe() functions match the output expected by the layout tests. -std::wstring EditorClientImpl::Describe(WebCore::Range* range) { - if (range) { - WebCore::ExceptionCode exception = 0; - std::wstring str = L"range from "; - int offset = range->startOffset(exception); - str.append(DescribeOrError(offset, exception)); - str.append(L" of "); - WebCore::Node* container = range->startContainer(exception); - str.append(DescribeOrError(container, exception)); - str.append(L" to "); - offset = range->endOffset(exception); - str.append(DescribeOrError(offset, exception)); - str.append(L" of "); - container = range->endContainer(exception); - str.append(DescribeOrError(container, exception)); - return str; - } - return L"(null)"; -} - -// See comment for Describe(), above. -std::wstring EditorClientImpl::Describe(WebCore::Node* node) { - if (node) { - std::wstring str = webkit_glue::StringToStdWString(node->nodeName()); - WebCore::Node* parent = node->parentNode(); - if (parent) { - str.append(L" > "); - str.append(Describe(parent)); - } - return str; - } - return L"(null)"; -} - -// See comment for Describe(), above. -std::wstring EditorClientImpl::Describe(WebCore::EditorInsertAction action) { - switch (action) { - case WebCore::EditorInsertActionTyped: - return L"WebViewInsertActionTyped"; - case WebCore::EditorInsertActionPasted: - return L"WebViewInsertActionPasted"; - case WebCore::EditorInsertActionDropped: - return L"WebViewInsertActionDropped"; - } - return L"(UNKNOWN ACTION)"; -} - -// See comment for Describe(), above. -std::wstring EditorClientImpl::Describe(WebCore::EAffinity affinity) { - switch (affinity) { - case WebCore::UPSTREAM: - return L"NSSelectionAffinityUpstream"; - case WebCore::DOWNSTREAM: - return L"NSSelectionAffinityDownstream"; - } - return L"(UNKNOWN AFFINITY)"; -} - -std::wstring EditorClientImpl::Describe(WebCore::CSSStyleDeclaration* style) { - // TODO(pamg): Implement me. It's not clear what WebKit produces for this - // (their [style description] method), and none of the layout tests provide - // an example. But because none of them use it, it's not yet important. - return std::wstring(); + if (editing_client_) + editing_client_->setInputMethodEnabled(enabled); } diff --git a/webkit/glue/editor_client_impl.h b/webkit/glue/editor_client_impl.h index ad133a7..1ca7ce1 100644 --- a/webkit/glue/editor_client_impl.h +++ b/webkit/glue/editor_client_impl.h @@ -18,13 +18,19 @@ class HTMLInputElement; class Node; class PlatformKeyboardEvent; } +namespace WebKit { +class WebEditingClient; +} -class WebView; class WebViewImpl; class EditorClientImpl : public WebCore::EditorClient { public: - EditorClientImpl(WebView* web_view); + EditorClientImpl(WebViewImpl* web_view, + WebKit::WebEditingClient* editing_client); + + void DropEditingClient() { editing_client_ = NULL; } + virtual ~EditorClientImpl(); virtual void pageDestroyed(); @@ -103,20 +109,6 @@ class EditorClientImpl : public WebCore::EditorClient { WTF::Vector<WebCore::String>& guesses); virtual void setInputMethodState(bool enabled); - void SetUseEditorDelegate(bool value) { use_editor_delegate_ = value; } - - // It would be better to add these methods to the objects they describe, but - // those are in WebCore and therefore inaccessible. - virtual std::wstring DescribeOrError(int number, - WebCore::ExceptionCode ec); - virtual std::wstring DescribeOrError(WebCore::Node* node, - WebCore::ExceptionCode ec); - virtual std::wstring Describe(WebCore::Range* range); - virtual std::wstring Describe(WebCore::Node* node); - virtual std::wstring Describe(WebCore::EditorInsertAction action); - virtual std::wstring Describe(WebCore::EAffinity affinity); - virtual std::wstring Describe(WebCore::CSSStyleDeclaration* style); - // Shows the form autofill popup for |node| if it is an HTMLInputElement and // it is empty. This is called when you press the up or down arrow in a // text-field or when clicking an already focused text-field. @@ -162,7 +154,7 @@ class EditorClientImpl : public WebCore::EditorClient { protected: WebViewImpl* web_view_; - bool use_editor_delegate_; + WebKit::WebEditingClient* editing_client_; bool in_redo_; typedef std::deque<WTF::RefPtr<WebCore::EditCommand> > EditCommandStack; diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index 2d75798..7346c1c 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -13,6 +13,7 @@ namespace WebKit { class WebDragData; +class WebEditingClient; class WebFrame; class WebSettings; struct WebPoint; @@ -49,12 +50,15 @@ class WebView : public WebKit::WebWidget { virtual ~WebView() {} // This method creates a WebView that is NOT yet initialized. You will need - // to call InitializeMainFrame to finish the initialization. - static WebView* Create(); + // to call InitializeMainFrame to finish the initialization. You may pass + // NULL for the editing_client parameter if you are not interested in those + // notifications. + static WebView* Create( + WebViewDelegate* delegate, WebKit::WebEditingClient* editing_client); // After creating a WebView, you should immediately call this function. // You can optionally modify the settings (via GetSettings()) in between. - virtual void InitializeMainFrame(WebViewDelegate* delegate) = 0; + virtual void InitializeMainFrame() = 0; // Tells all Page instances of this view to update the visited link state for // the specified hash. @@ -69,12 +73,6 @@ class WebView : public WebKit::WebWidget { // using it, it will be NULL during closing of the view. virtual WebViewDelegate* GetDelegate() = 0; - // Instructs the EditorClient whether to pass editing notifications on to a - // delegate, if one is present. This allows embedders that haven't - // overridden any editor delegate methods to avoid the performance impact of - // calling them. - virtual void SetUseEditorDelegate(bool value) = 0; - // Method that controls whether pressing Tab key cycles through page elements // or inserts a '\t' char in text area virtual void SetTabKeyCyclesThroughElements(bool value) = 0; diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 11a55f8..804049d 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -655,76 +655,8 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { virtual void JSOutOfMemory() { } - // EditorDelegate ---------------------------------------------------------- - - // These methods exist primarily to allow a specialized executable to record - // edit events for testing purposes. Most embedders are not expected to - // override them. In fact, by default these editor delegate methods aren't - // even called by the EditorClient, for performance reasons. To enable them, - // call WebView::SetUseEditorDelegate(true) for each WebView. - - virtual bool ShouldBeginEditing(WebView* webview, std::wstring range) { - return true; - } - - virtual bool ShouldEndEditing(WebView* webview, std::wstring range) { - return true; - } - - virtual bool ShouldInsertNode(WebView* webview, - std::wstring node, - std::wstring range, - std::wstring action) { - return true; - } - - virtual bool ShouldInsertText(WebView* webview, - std::wstring text, - std::wstring range, - std::wstring action) { - return true; - } - - virtual bool ShouldChangeSelectedRange(WebView* webview, - std::wstring fromRange, - std::wstring toRange, - std::wstring affinity, - bool stillSelecting) { - return true; - } - - virtual bool ShouldDeleteRange(WebView* webview, std::wstring range) { - return true; - } - - virtual bool ShouldApplyStyle(WebView* webview, - std::wstring style, - std::wstring range) { - return true; - } - - virtual bool SmartInsertDeleteEnabled() { - return true; - } - - virtual bool IsSelectTrailingWhitespaceEnabled() { -#if defined(OS_WIN) - return true; -#else - return false; -#endif - } - - virtual void DidBeginEditing() { } - virtual void DidChangeSelection(bool is_empty_selection) { } - virtual void DidChangeContents() { } - virtual void DidEndEditing() { } - // Notification that a user metric has occurred. virtual void UserMetricsRecordAction(const std::wstring& action) { } - virtual void UserMetricsRecordComputedAction(const std::wstring& action) { - UserMetricsRecordAction(action); - } // ------------------------------------------------------------------------- @@ -811,9 +743,6 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { return std::wstring(); } - // Changes the state of the input method editor. - virtual void SetInputMethodState(bool enabled) { } - // Asks the user to print the page or a specific frame. Called in response to // a window.print() call. virtual void ScriptedPrint(WebKit::WebFrame* frame) { } diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index d5f9c06..b065563 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -101,6 +101,7 @@ using WebKit::WebCompositionCommand; using WebKit::WebCompositionCommandConfirm; using WebKit::WebCompositionCommandDiscard; using WebKit::WebDragData; +using WebKit::WebEditingClient; using WebKit::WebFrame; using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; @@ -323,24 +324,22 @@ static const WebCore::PopupContainerSettings kAutocompletePopupSettings = { // WebView ---------------------------------------------------------------- /*static*/ -WebView* WebView::Create() { - WebViewImpl* instance = new WebViewImpl(); +WebView* WebView::Create(WebViewDelegate* delegate, + WebEditingClient* editing_client) { + WebViewImpl* instance = new WebViewImpl(delegate, editing_client); instance->AddRef(); return instance; } -void WebViewImpl::InitializeMainFrame(WebViewDelegate* delegate) { +void WebViewImpl::InitializeMainFrame() { // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame // and releases that reference once the corresponding Frame is destroyed. scoped_refptr<WebFrameImpl> main_frame = new WebFrameImpl(); - // Set the delegate before initializing the frame, so that notifications like - // DidCreateDataSource make their way to the client. - delegate_ = delegate; main_frame->InitMainFrame(this); WebDevToolsAgentDelegate* tools_delegate = - delegate->GetWebDevToolsAgentDelegate(); + delegate_->GetWebDevToolsAgentDelegate(); if (tools_delegate) devtools_agent_.reset(new WebDevToolsAgentImpl(this, tools_delegate)); @@ -363,8 +362,11 @@ void WebView::ResetVisitedLinkState() { } -WebViewImpl::WebViewImpl() - : ALLOW_THIS_IN_INITIALIZER_LIST(back_forward_list_client_impl_(this)), +WebViewImpl::WebViewImpl(WebViewDelegate* delegate, + WebEditingClient* editing_client) + : delegate_(delegate), + ALLOW_THIS_IN_INITIALIZER_LIST(editor_client_impl_(this, editing_client)), + ALLOW_THIS_IN_INITIALIZER_LIST(back_forward_list_client_impl_(this)), observed_new_navigation_(false), #ifndef NDEBUG new_navigation_loader_(NULL), @@ -393,7 +395,7 @@ WebViewImpl::WebViewImpl() // the page will take ownership of the various clients page_.reset(new Page(new ChromeClientImpl(this), new ContextMenuClientImpl(this), - new EditorClientImpl(this), + &editor_client_impl_, new DragClientImpl(this), new WebInspectorClient(this))); @@ -413,14 +415,6 @@ RenderTheme* WebViewImpl::theme() const { return page_.get() ? page_->theme() : RenderTheme::defaultTheme().get(); } -void WebViewImpl::SetUseEditorDelegate(bool value) { - ASSERT(page_ != 0); // The macro doesn't like (!page_) with a scoped_ptr. - ASSERT(page_->editorClient()); - EditorClientImpl* editor_client = - static_cast<EditorClientImpl*>(page_->editorClient()); - editor_client->SetUseEditorDelegate(value); -} - void WebViewImpl::SetTabKeyCyclesThroughElements(bool value) { if (page_ != NULL) { page_->setTabKeyCyclesThroughElements(value); @@ -957,6 +951,7 @@ void WebViewImpl::close() { // Reset the delegate to prevent notifications being sent as we're being // deleted. delegate_ = NULL; + editor_client_impl_.DropEditingClient(); Release(); // Balances AddRef from WebView::Create } diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index f16206e..132f7b2 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -16,6 +16,7 @@ #include "webkit/api/public/WebSize.h" #include "webkit/api/src/NotificationPresenterImpl.h" #include "webkit/glue/back_forward_list_client_impl.h" +#include "webkit/glue/editor_client_impl.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" @@ -35,6 +36,7 @@ class Widget; } namespace WebKit { +class WebEditingClient; class WebKeyboardEvent; class WebMouseEvent; class WebMouseWheelEvent; @@ -74,11 +76,10 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual void setTextDirection(WebKit::WebTextDirection direction); // WebView methods: - virtual void InitializeMainFrame(WebViewDelegate* delegate); + virtual void InitializeMainFrame(); virtual bool ShouldClose(); virtual void ClosePage(); virtual WebViewDelegate* GetDelegate(); - virtual void SetUseEditorDelegate(bool value); virtual void SetTabKeyCyclesThroughElements(bool value); virtual WebKit::WebFrame* GetMainFrame(); virtual WebKit::WebFrame* GetFocusedFrame(); @@ -244,7 +245,8 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { void OnImageFetchComplete(webkit_glue::ImageResourceFetcher* fetcher, const SkBitmap& bitmap); - WebViewImpl(); + WebViewImpl( + WebViewDelegate* delegate, WebKit::WebEditingClient* editing_client); ~WebViewImpl(); void ModifySelection(uint32 message, @@ -252,6 +254,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { const WebCore::PlatformKeyboardEvent& e); WebViewDelegate* delegate_; + EditorClientImpl editor_client_impl_; WebKit::WebSize size_; WebKit::WebPoint last_mouse_position_; diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc index 9ad4d49..60fe5d0 100644 --- a/webkit/glue/webworker_impl.cc +++ b/webkit/glue/webworker_impl.cc @@ -149,9 +149,9 @@ void WebWorkerImpl::startWorkerContext(const WebURL& script_url, // loading requests from the worker context to the rest of WebKit and Chromium // infrastructure. DCHECK(!web_view_); - web_view_ = WebView::Create(); + web_view_ = WebView::Create(WorkerWebViewDelegate::worker_delegate(), NULL); WebPreferences().Apply(web_view_); - web_view_->InitializeMainFrame(WorkerWebViewDelegate::worker_delegate()); + web_view_->InitializeMainFrame(); WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(web_view_->GetMainFrame()); diff --git a/webkit/tools/test_shell/keyboard_unittest.cc b/webkit/tools/test_shell/keyboard_unittest.cc index 3ced54e..85e6ff6 100644 --- a/webkit/tools/test_shell/keyboard_unittest.cc +++ b/webkit/tools/test_shell/keyboard_unittest.cc @@ -39,7 +39,7 @@ class KeyboardTest : public testing::Test { const char* InterpretKeyEvent( const WebKeyboardEvent& keyboard_event, PlatformKeyboardEvent::Type key_type) { - EditorClientImpl editor_impl(NULL); + EditorClientImpl editor_impl(NULL, NULL); PlatformKeyboardEventBuilder evt(keyboard_event); evt.setKeyType(key_type); diff --git a/webkit/tools/test_shell/mac/webview_host.mm b/webkit/tools/test_shell/mac/webview_host.mm index 2acc00c..c8ffa08 100644 --- a/webkit/tools/test_shell/mac/webview_host.mm +++ b/webkit/tools/test_shell/mac/webview_host.mm @@ -13,12 +13,13 @@ #include "webkit/api/public/WebSize.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" +#include "webkit/tools/test_shell/test_webview_delegate.h" using WebKit::WebSize; // static WebViewHost* WebViewHost::Create(NSView* parent_view, - WebViewDelegate* delegate, + TestWebViewDelegate* delegate, const WebPreferences& prefs) { WebViewHost* host = new WebViewHost(); @@ -34,9 +35,9 @@ WebViewHost* WebViewHost::Create(NSView* parent_view, [parent_view addSubview:host->view_]; [host->view_ release]; - host->webwidget_ = WebView::Create(); + host->webwidget_ = WebView::Create(delegate, delegate); prefs.Apply(host->webview()); - host->webview()->InitializeMainFrame(delegate); + host->webview()->InitializeMainFrame(); host->webwidget_->resize(WebSize(content_rect.size.width, content_rect.size.height)); diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index 501aadd..86ce5d6 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -369,10 +369,6 @@ bool TestShell::Initialize(const std::wstring& startingURL) { m_webViewHost.reset( WebViewHost::Create(vbox, delegate_.get(), *TestShell::web_prefs_)); - // Enables output of "EDDITING DELEGATE: " debugging lines in the layout test - // output. - webView()->SetUseEditorDelegate(true); - gtk_container_add(GTK_CONTAINER(m_mainWnd), vbox); gtk_widget_show_all(GTK_WIDGET(m_mainWnd)); diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index dfd53f8..c3c0985 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -264,7 +264,6 @@ bool TestShell::Initialize(const std::wstring& startingURL) { WebViewHost::Create([m_mainWnd contentView], delegate_.get(), *TestShell::web_prefs_)); - webView()->SetUseEditorDelegate(true); delegate_->RegisterDragDrop(); TestShellWebView* web_view = static_cast<TestShellWebView*>(m_webViewHost->view_handle()); diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index 9a06a8c..17a707a 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -359,7 +359,6 @@ bool TestShell::Initialize(const std::wstring& startingURL) { // create webview m_webViewHost.reset( WebViewHost::Create(m_mainWnd, delegate_.get(), *TestShell::web_prefs_)); - webView()->SetUseEditorDelegate(true); delegate_->RegisterDragDrop(); // Load our initial content. diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 27eacce..b8b2a11 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -26,6 +26,8 @@ #include "webkit/api/public/WebHistoryItem.h" #include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebKit.h" +#include "webkit/api/public/WebNode.h" +#include "webkit/api/public/WebRange.h" #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" @@ -59,16 +61,20 @@ using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebDragData; +using WebKit::WebEditingAction; using WebKit::WebFrame; using WebKit::WebHistoryItem; using WebKit::WebNavigationType; using WebKit::WebNavigationPolicy; +using WebKit::WebNode; using WebKit::WebPlugin; using WebKit::WebPluginParams; +using WebKit::WebRange; using WebKit::WebRect; using WebKit::WebScreenInfo; using WebKit::WebSize; using WebKit::WebString; +using WebKit::WebTextAffinity; using WebKit::WebURL; using WebKit::WebURLError; using WebKit::WebURLRequest; @@ -172,6 +178,61 @@ std::string GetErrorDescription(const WebURLError& error) { domain.c_str(), code, error.unreachableURL.spec().data()); } +std::string GetNodeDescription(const WebNode& node, int exception) { + if (exception) + return "ERROR"; + if (node.isNull()) + return "(null)"; + std::string str = node.nodeName().utf8(); + const WebNode& parent = node.parentNode(); + if (!parent.isNull()) { + str.append(" > "); + str.append(GetNodeDescription(parent, 0)); + } + return str; +} + +std::string GetRangeDescription(const WebRange& range) { + if (range.isNull()) + return "(null)"; + int exception = 0; + std::string str = "range from "; + int offset = range.startOffset(); + str.append(IntToString(offset)); + str.append(" of "); + WebNode container = range.startContainer(exception); + str.append(GetNodeDescription(container, exception)); + str.append(" to "); + offset = range.endOffset(); + str.append(IntToString(offset)); + str.append(" of "); + container = range.endContainer(exception); + str.append(GetNodeDescription(container, exception)); + return str; +} + +std::string GetEditingActionDescription(WebEditingAction action) { + switch (action) { + case WebKit::WebEditingActionTyped: + return "WebViewInsertActionTyped"; + case WebKit::WebEditingActionPasted: + return "WebViewInsertActionPasted"; + case WebKit::WebEditingActionDropped: + return "WebViewInsertActionDropped"; + } + return "(UNKNOWN ACTION)"; +} + +std::string GetTextAffinityDescription(WebTextAffinity affinity) { + switch (affinity) { + case WebKit::WebTextAffinityUpstream: + return "NSSelectionAffinityUpstream"; + case WebKit::WebTextAffinityDownstream: + return "NSSelectionAffinityDownstream"; + } + return "(UNKNOWN AFFINITY)"; +} + } // namespace // WebViewDelegate ----------------------------------------------------------- @@ -659,114 +720,160 @@ void TestWebViewDelegate::ShowContextMenu( captured_context_menu_events_.push_back(context); } +void TestWebViewDelegate::NavigateBackForwardSoon(int offset) { + shell_->navigation_controller()->GoToOffset(offset); +} + +int TestWebViewDelegate::GetHistoryBackListCount() { + int current_index = + shell_->navigation_controller()->GetLastCommittedEntryIndex(); + return current_index; +} + +int TestWebViewDelegate::GetHistoryForwardListCount() { + int current_index = + shell_->navigation_controller()->GetLastCommittedEntryIndex(); + return shell_->navigation_controller()->GetEntryCount() - current_index - 1; +} + +void TestWebViewDelegate::SetUserStyleSheetEnabled(bool is_enabled) { + WebPreferences* prefs = shell_->GetWebPreferences(); + prefs->user_style_sheet_enabled = is_enabled; + prefs->Apply(shell_->webView()); +} + +void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { + WebPreferences* prefs = shell_->GetWebPreferences(); + prefs->user_style_sheet_enabled = true; + prefs->user_style_sheet_location = location; + prefs->Apply(shell_->webView()); +} + +// WebWidgetClient ----------------------------------------------------------- + +void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) { + if (WebWidgetHost* host = GetWidgetHost()) + host->DidInvalidateRect(rect); +} + +void TestWebViewDelegate::didScrollRect(int dx, int dy, + const WebRect& clip_rect) { + if (WebWidgetHost* host = GetWidgetHost()) + host->DidScrollRect(dx, dy, clip_rect); +} + +void TestWebViewDelegate::didFocus() { + if (WebWidgetHost* host = GetWidgetHost()) + shell_->SetFocus(host, true); +} + +void TestWebViewDelegate::didBlur() { + if (WebWidgetHost* host = GetWidgetHost()) + shell_->SetFocus(host, false); +} + +WebScreenInfo TestWebViewDelegate::screenInfo() { + if (WebWidgetHost* host = GetWidgetHost()) + return host->GetScreenInfo(); + + return WebScreenInfo(); +} + +// WebEditingClient ---------------------------------------------------------- // The output from these methods in layout test mode should match that // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. -bool TestWebViewDelegate::ShouldBeginEditing(WebView* webview, - std::wstring range) { + +bool TestWebViewDelegate::shouldBeginEditing(const WebRange& range) { if (shell_->ShouldDumpEditingCallbacks()) { - std::string utf8 = WideToUTF8(range); printf("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n", - utf8.c_str()); + GetRangeDescription(range).c_str()); } return shell_->AcceptsEditing(); } -bool TestWebViewDelegate::ShouldEndEditing(WebView* webview, - std::wstring range) { +bool TestWebViewDelegate::shouldEndEditing(const WebRange& range) { if (shell_->ShouldDumpEditingCallbacks()) { - std::string utf8 = WideToUTF8(range); printf("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n", - utf8.c_str()); + GetRangeDescription(range).c_str()); } return shell_->AcceptsEditing(); } -bool TestWebViewDelegate::ShouldInsertNode(WebView* webview, - std::wstring node, - std::wstring range, - std::wstring action) { +bool TestWebViewDelegate::shouldInsertNode(const WebNode& node, + const WebRange& range, + WebEditingAction action) { if (shell_->ShouldDumpEditingCallbacks()) { - std::string utf8_node = WideToUTF8(node); - std::string utf8_range = WideToUTF8(range); - std::string utf8_action = WideToUTF8(action); printf("EDITING DELEGATE: shouldInsertNode:%s " - "replacingDOMRange:%s givenAction:%s\n", - utf8_node.c_str(), utf8_range.c_str(), utf8_action.c_str()); + "replacingDOMRange:%s givenAction:%s\n", + GetNodeDescription(node, 0).c_str(), + GetRangeDescription(range).c_str(), + GetEditingActionDescription(action).c_str()); } return shell_->AcceptsEditing(); } -bool TestWebViewDelegate::ShouldInsertText(WebView* webview, - std::wstring text, - std::wstring range, - std::wstring action) { +bool TestWebViewDelegate::shouldInsertText(const WebString& text, + const WebRange& range, + WebEditingAction action) { if (shell_->ShouldDumpEditingCallbacks()) { - std::string utf8_text = WideToUTF8(text); - std::string utf8_range = WideToUTF8(range); - std::string utf8_action = WideToUTF8(action); printf("EDITING DELEGATE: shouldInsertText:%s " - "replacingDOMRange:%s givenAction:%s\n", - utf8_text.c_str(), utf8_range.c_str(), utf8_action.c_str()); + "replacingDOMRange:%s givenAction:%s\n", + text.utf8().data(), + GetRangeDescription(range).c_str(), + GetEditingActionDescription(action).c_str()); } return shell_->AcceptsEditing(); } -bool TestWebViewDelegate::ShouldChangeSelectedRange(WebView* webview, - std::wstring fromRange, - std::wstring toRange, - std::wstring affinity, - bool stillSelecting) { +bool TestWebViewDelegate::shouldChangeSelectedRange(const WebRange& from_range, + const WebRange& to_range, + WebTextAffinity affinity, + bool still_selecting) { if (shell_->ShouldDumpEditingCallbacks()) { - std::string utf8_from = WideToUTF8(fromRange); - std::string utf8_to = WideToUTF8(toRange); - std::string utf8_affinity = WideToUTF8(affinity); printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s " - "toDOMRange:%s affinity:%s stillSelecting:%s\n", - utf8_from.c_str(), - utf8_to.c_str(), - utf8_affinity.c_str(), - (stillSelecting ? "TRUE" : "FALSE")); + "toDOMRange:%s affinity:%s stillSelecting:%s\n", + GetRangeDescription(from_range).c_str(), + GetRangeDescription(to_range).c_str(), + GetTextAffinityDescription(affinity).c_str(), + (still_selecting ? "TRUE" : "FALSE")); } return shell_->AcceptsEditing(); } -bool TestWebViewDelegate::ShouldDeleteRange(WebView* webview, - std::wstring range) { +bool TestWebViewDelegate::shouldDeleteRange(const WebRange& range) { if (shell_->ShouldDumpEditingCallbacks()) { - std::string utf8 = WideToUTF8(range); - printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", utf8.c_str()); + printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", + GetRangeDescription(range).c_str()); } return shell_->AcceptsEditing(); } -bool TestWebViewDelegate::ShouldApplyStyle(WebView* webview, - std::wstring style, - std::wstring range) { +bool TestWebViewDelegate::shouldApplyStyle(const WebString& style, + const WebRange& range) { if (shell_->ShouldDumpEditingCallbacks()) { - std::string utf8_style = WideToUTF8(style); - std::string utf8_range = WideToUTF8(range); printf("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n", - utf8_style.c_str(), utf8_range.c_str()); + style.utf8().data(), + GetRangeDescription(range).c_str()); } return shell_->AcceptsEditing(); } -bool TestWebViewDelegate::SmartInsertDeleteEnabled() { +bool TestWebViewDelegate::isSmartInsertDeleteEnabled() { return smart_insert_delete_enabled_; } -bool TestWebViewDelegate::IsSelectTrailingWhitespaceEnabled() { +bool TestWebViewDelegate::isSelectTrailingWhitespaceEnabled() { return select_trailing_whitespace_enabled_; } -void TestWebViewDelegate::DidBeginEditing() { +void TestWebViewDelegate::didBeginEditing() { if (shell_->ShouldDumpEditingCallbacks()) { printf("EDITING DELEGATE: " "webViewDidBeginEditing:WebViewDidBeginEditingNotification\n"); } } -void TestWebViewDelegate::DidChangeSelection(bool is_empty_selection) { +void TestWebViewDelegate::didChangeSelection(bool is_empty_selection) { if (shell_->ShouldDumpEditingCallbacks()) { printf("EDITING DELEGATE: " "webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); @@ -774,79 +881,20 @@ void TestWebViewDelegate::DidChangeSelection(bool is_empty_selection) { UpdateSelectionClipboard(is_empty_selection); } -void TestWebViewDelegate::DidChangeContents() { +void TestWebViewDelegate::didChangeContents() { if (shell_->ShouldDumpEditingCallbacks()) { printf("EDITING DELEGATE: " "webViewDidChange:WebViewDidChangeNotification\n"); } } -void TestWebViewDelegate::DidEndEditing() { +void TestWebViewDelegate::didEndEditing() { if (shell_->ShouldDumpEditingCallbacks()) { printf("EDITING DELEGATE: " "webViewDidEndEditing:WebViewDidEndEditingNotification\n"); } } -void TestWebViewDelegate::NavigateBackForwardSoon(int offset) { - shell_->navigation_controller()->GoToOffset(offset); -} - -int TestWebViewDelegate::GetHistoryBackListCount() { - int current_index = - shell_->navigation_controller()->GetLastCommittedEntryIndex(); - return current_index; -} - -int TestWebViewDelegate::GetHistoryForwardListCount() { - int current_index = - shell_->navigation_controller()->GetLastCommittedEntryIndex(); - return shell_->navigation_controller()->GetEntryCount() - current_index - 1; -} - -void TestWebViewDelegate::SetUserStyleSheetEnabled(bool is_enabled) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->user_style_sheet_enabled = is_enabled; - prefs->Apply(shell_->webView()); -} - -void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->user_style_sheet_enabled = true; - prefs->user_style_sheet_location = location; - prefs->Apply(shell_->webView()); -} - -// WebWidgetClient ----------------------------------------------------------- - -void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) { - if (WebWidgetHost* host = GetWidgetHost()) - host->DidInvalidateRect(rect); -} - -void TestWebViewDelegate::didScrollRect(int dx, int dy, - const WebRect& clip_rect) { - if (WebWidgetHost* host = GetWidgetHost()) - host->DidScrollRect(dx, dy, clip_rect); -} - -void TestWebViewDelegate::didFocus() { - if (WebWidgetHost* host = GetWidgetHost()) - shell_->SetFocus(host, true); -} - -void TestWebViewDelegate::didBlur() { - if (WebWidgetHost* host = GetWidgetHost()) - shell_->SetFocus(host, false); -} - -WebScreenInfo TestWebViewDelegate::screenInfo() { - if (WebWidgetHost* host = GetWidgetHost()) - return host->GetScreenInfo(); - - return WebScreenInfo(); -} - // Public methods ------------------------------------------------------------ TestWebViewDelegate::TestWebViewDelegate(TestShell* shell) diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 9887246..d18999e 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -24,6 +24,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "base/weak_ptr.h" +#include "webkit/api/public/WebEditingClient.h" #if defined(OS_MACOSX) #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebPopupMenuInfo.h" @@ -44,6 +45,7 @@ class TestShell; class WebWidgetHost; class TestWebViewDelegate : public WebViewDelegate, + public WebKit::WebEditingClient, public webkit_glue::WebPluginPageDelegate, public base::SupportsWeakPtr<TestWebViewDelegate> { public: @@ -174,6 +176,7 @@ class TestWebViewDelegate : public WebViewDelegate, uint32 identifier, const WebKit::WebURLError& error); +#if 0 virtual bool ShouldBeginEditing(WebView* webview, std::wstring range); virtual bool ShouldEndEditing(WebView* webview, std::wstring range); virtual bool ShouldInsertNode(WebView* webview, @@ -199,6 +202,8 @@ class TestWebViewDelegate : public WebViewDelegate, virtual void DidChangeSelection(bool is_empty_selection); virtual void DidChangeContents(); virtual void DidEndEditing(); +#endif + virtual void WindowObjectCleared(WebKit::WebFrame* webframe); virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( WebView* webview, @@ -211,7 +216,7 @@ class TestWebViewDelegate : public WebViewDelegate, virtual int GetHistoryBackListCount(); virtual int GetHistoryForwardListCount(); - // WebWidgetClient + // WebKit::WebWidgetClient virtual void didInvalidateRect(const WebKit::WebRect& rect); virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clip_rect); @@ -227,6 +232,30 @@ class TestWebViewDelegate : public WebViewDelegate, virtual WebKit::WebRect windowResizerRect(); virtual WebKit::WebScreenInfo screenInfo(); + // 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_glue::WebPluginPageDelegate virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( const GURL& url, diff --git a/webkit/tools/test_shell/webview_host.h b/webkit/tools/test_shell/webview_host.h index 3c95e1d..0fd8490 100644 --- a/webkit/tools/test_shell/webview_host.h +++ b/webkit/tools/test_shell/webview_host.h @@ -17,7 +17,7 @@ struct WebPreferences; class WebView; -class WebViewDelegate; +class TestWebViewDelegate; // This class is a simple NativeView-based host for a WebView class WebViewHost : public WebWidgetHost { @@ -26,7 +26,7 @@ class WebViewHost : public WebWidgetHost { // The newly created window should be resized after it is created, using the // MoveWindow (or equivalent) function. static WebViewHost* Create(gfx::NativeView parent_view, - WebViewDelegate* delegate, + TestWebViewDelegate* delegate, const WebPreferences& prefs); WebView* webview() const; diff --git a/webkit/tools/test_shell/webview_host_gtk.cc b/webkit/tools/test_shell/webview_host_gtk.cc index 6554cc5..ededb21 100644 --- a/webkit/tools/test_shell/webview_host_gtk.cc +++ b/webkit/tools/test_shell/webview_host_gtk.cc @@ -13,19 +13,20 @@ #include "webkit/glue/plugins/gtk_plugin_container.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" +#include "webkit/tools/test_shell/test_webview_delegate.h" // static WebViewHost* WebViewHost::Create(GtkWidget* parent_view, - WebViewDelegate* delegate, + TestWebViewDelegate* delegate, const WebPreferences& prefs) { WebViewHost* host = new WebViewHost(); host->view_ = WebWidgetHost::CreateWidget(parent_view, host); host->plugin_container_manager_.set_host_widget(host->view_); - host->webwidget_ = WebView::Create(); + host->webwidget_ = WebView::Create(delegate, delegate); prefs.Apply(host->webview()); - host->webview()->InitializeMainFrame(delegate); + host->webview()->InitializeMainFrame(); host->webwidget_->layout(); return host; diff --git a/webkit/tools/test_shell/webview_host_win.cc b/webkit/tools/test_shell/webview_host_win.cc index 79b46b5..216e54d 100644 --- a/webkit/tools/test_shell/webview_host_win.cc +++ b/webkit/tools/test_shell/webview_host_win.cc @@ -10,12 +10,13 @@ #include "skia/ext/platform_canvas.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" +#include "webkit/tools/test_shell/test_webview_delegate.h" static const wchar_t kWindowClassName[] = L"WebViewHost"; /*static*/ WebViewHost* WebViewHost::Create(HWND parent_view, - WebViewDelegate* delegate, + TestWebViewDelegate* delegate, const WebPreferences& prefs) { WebViewHost* host = new WebViewHost(); @@ -38,9 +39,9 @@ WebViewHost* WebViewHost::Create(HWND parent_view, GetModuleHandle(NULL), NULL); win_util::SetWindowUserData(host->view_, host); - host->webwidget_ = WebView::Create(); + host->webwidget_ = WebView::Create(delegate, delegate); prefs.Apply(host->webview()); - host->webview()->InitializeMainFrame(delegate); + host->webview()->InitializeMainFrame(); return host; } diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index f700208..809506b 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -995,6 +995,8 @@ 'api/public/WebData.h', 'api/public/WebDataSource.h', 'api/public/WebDragData.h', + 'api/public/WebEditingAction.h', + 'api/public/WebEditingClient.h', 'api/public/WebFindOptions.h', 'api/public/WebFrame.h', 'api/public/WebForm.h', @@ -1031,6 +1033,7 @@ 'api/public/WebStorageArea.h', 'api/public/WebStorageNamespace.h', 'api/public/WebString.h', + 'api/public/WebTextAffinity.h', 'api/public/WebTextDirection.h', 'api/public/WebURL.h', 'api/public/WebURLError.h', @@ -1048,6 +1051,7 @@ 'api/public/win/WebScreenInfoFactory.h', 'api/public/win/WebScreenInfoFactory.h', 'api/src/ApplicationCacheHost.cpp', + 'api/src/AssertMatchingEnums.cpp', 'api/src/ChromiumBridge.cpp', 'api/src/ChromiumCurrentTime.cpp', 'api/src/ChromiumThreading.cpp', |