+2011-08-24 Ilya Sherman <isherman@chromium.org>
+
+ 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 <tsepez@chromium.org>
chromium WebFrameImpl - don't load javascript URLs against chrome internal pages.
'public/WebPageSerializer.h',
'public/WebPageSerializerClient.h',
'public/WebPageVisibilityState.h',
- 'public/WebPasswordAutocompleteListener.h',
'public/WebPasswordFormData.h',
'public/WebPerformance.h',
'public/WebPermissionClient.h',
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&) { }
class WebFormElement;
class WebHistoryItem;
class WebInputElement;
-class WebPasswordAutocompleteListener;
class WebPerformance;
class WebRange;
class WebSecurityOrigin;
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
+++ /dev/null
-/*
- * 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
#include "WebInputElement.h"
#include "WebInputEventConversion.h"
#include "WebNode.h"
-#include "WebPasswordAutocompleteListener.h"
#include "WebPermissionClient.h"
#include "WebRange.h"
#include "WebSpellCheckClient.h"
// 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)
{
}
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())
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)
// 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)
HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(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<EditorClientImpl>* timer)
-{
- OwnPtr<AutofillArgs> 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<int>(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,
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.
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<EditorClientImpl>*);
-
- 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 <textarea> element or an element whose
EditCommandStack m_undoStack;
EditCommandStack m_redoStack;
- // Whether the last entered key was a backspace.
- bool m_backspaceOrDeletePressed;
-
// This flag is set to false if spell check for this editor is manually
// turned off. The default setting is SpellCheckAutomatic.
enum {
SpellCheckForcedOff
};
int m_spellCheckThisFieldStatus;
-
- // Used to delay autofill processing.
- WebCore::Timer<EditorClientImpl> m_autofillTimer;
-
- struct AutofillArgs {
- RefPtr<WebCore::HTMLInputElement> inputElement;
- bool autofillFormOnly;
- bool autofillOnEmptyValue;
- bool requireCaretAtEnd;
- bool backspaceOrDeletePressed;
- };
- OwnPtr<AutofillArgs> m_autofillArgs;
};
} // namespace WebKit
void FrameLoaderClientImpl::dispatchDidFinishDocumentLoad()
{
- // A frame may be reused. This call ensures we don't hold on to our password
- // listeners and their associated HTMLInputElements.
- m_webFrame->clearPasswordListeners();
-
if (m_webFrame->client())
m_webFrame->client()->didFinishDocumentLoad(m_webFrame);
}
#include "WebIconURL.h"
#include "WebInputElement.h"
#include "WebNode.h"
-#include "WebPasswordAutocompleteListener.h"
#include "WebPerformance.h"
#include "WebPlugin.h"
#include "WebPluginContainerImpl.h"
for (Frame* curChild = frameTree->firstChild(); curChild; curChild = curChild->tree()->nextSibling()) {
// Ignore the text of non-visible frames.
RenderView* contentRenderer = curChild->contentRenderer();
- RenderPart* ownerRenderer = curChild->ownerRenderer();
+ RenderPart* ownerRenderer = curChild->ownerRenderer();
if (!contentRenderer || !contentRenderer->width() || !contentRenderer->height()
|| (contentRenderer->x() + contentRenderer->width() <= 0) || (contentRenderer->y() + contentRenderer->height() <= 0)
|| (ownerRenderer && ownerRenderer->style() && ownerRenderer->style()->visibility() != VISIBLE)) {
// Set the new start for the search range to be the end of the previous
// result range. There is no need to use a VisiblePosition here,
// since findPlainText will use a TextIterator to go over the visible
- // text nodes.
+ // text nodes.
searchRange->setStart(resultRange->endContainer(ec), resultRange->endOffset(ec), ec);
Node* shadowTreeRoot = searchRange->shadowTreeRootNode();
frameCount--;
cancelPendingScopingEffort();
- clearPasswordListeners();
}
void WebFrameImpl::initializeAsMainFrame(WebViewImpl* webViewImpl)
m_frame->view()->setCanHaveScrollbars(canHaveScrollbars);
}
-bool WebFrameImpl::registerPasswordListener(
- WebInputElement inputElement,
- WebPasswordAutocompleteListener* listener)
-{
- RefPtr<HTMLInputElement> element(inputElement.unwrap<HTMLInputElement>());
- if (!m_passwordListeners.add(element, listener).second) {
- delete listener;
- return false;
- }
- return true;
-}
-
-void WebFrameImpl::notifiyPasswordListenerOfAutocomplete(
- const WebInputElement& inputElement)
-{
- const HTMLInputElement* element = inputElement.constUnwrap<HTMLInputElement>();
- WebPasswordAutocompleteListener* listener = getPasswordListener(element);
- // Password listeners need to autocomplete other fields that depend on the
- // input element with autofill suggestions.
- if (listener)
- listener->performInlineAutocomplete(element->value(), false, false);
-}
-
-WebPasswordAutocompleteListener* WebFrameImpl::getPasswordListener(
- const HTMLInputElement* inputElement)
-{
- return m_passwordListeners.get(RefPtr<HTMLInputElement>(const_cast<HTMLInputElement*>(inputElement)));
-}
-
// WebFrameImpl private --------------------------------------------------------
void WebFrameImpl::closing()
}
}
-void WebFrameImpl::clearPasswordListeners()
-{
- deleteAllValues(m_passwordListeners);
- m_passwordListeners.clear();
-}
-
void WebFrameImpl::loadJavaScriptURL(const KURL& url)
{
// This is copied from ScriptController::executeIfJavaScriptURL.
class WebDataSourceImpl;
class WebInputElement;
class WebFrameClient;
-class WebPasswordAutocompleteListener;
class WebPerformance;
class WebPluginContainerImpl;
class WebView;
virtual void cancelPendingScopingEffort();
virtual void increaseMatchCount(int count, int identifier);
virtual void resetMatchCount();
- virtual bool registerPasswordListener(
- WebInputElement, WebPasswordAutocompleteListener*);
- virtual void notifiyPasswordListenerOfAutocomplete(
- const WebInputElement&);
virtual WebString contentAsText(size_t maxChars) const;
virtual WebString contentAsMarkup() const;
// Otherwise, disallow scrolling.
void setCanHaveScrollbars(bool);
- // Returns the password autocomplete listener associated with the passed
- // user name input element, or 0 if none available.
- // Note that the returned listener is owner by the WebFrameImpl and should not
- // be kept around as it is deleted when the page goes away.
- WebPasswordAutocompleteListener* getPasswordListener(const WebCore::HTMLInputElement*);
-
WebFrameClient* client() const { return m_client; }
void setClient(WebFrameClient* client) { m_client = client; }
// Determines whether to invalidate the content area and scrollbar.
void invalidateIfNecessary();
- // Clears the map of password listeners.
- void clearPasswordListeners();
-
void loadJavaScriptURL(const WebCore::KURL&);
// Returns a hit-tested VisiblePosition for the given point
// information. Is used by PrintPage().
OwnPtr<ChromePrintContext> m_printContext;
- // The input fields that are interested in edit events and their associated
- // listeners.
- typedef HashMap<RefPtr<WebCore::HTMLInputElement>,
- WebPasswordAutocompleteListener*> PasswordListenerMap;
- PasswordListenerMap m_passwordListeners;
-
// Keeps a reference to the frame's WebAnimationController.
WebAnimationControllerImpl m_animationController;
m_lastMouseDownPoint = WebPoint(event.x, event.y);
- RefPtr<Node> clickedNode;
if (event.button == WebMouseEvent::ButtonLeft) {
IntPoint point(event.x, event.y);
point = m_page->mainFrame()->view()->windowToContents(point);
// Take capture on a mouse down on a plugin so we can send it mouse events.
if (hitNode && hitNode->renderer() && hitNode->renderer()->isEmbeddedObject())
m_mouseCaptureNode = hitNode;
-
- // If a text field that has focus is clicked again, we should display the
- // Autofill popup.
- RefPtr<Node> focusedNode = focusedWebCoreNode();
- if (focusedNode.get() && toHTMLInputElement(focusedNode.get())) {
- if (hitNode == focusedNode) {
- // Already focused text field was clicked, let's remember this. If
- // focus has not changed after the mouse event is processed, we'll
- // trigger the autocomplete.
- clickedNode = focusedNode;
- }
- }
}
mainFrameImpl()->frame()->loader()->resetMultipleFormSubmissionProtection();
mainFrameImpl()->frame()->eventHandler()->handleMousePressEvent(
PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
- if (clickedNode.get() && clickedNode == focusedWebCoreNode()) {
- // Focus has not changed, show the Autofill popup.
- static_cast<EditorClientImpl*>(m_page->editorClient())->
- showFormAutofillForNode(clickedNode.get());
- }
if (m_selectPopup && m_selectPopup == selectPopup) {
// That click triggered a select popup which is the same as the one that
// was showing before the click. It means the user clicked the select