From bb928d92d9fe26e1158240e7c2eb156a5509254f Mon Sep 17 00:00:00 2001 From: "isherman@chromium.org" Date: Wed, 24 Aug 2011 23:01:55 +0000 Subject: [PATCH] Remove some dead Autofill code https://bugs.webkit.org/show_bug.cgi?id=66899 http://code.google.com/p/chromium/issues/detail?id=51644 Reviewed by James Robinson. * WebKit.gyp: * public/WebAutofillClient.h: * public/WebFrame.h: * public/WebPasswordAutocompleteListener.h: Removed. * src/EditorClientImpl.cpp: (WebKit::EditorClientImpl::EditorClientImpl): (WebKit::EditorClientImpl::handleKeyboardEvent): (WebKit::EditorClientImpl::textFieldDidBeginEditing): (WebKit::EditorClientImpl::textFieldDidEndEditing): (WebKit::EditorClientImpl::textDidChangeInTextField): (WebKit::EditorClientImpl::doTextFieldCommandFromEvent): * src/EditorClientImpl.h: * src/FrameLoaderClientImpl.cpp: (WebKit::FrameLoaderClientImpl::dispatchDidFinishDocumentLoad): * src/WebFrameImpl.cpp: (WebKit::frameContentAsPlainText): (WebKit::WebFrameImpl::scopeStringMatches): (WebKit::WebFrameImpl::~WebFrameImpl): * src/WebFrameImpl.h: * src/WebViewImpl.cpp: (WebKit::WebViewImpl::mouseDown): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93747 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebKit/chromium/ChangeLog | 30 ++++ Source/WebKit/chromium/WebKit.gyp | 1 - .../chromium/public/WebAutofillClient.h | 1 - Source/WebKit/chromium/public/WebFrame.h | 19 --- .../public/WebPasswordAutocompleteListener.h | 52 ------- .../WebKit/chromium/src/EditorClientImpl.cpp | 139 ------------------ Source/WebKit/chromium/src/EditorClientImpl.h | 44 ------ .../chromium/src/FrameLoaderClientImpl.cpp | 4 - Source/WebKit/chromium/src/WebFrameImpl.cpp | 41 +----- Source/WebKit/chromium/src/WebFrameImpl.h | 20 --- Source/WebKit/chromium/src/WebViewImpl.cpp | 18 --- 11 files changed, 32 insertions(+), 337 deletions(-) delete mode 100644 Source/WebKit/chromium/public/WebPasswordAutocompleteListener.h diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 0889b553faa0..666f5e3099c7 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,33 @@ +2011-08-24 Ilya Sherman + + Remove some dead Autofill code + https://bugs.webkit.org/show_bug.cgi?id=66899 + http://code.google.com/p/chromium/issues/detail?id=51644 + + Reviewed by James Robinson. + + * WebKit.gyp: + * public/WebAutofillClient.h: + * public/WebFrame.h: + * public/WebPasswordAutocompleteListener.h: Removed. + * src/EditorClientImpl.cpp: + (WebKit::EditorClientImpl::EditorClientImpl): + (WebKit::EditorClientImpl::handleKeyboardEvent): + (WebKit::EditorClientImpl::textFieldDidBeginEditing): + (WebKit::EditorClientImpl::textFieldDidEndEditing): + (WebKit::EditorClientImpl::textDidChangeInTextField): + (WebKit::EditorClientImpl::doTextFieldCommandFromEvent): + * src/EditorClientImpl.h: + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchDidFinishDocumentLoad): + * src/WebFrameImpl.cpp: + (WebKit::frameContentAsPlainText): + (WebKit::WebFrameImpl::scopeStringMatches): + (WebKit::WebFrameImpl::~WebFrameImpl): + * src/WebFrameImpl.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::mouseDown): + 2011-08-24 Tom Sepez chromium WebFrameImpl - don't load javascript URLs against chrome internal pages. diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index bd72a054f6e8..6e3915a3cb0c 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -234,7 +234,6 @@ 'public/WebPageSerializer.h', 'public/WebPageSerializerClient.h', 'public/WebPageVisibilityState.h', - 'public/WebPasswordAutocompleteListener.h', 'public/WebPasswordFormData.h', 'public/WebPerformance.h', 'public/WebPermissionClient.h', diff --git a/Source/WebKit/chromium/public/WebAutofillClient.h b/Source/WebKit/chromium/public/WebAutofillClient.h index 1eb7cb6f5fb8..5824f170a38c 100644 --- a/Source/WebKit/chromium/public/WebAutofillClient.h +++ b/Source/WebKit/chromium/public/WebAutofillClient.h @@ -71,7 +71,6 @@ public: const WebString& value) { } // 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&) { } diff --git a/Source/WebKit/chromium/public/WebFrame.h b/Source/WebKit/chromium/public/WebFrame.h index 5412764d27e1..26fb67f65ccd 100644 --- a/Source/WebKit/chromium/public/WebFrame.h +++ b/Source/WebKit/chromium/public/WebFrame.h @@ -59,7 +59,6 @@ class WebElement; class WebFormElement; class WebHistoryItem; class WebInputElement; -class WebPasswordAutocompleteListener; class WebPerformance; class WebRange; class WebSecurityOrigin; @@ -522,24 +521,6 @@ public: virtual void resetMatchCount() = 0; - // Password autocompletion --------------------------------------------- - - // Registers a listener for the specified user name input element. The - // listener will receive notifications for blur and when autocomplete - // should be triggered. - // An element can have only one listener. If a listener already exists, - // this method returns false and does not add the new one. - // Either way, the WebFrame becomes the owner of the passed listener. - virtual bool registerPasswordListener( - WebInputElement, - WebPasswordAutocompleteListener*) = 0; - - // Dispatches an Autocompletion notification to registered listener if one - // exists that is registered against the WebInputElement specified. - virtual void notifiyPasswordListenerOfAutocomplete( - const WebInputElement&) = 0; - - // Utility ------------------------------------------------------------- // Returns the contents of this frame as a string. If the text is diff --git a/Source/WebKit/chromium/public/WebPasswordAutocompleteListener.h b/Source/WebKit/chromium/public/WebPasswordAutocompleteListener.h deleted file mode 100644 index fdc8476cda48..000000000000 --- a/Source/WebKit/chromium/public/WebPasswordAutocompleteListener.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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. - */ - -#ifndef WebPasswordAutocompleteListener_h -#define WebPasswordAutocompleteListener_h - -namespace WebKit { -class WebString; - -class WebPasswordAutocompleteListener { -public: - virtual ~WebPasswordAutocompleteListener() {} - - virtual void didBlurInputElement( - const WebString& userInput) = 0; - - virtual void performInlineAutocomplete( - const WebString& userInput, - bool backSpaceOrDeletePressed, - bool showSuggestions) = 0; -}; - -} // namespace WebKit - -#endif diff --git a/Source/WebKit/chromium/src/EditorClientImpl.cpp b/Source/WebKit/chromium/src/EditorClientImpl.cpp index ca8d4f99e97c..ef305cc2f2f0 100644 --- a/Source/WebKit/chromium/src/EditorClientImpl.cpp +++ b/Source/WebKit/chromium/src/EditorClientImpl.cpp @@ -52,7 +52,6 @@ #include "WebInputElement.h" #include "WebInputEventConversion.h" #include "WebNode.h" -#include "WebPasswordAutocompleteListener.h" #include "WebPermissionClient.h" #include "WebRange.h" #include "WebSpellCheckClient.h" @@ -71,16 +70,10 @@ namespace WebKit { // into a single action. static const size_t maximumUndoStackDepth = 1000; -// The size above which we stop triggering autofill for an input text field -// (so to avoid sending long strings through IPC). -static const size_t maximumTextSizeForAutofill = 1000; - EditorClientImpl::EditorClientImpl(WebViewImpl* webview) : m_webView(webview) , m_inRedo(false) - , m_backspaceOrDeletePressed(false) , m_spellCheckThisFieldStatus(SpellCheckAutomatic) - , m_autofillTimer(this, &EditorClientImpl::doAutofill) { } @@ -643,12 +636,6 @@ bool EditorClientImpl::handleEditingKeyboardEvent(KeyboardEvent* evt) void EditorClientImpl::handleKeyboardEvent(KeyboardEvent* evt) { - if (evt->keyCode() == VKEY_DOWN - || evt->keyCode() == VKEY_UP) { - ASSERT(evt->target()->toNode()); - showFormAutofillForNode(evt->target()->toNode()); - } - // Give the embedder a chance to handle the keyboard event. if ((m_webView->client() && m_webView->client()->handleCurrentKeyboardEvent()) @@ -663,9 +650,6 @@ void EditorClientImpl::handleInputMethodKeydown(KeyboardEvent* keyEvent) void EditorClientImpl::textFieldDidBeginEditing(Element* element) { - HTMLInputElement* inputElement = toHTMLInputElement(element); - if (m_webView->autofillClient() && inputElement) - m_webView->autofillClient()->textFieldDidBeginEditing(WebInputElement(inputElement)); } void EditorClientImpl::textFieldDidEndEditing(Element* element) @@ -677,29 +661,8 @@ void EditorClientImpl::textFieldDidEndEditing(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 call. - m_autofillArgs.clear(); - m_autofillTimer.stop(); - // Hide any showing popup. m_webView->hideAutofillPopup(); - - if (!m_webView->client()) - return; // The page is getting closed, don't fill the password. - - // Notify any password-listener of the focus change. - if (!inputElement) - return; - - WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame()); - if (!webframe) - return; - - WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement); - if (!listener) - return; - - listener->didBlurInputElement(inputElement->value()); } void EditorClientImpl::textDidChangeInTextField(Element* element) @@ -708,102 +671,6 @@ void EditorClientImpl::textDidChangeInTextField(Element* element) HTMLInputElement* inputElement = static_cast(element); 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. - autofill(inputElement, false, false, true); -} - -bool EditorClientImpl::showFormAutofillForNode(Node* node) -{ - HTMLInputElement* inputElement = toHTMLInputElement(node); - if (inputElement) - return autofill(inputElement, true, true, false); - return false; -} - -bool EditorClientImpl::autofill(HTMLInputElement* inputElement, - bool autofillFormOnly, - bool autofillOnEmptyValue, - bool requireCaretAtEnd) -{ - // Cancel any pending DoAutofill call. - m_autofillArgs.clear(); - m_autofillTimer.stop(); - - // Let's try to trigger autofill for that field, if applicable. - if (!inputElement->isEnabledFormControl() || !inputElement->isTextField() - || inputElement->isPasswordField() || !inputElement->shouldAutocomplete() - || inputElement->isReadOnlyFormControl()) - return false; - - WebString name = WebInputElement(inputElement).nameForAutofill(); - if (name.isEmpty()) // If the field has no name, then we won't have values. - return false; - - // Don't attempt to autofill with values that are too large. - if (inputElement->value().length() > maximumTextSizeForAutofill) - return false; - - m_autofillArgs = adoptPtr(new AutofillArgs); - m_autofillArgs->inputElement = inputElement; - m_autofillArgs->autofillFormOnly = autofillFormOnly; - m_autofillArgs->autofillOnEmptyValue = autofillOnEmptyValue; - m_autofillArgs->requireCaretAtEnd = requireCaretAtEnd; - m_autofillArgs->backspaceOrDeletePressed = m_backspaceOrDeletePressed; - - if (!requireCaretAtEnd) - doAutofill(0); - 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. - m_autofillTimer.startOneShot(0.0); - } - return true; -} - -void EditorClientImpl::doAutofill(Timer* timer) -{ - OwnPtr args(m_autofillArgs.release()); - HTMLInputElement* inputElement = args->inputElement.get(); - - const String& value = inputElement->value(); - - // Enforce autofill_on_empty_value and caret_at_end. - - bool isCaretAtEnd = true; - if (args->requireCaretAtEnd) - isCaretAtEnd = inputElement->selectionStart() == inputElement->selectionEnd() - && inputElement->selectionEnd() == static_cast(value.length()); - - if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) { - m_webView->hideAutofillPopup(); - return; - } - - // First let's see if there is a password listener for that element. - // We won't trigger form autofill in that case, as having both behavior on - // a node would be confusing. - WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame()); - if (!webframe) - return; - WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement); - if (listener) { - if (args->autofillFormOnly) - return; - - listener->performInlineAutocomplete(value, - args->backspaceOrDeletePressed, - true); - return; - } -} - -void EditorClientImpl::cancelPendingAutofill() -{ - m_autofillArgs.clear(); - m_autofillTimer.stop(); } bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element, @@ -815,12 +682,6 @@ bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element, WebKeyboardEventBuilder(*event)); } - // Remember if backspace was pressed for the autofill. It is not clear how to - // find if backspace was pressed from textFieldDidBeginEditing and - // textDidChangeInTextField as when these methods are called the value of the - // input element already contains the type character. - m_backspaceOrDeletePressed = event->keyCode() == VKEY_BACK || event->keyCode() == VKEY_DELETE; - // The Mac code appears to use this method as a hook to implement special // keyboard commands specific to Safari's auto-fill implementation. We // just return false to allow the default action. diff --git a/Source/WebKit/chromium/src/EditorClientImpl.h b/Source/WebKit/chromium/src/EditorClientImpl.h index 6bcc79dd19f5..2ddee36dead7 100644 --- a/Source/WebKit/chromium/src/EditorClientImpl.h +++ b/Source/WebKit/chromium/src/EditorClientImpl.h @@ -118,38 +118,9 @@ public: virtual WebCore::TextCheckerClient* textChecker() { return this; } - // 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. - // Returns true if the autofill popup has been scheduled to be shown, false - // otherwise. - virtual bool showFormAutofillForNode(WebCore::Node*); - private: void modifySelection(WebCore::Frame*, WebCore::KeyboardEvent*); - // Triggers autofill for an input element if applicable. This can be form - // autofill (via a popup-menu) or password autofill depending on the - // input element. If |formAutofillOnly| is true, password autofill is not - // triggered. - // |autofillOnEmptyValue| indicates whether the autofill should be shown - // when the text-field is empty. - // If |requiresCaretAtEnd| is true, the autofill popup is only shown if the - // caret is located at the end of the entered text. - // Returns true if the autofill popup has been scheduled to be shown, false - // otherwise. - bool autofill(WebCore::HTMLInputElement*, - bool formAutofillOnly, bool autofillOnEmptyValue, - bool requiresCaretAtEnd); - - // Called to process the autofill described by m_autofillArgs. - // 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*); - - void cancelPendingAutofill(); - // 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