<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[280541] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/280541">280541</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-08-02 10:28:58 -0700 (Mon, 02 Aug 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>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>:
- 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 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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsaccessibilitymacpseudoelementtextmarkersexpectedtxt">trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmldomelementstheinnertextandoutertextpropertiesinnertextsetterexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/innertext-setter-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmldomelementstheinnertextidlattributesetterexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-idl-attribute/setter-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsinnerTextsetterexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/innerText/setter-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementcpp">trunk/Source/WebCore/html/HTMLElement.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsaccessibilitymacpseudoelementtextmarkersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt (280540 => 280541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt     2021-08-02 17:09:40 UTC (rev 280540)
+++ trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt        2021-08-02 17:28:58 UTC (rev 280541)
</span><span class="lines">@@ -27,17 +27,16 @@
</span><span class="cx"> AXRole: AXStaticText AXValue: ".
</span><span class="cx"> AXRole: AXGroup AXValue:
</span><span class="cx"> AXRole: AXStaticText AXValue: AXRole: AXScrollArea AXValue:
</span><del>-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:
</del><ins>+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:
</ins><span class="cx"> 
</span><del>-
</del></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (280540 => 280541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-08-02 17:09:40 UTC (rev 280540)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-08-02 17:28:58 UTC (rev 280541)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-08-02  Chris Dumez  <cdumez@apple.com>
+
+        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.
+
+        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:
+
</ins><span class="cx"> 2021-08-02  Jer Noble  <jer.noble@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [Cocoa] Remove support for AVAssetImageGenerator
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmldomelementstheinnertextandoutertextpropertiesinnertextsetterexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/innertext-setter-expected.txt (280540 => 280541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/innertext-setter-expected.txt 2021-08-02 17:09:40 UTC (rev 280540)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/innertext-setter-expected.txt    2021-08-02 17:28:58 UTC (rev 280541)
</span><span class="lines">@@ -3,15 +3,15 @@
</span><span class="cx"> PASS Simplest possible test, detached
</span><span class="cx"> PASS Newlines convert to <br> in non-white-space:pre elements
</span><span class="cx"> PASS Newlines convert to <br> in non-white-space:pre elements, detached
</span><del>-FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in <pre> element
</ins><span class="cx"> PASS Newlines convert to <br> in <pre> element, detached
</span><del>-FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in <textarea> element
</ins><span class="cx"> PASS Newlines convert to <br> in <textarea> element, detached
</span><del>-FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in white-space:pre element
</ins><span class="cx"> PASS Newlines convert to <br> in white-space:pre element, detached
</span><span class="cx"> PASS CRs convert to <br> in non-white-space:pre elements
</span><span class="cx"> PASS CRs convert to <br> in non-white-space:pre elements, detached
</span><del>-FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS CRs convert to <br> in <pre> element
</ins><span class="cx"> PASS CRs convert to <br> in <pre> element, detached
</span><span class="cx"> PASS Newline/CR pair converts to <br> in non-white-space:pre element
</span><span class="cx"> PASS Newline/CR pair converts to <br> in non-white-space:pre element, detached
</span><span class="lines">@@ -19,7 +19,7 @@
</span><span class="cx"> PASS Newline/newline pair converts to two <br>s in non-white-space:pre element, detached
</span><span class="cx"> PASS CR/CR pair converts to two <br>s in non-white-space:pre element
</span><span class="cx"> PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
</span><del>-FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS CRs convert to <br> in white-space:pre element
</ins><span class="cx"> PASS CRs convert to <br> in white-space:pre element, detached
</span><span class="cx"> PASS < preserved
</span><span class="cx"> PASS < preserved, detached
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmldomelementstheinnertextidlattributesetterexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-idl-attribute/setter-expected.txt (280540 => 280541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-idl-attribute/setter-expected.txt      2021-08-02 17:09:40 UTC (rev 280540)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-idl-attribute/setter-expected.txt 2021-08-02 17:28:58 UTC (rev 280541)
</span><span class="lines">@@ -3,15 +3,15 @@
</span><span class="cx"> PASS Simplest possible test, detached
</span><span class="cx"> PASS Newlines convert to <br> in non-white-space:pre elements
</span><span class="cx"> PASS Newlines convert to <br> in non-white-space:pre elements, detached
</span><del>-FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in <pre> element
</ins><span class="cx"> PASS Newlines convert to <br> in <pre> element, detached
</span><del>-FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in <textarea> element
</ins><span class="cx"> PASS Newlines convert to <br> in <textarea> element, detached
</span><del>-FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in white-space:pre element
</ins><span class="cx"> PASS Newlines convert to <br> in white-space:pre element, detached
</span><span class="cx"> PASS CRs convert to <br> in non-white-space:pre elements
</span><span class="cx"> PASS CRs convert to <br> in non-white-space:pre elements, detached
</span><del>-FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS CRs convert to <br> in <pre> element
</ins><span class="cx"> PASS CRs convert to <br> in <pre> element, detached
</span><span class="cx"> PASS Newline/CR pair converts to <br> in non-white-space:pre element
</span><span class="cx"> PASS Newline/CR pair converts to <br> in non-white-space:pre element, detached
</span><span class="lines">@@ -19,7 +19,7 @@
</span><span class="cx"> PASS Newline/newline pair converts to two <br>s in non-white-space:pre element, detached
</span><span class="cx"> PASS CR/CR pair converts to two <br>s in non-white-space:pre element
</span><span class="cx"> PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
</span><del>-FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS CRs convert to <br> in white-space:pre element
</ins><span class="cx"> PASS CRs convert to <br> in white-space:pre element, detached
</span><span class="cx"> PASS < preserved
</span><span class="cx"> PASS < preserved, detached
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsinnerTextsetterexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/innerText/setter-expected.txt (280540 => 280541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/innerText/setter-expected.txt  2021-08-02 17:09:40 UTC (rev 280540)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/innerText/setter-expected.txt     2021-08-02 17:28:58 UTC (rev 280541)
</span><span class="lines">@@ -3,15 +3,15 @@
</span><span class="cx"> PASS Simplest possible test, detached
</span><span class="cx"> PASS Newlines convert to <br> in non-white-space:pre elements
</span><span class="cx"> PASS Newlines convert to <br> in non-white-space:pre elements, detached
</span><del>-FAIL Newlines convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in <pre> element
</ins><span class="cx"> PASS Newlines convert to <br> in <pre> element, detached
</span><del>-FAIL Newlines convert to <br> in <textarea> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in <textarea> element
</ins><span class="cx"> PASS Newlines convert to <br> in <textarea> element, detached
</span><del>-FAIL Newlines convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS Newlines convert to <br> in white-space:pre element
</ins><span class="cx"> PASS Newlines convert to <br> in white-space:pre element, detached
</span><span class="cx"> PASS CRs convert to <br> in non-white-space:pre elements
</span><span class="cx"> PASS CRs convert to <br> in non-white-space:pre elements, detached
</span><del>-FAIL CRs convert to <br> in <pre> element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS CRs convert to <br> in <pre> element
</ins><span class="cx"> PASS CRs convert to <br> in <pre> element, detached
</span><span class="cx"> PASS Newline/CR pair converts to <br> in non-white-space:pre element
</span><span class="cx"> PASS Newline/CR pair converts to <br> in non-white-space:pre element, detached
</span><span class="lines">@@ -19,7 +19,7 @@
</span><span class="cx"> PASS Newline/newline pair converts to two <br>s in non-white-space:pre element, detached
</span><span class="cx"> PASS CR/CR pair converts to two <br>s in non-white-space:pre element
</span><span class="cx"> PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
</span><del>-FAIL CRs convert to <br> in white-space:pre element assert_equals: expected "abc<br>def" but got "abc\ndef"
</del><ins>+PASS CRs convert to <br> in white-space:pre element
</ins><span class="cx"> PASS CRs convert to <br> in white-space:pre element, detached
</span><span class="cx"> PASS < preserved
</span><span class="cx"> PASS < preserved, detached
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (280540 => 280541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-08-02 17:09:40 UTC (rev 280540)
+++ trunk/Source/WebCore/ChangeLog      2021-08-02 17:28:58 UTC (rev 280541)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2021-08-02  Chris Dumez  <cdumez@apple.com>
+
+        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.
+
+        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 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):
+
</ins><span class="cx"> 2021-08-02  Sam Weinig  <weinig@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Address additional feedback on LayoutTraits refactor
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.cpp (280540 => 280541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.cpp        2021-08-02 17:09:40 UTC (rev 280540)
+++ trunk/Source/WebCore/html/HTMLElement.cpp   2021-08-02 17:28:58 UTC (rev 280541)
</span><span class="lines">@@ -566,11 +566,7 @@
</span><span class="cx">         return { };
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // FIXME: Do we need to be able to detect preserveNewline style even when there's no renderer?
-    // FIXME: Can the renderer be out of date here? Do we need to call updateStyleIfNeeded?
-    // For example, for the contents of textarea elements that are display:none?
-    auto* r = renderer();
-    if ((r && r->style().preserveNewline()) || (isConnected() && isTextControlInnerTextElement())) {
</del><ins>+    if (isConnected() && isTextControlInnerTextElement()) {
</ins><span class="cx">         if (!text.contains('\r')) {
</span><span class="cx">             stringReplaceAll(text);
</span><span class="cx">             return { };
</span></span></pre>
</div>
</div>

</body>
</html>