2011-01-10 John Abd-El-Malek <jam@chromium.org>
authorjam@chromium.org <jam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jan 2011 00:27:16 +0000 (00:27 +0000)
committerjam@chromium.org <jam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jan 2011 00:27:16 +0000 (00:27 +0000)
        Reviewed by James Robinson.

        [chromium] Call WebAutoFillClient instead of WebViewClient for autofill related callbacks
        https://bugs.webkit.org/show_bug.cgi?id=52169

        * public/WebView.h:
        * public/WebViewClient.h:
        (WebKit::WebViewClient::didUpdateInspectorSetting):
        * src/AutoFillPopupMenuClient.cpp:
        (WebKit::AutoFillPopupMenuClient::valueChanged):
        (WebKit::AutoFillPopupMenuClient::selectionChanged):
        (WebKit::AutoFillPopupMenuClient::selectionCleared):
        (WebKit::AutoFillPopupMenuClient::popupDidHide):
        * src/EditorClientImpl.cpp:
        (WebKit::EditorClientImpl::textFieldDidBeginEditing):
        (WebKit::EditorClientImpl::textFieldDidEndEditing):
        (WebKit::EditorClientImpl::textDidChangeInTextField):
        (WebKit::EditorClientImpl::doAutofill):
        (WebKit::EditorClientImpl::onAutocompleteSuggestionAccepted):
        (WebKit::EditorClientImpl::doTextFieldCommandFromEvent):
        * src/WebViewImpl.cpp:
        (WebKit::WebView::create):
        (WebKit::WebViewImpl::WebViewImpl):
        (WebKit::WebViewImpl::autocompleteHandleKeyEvent):
        * src/WebViewImpl.h:
        (WebKit::WebViewImpl::autoFillClient):
        * src/WebWorkerBase.cpp:
        (WebKit::WebWorkerBase::initializeLoader):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@75448 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Tools/DumpRenderTree/chromium/TestShell.cpp
WebKit/chromium/ChangeLog
WebKit/chromium/DEPS
WebKit/chromium/public/WebView.h
WebKit/chromium/public/WebViewClient.h
WebKit/chromium/src/AutoFillPopupMenuClient.cpp
WebKit/chromium/src/EditorClientImpl.cpp
WebKit/chromium/src/WebViewImpl.cpp
WebKit/chromium/src/WebViewImpl.h
WebKit/chromium/src/WebWorkerBase.cpp
WebKit/chromium/tests/PopupMenuTest.cpp
WebKit/chromium/tests/WebFrameTest.cpp

index 14fcdc7..ec6a502 100644 (file)
@@ -571,7 +571,7 @@ WebViewHost* TestShell::createNewWindow(const WebKit::WebURL& url)
 WebViewHost* TestShell::createNewWindow(const WebKit::WebURL& url, DRTDevToolsAgent* devToolsAgent)
 {
     WebViewHost* host = new WebViewHost(this);
-    WebView* view = WebView::create(host, devToolsAgent);
+    WebView* view = WebView::create(host, devToolsAgent, 0);
     host->setWebWidget(view);
     m_prefs.applyTo(view);
     view->initializeMainFrame(host);
index a85bc15..49501c5 100644 (file)
@@ -1,3 +1,34 @@
+2011-01-10  John Abd-El-Malek  <jam@chromium.org>
+
+        Reviewed by James Robinson.
+
+        [chromium] Call WebAutoFillClient instead of WebViewClient for autofill related callbacks
+        https://bugs.webkit.org/show_bug.cgi?id=52169
+
+        * public/WebView.h:
+        * public/WebViewClient.h:
+        (WebKit::WebViewClient::didUpdateInspectorSetting):
+        * src/AutoFillPopupMenuClient.cpp:
+        (WebKit::AutoFillPopupMenuClient::valueChanged):
+        (WebKit::AutoFillPopupMenuClient::selectionChanged):
+        (WebKit::AutoFillPopupMenuClient::selectionCleared):
+        (WebKit::AutoFillPopupMenuClient::popupDidHide):
+        * src/EditorClientImpl.cpp:
+        (WebKit::EditorClientImpl::textFieldDidBeginEditing):
+        (WebKit::EditorClientImpl::textFieldDidEndEditing):
+        (WebKit::EditorClientImpl::textDidChangeInTextField):
+        (WebKit::EditorClientImpl::doAutofill):
+        (WebKit::EditorClientImpl::onAutocompleteSuggestionAccepted):
+        (WebKit::EditorClientImpl::doTextFieldCommandFromEvent):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebView::create):
+        (WebKit::WebViewImpl::WebViewImpl):
+        (WebKit::WebViewImpl::autocompleteHandleKeyEvent):
+        * src/WebViewImpl.h:
+        (WebKit::WebViewImpl::autoFillClient):
+        * src/WebWorkerBase.cpp:
+        (WebKit::WebWorkerBase::initializeLoader):
+
 2011-01-10  John Knottenbelt  <jknotten@chromium.org>
 
         Reviewed by Jeremy Orlow.
index b6cbd68..58aeb5c 100644 (file)
@@ -32,7 +32,7 @@
 
 vars = {
   'chromium_svn': 'http://src.chromium.org/svn/trunk/src',
-  'chromium_rev': '70844'
+  'chromium_rev': '70952'
 }
 
 deps = {
@@ -107,6 +107,8 @@ deps = {
     Var('chromium_svn')+'/tools/grit@'+Var('chromium_rev'),
   'tools/generate_stubs':
     Var('chromium_svn')+'/tools/generate_stubs@'+Var('chromium_rev'),
+  'ui':
+    Var('chromium_svn')+'/ui@'+Var('chromium_rev'), # needed by app
 
   # other third party
   'third_party/icu':
index a18a64e..4243998 100644 (file)
 #include "WebVector.h"
 #include "WebWidget.h"
 
+// FIXME(jam): take out once Chromium rolls past this revision
+#define WEBKIT_HAS_WEB_AUTO_FILL_CLIENT
+
 namespace WebKit {
 
 class WebAccessibilityObject;
+class WebAutoFillClient;
 class WebDevToolsAgent;
 class WebDevToolsAgentClient;
 class WebDragData;
@@ -81,8 +85,10 @@ public:
 
     // Creates a WebView that is NOT yet initialized.  You will need to
     // call initializeMainFrame to finish the initialization.  It is valid
-    // to pass null WebViewClient and WebDevToolsAgentClient pointers.
-    WEBKIT_API static WebView* create(WebViewClient*, WebDevToolsAgentClient*);
+    // to pass null client pointers.
+    WEBKIT_API static WebView* create(WebViewClient*,
+                                      WebDevToolsAgentClient*,
+                                      WebAutoFillClient*);
 
     // After creating a WebView, you should immediately call this method.
     // You can optionally modify the settings before calling this method.
index da7a1b3..a3ad9b4 100644 (file)
@@ -166,12 +166,6 @@ public:
     virtual void didExecuteCommand(const WebString& commandName) { }
     virtual void didEndEditing() { }
 
-    // These methods are called when the users edits a text-field.
-    virtual void textFieldDidBeginEditing(const WebInputElement&) { }
-    virtual void textFieldDidEndEditing(const WebInputElement&) { }
-    virtual void textFieldDidChange(const WebInputElement&) { }
-    virtual void textFieldDidReceiveKeyDown(const WebInputElement&, const WebKeyboardEvent&) { }
-
     // This method is called in response to WebView's handleInputEvent()
     // when the default action for the current keyboard event is not
     // suppressed by the page, to give the embedder a chance to handle
@@ -311,52 +305,6 @@ public:
 
     virtual void didUpdateInspectorSetting(const WebString& key, const WebString& value) { }
 
-
-    // AutoFill ------------------------------------------------------------
-
-    // Queries the browser for suggestions to be shown for the form text
-    // field named |name|.  |value| is the text entered by the user so
-    // far and the WebNode corresponds to the input field.
-    virtual void queryAutofillSuggestions(const WebNode&,
-                                          const WebString& name,
-                                          const WebString& value) { }
-
-    // Instructs the browser to remove the Autocomplete entry specified from
-    // its DB.
-    // FIXME: This method should be named removeAutocompleteSugestion.
-    virtual void removeAutofillSuggestions(const WebString& name,
-                                           const WebString& value) { }
-
-    // Informs the browser that the user has accepted an AutoFill suggestion for
-    // a WebNode.  |uniqueID| is used as a key into the set of AutoFill profiles,
-    // and should never be negative.  If it is 0, then the suggestion is an
-    // Autocomplete suggestion; and |value| stores the suggested text.  |index|
-    // is an index of the selected suggestion in the list of suggestions provided
-    // by the client.
-    virtual void didAcceptAutoFillSuggestion(const WebNode&,
-                                             const WebString& value,
-                                             const WebString& label,
-                                             int uniqueID,
-                                             unsigned index) { }
-
-    // Informs the browser that the user has selected an AutoFill suggestion for
-    // a WebNode.  This happens when the user hovers over a suggestion or uses
-    // the arrow keys to navigate to a suggestion.
-    virtual void didSelectAutoFillSuggestion(const WebNode&,
-                                             const WebString& name,
-                                             const WebString& label,
-                                             int uniqueID) { }
-
-    // Informs the browser that the user has cleared the selection from the
-    // AutoFill suggestions popup.  This happens when a user uses the arrow
-    // keys to navigate outside the range of possible selections.
-    virtual void didClearAutoFillSelection(const WebNode&) { }
-
-    // Informs the browser that the user has selected an autocomplete (password
-    // or field) suggestion from the drop-down.  The input element text has
-    // already been set to the selected suggestion.
-    virtual void didAcceptAutocompleteSuggestion(const WebInputElement&) { }
-
     // Geolocation ---------------------------------------------------------
 
     // Access the embedder API for (client-based) geolocation client .
index 704ba69..4f57994 100644 (file)
@@ -37,6 +37,7 @@
 #include "FrameView.h"
 #include "HTMLInputElement.h"
 #include "RenderTheme.h"
+#include "WebAutoFillClient.h"
 #include "WebNode.h"
 #include "WebString.h"
 #include "WebVector.h"
@@ -131,11 +132,11 @@ void AutoFillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents)
 
     ASSERT(listIndex < m_names.size());
 
-    webView->client()->didAcceptAutoFillSuggestion(WebNode(getTextField()),
-                                                   m_names[listIndex],
-                                                   m_labels[listIndex],
-                                                   m_uniqueIDs[listIndex],
-                                                   listIndex);
+    webView->autoFillClient()->didAcceptAutoFillSuggestion(WebNode(getTextField()),
+                                                           m_names[listIndex],
+                                                           m_labels[listIndex],
+                                                           m_uniqueIDs[listIndex],
+                                                           listIndex);
 }
 
 void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents)
@@ -149,17 +150,17 @@ void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEven
 
     ASSERT(listIndex < m_names.size());
 
-    webView->client()->didSelectAutoFillSuggestion(WebNode(getTextField()),
-                                                   m_names[listIndex],
-                                                   m_labels[listIndex],
-                                                   m_uniqueIDs[listIndex]);
+    webView->autoFillClient()->didSelectAutoFillSuggestion(WebNode(getTextField()),
+                                                           m_names[listIndex],
+                                                           m_labels[listIndex],
+                                                           m_uniqueIDs[listIndex]);
 }
 
 void AutoFillPopupMenuClient::selectionCleared()
 {
     WebViewImpl* webView = getWebView();
     if (webView)
-        webView->client()->didClearAutoFillSelection(WebNode(getTextField()));
+        webView->autoFillClient()->didClearAutoFillSelection(WebNode(getTextField()));
 }
 
 String AutoFillPopupMenuClient::itemText(unsigned listIndex) const
@@ -219,7 +220,7 @@ void AutoFillPopupMenuClient::popupDidHide()
         return;
 
     webView->autoFillPopupDidHide();
-    webView->client()->didClearAutoFillSelection(WebNode(getTextField()));
+    webView->autoFillClient()->didClearAutoFillSelection(WebNode(getTextField()));
 }
 
 bool AutoFillPopupMenuClient::itemIsSeparator(unsigned listIndex) const
index 6f1739f..19b5873 100644 (file)
@@ -42,6 +42,7 @@
 #include "RenderObject.h"
 
 #include "DOMUtilitiesPrivate.h"
+#include "WebAutoFillClient.h"
 #include "WebEditingAction.h"
 #include "WebElement.h"
 #include "WebFrameImpl.h"
@@ -649,15 +650,15 @@ void EditorClientImpl::handleInputMethodKeydown(KeyboardEvent* keyEvent)
 void EditorClientImpl::textFieldDidBeginEditing(Element* element)
 {
     HTMLInputElement* inputElement = toHTMLInputElement(element);
-    if (m_webView->client() && inputElement)
-        m_webView->client()->textFieldDidBeginEditing(WebInputElement(inputElement));
+    if (m_webView->autoFillClient() && inputElement)
+        m_webView->autoFillClient()->textFieldDidBeginEditing(WebInputElement(inputElement));
 }
 
 void EditorClientImpl::textFieldDidEndEditing(Element* element)
 {
     HTMLInputElement* inputElement = toHTMLInputElement(element);
-    if (m_webView->client() && inputElement)
-        m_webView->client()->textFieldDidEndEditing(WebInputElement(inputElement));
+    if (m_webView->autoFillClient() && inputElement)
+        m_webView->autoFillClient()->textFieldDidEndEditing(WebInputElement(inputElement));
 
     // Notification that focus was lost.  Be careful with this, it's also sent
     // when the page is being closed.
@@ -691,8 +692,8 @@ void EditorClientImpl::textDidChangeInTextField(Element* element)
 {
     ASSERT(element->hasLocalName(HTMLNames::inputTag));
     HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
-    if (m_webView->client())
-        m_webView->client()->textFieldDidChange(WebInputElement(inputElement));
+    if (m_webView->autoFillClient())
+        m_webView->autoFillClient()->textFieldDidChange(WebInputElement(inputElement));
 
     // Note that we only show the autofill popup in this case if the caret is at
     // the end.  This matches FireFox and Safari but not IE.
@@ -785,14 +786,6 @@ void EditorClientImpl::doAutofill(Timer<EditorClientImpl>* timer)
                                             true);
         return;
     }
-
-    // Then trigger form autofill.
-    WebString name = WebInputElement(inputElement).nameForAutofill();
-    ASSERT(static_cast<int>(name.length()) > 0);
-
-    if (m_webView->client())
-        m_webView->client()->queryAutofillSuggestions(WebNode(inputElement),
-                                                      name, WebString(value));
 }
 
 void EditorClientImpl::cancelPendingAutofill()
@@ -803,8 +796,8 @@ void EditorClientImpl::cancelPendingAutofill()
 
 void EditorClientImpl::onAutocompleteSuggestionAccepted(HTMLInputElement* textField)
 {
-    if (m_webView->client())
-        m_webView->client()->didAcceptAutocompleteSuggestion(WebInputElement(textField));
+    if (m_webView->autoFillClient())
+        m_webView->autoFillClient()->didAcceptAutocompleteSuggestion(WebInputElement(textField));
 
     WebFrameImpl* webframe = WebFrameImpl::fromFrame(textField->document()->frame());
     if (!webframe)
@@ -817,9 +810,9 @@ bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element,
                                                    KeyboardEvent* event)
 {
     HTMLInputElement* inputElement = toHTMLInputElement(element);
-    if (m_webView->client() && inputElement) {
-        m_webView->client()->textFieldDidReceiveKeyDown(WebInputElement(inputElement),
-                                                        WebKeyboardEventBuilder(*event));
+    if (m_webView->autoFillClient() && inputElement) {
+        m_webView->autoFillClient()->textFieldDidReceiveKeyDown(WebInputElement(inputElement),
+                                                                WebKeyboardEventBuilder(*event));
     }
 
     // Remember if backspace was pressed for the autofill.  It is not clear how to
index 7056a0a..44efeea 100644 (file)
@@ -97,6 +97,7 @@
 #include "UserGestureIndicator.h"
 #include "Vector.h"
 #include "WebAccessibilityObject.h"
+#include "WebAutoFillClient.h"
 #include "WebDevToolsAgentPrivate.h"
 #include "WebDevToolsAgentImpl.h"
 #include "WebDragData.h"
@@ -212,13 +213,13 @@ static bool shouldUseExternalPopupMenus = false;
 
 // WebView ----------------------------------------------------------------
 
-WebView* WebView::create(WebViewClient* client, WebDevToolsAgentClient* devToolsClient)
+WebView* WebView::create(WebViewClient* client, WebDevToolsAgentClient* devToolsClient, WebAutoFillClient* autoFillClient)
 {
     // Keep runtime flag for device motion turned off until it's implemented.
     WebRuntimeFeatures::enableDeviceMotion(false);
 
     // Pass the WebViewImpl's self-reference to the caller.
-    return adoptRef(new WebViewImpl(client, devToolsClient)).leakRef();
+    return adoptRef(new WebViewImpl(client, devToolsClient, autoFillClient)).leakRef();
 }
 
 void WebView::setUseExternalPopupMenus(bool useExternalPopupMenus)
@@ -270,8 +271,9 @@ void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient)
     SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForLocalOnly);
 }
 
-WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devToolsClient)
+WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devToolsClient, WebAutoFillClient* autoFillClient)
     : m_client(client)
+    , m_autoFillClient(autoFillClient)
     , m_backForwardListClientImpl(this)
     , m_chromeClientImpl(this)
     , m_contextMenuClientImpl(this)
@@ -664,7 +666,7 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
 
         WebString name = WebInputElement(static_cast<HTMLInputElement*>(element)).nameForAutofill();
         WebString value = m_autoFillPopupClient->itemText(selectedIndex);
-        m_client->removeAutofillSuggestions(name, value);
+        m_autoFillClient->removeAutocompleteSuggestion(name, value);
         // Update the entries in the currently showing popup to reflect the
         // deletion.
         m_autoFillPopupClient->removeSuggestionAtIndex(selectedIndex);
index 0857d11..c9ecc16 100644 (file)
@@ -220,6 +220,11 @@ public:
         return m_client;
     }
 
+    WebAutoFillClient* autoFillClient()
+    {
+        return m_autoFillClient;
+    }
+
     // Returns the page object associated with this view. This may be null when
     // the page is shutting down, but will be valid at all other times.
     WebCore::Page* page() const
@@ -362,7 +367,7 @@ private:
       DragOver
     };
 
-    WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devToolsClient);
+    WebViewImpl(WebViewClient*, WebDevToolsAgentClient*, WebAutoFillClient*);
     ~WebViewImpl();
 
     // Returns true if the event was actually processed.
@@ -403,6 +408,7 @@ private:
 #endif
 
     WebViewClient* m_client;
+    WebAutoFillClient* m_autoFillClient;
 
     BackForwardListClientImpl m_backForwardListClientImpl;
     ChromeClientImpl m_chromeClientImpl;
index de4858c..06eb7b1 100644 (file)
@@ -170,7 +170,7 @@ void WebWorkerBase::initializeLoader(const WebURL& url)
     // loading requests from the worker context to the rest of WebKit and Chromium
     // infrastructure.
     ASSERT(!m_webView);
-    m_webView = WebView::create(0, 0);
+    m_webView = WebView::create(0, 0, 0);
     m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatures::isApplicationCacheEnabled());
     m_webView->initializeMainFrame(this);
 
index 4b6b123..dab5ff9 100644 (file)
@@ -181,7 +181,7 @@ public:
 protected:
     virtual void SetUp()
     {
-        m_webView = static_cast<WebViewImpl*>(WebView::create(&m_webviewClient, 0));
+        m_webView = static_cast<WebViewImpl*>(WebView::create(&m_webviewClient, 0, 0));
         m_webView->initializeMainFrame(&m_webFrameClient);
         m_popupMenu = adoptRef(new PopupMenuChromium(&m_popupMenuClient));
     }
index cf91cb4..540fa1b 100644 (file)
@@ -85,7 +85,7 @@ TEST_F(WebFrameTest, ContentText)
 
     // Create and initialize the WebView.    
     TestWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0, 0);
+    WebView* webView = WebView::create(0, 0, 0);
     webView->initializeMainFrame(&webFrameClient);
 
     // Load the main frame URL.