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

Unified Diff: Source/web/WebViewImpl.cpp

Issue 939603002: Adding support for Smart GO NEXT feature in Android Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed the treescope problem for the current form. Created 5 years, 8 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
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | public/web/WebTextInputType.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 24c6618d60dcf9d6305107730de5e7ca771ec25f..19c1fb7d146d6521a915f2331cd0cbd626dfe021 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -116,6 +116,7 @@
#include "public/platform/WebCompositeAndReadbackAsyncCallback.h"
#include "public/platform/WebDragData.h"
#include "public/platform/WebFloatPoint.h"
+#include "public/platform/WebFocusType.h"
#include "public/platform/WebGestureCurve.h"
#include "public/platform/WebImage.h"
#include "public/platform/WebLayerTreeView.h"
@@ -2515,9 +2516,67 @@ int WebViewImpl::textInputFlags()
}
}
+ if (wantEnterEvents(element))
+ flags |= WebTextInputFlagWantEnterEvents;
+
+ if (haveNextInput(element, WebFocusTypeForward))
+ flags |= WebTextInputFlagHaveNextInput;
+
+ if (haveNextInput(element, WebFocusTypeBackward))
+ flags |= WebTextInputFlagHavePreviousInput;
+
return flags;
}
+Element* WebViewImpl::haveNextInput(Element* element, WebFocusType focusType)
+{
+ if (!element->isFormControlElement())
+ return nullptr;
+
+ HTMLFormControlElement* formControlElement = toHTMLFormControlElement(element);
+ Node* parentFormNode = reinterpret_cast<Node*>(formControlElement->formOwner());
+ if (!parentFormNode)
+ return nullptr;
+
+ Node* nextNode = element;
+ while ((nextNode = page()->focusController().findFocusableNode(focusType, *nextNode))) {
+ if (nextNode->isDescendantOf(parentFormNode)) {
+ LayoutObject* layout = nextNode->layoutObject();
+ if (nextNode->isContentEditable() || (layout && layout->isTextControl())) {
+ // TODO(AKV) Extend it for Select element, Radio button and Check boxes
+ if (nextNode->isElementNode())
+ return toElement(nextNode);
+ }
+ } else {
+ // TODO(AKV) Do we need to quit as and when we found a node which is not child of this form. (Need to discuss with Kochi)
kochi 2015/04/14 05:08:30 Yeah, I think once you go out of the current form,
AKV 2015/04/14 06:01:47 Thanks. I did same :)
+ }
+ }
+ return nullptr;
+}
+
+bool WebViewImpl::wantEnterEvents(Element* element)
+{
+ if (!element->isFormControlElement())
+ return false;
+
+ return (element->hasEventListeners(EventTypeNames::keydown) || element->hasEventListeners(EventTypeNames::keypress) || element->hasEventListeners(EventTypeNames::keystatuseschange) || element->hasEventListeners(EventTypeNames::keyup));
+}
+
+void WebViewImpl::advanceFocusToNextInputField(WebFocusType focusType)
+{
+ Element* element = focusedElement();
+ if (!element)
+ return;
+
+ Element* nextElement = haveNextInput(element, focusType);
+ if (!nextElement)
+ return;
+
+ nextElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/);
+ nextElement->dispatchSimulatedClick(0, SendMouseUpDownEvents);
+ nextElement->focus(false, focusType);
+}
+
WebString WebViewImpl::inputModeOfFocusedElement()
{
if (!RuntimeEnabledFeatures::inputModeAttributeEnabled())
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | public/web/WebTextInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698