Changeset 232259 in webkit


Ignore:
Timestamp:
May 29, 2018 9:19:09 AM (6 years ago)
Author:
n_wang@apple.com
Message:

AX: setValue on contenteditable should preserve whitespace
https://bugs.webkit.org/show_bug.cgi?id=185897

Reviewed by Ryosuke Niwa.

Source/WebCore:

We should mimic typing when setting value to a contenteditable from accessibility
instead of mutating the DOM by using setInnerText.

Updated tests to cover this change.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::setValue):

LayoutTests:

  • accessibility/mac/AOM-event-accessiblesetvalue-expected.txt:
  • accessibility/mac/AOM-event-accessiblesetvalue.html:
  • accessibility/mac/set-value-editable-types-expected.txt:
  • accessibility/mac/set-value-editable-types.html:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r232255 r232259  
     12018-05-29  Nan Wang  <n_wang@apple.com>
     2
     3        AX: setValue on contenteditable should preserve whitespace
     4        https://bugs.webkit.org/show_bug.cgi?id=185897
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * accessibility/mac/AOM-event-accessiblesetvalue-expected.txt:
     9        * accessibility/mac/AOM-event-accessiblesetvalue.html:
     10        * accessibility/mac/set-value-editable-types-expected.txt:
     11        * accessibility/mac/set-value-editable-types.html:
     12
    1132018-05-29  Antoine Quint  <graouts@apple.com>
    214
  • trunk/LayoutTests/accessibility/mac/AOM-event-accessiblesetvalue-expected.txt

    r230890 r232259  
    1414Test Contenteditable.
    1515contenteditable accessible set value to: contenteditable new value
     16PASS axNode.stringValue is 'AXValue: contenteditable new value'
    1617
    1718Test Slider.
  • trunk/LayoutTests/accessibility/mac/AOM-event-accessiblesetvalue.html

    r230890 r232259  
    6464           node.onaccessiblesetvalue = function(event) {
    6565              debug("contenteditable accessible set value to: " + event.value);
    66               testSlider();
    6766           };
     67           accessibilityController.addNotificationListener(function(element, notification) {
     68               if (notification == "AXValueChanged") {
     69                   shouldBe("axNode.stringValue", "'AXValue: contenteditable new value'");
     70                   node.blur();
     71                   accessibilityController.removeNotificationListener();
     72                   testSlider();
     73               }
     74           });
     75           node.focus();
    6876           axNode.setValue("contenteditable new value");
    6977       }
  • trunk/LayoutTests/accessibility/mac/set-value-editable-types-expected.txt

    r232120 r232259  
    1010Writable: true
    1111Value change notification received
    12 Updated Value: AXValue:    leading and trailing spaces   
     12Updated Value: AXValue:    leading and trailing spaces   
    1313PASS successfullyParsed is true
    1414
  • trunk/LayoutTests/accessibility/mac/set-value-editable-types.html

    r232120 r232259  
    3838            debug("Writable: " + writable);
    3939
     40            document.getElementById(idValue).focus();
     41
    4042            axElement.setValue("   leading and trailing spaces   ");
    4143        }
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r232032 r232259  
    515515webkit.org/b/183352 accessibility/ios-simulator/AOM-dismiss-event.html [ Skip ]
    516516webkit.org/b/184742 accessibility/mac/async-increment-decrement-action.html [ Skip ]
     517webkit.org/b/185897 accessibility/mac/AOM-event-accessiblesetvalue.html [ Skip ]
     518webkit.org/b/185897 accessibility/mac/set-value-editable-types.html [ Skip ]
    517519
    518520webkit.org/b/182752 accessibility/mac/accessibility-make-first-responder.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r232257 r232259  
     12018-05-29  Nan Wang  <n_wang@apple.com>
     2
     3        AX: setValue on contenteditable should preserve whitespace
     4        https://bugs.webkit.org/show_bug.cgi?id=185897
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        We should mimic typing when setting value to a contenteditable from accessibility
     9        instead of mutating the DOM by using setInnerText.
     10
     11        Updated tests to cover this change.
     12
     13        * accessibility/AccessibilityRenderObject.cpp:
     14        (WebCore::AccessibilityRenderObject::setValue):
     15
    1162018-05-29  Zalan Bujtas  <zalan@apple.com>
    217
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r232229 r232259  
    17791779        downcast<HTMLTextAreaElement>(element).setValue(string);
    17801780    else if (is<HTMLElement>(element) && contentEditableAttributeIsEnabled(&element)) {
    1781         // Set the style to the element so the child Text node won't collapse spaces
    1782         if (is<RenderElement>(renderer)) {
    1783             RenderElement& renderElement = downcast<RenderElement>(renderer);
    1784             auto style = RenderStyle::create();
    1785             style.inheritFrom(renderElement.style());
    1786             style.setWhiteSpace(WhiteSpace::Pre);
    1787             renderElement.setStyleInternal(WTFMove(style));
    1788         }
    1789         downcast<HTMLElement>(element).setInnerText(string);
     1781        // We should use the editor's insertText to mimic typing into the contenteditable field.
     1782        // Also only do this when the field is in editing mode.
     1783        if (Frame* frame = renderer.document().frame()) {
     1784            Editor& editor = frame->editor();
     1785            if (element.shouldUseInputMethod()) {
     1786                editor.clearText();
     1787                editor.insertText(string, nullptr);
     1788            }
     1789        }
    17901790    }
    17911791}
Note: See TracChangeset for help on using the changeset viewer.