Chromium Code Reviews| 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()) |