<!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>[281358] trunk/Source/WebCore</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/281358">281358</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2021-08-20 19:44:59 -0700 (Fri, 20 Aug 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][Integration] HTMLTextFormControlElement should use the inline iterator to collect content for wrap=hard
https://bugs.webkit.org/show_bug.cgi?id=228882

Reviewed by Antti Koivisto.

getNextSoftBreak is simply returns the position of the last item on the line unless it's a hard line break.
(endsWithBreak -> previousLineBrokeCleanly -> previousLineBrokeAtBR  see https://trac.webkit.org/changeset/6107)

* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const):
(WebCore::getNextSoftBreak): Deleted. line->lineBreakPos() translates to the position where the line breaks within the run.
maximumCaretOffset() returns the same value, though the naming is a bit confusing and probably should be renamed or introduce
something similar on the line iterator.
* layout/integration/LayoutIntegrationCoverage.cpp:
(WebCore::LayoutIntegration::canUseForLineLayoutWithReason):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTextFormControlElementcpp">trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationCoveragecpp">trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationCoverageh">trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (281357 => 281358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-08-21 01:45:09 UTC (rev 281357)
+++ trunk/Source/WebCore/ChangeLog      2021-08-21 02:44:59 UTC (rev 281358)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2021-08-20  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][Integration] HTMLTextFormControlElement should use the inline iterator to collect content for wrap=hard
+        https://bugs.webkit.org/show_bug.cgi?id=228882
+
+        Reviewed by Antti Koivisto.
+
+        getNextSoftBreak is simply returns the position of the last item on the line unless it's a hard line break.
+        (endsWithBreak -> previousLineBrokeCleanly -> previousLineBrokeAtBR  see https://trac.webkit.org/changeset/6107)
+
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const):
+        (WebCore::getNextSoftBreak): Deleted. line->lineBreakPos() translates to the position where the line breaks within the run.
+        maximumCaretOffset() returns the same value, though the naming is a bit confusing and probably should be renamed or introduce
+        something similar on the line iterator.
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        (WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
+
</ins><span class="cx"> 2021-08-20  Zalan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [IFC][Integration] Enable inline level boxes with relative (min/max)width and (min/max)height values
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTextFormControlElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (281357 => 281358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2021-08-21 01:45:09 UTC (rev 281357)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp    2021-08-21 02:44:59 UTC (rev 281358)
</span><span class="lines">@@ -41,9 +41,12 @@
</span><span class="cx"> #include "HTMLNames.h"
</span><span class="cx"> #include "HTMLParserIdioms.h"
</span><span class="cx"> #include "LayoutDisallowedScope.h"
</span><ins>+#include "LayoutIntegrationLineIterator.h"
+#include "LayoutIntegrationRunIterator.h"
</ins><span class="cx"> #include "Logging.h"
</span><span class="cx"> #include "NodeTraversal.h"
</span><span class="cx"> #include "Page.h"
</span><ins>+#include "RenderLineBreak.h"
</ins><span class="cx"> #include "RenderTextControlSingleLine.h"
</span><span class="cx"> #include "RenderTheme.h"
</span><span class="cx"> #include "ScriptDisallowedScope.h"
</span><span class="lines">@@ -681,23 +684,6 @@
</span><span class="cx">     return index;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void getNextSoftBreak(LegacyRootInlineBox*& line, Node*& breakNode, unsigned& breakOffset)
-{
-    LegacyRootInlineBox* next;
-    for (; line; line = next) {
-        next = line->nextRootBox();
-        if (next && !line->endsWithBreak()) {
-            ASSERT(line->lineBreakObj());
-            breakNode = line->lineBreakObj()->node();
-            breakOffset = line->lineBreakPos();
-            line = next;
-            return;
-        }
-    }
-    breakNode = 0;
-    breakOffset = 0;
-}
-
</del><span class="cx"> String HTMLTextFormControlElement::valueWithHardLineBreaks() const
</span><span class="cx"> {
</span><span class="cx">     // FIXME: It's not acceptable to ignore the HardWrap setting when there is no renderer.
</span><span class="lines">@@ -713,14 +699,31 @@
</span><span class="cx">     if (!renderer)
</span><span class="cx">         return value();
</span><span class="cx"> 
</span><del>-    Node* breakNode;
-    unsigned breakOffset;
-    LegacyRootInlineBox* line = renderer->firstRootBox();
-    if (!line)
</del><ins>+    Node* softLineBreakNode = nullptr;
+    unsigned softLineBreakOffset = 0;
+    auto currentLine = LayoutIntegration::firstLineFor(*renderer);
+    if (!currentLine)
</ins><span class="cx">         return value();
</span><span class="cx"> 
</span><del>-    getNextSoftBreak(line, breakNode, breakOffset);
</del><ins>+    auto skipToNextSoftLineBreakPosition = [&] {
+        for (; currentLine; currentLine.traverseNext()) {
+            auto lastRun = currentLine.lastRun();
+            ASSERT(lastRun);
+            auto& renderer = lastRun->renderer();
+            auto lineEndsWithBR = is<RenderLineBreak>(renderer) && !downcast<RenderLineBreak>(renderer).isWBR();
+            if (!lineEndsWithBR) {
+                softLineBreakNode = renderer.node();
+                softLineBreakOffset = lastRun->maximumCaretOffset();
+                currentLine.traverseNext();
+                return;
+            }
+        }
+        softLineBreakNode = nullptr;
+        softLineBreakOffset = 0;
+    };
</ins><span class="cx"> 
</span><ins>+    skipToNextSoftLineBreakPosition();
+
</ins><span class="cx">     StringBuilder result;
</span><span class="cx">     for (RefPtr<Node> node = innerText->firstChild(); node; node = NodeTraversal::next(*node, innerText.get())) {
</span><span class="cx">         if (is<HTMLBRElement>(*node))
</span><span class="lines">@@ -729,18 +732,18 @@
</span><span class="cx">             String data = downcast<Text>(*node).data();
</span><span class="cx">             unsigned length = data.length();
</span><span class="cx">             unsigned position = 0;
</span><del>-            while (breakNode == node && breakOffset <= length) {
-                if (breakOffset > position) {
-                    result.appendSubstring(data, position, breakOffset - position);
-                    position = breakOffset;
</del><ins>+            while (softLineBreakNode == node && softLineBreakOffset <= length) {
+                if (softLineBreakOffset > position) {
+                    result.appendSubstring(data, position, softLineBreakOffset - position);
+                    position = softLineBreakOffset;
</ins><span class="cx">                     result.append(newlineCharacter);
</span><span class="cx">                 }
</span><del>-                getNextSoftBreak(line, breakNode, breakOffset);
</del><ins>+                skipToNextSoftLineBreakPosition();
</ins><span class="cx">             }
</span><span class="cx">             result.appendSubstring(data, position, length - position);
</span><span class="cx">         }
</span><del>-        while (breakNode == node)
-            getNextSoftBreak(line, breakNode, breakOffset);
</del><ins>+        while (softLineBreakNode == node)
+            skipToNextSoftLineBreakPosition();
</ins><span class="cx">     }
</span><span class="cx">     stripTrailingNewline(result);
</span><span class="cx">     return result.toString();
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationCoveragecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (281357 => 281358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp    2021-08-21 01:45:09 UTC (rev 281357)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp       2021-08-21 02:44:59 UTC (rev 281358)
</span><span class="lines">@@ -114,9 +114,6 @@
</span><span class="cx">     case AvoidanceReason::FlowParentIsPlaceholderElement:
</span><span class="cx">         stream << "placeholder element";
</span><span class="cx">         break;
</span><del>-    case AvoidanceReason::FlowParentIsTextAreaWithWrapping:
-        stream << "wrapping textarea";
-        break;
</del><span class="cx">     case AvoidanceReason::FlowHasNonSupportedChild:
</span><span class="cx">         stream << "unsupported child renderer";
</span><span class="cx">         break;
</span><span class="lines">@@ -757,9 +754,6 @@
</span><span class="cx">     // FIXME: Placeholders do something strange.
</span><span class="cx">     if (is<RenderTextControl>(*flow.parent()) && downcast<RenderTextControl>(*flow.parent()).textFormControlElement().placeholderElement())
</span><span class="cx">         SET_REASON_AND_RETURN_IF_NEEDED(FlowParentIsPlaceholderElement, reasons, includeReasons);
</span><del>-    // FIXME: Implementation of wrap=hard looks into lineboxes.
-    if (flow.parent()->isTextArea() && flow.parent()->element()->hasAttributeWithoutSynchronization(HTMLNames::wrapAttr))
-        SET_REASON_AND_RETURN_IF_NEEDED(FlowParentIsTextAreaWithWrapping, reasons, includeReasons);
</del><span class="cx">     // This currently covers <blockflow>#text</blockflow>, <blockflow>#text<br></blockflow> and mutiple (sibling) RenderText cases.
</span><span class="cx">     // The <blockflow><inline>#text</inline></blockflow> case is also popular and should be relatively easy to cover.
</span><span class="cx">     for (auto walker = InlineWalker(const_cast<RenderBlockFlow&>(flow)); !walker.atEnd(); walker.advance()) {
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationCoverageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h (281357 => 281358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h      2021-08-21 01:45:09 UTC (rev 281357)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h 2021-08-21 02:44:59 UTC (rev 281358)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">     FlowHasTextOverflow                          = 1LLU  << 5,
</span><span class="cx">     FlowHasLineClamp                             = 1LLU  << 6,
</span><span class="cx">     FlowParentIsPlaceholderElement               = 1LLU  << 7,
</span><del>-    FlowParentIsTextAreaWithWrapping             = 1LLU  << 8,
</del><ins>+    // Unused                                    = 1LLU  << 8,
</ins><span class="cx">     FlowHasNonSupportedChild                     = 1LLU  << 9,
</span><span class="cx">     FlowHasUnsupportedFloat                      = 1LLU  << 10,
</span><span class="cx">     // Unused                                    = 1LLU  << 11,
</span></span></pre>
</div>
</div>

</body>
</html>