Skip to content
Permalink
Browse files
HTMLElement.innerText setter should convert new lines to <br>
https://bugs.webkit.org/show_bug.cgi?id=228605

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaselined WPT tests that are now passing. Note that those were failing in WebKit but passing in Firefox
and Chrome.

* 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>:
- https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute:dom-innertext-3
- https://html.spec.whatwg.org/multipage/dom.html#rendered-text-fragment

Our innerText setter had some logic that was specific to form elements and specific render
styles that wasn't part of the specification. It was causing us to not replace the new lines
with <br> in some cases. I dropped this logic to align with Blink and Gecko, as those are
passing the same WPT tests.

No new tests, rebaselined existing tests.

* html/HTMLElement.cpp:
(WebCore::HTMLElement::setInnerText):

LayoutTests:

Rebaseline a few tests that changed output.

* editing/pasteboard/smart-paste-paragraph-003-expected.txt:
* platform/mac/editing/input/reveal-caret-of-multiline-input-expected.txt:
* platform/mac/fast/forms/basic-textareas-quirks-expected.txt:
* platform/mac/fast/forms/textarea-scroll-height-expected.txt:
* platform/mac/fast/forms/textarea-scrollbar-expected.txt:
* platform/mac/fast/forms/textarea-scrolled-type-expected.txt:
* platform/mac/fast/forms/textarea-width-expected.txt:
* platform/mac/fast/parser/open-comment-in-textarea-expected.txt:
* platform/mac/fast/text/international/unicode-bidi-plaintext-in-textarea-expected.txt:
* platform/mac/http/tests/navigation/javascriptlink-frames-expected.txt:


Canonical link: https://commits.webkit.org/240117@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Jul 30, 2021
1 parent fa545a7 commit 619c8f023b4a4b2316b3aa165c51c14ab0f0492a
Show file tree
Hide file tree
Showing 28 changed files with 674 additions and 380 deletions.
@@ -1,3 +1,23 @@
2021-07-30 Chris Dumez <cdumez@apple.com>

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

Reviewed by Sam Weinig.

Rebaseline a few tests that changed output.

* editing/pasteboard/smart-paste-paragraph-003-expected.txt:
* platform/mac/editing/input/reveal-caret-of-multiline-input-expected.txt:
* platform/mac/fast/forms/basic-textareas-quirks-expected.txt:
* platform/mac/fast/forms/textarea-scroll-height-expected.txt:
* platform/mac/fast/forms/textarea-scrollbar-expected.txt:
* platform/mac/fast/forms/textarea-scrolled-type-expected.txt:
* platform/mac/fast/forms/textarea-width-expected.txt:
* platform/mac/fast/parser/open-comment-in-textarea-expected.txt:
* platform/mac/fast/text/international/unicode-bidi-plaintext-in-textarea-expected.txt:
* platform/mac/http/tests/navigation/javascriptlink-frames-expected.txt:

2021-07-30 Sihui Liu <sihui_liu@apple.com>

Layout Test imported/w3c/web-platform-tests/IndexedDB/fire-error-event-exception.html is a Flaky Failure
@@ -27,17 +27,16 @@ AXRole: AXStaticText AXValue: TEST COMPLETE
AXRole: AXStaticText AXValue: ".
AXRole: AXGroup AXValue:
AXRole: AXStaticText AXValue: AXRole: AXScrollArea AXValue:
AXRole: AXWebArea AXValue:
AXRole: AXGroup AXValue:
AXRole: AXStaticText AXValue: Hello
AXRole: AXGroup AXValue:
AXRole: AXStaticText AXValue: This tests that the pseudo element style:body:before is accessible via the accessibility tree but not via TextMarkers.
AXRole: AXGroup AXValue:
AXRole: AXStaticText AXValue: On success, you will see a series of "
AXRole: AXStaticText AXValue: PASS
AXRole: AXStaticText AXValue: " messages, followed by "
AXRole: AXStaticText AXValue: TEST COMPLETE
AXRole: AXStaticText AXValue: ".
AXRole: AXGroup AXValue:

AXRole: AXStaticText AXValue: AXRole: AXWebArea AXValue:
AXRole: AXStaticText AXValue: AXRole: AXGroup AXValue:
AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: Hello
AXRole: AXStaticText AXValue: AXRole: AXGroup AXValue:
AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: This tests that the pseudo element style:body:before is accessible via the accessibility tree but not via TextMarkers.
AXRole: AXStaticText AXValue: AXRole: AXGroup AXValue:
AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: On success, you will see a series of "
AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: PASS
AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: " messages, followed by "
AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: TEST COMPLETE
AXRole: AXStaticText AXValue: AXRole: AXStaticText AXValue: ".
AXRole: AXStaticText AXValue: AXRole: AXGroup AXValue:

@@ -6,9 +6,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldInsertText:Test paragraph. replacingDOMRange:range from 16 of #text > DIV > #document-fragment to 16 of #text > DIV > #document-fragment givenAction:WebViewInsertActionPasted
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 32 of #text > DIV > #document-fragment to 32 of #text > DIV > #document-fragment toDOMRange:range from 1 of #text > DIV > #document-fragment to 1 of #text > DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldInsertText:Test paragraph. replacingDOMRange:range from 2 of DIV > #document-fragment to 2 of DIV > #document-fragment givenAction:WebViewInsertActionPasted
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
Tests:
@@ -1,3 +1,17 @@
2021-07-30 Chris Dumez <cdumez@apple.com>

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

Reviewed by Sam Weinig.

Rebaselined WPT tests that are now passing. Note that those were failing in WebKit but passing in Firefox
and Chrome.

* 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:

2021-07-30 Chris Dumez <cdumez@apple.com>

Clicking an HTMLLinkElement should not trigger a navigation
@@ -3,23 +3,23 @@ PASS Simplest possible test
PASS Simplest possible test, detached
PASS Newlines convert to <br> in non-white-space:pre elements
PASS Newlines convert to <br> in non-white-space:pre elements, detached
FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in <pre> element
PASS Newlines convert to <br> in <pre> element, detached
FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in <textarea> element
PASS Newlines convert to <br> in <textarea> element, detached
FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in white-space:pre element
PASS Newlines convert to <br> in white-space:pre element, detached
PASS CRs convert to <br> in non-white-space:pre elements
PASS CRs convert to <br> in non-white-space:pre elements, detached
FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS CRs convert to <br> in <pre> element
PASS CRs convert to <br> in <pre> element, detached
PASS Newline/CR pair converts to <br> in non-white-space:pre element
PASS Newline/CR pair converts to <br> in non-white-space:pre element, detached
PASS Newline/newline pair converts to two <br>s in non-white-space:pre element
PASS Newline/newline pair converts to two <br>s in non-white-space:pre element, detached
PASS CR/CR pair converts to two <br>s in non-white-space:pre element
PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS CRs convert to <br> in white-space:pre element
PASS CRs convert to <br> in white-space:pre element, detached
PASS < preserved
PASS < preserved, detached
@@ -3,23 +3,23 @@ PASS Simplest possible test
PASS Simplest possible test, detached
PASS Newlines convert to <br> in non-white-space:pre elements
PASS Newlines convert to <br> in non-white-space:pre elements, detached
FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in <pre> element
PASS Newlines convert to <br> in <pre> element, detached
FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in <textarea> element
PASS Newlines convert to <br> in <textarea> element, detached
FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in white-space:pre element
PASS Newlines convert to <br> in white-space:pre element, detached
PASS CRs convert to <br> in non-white-space:pre elements
PASS CRs convert to <br> in non-white-space:pre elements, detached
FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS CRs convert to <br> in <pre> element
PASS CRs convert to <br> in <pre> element, detached
PASS Newline/CR pair converts to <br> in non-white-space:pre element
PASS Newline/CR pair converts to <br> in non-white-space:pre element, detached
PASS Newline/newline pair converts to two <br>s in non-white-space:pre element
PASS Newline/newline pair converts to two <br>s in non-white-space:pre element, detached
PASS CR/CR pair converts to two <br>s in non-white-space:pre element
PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS CRs convert to <br> in white-space:pre element
PASS CRs convert to <br> in white-space:pre element, detached
PASS < preserved
PASS < preserved, detached
@@ -3,23 +3,23 @@ PASS Simplest possible test
PASS Simplest possible test, detached
PASS Newlines convert to <br> in non-white-space:pre elements
PASS Newlines convert to <br> in non-white-space:pre elements, detached
FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in <pre> element
PASS Newlines convert to <br> in <pre> element, detached
FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in <textarea> element
PASS Newlines convert to <br> in <textarea> element, detached
FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS Newlines convert to <br> in white-space:pre element
PASS Newlines convert to <br> in white-space:pre element, detached
PASS CRs convert to <br> in non-white-space:pre elements
PASS CRs convert to <br> in non-white-space:pre elements, detached
FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS CRs convert to <br> in <pre> element
PASS CRs convert to <br> in <pre> element, detached
PASS Newline/CR pair converts to <br> in non-white-space:pre element
PASS Newline/CR pair converts to <br> in non-white-space:pre element, detached
PASS Newline/newline pair converts to two <br>s in non-white-space:pre element
PASS Newline/newline pair converts to two <br>s in non-white-space:pre element, detached
PASS CR/CR pair converts to two <br>s in non-white-space:pre element
PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
PASS CRs convert to <br> in white-space:pre element
PASS CRs convert to <br> in white-space:pre element, detached
PASS < preserved
PASS < preserved, detached
@@ -12,68 +12,98 @@ layer at (0,0) size 800x191
layer at (10,30) size 98x146 clip at (11,31) size 81x144 scrollHeight 452
RenderTextControl {TEXTAREA} at (2,2) size 98x146 [bgcolor=#FFFFFF] [border: (1px solid #3C3C4399)]
RenderBlock {DIV} at (6,3) size 71x448
RenderText {#text} at (0,0) size 15x434
RenderText {#text} at (0,0) size 14x14
text run at (0,0) width 14: "00"
text run at (13,0) width 1: " "
RenderBR {BR} at (13,0) size 1x14
RenderText {#text} at (0,14) size 13x14
text run at (0,14) width 13: "01"
text run at (12,14) width 1: " "
RenderBR {BR} at (12,14) size 1x14
RenderText {#text} at (0,28) size 14x14
text run at (0,28) width 14: "02"
text run at (13,28) width 1: " "
RenderBR {BR} at (13,28) size 1x14
RenderText {#text} at (0,42) size 14x14
text run at (0,42) width 14: "03"
text run at (13,42) width 1: " "
RenderBR {BR} at (13,42) size 1x14
RenderText {#text} at (0,56) size 15x14
text run at (0,56) width 15: "04"
text run at (14,56) width 1: " "
RenderBR {BR} at (14,56) size 1x14
RenderText {#text} at (0,70) size 14x14
text run at (0,70) width 14: "05"
text run at (13,70) width 1: " "
RenderBR {BR} at (13,70) size 1x14
RenderText {#text} at (0,84) size 15x14
text run at (0,84) width 15: "06"
text run at (14,84) width 1: " "
RenderBR {BR} at (14,84) size 1x14
RenderText {#text} at (0,98) size 14x14
text run at (0,98) width 14: "07"
text run at (13,98) width 1: " "
RenderBR {BR} at (13,98) size 1x14
RenderText {#text} at (0,112) size 15x14
text run at (0,112) width 15: "08"
text run at (14,112) width 1: " "
RenderBR {BR} at (14,112) size 1x14
RenderText {#text} at (0,126) size 15x14
text run at (0,126) width 15: "09"
text run at (14,126) width 1: " "
RenderBR {BR} at (14,126) size 1x14
RenderText {#text} at (0,140) size 13x14
text run at (0,140) width 13: "10"
text run at (12,140) width 1: " "
RenderBR {BR} at (12,140) size 1x14
RenderText {#text} at (0,154) size 11x14
text run at (0,154) width 11: "11"
text run at (10,154) width 1: " "
RenderBR {BR} at (10,154) size 1x14
RenderText {#text} at (0,168) size 12x14
text run at (0,168) width 12: "12"
text run at (11,168) width 1: " "
RenderBR {BR} at (11,168) size 1x14
RenderText {#text} at (0,182) size 13x14
text run at (0,182) width 13: "13"
text run at (12,182) width 1: " "
RenderBR {BR} at (12,182) size 1x14
RenderText {#text} at (0,196) size 13x14
text run at (0,196) width 13: "14"
text run at (12,196) width 1: " "
RenderBR {BR} at (12,196) size 1x14
RenderText {#text} at (0,210) size 13x14
text run at (0,210) width 13: "15"
text run at (12,210) width 1: " "
RenderBR {BR} at (12,210) size 1x14
RenderText {#text} at (0,224) size 13x14
text run at (0,224) width 13: "16"
text run at (12,224) width 1: " "
RenderBR {BR} at (12,224) size 1x14
RenderText {#text} at (0,238) size 12x14
text run at (0,238) width 12: "17"
text run at (11,238) width 1: " "
RenderBR {BR} at (11,238) size 1x14
RenderText {#text} at (0,252) size 13x14
text run at (0,252) width 13: "18"
text run at (12,252) width 1: " "
RenderBR {BR} at (12,252) size 1x14
RenderText {#text} at (0,266) size 13x14
text run at (0,266) width 13: "19"
text run at (12,266) width 1: " "
RenderBR {BR} at (12,266) size 1x14
RenderText {#text} at (0,280) size 14x14
text run at (0,280) width 14: "20"
text run at (13,280) width 1: " "
RenderBR {BR} at (13,280) size 1x14
RenderText {#text} at (0,294) size 12x14
text run at (0,294) width 12: "21"
text run at (11,294) width 1: " "
RenderBR {BR} at (11,294) size 1x14
RenderText {#text} at (0,308) size 14x14
text run at (0,308) width 14: "22"
text run at (13,308) width 1: " "
RenderBR {BR} at (13,308) size 1x14
RenderText {#text} at (0,322) size 14x14
text run at (0,322) width 14: "23"
text run at (13,322) width 1: " "
RenderBR {BR} at (13,322) size 1x14
RenderText {#text} at (0,336) size 14x14
text run at (0,336) width 14: "24"
text run at (13,336) width 1: " "
RenderBR {BR} at (13,336) size 1x14
RenderText {#text} at (0,350) size 14x14
text run at (0,350) width 14: "25"
text run at (13,350) width 1: " "
RenderBR {BR} at (13,350) size 1x14
RenderText {#text} at (0,364) size 14x14
text run at (0,364) width 14: "26"
text run at (13,364) width 1: " "
RenderBR {BR} at (13,364) size 1x14
RenderText {#text} at (0,378) size 14x14
text run at (0,378) width 14: "27"
text run at (13,378) width 1: " "
RenderBR {BR} at (13,378) size 1x14
RenderText {#text} at (0,392) size 14x14
text run at (0,392) width 14: "28"
text run at (13,392) width 1: " "
RenderBR {BR} at (13,392) size 1x14
RenderText {#text} at (0,406) size 14x14
text run at (0,406) width 14: "29"
text run at (13,406) width 1: " "
RenderBR {BR} at (13,406) size 1x14
RenderText {#text} at (0,420) size 14x14
text run at (0,420) width 14: "30"
text run at (13,420) width 1: " "
RenderBR {BR} at (13,420) size 1x14
RenderBR {BR} at (0,434) size 0x14
caret: position 36 of child 0 {#text} of child 0 {DIV} of {#document-fragment} of child 3 {TEXTAREA} of body
caret: position 0 of child 24 {#text} of child 0 {DIV} of {#document-fragment} of child 3 {TEXTAREA} of body

0 comments on commit 619c8f0

Please sign in to comment.