| Index: Source/web/WebViewImpl.cpp
|
| diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
|
| index 24c6618d60dcf9d6305107730de5e7ca771ec25f..49b7fa35261ba6d33b89dbdeb5650a9d63280af1 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, parentFormNode, *nextNode))) {
|
| + 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);
|
| + }
|
| + // TODO(AKV) Need to handle when form has an iframe/frame as its child.
|
| + }
|
| + 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())
|
|
|