Title: [233525] trunk
Revision
233525
Author
n_w...@apple.com
Date
2018-07-05 10:20:24 -0700 (Thu, 05 Jul 2018)

Log Message

AX: setValue on text controls should send out key events
https://bugs.webkit.org/show_bug.cgi?id=186690
<rdar://problem/41169985>

Reviewed by Chris Fleizach.

Source/WebCore:

Use Editor's insertText function when the text control element is being
focused, so that the InputEvent will be dispatched properly.

Test: accessibility/mac/set-value-editable-dispatch-events.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::setValue):

LayoutTests:

* accessibility/mac/set-value-editable-dispatch-events-expected.txt: Added.
* accessibility/mac/set-value-editable-dispatch-events.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (233524 => 233525)


--- trunk/LayoutTests/ChangeLog	2018-07-05 17:09:12 UTC (rev 233524)
+++ trunk/LayoutTests/ChangeLog	2018-07-05 17:20:24 UTC (rev 233525)
@@ -1,3 +1,14 @@
+2018-07-05  Nan Wang  <n_w...@apple.com>
+
+        AX: setValue on text controls should send out key events
+        https://bugs.webkit.org/show_bug.cgi?id=186690
+        <rdar://problem/41169985>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/set-value-editable-dispatch-events-expected.txt: Added.
+        * accessibility/mac/set-value-editable-dispatch-events.html: Added.
+
 2018-07-05  Truitt Savell  <tsav...@apple.com>
 
         Layout Test svg/animations/animateMotion-additive-2c.svg and svg/animations/animateMotion-additive-2d.svg is flaky 

Added: trunk/LayoutTests/accessibility/mac/set-value-editable-dispatch-events-expected.txt (0 => 233525)


--- trunk/LayoutTests/accessibility/mac/set-value-editable-dispatch-events-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/set-value-editable-dispatch-events-expected.txt	2018-07-05 17:20:24 UTC (rev 233525)
@@ -0,0 +1,29 @@
+
+ 
+This tests that setting value to a text control would dispatch input events.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Test: contenteditable
+Role: AXRole: AXTextArea
+Value: AXValue: current
+Writable: true
+input event dispatched for contenteditable
+
+Test: input
+Role: AXRole: AXTextField
+Value: AXValue: somevalue
+Writable: true
+input event dispatched for input
+
+Test: textarea
+Role: AXRole: AXTextArea
+Value: AXValue: sometext
+Writable: true
+input event dispatched for textarea
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/mac/set-value-editable-dispatch-events.html (0 => 233525)


--- trunk/LayoutTests/accessibility/mac/set-value-editable-dispatch-events.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/set-value-editable-dispatch-events.html	2018-07-05 17:20:24 UTC (rev 233525)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<body id="body">
+<script src=""
+<div id="content">
+
+<div contenteditable="true" id="contenteditable" _oninput_="updateContenteditable();">current</div>
+<input type="text" id="input" value="somevalue" _oninput_="updateInput();">
+<textarea id="textarea" _oninput_="updateTextarea();">sometext</textarea>
+
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that setting value to a text control would dispatch input events.");
+
+    if (window.accessibilityController) {
+        jsTestIsAsync = true;
+
+        var inputValue;
+        var contenteditableValue;
+        var textareaValue;
+
+       function updateContenteditable(){
+           debug("input event dispatched for contenteditable");
+           testElement("input");
+       }
+
+       function updateInput(){
+          debug("input event dispatched for input");
+          testElement("textarea");
+       }
+
+       function updateTextarea(){
+          debug("input event dispatched for textarea");
+          finishJSTest();
+       }
+
+        function testElement(idValue) {
+            debug("\nTest: " + idValue);
+            var axElement = accessibilityController.accessibleElementById(idValue);
+            debug("Role: " + axElement.role);
+            debug("Value: " + axElement.stringValue);
+
+            var writable = axElement.isAttributeSettable("AXValue");
+            debug("Writable: " + writable);
+
+            document.getElementById(idValue).focus();
+
+            axElement.setValue("Updated value for " + idValue);
+        }
+
+        testElement("contenteditable");
+    } else {
+        testFailed("Could not load accessibility controller");
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (233524 => 233525)


--- trunk/Source/WebCore/ChangeLog	2018-07-05 17:09:12 UTC (rev 233524)
+++ trunk/Source/WebCore/ChangeLog	2018-07-05 17:20:24 UTC (rev 233525)
@@ -1,3 +1,19 @@
+2018-07-05  Nan Wang  <n_w...@apple.com>
+
+        AX: setValue on text controls should send out key events
+        https://bugs.webkit.org/show_bug.cgi?id=186690
+        <rdar://problem/41169985>
+
+        Reviewed by Chris Fleizach.
+
+        Use Editor's insertText function when the text control element is being
+        focused, so that the InputEvent will be dispatched properly.
+
+        Test: accessibility/mac/set-value-editable-dispatch-events.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::setValue):
+
 2018-07-05  Chris Dumez  <cdu...@apple.com>
 
         ASSERT(m_dictionaryStack.size() == 1) assertion hit in ~KeyedDecoderCF() when decoding fails

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (233524 => 233525)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2018-07-05 17:09:12 UTC (rev 233524)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2018-07-05 17:20:24 UTC (rev 233525)
@@ -1772,22 +1772,21 @@
     Element& element = downcast<Element>(*m_renderer->node());
     RenderObject& renderer = *m_renderer;
     
+    // We should use the editor's insertText to mimic typing into the field.
+    // Also only do this when the field is in editing mode.
+    if (Frame* frame = renderer.document().frame()) {
+        Editor& editor = frame->editor();
+        if (element.shouldUseInputMethod()) {
+            editor.clearText();
+            editor.insertText(string, nullptr);
+            return;
+        }
+    }
     // FIXME: Do we want to do anything here for ARIA textboxes?
     if (renderer.isTextField() && is<HTMLInputElement>(element))
         downcast<HTMLInputElement>(element).setValue(string);
     else if (renderer.isTextArea() && is<HTMLTextAreaElement>(element))
         downcast<HTMLTextAreaElement>(element).setValue(string);
-    else if (is<HTMLElement>(element) && contentEditableAttributeIsEnabled(&element)) {
-        // We should use the editor's insertText to mimic typing into the contenteditable field.
-        // Also only do this when the field is in editing mode.
-        if (Frame* frame = renderer.document().frame()) {
-            Editor& editor = frame->editor();
-            if (element.shouldUseInputMethod()) {
-                editor.clearText();
-                editor.insertText(string, nullptr);
-            }
-        }
-    }
 }
 
 bool AccessibilityRenderObject::supportsARIAOwns() const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to