Commit 5312f6f0 authored by tkent@chromium.org's avatar tkent@chromium.org

Revert of Adding support for Smart GO NEXT feature in Android Chrome (patchset...

Revert of Adding support for Smart GO NEXT feature in Android Chrome (patchset #23 id:460001 of https://codereview.chromium.org/939603002/ )

Reason for revert:
Regression in power.android_acceptance.
crbug.com/520952


Original issue's description:
> Adding support for Smart GO NEXT feature in Android Chrome
> 
> This change takes care of providing easy navigation among text input
> elements inside a form.
> 
> Corresponding changes to control the PREVIOUS, NEXT and GO button is done
> at https://codereview.chromium.org/1080693002/
> 
> BUG=410785
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=200398

TBR=kochi@chromium.org,l.gombos@samsung.com,ajith.v@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=410785,520952

Review URL: https://codereview.chromium.org/1303123002

git-svn-id: svn://svn.chromium.org/blink/trunk@200948 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5b066328
......@@ -36,7 +36,6 @@
#include "core/InputTypeNames.h"
#include "core/clipboard/DataObject.h"
#include "core/dom/Document.h"
#include "core/dom/ElementTraversal.h"
#include "core/dom/Fullscreen.h"
#include "core/dom/LayoutTreeBuilderTraversal.h"
#include "core/dom/Text.h"
......@@ -62,7 +61,6 @@
#include "core/frame/SmartClip.h"
#include "core/frame/TopControls.h"
#include "core/frame/VisualViewport.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLMediaElement.h"
#include "core/html/HTMLPlugInElement.h"
......@@ -2493,78 +2491,9 @@ int WebViewImpl::textInputFlags()
}
}
if (isListeningToKeyboardEvents(element))
flags |= WebTextInputFlagListeningToKeyboardEvents;
if (nextFocusableElementInForm(element, WebFocusTypeForward))
flags |= WebTextInputFlagHaveNextFocusableElement;
if (nextFocusableElementInForm(element, WebFocusTypeBackward))
flags |= WebTextInputFlagHavePreviousFocusableElement;
return flags;
}
Element* WebViewImpl::nextFocusableElementInForm(Element* element, WebFocusType focusType)
{
if (!element->isFormControlElement() && !element->isContentEditable())
return nullptr;
HTMLFormElement* formOwner = nullptr;
if (element->isContentEditable())
formOwner = Traversal<HTMLFormElement>::firstAncestor(*element);
else
formOwner = toHTMLFormControlElement(element)->formOwner();
if (!formOwner)
return nullptr;
Element* nextElement = element;
for (nextElement = page()->focusController().findFocusableElement(focusType, *nextElement); nextElement; nextElement = page()->focusController().findFocusableElement(focusType, *nextElement)) {
if (nextElement->isContentEditable() && nextElement->isDescendantOf(formOwner))
return nextElement;
if (!nextElement->isFormControlElement())
continue;
HTMLFormControlElement* formElement = toHTMLFormControlElement(nextElement);
if (formElement->formOwner() != formOwner)
continue;
// Skip disabled or readonly editable elements.
if (formElement->isDisabledOrReadOnly())
continue;
LayoutObject* layout = nextElement->layoutObject();
if (layout && layout->isTextControl()) {
// TODO(ajith.v) Extend it for Select element, Radio button and Check boxes
return nextElement;
}
}
return nullptr;
}
bool WebViewImpl::isListeningToKeyboardEvents(Element* element)
{
if (!element->isFormControlElement() && !element->isContentEditable())
return false;
for (Node* node = element; node; node = node->parentNode()) {
if (node->hasEventListeners(EventTypeNames::keydown) || node->hasEventListeners(EventTypeNames::keypress) || node->hasEventListeners(EventTypeNames::keyup))
return true;
}
return false;
}
void WebViewImpl::advanceFocusInForm(WebFocusType focusType)
{
Element* element = focusedElement();
if (!element)
return;
RefPtrWillBeRawPtr<Element> nextElement = nextFocusableElementInForm(element, focusType);
if (!nextElement)
return;
nextElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/);
nextElement->focus(false, focusType);
}
WebString WebViewImpl::inputModeOfFocusedElement()
{
if (!RuntimeEnabledFeatures::inputModeAttributeEnabled())
......
......@@ -188,7 +188,6 @@ public:
bool scrollFocusedNodeIntoRect(const WebRect&) override;
void smoothScroll(int targetX, int targetY, long durationMs) override;
void zoomToFindInPageRect(const WebRect&);
void advanceFocusInForm(WebFocusType) override;
void advanceFocus(bool reverse) override;
double zoomLevel() override;
double setZoomLevel(double) override;
......@@ -565,8 +564,6 @@ private:
WebTextInputType textInputType();
int textInputFlags();
Element* nextFocusableElementInForm(Element*, WebFocusType);
bool isListeningToKeyboardEvents(Element*);
WebString inputModeOfFocusedElement();
......
<html>
<body>
<form id="form1">
<div id="contenteditable6" contenteditable="true">contenteditable6 from form4</div><br>
<input type="text" id="input7" disabled value="input7 from form4 but skipped due to disabled element"><br>
<input type="text" id="input8" readonly value="input8 from form4 but skipped due to readonly element"><br>
<textarea id="textarea7" disabled readonly>textarea7 from form4 but skipped due to disabled and readonly element</textarea><br>
<div id="contenteditable7" contenteditable="true">contenteditable7 from form4</div><br>
</form>
</body>
</html>
<html>
<body>
<!-- If any of these form element can handle key event, software keyboard should show ENTER key
instead of GO key, for textarea element it's exceptional, as it requires ENTER key by default
for enabling multiline inputs. (This will be determined from Chromium layer)" -->
<h3>form1 starts here</h3>
<form id="form1">
<input type="text" id="input1" form="form1" value="input1 from form1"><br>
<button type="button" id="button1" form="form1">button1 from form1</button><br>
<div id="contenteditable1" contenteditable="true">contenteditable1 from form1</div><br>
<div id="div1" onkeypress="alert('if key event is handled, software keyboard should show ENTER key instead of GO key');"><br>
<input type="text" id="input2" value="input2 from div1 form1"><br>
</div>
<a href="#" id="anchor1">anchor1 from form1</a><br>
<textarea id="textarea1">textarea1 from form1</textarea><br>
<input type="text" id="input3" value="input3 from form1"><br>
</form>
<h3>form1 ends here</h3>
<textarea id="textarea2" form="form1">textarea2 from form1, which is outside parent hierarchy</textarea><br>
<textarea id="textarea3">textarea3 neither from form1 nor from form2</textarea><br>
<button type="button" id="button2" form="form1">button2 from form1, which is outside parent hierarchy, but can't navigate due to non-editable element</button><br>
<div id="contenteditable2" contenteditable="true">contenteditable2 neither from form1 nor from form2</div><br>
<textarea id="textarea4" form="formInvalid">textarea4 neither from form1 nor from form2, form attribute is invalid</textarea><br>
<h3>form2 starts here</h3><br>
<form id="form2" onkeypress="alert('if key event is handled, software keyboard should show ENTER key instead of GO key');">
<textarea id="textarea5">textarea5 from form2</textarea><br>
<input type="text" id="input4" value="input4 from form2"><br>
<div id="contenteditable3" contenteditable="true">contenteditable3 from form2</div><br>
<a href="#" id="anchor2">anchor2 from form2</a><br>
</form>
<h3>form2 ends here</h3><br>
</body>
</html>
<html>
<body>
<form id="form1">
<input type="text" id="input5" value="input5 from form3" tabindex="2"><br>
<div id="contenteditable4" contenteditable="true" tabindex="3">contenteditable4 from form3</div><br>
<a href="#" id="anchor3" tabindex="4">anchor3 from form3</a><br>
<textarea id="textarea6" tabindex="1">textarea6 from form3</textarea><br>
<div id="contenteditable5" contenteditable="true" tabindex="-1">contenteditable5 from form3, but not considered for navigation due to invalid tabindex</div><br>
<input type="text" id="input6" value="input6 from form3" tabindex="5"><br>
</form>
</body>
</html>
......@@ -85,10 +85,7 @@ enum WebTextInputFlags {
WebTextInputFlagAutocapitalizeNone = 1 << 6,
WebTextInputFlagAutocapitalizeCharacters = 1 << 7,
WebTextInputFlagAutocapitalizeWords = 1 << 8,
WebTextInputFlagAutocapitalizeSentences = 1 << 9,
WebTextInputFlagListeningToKeyboardEvents = 1 << 10,
WebTextInputFlagHaveNextFocusableElement = 1 << 11,
WebTextInputFlagHavePreviousFocusableElement = 1 << 12
WebTextInputFlagAutocapitalizeSentences = 1 << 9
};
} // namespace blink
......
......@@ -33,7 +33,6 @@
#include "../platform/WebColor.h"
#include "../platform/WebDisplayMode.h"
#include "../platform/WebFocusType.h"
#include "../platform/WebPageVisibilityState.h"
#include "../platform/WebString.h"
#include "../platform/WebVector.h"
......@@ -181,12 +180,6 @@ public:
// Smooth scroll the root layer to |targetX|, |targetY| in |durationMs|.
virtual void smoothScroll(int targetX, int targetY, long durationMs) { }
// Advance the focus of the WebView to next text input element from current
// input field wrt sequential navigation with TAB or Shift + TAB
// WebFocusTypeForward simulates TAB and WebFocusTypeBackward simulates
// Shift + TAB. (Will be extended to other form Controls like Select element, Checkbox, Radio etc.)
virtual void advanceFocusInForm(WebFocusType focusType) {}
// Advance the focus of the WebView forward to the next element or to the
// previous element in the tab sequence (if reverse is true).
virtual void advanceFocus(bool reverse) { }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment