diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-05 04:20:31 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-05 04:20:31 +0000 |
commit | 5ae8ce17da13ea2755858d834c4e7e890534a069 (patch) | |
tree | d9930f99f8a6a182e673212df599501aba3b2ccb /webkit | |
parent | ffa2b24e61f3d5bb0696014b2f0acb1399bd31cc (diff) | |
download | chromium_src-5ae8ce17da13ea2755858d834c4e7e890534a069.zip chromium_src-5ae8ce17da13ea2755858d834c4e7e890534a069.tar.gz chromium_src-5ae8ce17da13ea2755858d834c4e7e890534a069.tar.bz2 |
Some cleanup to various WebCore client implementations.
Replaced usage of MessageLoop in EditorClientImpl with WebCore::Timer.
Changed the clients to be instance variables of WebViewImpl instead of
being separately heap allocated. This cleaned up some of the lifetime
issues.
R=dglazkov
Review URL: http://codereview.chromium.org/198030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/chrome_client_impl.cc | 12 | ||||
-rw-r--r-- | webkit/glue/context_menu_client_impl.cc | 23 | ||||
-rw-r--r-- | webkit/glue/context_menu_client_impl.h | 21 | ||||
-rw-r--r-- | webkit/glue/dragclient_impl.cc | 18 | ||||
-rw-r--r-- | webkit/glue/editor_client_impl.cc | 114 | ||||
-rw-r--r-- | webkit/glue/editor_client_impl.h | 54 | ||||
-rw-r--r-- | webkit/glue/inspector_client_impl.cc | 46 | ||||
-rw-r--r-- | webkit/glue/inspector_client_impl.h | 19 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 20 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 13 |
10 files changed, 157 insertions, 183 deletions
diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 5325a28..1f6b331 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -4,9 +4,6 @@ #include "config.h" -#include "base/compiler_specific.h" - -MSVC_PUSH_WARNING_LEVEL(0); #include "AccessibilityObject.h" #include "AXObjectCache.h" #include "CharacterNames.h" @@ -29,14 +26,8 @@ MSVC_PUSH_WARNING_LEVEL(0); #if USE(V8) #include "V8Proxy.h" #endif -MSVC_POP_WARNING(); - #undef LOG -#include "webkit/glue/chrome_client_impl.h" - -#include "base/gfx/rect.h" -#include "base/logging.h" #include "googleurl/src/gurl.h" #include "webkit/api/public/WebCursorInfo.h" #include "webkit/api/public/WebInputEvent.h" @@ -47,6 +38,7 @@ MSVC_POP_WARNING(); #include "webkit/api/public/WebURLRequest.h" #include "webkit/api/src/NotificationPresenterImpl.h" #include "webkit/api/src/WrappedResourceRequest.h" +#include "webkit/glue/chrome_client_impl.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webkit_glue.h" @@ -111,7 +103,7 @@ ChromeClientImpl::~ChromeClientImpl() { } void ChromeClientImpl::chromeDestroyed() { - delete this; + // Our lifetime is bound to the WebViewImpl. } void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) { diff --git a/webkit/glue/context_menu_client_impl.cc b/webkit/glue/context_menu_client_impl.cc index c3c6ff2..3a36fc5c 100644 --- a/webkit/glue/context_menu_client_impl.cc +++ b/webkit/glue/context_menu_client_impl.cc @@ -4,9 +4,6 @@ #include "config.h" -#include "base/compiler_specific.h" - -MSVC_PUSH_WARNING_LEVEL(0); #include "ContextMenu.h" #include "Document.h" #include "DocumentLoader.h" @@ -20,21 +17,18 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "KURL.h" #include "MediaError.h" #include "Widget.h" -MSVC_POP_WARNING(); #undef LOG -#include "webkit/glue/context_menu_client_impl.h" - #include "base/string_util.h" +#include "base/word_iterator.h" #include "webkit/api/public/WebURL.h" #include "webkit/api/public/WebURLResponse.h" #include "webkit/api/src/WebDataSourceImpl.h" #include "webkit/glue/context_menu.h" +#include "webkit/glue/context_menu_client_impl.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webview_impl.h" -#include "base/word_iterator.h" - using WebKit::WebDataSource; using WebKit::WebDataSourceImpl; @@ -79,8 +73,7 @@ std::wstring GetMisspelledWord(const WebCore::ContextMenu* default_menu, // Don't provide suggestions for multiple words. if (!IsASingleWord(misspelled_word_string)) return L""; - else - return misspelled_word_string; + return misspelled_word_string; } WebCore::HitTestResult hit_test_result = selected_frame->eventHandler()-> @@ -122,7 +115,7 @@ ContextMenuClientImpl::~ContextMenuClientImpl() { } void ContextMenuClientImpl::contextMenuDestroyed() { - delete this; + // Our lifetime is bound to the WebViewImpl. } // Figure out the URL of a page or subframe. Returns |page_type| as the type, @@ -328,11 +321,5 @@ void ContextMenuClientImpl::stopSpeaking() { } bool ContextMenuClientImpl::shouldIncludeInspectElementItem() { - return false; // TODO(jackson): Eventually include the inspector context menu item -} - -#if defined(OS_MACOSX) -void ContextMenuClientImpl::searchWithSpotlight() { - // TODO(pinkerton): write this + return false; } -#endif diff --git a/webkit/glue/context_menu_client_impl.h b/webkit/glue/context_menu_client_impl.h index 176196e..00d373b 100644 --- a/webkit/glue/context_menu_client_impl.h +++ b/webkit/glue/context_menu_client_impl.h @@ -1,23 +1,17 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_GLUE_CONTEXT_MENU_CLIENT_IMPL_H__ -#define WEBKIT_GLUE_CONTEXT_MENU_CLIENT_IMPL_H__ +#ifndef WEBKIT_GLUE_CONTEXT_MENU_CLIENT_IMPL_H_ +#define WEBKIT_GLUE_CONTEXT_MENU_CLIENT_IMPL_H_ -#include "build/build_config.h" - -#include "base/compiler_specific.h" - -MSVC_PUSH_WARNING_LEVEL(0); #include "ContextMenuClient.h" -MSVC_POP_WARNING(); class WebViewImpl; // Handles window-level notifications from WebCore on behalf of a WebView. class ContextMenuClientImpl : public WebCore::ContextMenuClient { -public: + public: ContextMenuClientImpl(WebViewImpl* webview) : webview_(webview) { } @@ -38,11 +32,8 @@ public: virtual void stopSpeaking(); virtual bool shouldIncludeInspectElementItem(); -#if defined(OS_MACOSX) - virtual void searchWithSpotlight(); -#endif -private: + private: WebViewImpl* webview_; // weak pointer }; -#endif // WEBKIT_GLUE_CONTEXT_MENU_CLIENT_IMPL_H__ +#endif // WEBKIT_GLUE_CONTEXT_MENU_CLIENT_IMPL_H_ diff --git a/webkit/glue/dragclient_impl.cc b/webkit/glue/dragclient_impl.cc index 1a7d73d..661a7a0 100644 --- a/webkit/glue/dragclient_impl.cc +++ b/webkit/glue/dragclient_impl.cc @@ -4,27 +4,15 @@ #include "config.h" -#include "base/compiler_specific.h" - -MSVC_PUSH_WARNING_LEVEL(0); +#include "ChromiumDataObject.h" #include "ClipboardChromium.h" -#include "DragData.h" #include "Frame.h" -#include "HitTestResult.h" -#include "Image.h" -#include "KURL.h" -MSVC_POP_WARNING(); #undef LOG -#include "webkit/glue/dragclient_impl.h" - -#include "base/logging.h" -#include "base/string_util.h" #include "webkit/api/public/WebDragData.h" -#include "webkit/glue/context_menu.h" +#include "webkit/glue/dragclient_impl.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_impl.h" using WebKit::WebDragData; @@ -83,5 +71,5 @@ WebCore::DragImageRef DragClientImpl::createDragImageForLink( } void DragClientImpl::dragControllerDestroyed() { - delete this; + // Our lifetime is bound to the WebViewImpl. } diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index 64a1869..a090eb7 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -6,7 +6,6 @@ // and I'm not really sure what to do about most of them. #include "config.h" -#include "webkit/glue/editor_client_impl.h" #include "Document.h" #include "EditCommand.h" @@ -22,10 +21,8 @@ #include "PlatformKeyboardEvent.h" #include "PlatformString.h" #include "RenderObject.h" - #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" @@ -40,11 +37,11 @@ #include "webkit/glue/webview.h" #include "webkit/glue/webview_impl.h" -using webkit_glue::AutofillForm; using WebKit::WebEditingAction; using WebKit::WebEditingClient; using WebKit::WebString; using WebKit::WebTextAffinity; +using webkit_glue::AutofillForm; // Arbitrary depth limit for the undo stack, to keep it from using // unbounded memory. This is the maximum number of distinct undoable @@ -63,14 +60,17 @@ EditorClientImpl::EditorClientImpl(WebViewImpl* web_view, in_redo_(false), backspace_or_delete_pressed_(false), spell_check_this_field_status_(SPELLCHECK_AUTOMATIC), - ALLOW_THIS_IN_INITIALIZER_LIST(autofill_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST( + autofill_timer_(this, &EditorClientImpl::DoAutofill)) { } EditorClientImpl::~EditorClientImpl() { } void EditorClientImpl::pageDestroyed() { - // Ignored since our lifetime is managed by the WebViewImpl. + // Our lifetime is bound to the WebViewImpl. This is our signal that we + // should no longer notify the consumer. + editing_client_ = NULL; } bool EditorClientImpl::shouldShowDeleteInterface(WebCore::HTMLElement* elem) { @@ -272,15 +272,15 @@ void EditorClientImpl::didSetSelectionTypesForPasteboard() { void EditorClientImpl::registerCommandForUndo( PassRefPtr<WebCore::EditCommand> command) { if (undo_stack_.size() == kMaximumUndoStackDepth) - undo_stack_.pop_front(); // drop oldest item off the far end + undo_stack_.removeFirst(); // drop oldest item off the far end if (!in_redo_) redo_stack_.clear(); - undo_stack_.push_back(command); + undo_stack_.append(command); } void EditorClientImpl::registerCommandForRedo( PassRefPtr<WebCore::EditCommand> command) { - redo_stack_.push_back(command); + redo_stack_.append(command); } void EditorClientImpl::clearUndoRedoOperations() { @@ -289,17 +289,18 @@ void EditorClientImpl::clearUndoRedoOperations() { } bool EditorClientImpl::canUndo() const { - return !undo_stack_.empty(); + return !undo_stack_.isEmpty(); } bool EditorClientImpl::canRedo() const { - return !redo_stack_.empty(); + return !redo_stack_.isEmpty(); } void EditorClientImpl::undo() { if (canUndo()) { - RefPtr<WebCore::EditCommand> command(undo_stack_.back()); - undo_stack_.pop_back(); + EditCommandStack::iterator back = --undo_stack_.end(); + RefPtr<WebCore::EditCommand> command(*back); + undo_stack_.remove(back); command->unapply(); // unapply will call us back to push this command onto the redo stack. } @@ -307,8 +308,9 @@ void EditorClientImpl::undo() { void EditorClientImpl::redo() { if (canRedo()) { - RefPtr<WebCore::EditCommand> command(redo_stack_.back()); - redo_stack_.pop_back(); + EditCommandStack::iterator back = --redo_stack_.end(); + RefPtr<WebCore::EditCommand> command(*back); + redo_stack_.remove(back); ASSERT(!in_redo_); in_redo_ = true; @@ -649,8 +651,9 @@ void EditorClientImpl::textFieldDidEndEditing(WebCore::Element* element) { // Notification that focus was lost. Be careful with this, it's also sent // when the page is being closed. - // Cancel any pending DoAutofill calls. - autofill_factory_.RevokeAll(); + // Cancel any pending DoAutofill call. + autofill_args_.clear(); + autofill_timer_.stop(); // Hide any showing popup. web_view_->HideAutoCompletePopup(); @@ -693,11 +696,12 @@ bool EditorClientImpl::ShowFormAutofillForNode(WebCore::Node* node) { } bool EditorClientImpl::Autofill(WebCore::HTMLInputElement* input_element, - bool form_autofill_only, + bool autofill_form_only, bool autofill_on_empty_value, - bool requires_caret_at_end) { - // Cancel any pending DoAutofill calls. - autofill_factory_.RevokeAll(); + bool require_caret_at_end) { + // Cancel any pending DoAutofill call. + autofill_args_.clear(); + autofill_timer_.stop(); // Let's try to trigger autofill for that field, if applicable. if (!input_element->isEnabledFormControl() || !input_element->isTextField() || @@ -713,41 +717,37 @@ bool EditorClientImpl::Autofill(WebCore::HTMLInputElement* input_element, if (input_element->value().length() > kMaximumTextSizeForAutofill) return false; - if (!requires_caret_at_end) { - DoAutofill(input_element, form_autofill_only, autofill_on_empty_value, - false, backspace_or_delete_pressed_); + autofill_args_ = new AutofillArgs(); + autofill_args_->input_element = input_element; + autofill_args_->autofill_form_only = autofill_form_only; + autofill_args_->autofill_on_empty_value = autofill_on_empty_value; + autofill_args_->require_caret_at_end = require_caret_at_end; + autofill_args_->backspace_or_delete_pressed = backspace_or_delete_pressed_; + + if (!require_caret_at_end) { + DoAutofill(NULL); } else { // We post a task for doing the autofill as the caret position is not set - // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and - // we need it to determine whether or not to trigger autofill. - std::wstring value = - webkit_glue::StringToStdWString(input_element->value()); - MessageLoop::current()->PostTask( - FROM_HERE, - autofill_factory_.NewRunnableMethod(&EditorClientImpl::DoAutofill, - input_element, - form_autofill_only, - autofill_on_empty_value, - true, - backspace_or_delete_pressed_)); + // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) + // and we need it to determine whether or not to trigger autofill. + autofill_timer_.startOneShot(0.0); } return true; } -void EditorClientImpl::DoAutofill(WebCore::HTMLInputElement* input_element, - bool form_autofill_only, - bool autofill_on_empty_value, - bool requires_caret_at_end, - bool backspace) { +void EditorClientImpl::DoAutofill(WebCore::Timer<EditorClientImpl>* timer) { + OwnPtr<AutofillArgs> args(autofill_args_.release()); + WebCore::HTMLInputElement* input_element = args->input_element.get(); + std::wstring value = webkit_glue::StringToStdWString(input_element->value()); // Enforce autofill_on_empty_value and caret_at_end. - bool is_caret_at_end = requires_caret_at_end ? - input_element->selectionStart() == input_element->selectionEnd() && - input_element->selectionEnd() == static_cast<int>(value.length()) : - true; // When |requires_caret_at_end| is false, just pretend we are at - // the end. - if ((!autofill_on_empty_value && value.empty()) || !is_caret_at_end) { + bool is_caret_at_end = args->require_caret_at_end ? + input_element->selectionStart() == input_element->selectionEnd() && + input_element->selectionEnd() == static_cast<int>(value.length()) : + true; // When |require_caret_at_end| is false, just pretend we are at + // the end. + if ((!args->autofill_on_empty_value && value.empty()) || !is_caret_at_end) { web_view_->HideAutoCompletePopup(); return; } @@ -760,18 +760,26 @@ void EditorClientImpl::DoAutofill(WebCore::HTMLInputElement* input_element, webkit_glue::PasswordAutocompleteListener* listener = webframe->GetPasswordListener(input_element); if (listener) { - if (form_autofill_only) + if (args->autofill_form_only) return; - listener->OnInlineAutocompleteNeeded(input_element, value, backspace, true); + listener->OnInlineAutocompleteNeeded( + input_element, value, args->backspace_or_delete_pressed, true); return; } // Then trigger form autofill. std::wstring name = AutofillForm::GetNameForInputElement(input_element); - DCHECK_GT(static_cast<int>(name.length()), 0); - web_view_->delegate()->QueryFormFieldAutofill(name, value, - reinterpret_cast<int64>(input_element)); + ASSERT(static_cast<int>(name.length()) > 0); + + if (web_view_->delegate()) + web_view_->delegate()->QueryFormFieldAutofill(name, value, + reinterpret_cast<int64>(input_element)); +} + +void EditorClientImpl::CancelPendingAutofill() { + autofill_args_.clear(); + autofill_timer_.stop(); } void EditorClientImpl::OnAutofillSuggestionAccepted( diff --git a/webkit/glue/editor_client_impl.h b/webkit/glue/editor_client_impl.h index 1ca7ce1..c2712a9 100644 --- a/webkit/glue/editor_client_impl.h +++ b/webkit/glue/editor_client_impl.h @@ -5,12 +5,10 @@ #ifndef WEBKIT_GLUE_EDITOR_CLIENT_IMPL_H__ #define WEBKIT_GLUE_EDITOR_CLIENT_IMPL_H__ -#include <deque> - #include "DOMWindow.h" #include "EditorClient.h" - -#include "base/task.h" +#include "Timer.h" +#include <wtf/Deque.h> namespace WebCore { class Frame; @@ -29,8 +27,6 @@ class EditorClientImpl : public WebCore::EditorClient { EditorClientImpl(WebViewImpl* web_view, WebKit::WebEditingClient* editing_client); - void DropEditingClient() { editing_client_ = NULL; } - virtual ~EditorClientImpl(); virtual void pageDestroyed(); @@ -142,26 +138,15 @@ class EditorClientImpl : public WebCore::EditorClient { bool autofill_on_empty_value, bool requires_caret_at_end); - // This method is invoked later by Autofill() as when Autofill() is invoked - // (from one of the EditorClient callback) the carret position is not - // reflecting the last text change yet and we need it to decide whether or not - // to show the autofill popup. - void DoAutofill(WebCore::HTMLInputElement* input_element, - bool form_autofill_only, - bool autofill_on_empty_value, - bool requires_caret_at_end, - bool backspace); - - protected: - WebViewImpl* web_view_; - WebKit::WebEditingClient* editing_client_; - bool in_redo_; + private: + // Called to process the autofill described by autofill_args_. + // This method is invoked asynchronously if the caret position is not + // reflecting the last text change yet, and we need it to decide whether or + // not to show the autofill popup. + void DoAutofill(WebCore::Timer<EditorClientImpl>*); - typedef std::deque<WTF::RefPtr<WebCore::EditCommand> > EditCommandStack; - EditCommandStack undo_stack_; - EditCommandStack redo_stack_; + void CancelPendingAutofill(); - private: // Returns whether or not the focused control needs spell-checking. // Currently, this function just retrieves the focused node and determines // whether or not it is a <textarea> element or an element whose @@ -171,6 +156,14 @@ class EditorClientImpl : public WebCore::EditorClient { // for text fields and create a flag to over-write the default behavior. bool ShouldSpellcheckByDefault(); + WebViewImpl* web_view_; + WebKit::WebEditingClient* editing_client_; + bool in_redo_; + + typedef Deque< RefPtr<WebCore::EditCommand> > EditCommandStack; + EditCommandStack undo_stack_; + EditCommandStack redo_stack_; + // Whether the last entered key was a backspace. bool backspace_or_delete_pressed_; @@ -183,8 +176,17 @@ class EditorClientImpl : public WebCore::EditorClient { }; int spell_check_this_field_status_; - // The method factory used to post autofill related tasks. - ScopedRunnableMethodFactory<EditorClientImpl> autofill_factory_; + // Used to delay autofill processing. + WebCore::Timer<EditorClientImpl> autofill_timer_; + + struct AutofillArgs { + RefPtr<WebCore::HTMLInputElement> input_element; + bool autofill_form_only; + bool autofill_on_empty_value; + bool require_caret_at_end; + bool backspace_or_delete_pressed; + }; + OwnPtr<AutofillArgs> autofill_args_; }; #endif // WEBKIT_GLUE_EDITOR_CLIENT_IMPL_H__ diff --git a/webkit/glue/inspector_client_impl.cc b/webkit/glue/inspector_client_impl.cc index aee17a8..cf639b2 100644 --- a/webkit/glue/inspector_client_impl.cc +++ b/webkit/glue/inspector_client_impl.cc @@ -41,51 +41,51 @@ static const float kDefaultInspectorYPos = 50; static const float kDefaultInspectorHeight = 640; static const float kDefaultInspectorWidth = 480; -WebInspectorClient::WebInspectorClient(WebViewImpl* webView) - : inspected_web_view_(webView) { +InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView) + : inspected_web_view_(webView) { ASSERT(inspected_web_view_); } -WebInspectorClient::~WebInspectorClient() { +InspectorClientImpl::~InspectorClientImpl() { } -void WebInspectorClient::inspectorDestroyed() { - delete this; +void InspectorClientImpl::inspectorDestroyed() { + // Our lifetime is bound to the WebViewImpl. } -Page* WebInspectorClient::createPage() { +Page* InspectorClientImpl::createPage() { // This method should never be called in Chrome as inspector front-end lives // in a separate process. NOTREACHED(); return NULL; } -void WebInspectorClient::showWindow() { +void InspectorClientImpl::showWindow() { DCHECK(inspected_web_view_->GetWebDevToolsAgentImpl()); InspectorController* inspector = inspected_web_view_->page()->inspectorController(); inspector->setWindowVisible(true); } -void WebInspectorClient::closeWindow() { +void InspectorClientImpl::closeWindow() { if (inspected_web_view_->page()) inspected_web_view_->page()->inspectorController()->setWindowVisible(false); } -bool WebInspectorClient::windowVisible() { +bool InspectorClientImpl::windowVisible() { DCHECK(inspected_web_view_->GetWebDevToolsAgentImpl()); return false; } -void WebInspectorClient::attachWindow() { +void InspectorClientImpl::attachWindow() { // TODO(jackson): Implement this } -void WebInspectorClient::detachWindow() { +void InspectorClientImpl::detachWindow() { // TODO(jackson): Implement this } -void WebInspectorClient::setAttachedWindowHeight(unsigned int height) { +void InspectorClientImpl::setAttachedWindowHeight(unsigned int height) { // TODO(dglazkov): Implement this NOTIMPLEMENTED(); } @@ -100,33 +100,33 @@ static void invalidateNodeBoundingRect(WebViewImpl* web_view) { web_view->GetDelegate()->didInvalidateRect(damaged_rect); } -void WebInspectorClient::highlight(Node* node) { +void InspectorClientImpl::highlight(Node* node) { // InspectorController does the actually tracking of the highlighted node // and the drawing of the highlight. Here we just make sure to invalidate // the rects of the old and new nodes. hideHighlight(); } -void WebInspectorClient::hideHighlight() { +void InspectorClientImpl::hideHighlight() { // TODO: Should be able to invalidate a smaller rect. invalidateNodeBoundingRect(inspected_web_view_); } -void WebInspectorClient::inspectedURLChanged(const String& newURL) { +void InspectorClientImpl::inspectedURLChanged(const String& newURL) { // TODO(jackson): Implement this } -String WebInspectorClient::localizedStringsURL() { +String InspectorClientImpl::localizedStringsURL() { NOTIMPLEMENTED(); return String(); } -String WebInspectorClient::hiddenPanels() { +String InspectorClientImpl::hiddenPanels() { // Enumerate tabs that are currently disabled. return "scripts,profiles,databases"; } -void WebInspectorClient::populateSetting( +void InspectorClientImpl::populateSetting( const String& key, InspectorController::Setting& setting) { LoadSettings(); @@ -134,7 +134,7 @@ void WebInspectorClient::populateSetting( setting = settings_->get(key); } -void WebInspectorClient::storeSetting( +void InspectorClientImpl::storeSetting( const String& key, const InspectorController::Setting& setting) { LoadSettings(); @@ -142,17 +142,17 @@ void WebInspectorClient::storeSetting( SaveSettings(); } -void WebInspectorClient::removeSetting(const String& key) { +void InspectorClientImpl::removeSetting(const String& key) { LoadSettings(); settings_->remove(key); SaveSettings(); } -void WebInspectorClient::inspectorWindowObjectCleared() { +void InspectorClientImpl::inspectorWindowObjectCleared() { NOTIMPLEMENTED(); } -void WebInspectorClient::LoadSettings() { +void InspectorClientImpl::LoadSettings() { if (settings_) return; @@ -191,7 +191,7 @@ void WebInspectorClient::LoadSettings() { } } -void WebInspectorClient::SaveSettings() { +void InspectorClientImpl::SaveSettings() { String data; for (SettingsMap::iterator it = settings_->begin(); it != settings_->end(); ++it) { diff --git a/webkit/glue/inspector_client_impl.h b/webkit/glue/inspector_client_impl.h index 277c0ba..64d34d9 100644 --- a/webkit/glue/inspector_client_impl.h +++ b/webkit/glue/inspector_client_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_GLUE_INSPECTOR_CLIENT_IMPL_H__ -#define WEBKIT_GLUE_INSPECTOR_CLIENT_IMPL_H__ +#ifndef WEBKIT_GLUE_INSPECTOR_CLIENT_IMPL_H_ +#define WEBKIT_GLUE_INSPECTOR_CLIENT_IMPL_H_ #include "InspectorClient.h" #include "InspectorController.h" @@ -14,9 +14,10 @@ class WebNodeHighlight; class WebViewImpl; -class WebInspectorClient : public WebCore::InspectorClient { -public: - WebInspectorClient(WebViewImpl*); +class InspectorClientImpl : public WebCore::InspectorClient { + public: + InspectorClientImpl(WebViewImpl*); + ~InspectorClientImpl(); // InspectorClient virtual void inspectorDestroyed(); @@ -48,18 +49,16 @@ public: virtual void inspectorWindowObjectCleared(); -private: - ~WebInspectorClient(); - + private: void LoadSettings(); void SaveSettings(); // The WebViewImpl of the page being inspected; gets passed to the constructor - scoped_refptr<WebViewImpl> inspected_web_view_; + WebViewImpl* inspected_web_view_; typedef HashMap<WebCore::String, WebCore::InspectorController::Setting> SettingsMap; OwnPtr<SettingsMap> settings_; }; -#endif // WEBKIT_GLUE_INSPECTOR_CLIENT_IMPL_H__ +#endif // WEBKIT_GLUE_INSPECTOR_CLIENT_IMPL_H_ diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 2103ba5..f38c390 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -68,15 +68,10 @@ MSVC_POP_WARNING(); #include "webkit/api/public/WebString.h" #include "webkit/api/src/WebInputEventConversion.h" #include "webkit/api/src/WebSettingsImpl.h" -#include "webkit/glue/chrome_client_impl.h" -#include "webkit/glue/context_menu_client_impl.h" #include "webkit/glue/dom_operations.h" -#include "webkit/glue/dragclient_impl.h" -#include "webkit/glue/editor_client_impl.h" #include "webkit/glue/glue_serialize.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/image_resource_fetcher.h" -#include "webkit/glue/inspector_client_impl.h" #include "webkit/glue/media_player_action.h" #include "webkit/glue/searchable_form_data.h" #include "webkit/glue/webdevtoolsagent_impl.h" @@ -365,8 +360,12 @@ void WebView::ResetVisitedLinkState() { 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)), + ALLOW_THIS_IN_INITIALIZER_LIST(chrome_client_impl_(this)), + ALLOW_THIS_IN_INITIALIZER_LIST(context_menu_client_impl_(this)), + ALLOW_THIS_IN_INITIALIZER_LIST(drag_client_impl_(this)), + ALLOW_THIS_IN_INITIALIZER_LIST(editor_client_impl_(this, editing_client)), + ALLOW_THIS_IN_INITIALIZER_LIST(inspector_client_impl_(this)), observed_new_navigation_(false), #ifndef NDEBUG new_navigation_loader_(NULL), @@ -393,11 +392,11 @@ WebViewImpl::WebViewImpl(WebViewDelegate* delegate, last_mouse_position_ = WebPoint(-1, -1); // the page will take ownership of the various clients - page_.reset(new Page(new ChromeClientImpl(this), - new ContextMenuClientImpl(this), + page_.reset(new Page(&chrome_client_impl_, + &context_menu_client_impl_, &editor_client_impl_, - new DragClientImpl(this), - new WebInspectorClient(this))); + &drag_client_impl_, + &inspector_client_impl_)); page_->backForwardList()->setClient(&back_forward_list_client_impl_); page_->setGroupName(kPageGroupName); @@ -951,7 +950,6 @@ 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 ef181f0..2504c1e 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -18,7 +18,11 @@ #include "webkit/api/public/WebSize.h" #include "webkit/api/src/NotificationPresenterImpl.h" #include "webkit/glue/back_forward_list_client_impl.h" +#include "webkit/glue/chrome_client_impl.h" +#include "webkit/glue/context_menu_client_impl.h" +#include "webkit/glue/dragclient_impl.h" #include "webkit/glue/editor_client_impl.h" +#include "webkit/glue/inspector_client_impl.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" @@ -258,14 +262,19 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { const WebCore::PlatformKeyboardEvent& e); WebViewDelegate* delegate_; + + webkit_glue::BackForwardListClientImpl back_forward_list_client_impl_; + ChromeClientImpl chrome_client_impl_; + ContextMenuClientImpl context_menu_client_impl_; + DragClientImpl drag_client_impl_; EditorClientImpl editor_client_impl_; + InspectorClientImpl inspector_client_impl_; + WebKit::WebSize size_; WebKit::WebPoint last_mouse_position_; scoped_ptr<WebCore::Page> page_; - webkit_glue::BackForwardListClientImpl back_forward_list_client_impl_; - // This flag is set when a new navigation is detected. It is used to satisfy // the corresponding argument to WebViewDelegate::DidCommitLoadForFrame. bool observed_new_navigation_; |