summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/EditorClientImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/chromium/src/EditorClientImpl.cpp')
-rw-r--r--WebKit/chromium/src/EditorClientImpl.cpp64
1 files changed, 45 insertions, 19 deletions
diff --git a/WebKit/chromium/src/EditorClientImpl.cpp b/WebKit/chromium/src/EditorClientImpl.cpp
index d5bddc5..bc1d206 100644
--- a/WebKit/chromium/src/EditorClientImpl.cpp
+++ b/WebKit/chromium/src/EditorClientImpl.cpp
@@ -43,9 +43,11 @@
#include "DOMUtilitiesPrivate.h"
#include "WebEditingAction.h"
+#include "WebElement.h"
#include "WebFrameImpl.h"
#include "WebKit.h"
#include "WebInputElement.h"
+#include "WebInputEventConversion.h"
#include "WebNode.h"
#include "WebPasswordAutocompleteListener.h"
#include "WebRange.h"
@@ -90,7 +92,7 @@ bool EditorClientImpl::shouldShowDeleteInterface(HTMLElement* elem)
// Normally, we don't care to show WebCore's deletion UI, so we only enable
// it if in testing mode and the test specifically requests it by using this
// magic class name.
- return WebKit::layoutTestMode()
+ return layoutTestMode()
&& elem->getAttribute(HTMLNames::classAttr) == "needsDeletionUI";
}
@@ -122,7 +124,7 @@ bool EditorClientImpl::shouldSpellcheckByDefault()
const Editor* editor = frame->editor();
if (!editor)
return false;
- if (editor->spellCheckingEnabledInFocusedNode())
+ if (editor->isSpellCheckingEnabledInFocusedNode())
return true;
const Document* document = frame->document();
if (!document)
@@ -413,8 +415,10 @@ static const KeyDownEntry keyDownEntries[] = {
{ VKEY_DOWN, 0, "MoveDown" },
{ VKEY_DOWN, ShiftKey, "MoveDownAndModifySelection" },
{ VKEY_NEXT, ShiftKey, "MovePageDownAndModifySelection" },
+#if !OS(DARWIN)
{ VKEY_PRIOR, 0, "MovePageUp" },
{ VKEY_NEXT, 0, "MovePageDown" },
+#endif
{ VKEY_HOME, 0, "MoveToBeginningOfLine" },
{ VKEY_HOME, ShiftKey,
"MoveToBeginningOfLineAndModifySelection" },
@@ -422,6 +426,8 @@ static const KeyDownEntry keyDownEntries[] = {
{ VKEY_LEFT, CommandKey, "MoveToBeginningOfLine" },
{ VKEY_LEFT, CommandKey | ShiftKey,
"MoveToBeginningOfLineAndModifySelection" },
+ { VKEY_PRIOR, OptionKey, "MovePageUp" },
+ { VKEY_NEXT, OptionKey, "MovePageDown" },
#endif
#if OS(DARWIN)
{ VKEY_UP, CommandKey, "MoveToBeginningOfDocument" },
@@ -640,12 +646,19 @@ void EditorClientImpl::handleInputMethodKeydown(KeyboardEvent* keyEvent)
// We handle IME within chrome.
}
-void EditorClientImpl::textFieldDidBeginEditing(Element*)
+void EditorClientImpl::textFieldDidBeginEditing(Element* element)
{
+ HTMLInputElement* inputElement = toHTMLInputElement(element);
+ if (m_webView->client() && inputElement)
+ m_webView->client()->textFieldDidBeginEditing(WebInputElement(inputElement));
}
void EditorClientImpl::textFieldDidEndEditing(Element* element)
{
+ HTMLInputElement* inputElement = toHTMLInputElement(element);
+ if (m_webView->client() && inputElement)
+ m_webView->client()->textFieldDidEndEditing(WebInputElement(inputElement));
+
// Notification that focus was lost. Be careful with this, it's also sent
// when the page is being closed.
@@ -654,13 +667,12 @@ void EditorClientImpl::textFieldDidEndEditing(Element* element)
m_autofillTimer.stop();
// Hide any showing popup.
- m_webView->hideSuggestionsPopup();
+ 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.
- HTMLInputElement* inputElement = WebKit::toHTMLInputElement(element);
if (!inputElement)
return;
@@ -678,15 +690,18 @@ void EditorClientImpl::textFieldDidEndEditing(Element* element)
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));
+
// 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(static_cast<HTMLInputElement*>(element), false, false,
- true);
+ autofill(inputElement, false, false, true);
}
bool EditorClientImpl::showFormAutofillForNode(Node* node)
{
- HTMLInputElement* inputElement = WebKit::toHTMLInputElement(node);
+ HTMLInputElement* inputElement = toHTMLInputElement(node);
if (inputElement)
return autofill(inputElement, true, true, false);
return false;
@@ -701,10 +716,12 @@ bool EditorClientImpl::autofill(HTMLInputElement* inputElement,
m_autofillArgs.clear();
m_autofillTimer.stop();
+ // FIXME: Remove the extraneous isEnabledFormControl call below.
// Let's try to trigger autofill for that field, if applicable.
if (!inputElement->isEnabledFormControl() || !inputElement->isTextField()
- || inputElement->isPasswordField()
- || !inputElement->autoComplete())
+ || inputElement->isPasswordField() || !inputElement->autoComplete()
+ || !inputElement->isEnabledFormControl()
+ || inputElement->isReadOnlyFormControl())
return false;
WebString name = WebInputElement(inputElement).nameForAutofill();
@@ -748,7 +765,7 @@ void EditorClientImpl::doAutofill(Timer<EditorClientImpl>* timer)
&& inputElement->selectionEnd() == static_cast<int>(value.length());
if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) {
- m_webView->hideSuggestionsPopup();
+ m_webView->hideAutoFillPopup();
return;
}
@@ -784,22 +801,27 @@ void EditorClientImpl::cancelPendingAutofill()
m_autofillTimer.stop();
}
-void EditorClientImpl::onAutofillSuggestionAccepted(HTMLInputElement* textField)
+void EditorClientImpl::onAutocompleteSuggestionAccepted(HTMLInputElement* textField)
{
+ if (m_webView->client())
+ m_webView->client()->didAcceptAutocompleteSuggestion(WebInputElement(textField));
+
WebFrameImpl* webframe = WebFrameImpl::fromFrame(textField->document()->frame());
if (!webframe)
return;
- WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(textField);
- // Password listeners need to autocomplete other fields that depend on the
- // input element with autofill suggestions.
- if (listener)
- listener->performInlineAutocomplete(textField->value(), false, false);
+ webframe->notifiyPasswordListenerOfAutocomplete(WebInputElement(textField));
}
bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element,
KeyboardEvent* event)
{
+ HTMLInputElement* inputElement = toHTMLInputElement(element);
+ if (m_webView->client() && inputElement) {
+ m_webView->client()->textFieldDidReceiveKeyDown(WebInputElement(inputElement),
+ 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
@@ -913,10 +935,14 @@ void EditorClientImpl::getGuessesForWord(const String&,
notImplemented();
}
-void EditorClientImpl::setInputMethodState(bool enabled)
+void EditorClientImpl::willSetInputMethodState()
{
if (m_webView->client())
- m_webView->client()->setInputMethodEnabled(enabled);
+ m_webView->client()->resetInputMethod();
+}
+
+void EditorClientImpl::setInputMethodState(bool)
+{
}
} // namesace WebKit