Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2392463002: DO NOT SUBMIT: Fix input action type for Android
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« no previous file with comments | « third_party/WebKit/Source/core/page/FocusController.cpp ('k') | third_party/WebKit/public/web/WebTextInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698