Changeset 280541 in webkit


Ignore:
Timestamp:
Aug 2, 2021 10:28:58 AM (12 months ago)
Author:
Chris Dumez
Message:

HTMLElement.innerText setter should convert new lines to <br>
https://bugs.webkit.org/show_bug.cgi?id=228605
<rdar://problem/81333038>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline WPT tests that are now passing. Those tests were already passing in Chrome and Firefox.

  • web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/innertext-setter-expected.txt:
  • web-platform-tests/html/dom/elements/the-innertext-idl-attribute/setter-expected.txt:
  • web-platform-tests/innerText/setter-expected.txt:

Source/WebCore:

HTMLElement.innerText setter should convert new lines to <br>:

Our innerText setter had some logic that was specific to render styles that isn't part of
the specification. It was causing us to not replace the new lines with <br> in some
web-observable cases. I dropped this logic to align with Blink and Gecko.

No new tests, rebaselined existing tests.

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::setInnerText):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt

    r280502 r280541  
    2828AXRole: AXGroup AXValue:
    2929AXRole: AXStaticText AXValue: AXRole: AXScrollArea AXValue:
    30 AXRole: AXWebArea AXValue:
    31 AXRole: AXGroup AXValue:
    32 AXRole: AXStaticText AXValue: Hello
    33 AXRole: AXGroup AXValue:
    34 AXRole: AXStaticText AXValue: This tests that the pseudo element style:body:before is accessible via the accessibility tree but not via TextMarkers.
    35 AXRole: AXGroup AXValue:
    36 AXRole: AXStaticText AXValue: On success, you will see a series of "
    37 AXRole: AXStaticText AXValue: PASS
    38 AXRole: AXStaticText AXValue: " messages, followed by "
    39 AXRole: AXStaticText AXValue: TEST COMPLETE
    40 AXRole: AXStaticText AXValue: ".
    41 AXRole: AXGroup AXValue:
     30AXRole: AXStaticText AXValue: AXRole: AXWebArea AXValue:
     31AXRole: AXStaticText AXValue: AXRole: AXGroup AXValue:
     32AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: Hello
     33AXRole: AXStaticText AXValue: AXRole: AXGroup AXValue:
     34AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: This tests that the pseudo element style:body:before is accessible via the accessibility tree but not via TextMarkers.
     35AXRole: AXStaticText AXValue: AXRole: AXGroup AXValue:
     36AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: On success, you will see a series of "
     37AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: PASS
     38AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: " messages, followed by "
     39AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: TEST COMPLETE
     40AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: ".
     41AXRole: AXStaticText AXValue: AXRole: AXGroup AXValue:
    4242
    43 
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r280531 r280541  
     12021-08-02  Chris Dumez  <cdumez@apple.com>
     2
     3        HTMLElement.innerText setter should convert new lines to <br>
     4        https://bugs.webkit.org/show_bug.cgi?id=228605
     5        <rdar://problem/81333038>
     6
     7        Reviewed by Darin Adler.
     8
     9        Rebaseline WPT tests that are now passing. Those tests were already passing in Chrome and Firefox.
     10
     11        * web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/innertext-setter-expected.txt:
     12        * web-platform-tests/html/dom/elements/the-innertext-idl-attribute/setter-expected.txt:
     13        * web-platform-tests/innerText/setter-expected.txt:
     14
    1152021-08-02  Jer Noble  <jer.noble@apple.com>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/innertext-setter-expected.txt

    r280502 r280541  
    44PASS Newlines convert to <br> in non-white-space:pre elements
    55PASS Newlines convert to <br> in non-white-space:pre elements, detached
    6 FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     6PASS Newlines convert to <br> in <pre> element
    77PASS Newlines convert to <br> in <pre> element, detached
    8 FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     8PASS Newlines convert to <br> in <textarea> element
    99PASS Newlines convert to <br> in <textarea> element, detached
    10 FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
     10PASS Newlines convert to <br> in white-space:pre element
    1111PASS Newlines convert to <br> in white-space:pre element, detached
    1212PASS CRs convert to <br> in non-white-space:pre elements
    1313PASS CRs convert to <br> in non-white-space:pre elements, detached
    14 FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     14PASS CRs convert to <br> in <pre> element
    1515PASS CRs convert to <br> in <pre> element, detached
    1616PASS Newline/CR pair converts to <br> in non-white-space:pre element
     
    2020PASS CR/CR pair converts to two <br>s in non-white-space:pre element
    2121PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
    22 FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
     22PASS CRs convert to <br> in white-space:pre element
    2323PASS CRs convert to <br> in white-space:pre element, detached
    2424PASS < preserved
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-idl-attribute/setter-expected.txt

    r280502 r280541  
    44PASS Newlines convert to <br> in non-white-space:pre elements
    55PASS Newlines convert to <br> in non-white-space:pre elements, detached
    6 FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     6PASS Newlines convert to <br> in <pre> element
    77PASS Newlines convert to <br> in <pre> element, detached
    8 FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     8PASS Newlines convert to <br> in <textarea> element
    99PASS Newlines convert to <br> in <textarea> element, detached
    10 FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
     10PASS Newlines convert to <br> in white-space:pre element
    1111PASS Newlines convert to <br> in white-space:pre element, detached
    1212PASS CRs convert to <br> in non-white-space:pre elements
    1313PASS CRs convert to <br> in non-white-space:pre elements, detached
    14 FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     14PASS CRs convert to <br> in <pre> element
    1515PASS CRs convert to <br> in <pre> element, detached
    1616PASS Newline/CR pair converts to <br> in non-white-space:pre element
     
    2020PASS CR/CR pair converts to two <br>s in non-white-space:pre element
    2121PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
    22 FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
     22PASS CRs convert to <br> in white-space:pre element
    2323PASS CRs convert to <br> in white-space:pre element, detached
    2424PASS < preserved
  • trunk/LayoutTests/imported/w3c/web-platform-tests/innerText/setter-expected.txt

    r280502 r280541  
    44PASS Newlines convert to <br> in non-white-space:pre elements
    55PASS Newlines convert to <br> in non-white-space:pre elements, detached
    6 FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     6PASS Newlines convert to <br> in <pre> element
    77PASS Newlines convert to <br> in <pre> element, detached
    8 FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     8PASS Newlines convert to <br> in <textarea> element
    99PASS Newlines convert to <br> in <textarea> element, detached
    10 FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
     10PASS Newlines convert to <br> in white-space:pre element
    1111PASS Newlines convert to <br> in white-space:pre element, detached
    1212PASS CRs convert to <br> in non-white-space:pre elements
    1313PASS CRs convert to <br> in non-white-space:pre elements, detached
    14 FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
     14PASS CRs convert to <br> in <pre> element
    1515PASS CRs convert to <br> in <pre> element, detached
    1616PASS Newline/CR pair converts to <br> in non-white-space:pre element
     
    2020PASS CR/CR pair converts to two <br>s in non-white-space:pre element
    2121PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
    22 FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
     22PASS CRs convert to <br> in white-space:pre element
    2323PASS CRs convert to <br> in white-space:pre element, detached
    2424PASS < preserved
  • trunk/Source/WebCore/ChangeLog

    r280534 r280541  
     12021-08-02  Chris Dumez  <cdumez@apple.com>
     2
     3        HTMLElement.innerText setter should convert new lines to <br>
     4        https://bugs.webkit.org/show_bug.cgi?id=228605
     5        <rdar://problem/81333038>
     6
     7        Reviewed by Darin Adler.
     8
     9        HTMLElement.innerText setter should convert new lines to <br>:
     10        - https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute:dom-innertext-3
     11        - https://html.spec.whatwg.org/multipage/dom.html#rendered-text-fragment
     12
     13        Our innerText setter had some logic that was specific to render styles that isn't part of
     14        the specification. It was causing us to not replace the new lines with <br> in some
     15        web-observable cases. I dropped this logic to align with Blink and Gecko.
     16
     17        No new tests, rebaselined existing tests.
     18
     19        * html/HTMLElement.cpp:
     20        (WebCore::HTMLElement::setInnerText):
     21
    1222021-08-02  Sam Weinig  <weinig@apple.com>
    223
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r280502 r280541  
    567567    }
    568568
    569     // FIXME: Do we need to be able to detect preserveNewline style even when there's no renderer?
    570     // FIXME: Can the renderer be out of date here? Do we need to call updateStyleIfNeeded?
    571     // For example, for the contents of textarea elements that are display:none?
    572     auto* r = renderer();
    573     if ((r && r->style().preserveNewline()) || (isConnected() && isTextControlInnerTextElement())) {
     569    if (isConnected() && isTextControlInnerTextElement()) {
    574570        if (!text.contains('\r')) {
    575571            stringReplaceAll(text);
Note: See TracChangeset for help on using the changeset viewer.