| Index: Source/web/WebViewImpl.cpp
|
| diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
|
| index b1e7118cb1f524e3f2a50c6ef76f72406a734d44..94a73155ff805d826109ef4a55a52ce001e2db7b 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"
|
| @@ -2519,9 +2520,67 @@ int WebViewImpl::textInputFlags()
|
| }
|
| }
|
|
|
| + if (isListeningToKeyboardEvents(*element))
|
| + flags |= WebTextInputFlagListeningToKeyboardEvents;
|
| +
|
| + if (nextFocusableElement(element, WebFocusTypeForward))
|
| + flags |= WebTextInputFlagHaveNextFocusableElement;
|
| +
|
| + if (nextFocusableElement(element, WebFocusTypeBackward))
|
| + flags |= WebTextInputFlagHavePreviousFocusableElement;
|
| +
|
| return flags;
|
| }
|
|
|
| +Element* WebViewImpl::nextFocusableElement(Element* element, WebFocusType focusType)
|
| +{
|
| + if (!element->isFormControlElement())
|
| + return nullptr;
|
| +
|
| + HTMLFormControlElement* formControlElement = toHTMLFormControlElement(element);
|
| + HTMLFormElement* formOwner = formControlElement->formOwner();
|
| + if (!formOwner)
|
| + return nullptr;
|
| +
|
| + Node* nextNode = element;
|
| + while ((nextNode = page()->focusController().findFocusableNode(focusType, *nextNode))) {
|
| + if (!toElement(nextNode)->isFormControlElement())
|
| + continue;
|
| + HTMLFormControlElement* formElement = toHTMLFormControlElement(nextNode);
|
| + if (formElement->formOwner() != formOwner)
|
| + continue;
|
| + LayoutObject* layout = nextNode->layoutObject();
|
| + if (nextNode->isContentEditable() || (layout && layout->isTextControl())) {
|
| + // TODO(AKV) Extend it for Select element, Radio button and Check boxes
|
| + return toElement(nextNode);
|
| + }
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| +bool WebViewImpl::isListeningToKeyboardEvents(const Element& element)
|
| +{
|
| + if (!element.isFormControlElement())
|
| + return false;
|
| +
|
| + return (element.hasEventListeners(EventTypeNames::keydown) || element.hasEventListeners(EventTypeNames::keypress) || element.hasEventListeners(EventTypeNames::keyup));
|
| +}
|
| +
|
| +void WebViewImpl::advanceFocusToNextInputField(WebFocusType focusType)
|
| +{
|
| + Element* element = focusedElement();
|
| + if (!element)
|
| + return;
|
| +
|
| + Element* nextElement = nextFocusableElement(element, focusType);
|
| + if (!nextElement)
|
| + return;
|
| +
|
| + RefPtrWillBeRawPtr<Element> nextFocusElement = nextElement;
|
| + nextFocusElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/);
|
| + nextFocusElement->focus(false, focusType);
|
| +}
|
| +
|
| WebString WebViewImpl::inputModeOfFocusedElement()
|
| {
|
| if (!RuntimeEnabledFeatures::inputModeAttributeEnabled())
|
|
|