Commit e77498c3 authored by ajith.v's avatar ajith.v Committed by Commit bot

Fixed the insertion handle showing issue on readonly element.

Insertion handle is showing when we long press on readonly input
elements, which is not correct. This change takes care of correcting
it by counter measuring inside isEditableNode() API.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#300636}
parent 50df3edc
......@@ -1884,6 +1884,14 @@ public class ContentViewCore
return mHasSelection;
}
/**
* @return Whether the page has an active, touch-controlled insertion handle.
*/
@VisibleForTesting
protected boolean hasInsertion() {
return mHasInsertion;
}
private void hidePastePopup() {
if (mPastePopupMenu == null) return;
mPastePopupMenu.hide();
......
......@@ -32,6 +32,8 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase {
"<br/><input id=\"input_text\" type=\"text\" value=\"Sample Text\" />" +
"<br/><textarea id=\"empty_textarea\" rows=\"2\" cols=\"20\"></textarea>" +
"<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">Sample Text</textarea>" +
"<br/><input id=\"readonly_text\" type=\"text\" readonly value=\"Sample Text\"/>" +
"<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"Sample Text\" />" +
"</form></body></html>");
private ContentViewCore mContentViewCore;
......@@ -173,6 +175,30 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase {
assertWaitForPastePopupStatus(false);
}
@SmallTest
@Feature({"TextInput"})
public void testPastePopupNotShownOnLongPressingReadOnlyInput() throws Throwable {
copyStringToClipboard();
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text");
assertWaitForPastePopupStatus(true);
assertTrue(mContentViewCore.hasInsertion());
DOMUtils.longPressNode(this, mContentViewCore, "readonly_text");
assertWaitForPastePopupStatus(false);
assertFalse(mContentViewCore.hasInsertion());
}
@SmallTest
@Feature({"TextInput"})
public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throwable {
copyStringToClipboard();
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text");
assertWaitForPastePopupStatus(true);
assertTrue(mContentViewCore.hasInsertion());
DOMUtils.longPressNode(this, mContentViewCore, "disabled_text");
assertWaitForPastePopupStatus(false);
assertFalse(mContentViewCore.hasInsertion());
}
private void assertWaitForSelectActionBarVisible(
final boolean visible) throws InterruptedException {
assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
......
......@@ -2526,8 +2526,11 @@ bool RenderViewImpl::IsEditableNode(const WebNode& node) const {
if (node.isElementNode()) {
const WebElement& element = node.toConst<WebElement>();
if (element.isTextFormControlElement())
return true;
if (element.isTextFormControlElement()) {
if (!(element.hasAttribute("readonly") ||
element.hasAttribute("disabled")))
return true;
}
// Also return true if it has an ARIA role of 'textbox'.
for (unsigned i = 0; i < element.attributeCount(); ++i) {
......
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