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

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 naming issue in Keyboard function name. 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
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())
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | public/web/WebTextInputType.h » ('j') | public/web/WebView.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698