Index: third_party/WebKit/Source/web/WebViewImpl.cpp |
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp |
index f3691ab0d9df068f3dad7bc7368733ce2a5d264c..caf63c116b9aba46d5effc07d6631c5ada3117a4 100644 |
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp |
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp |
@@ -61,6 +61,7 @@ |
#include "core/frame/TopControls.h" |
#include "core/frame/UseCounter.h" |
#include "core/frame/VisualViewport.h" |
+#include "core/html/HTMLFormElement.h" |
#include "core/html/HTMLInputElement.h" |
#include "core/html/HTMLMediaElement.h" |
#include "core/html/HTMLPlugInElement.h" |
@@ -2421,6 +2422,39 @@ WebRange WebViewImpl::compositionRange() |
return PlainTextRange::create(*editable, range); |
} |
+int textInputActionFlags(int type, FocusController& focusController) { |
+ if (type == WebTextInputTypeSearch) { |
+ return WebTextInputFlagActionSearch; |
+ } |
+ HTMLElement* current = toHTMLElement(focusController.getCurrentElementForFocusNavigation(WebFocusTypeForward)); |
+ if (!current) |
+ return 0; |
+ |
+ HTMLFormElement* currentForm = FormAssociatedElement::findAssociatedForm(current); |
+ |
+ bool hasNextFocusableInFormOrDocument = false; |
+ // TODO(changwan): optimize this. |
+ Element* nextFocusableElement = focusController.findNextFocusableElementInDocumentOrder(); |
+ if (nextFocusableElement) { |
+ HTMLElement* nextFocusableHtmlElement = toHTMLElement(nextFocusableElement); |
+ if (nextFocusableHtmlElement) { |
+ HTMLFormElement* nextFocusableElementForm = FormAssociatedElement::findAssociatedForm(nextFocusableHtmlElement); |
+ // Both currentForm and nextFocusableElementForm may be nullptr. |
+ hasNextFocusableInFormOrDocument = currentForm == nextFocusableElementForm; |
+ } |
+ } |
+ |
+ int flags = 0; |
+ if (hasNextFocusableInFormOrDocument) { |
+ flags |= WebTextInputFlagActionNext; |
+ } else if (currentForm) { |
+ flags |= WebTextInputFlagActionGo; |
+ } else { |
+ flags |= WebTextInputFlagActionNone; |
+ } |
+ return flags; |
+} |
+ |
// TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as |
// well. This code needs to be refactored (http://crbug.com/629721). |
WebTextInputInfo WebViewImpl::textInputInfo() |
@@ -2456,6 +2490,8 @@ WebTextInputInfo WebViewImpl::textInputInfo() |
DocumentLifecycle::DisallowTransitionScope disallowTransition(focused->document()->lifecycle()); |
+ info.flags |= textInputActionFlags(info.type, page()->focusController()); |
+ |
// Emits an object replacement character for each replaced element so that |
// it is exposed to IME and thus could be deleted by IME on android. |
info.value = plainText(EphemeralRange::rangeOfContents(*element), TextIteratorEmitsObjectReplacementCharacter); |