Title: [237548] trunk
Revision
237548
Author
[email protected]
Date
2018-10-29 07:19:09 -0700 (Mon, 29 Oct 2018)

Log Message

[LFC][IFC] Inline layout produces separate runs when float is present.
https://bugs.webkit.org/show_bug.cgi?id=190980

Reviewed by Antti Koivisto.

Source/WebCore:

<div>foo<img src="" style="float: left">bar</div> produces 2 inline boxes (foo) and (bar) -> current inline code
while it is really just one continuous run (foobar) -> LFC
Adjust verification code to check for such runs.

* layout/Verification.cpp:
(WebCore::Layout::checkForMatchingNonTextRuns):
(WebCore::Layout::checkForMatchingTextRuns):
(WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
* layout/inlineformatting/InlineRun.h:
(WebCore::Layout::InlineRun::textContext const):

Tools:

* LayoutReloaded/misc/LFC-passing-tests.txt:

LayoutTests:

* fast/block/basic/inline-content-with-floating-images2-expected.txt: Added.
* fast/block/basic/inline-content-with-floating-images2.html: Added.
* platform/ios/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237547 => 237548)


--- trunk/LayoutTests/ChangeLog	2018-10-29 13:16:03 UTC (rev 237547)
+++ trunk/LayoutTests/ChangeLog	2018-10-29 14:19:09 UTC (rev 237548)
@@ -1,3 +1,14 @@
+2018-10-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Inline layout produces separate runs when float is present.
+        https://bugs.webkit.org/show_bug.cgi?id=190980
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/basic/inline-content-with-floating-images2-expected.txt: Added.
+        * fast/block/basic/inline-content-with-floating-images2.html: Added.
+        * platform/ios/TestExpectations:
+
 2018-10-29  Tadeu Zagallo  <[email protected]>
 
         New bytecode format for JSC

Added: trunk/LayoutTests/fast/block/basic/inline-content-with-floating-images2-expected.txt (0 => 237548)


--- trunk/LayoutTests/fast/block/basic/inline-content-with-floating-images2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/basic/inline-content-with-floating-images2-expected.txt	2018-10-29 14:19:09 UTC (rev 237548)
@@ -0,0 +1,41 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+layer at (8,8) size 300x54
+  RenderBlock {DIV} at (0,0) size 300x54
+    RenderText {#text} at (40,0) size 24x18
+      text run at (40,0) width 24: "this"
+    RenderImage {IMG} at (0,0) size 20x30
+    RenderText {#text} at (63,0) size 11x18
+      text run at (63,0) width 11: "is"
+    RenderImage {IMG} at (20,0) size 20x30
+    RenderText {#text} at (73,0) size 296x54
+      text run at (73,0) width 212: "one run long long long long long"
+      text run at (40,18) width 256: "long long long long long long long long"
+      text run at (0,36) width 89: "long long text"
+layer at (8,62) size 300x54
+  RenderBlock {DIV} at (0,54) size 300x54
+    RenderText {#text} at (15,0) size 24x18
+      text run at (15,0) width 24: "this"
+    RenderImage {IMG} at (280,0) size 20x30
+    RenderText {#text} at (38,0) size 12x18
+      text run at (38,0) width 12: "is"
+    RenderImage {IMG} at (260,0) size 20x30
+    RenderText {#text} at (49,0) size 296x54
+      text run at (49,0) width 211: "one run long long long long long"
+      text run at (4,18) width 256: "long long long long long long long long"
+      text run at (211,36) width 89: "long long text"
+layer at (8,116) size 300x54
+  RenderBlock {DIV} at (0,108) size 300x54
+    RenderText {#text} at (35,0) size 24x18
+      text run at (35,0) width 24: "this"
+    RenderImage {IMG} at (0,0) size 20x30
+    RenderText {#text} at (58,0) size 12x18
+      text run at (58,0) width 12: "is"
+    RenderImage {IMG} at (280,0) size 20x30
+    RenderText {#text} at (69,0) size 276x54
+      text run at (69,0) width 211: "one run long long long long long"
+      text run at (24,18) width 256: "long long long long long long long long"
+      text run at (211,36) width 89: "long long text"

Added: trunk/LayoutTests/fast/block/basic/inline-content-with-floating-images2.html (0 => 237548)


--- trunk/LayoutTests/fast/block/basic/inline-content-with-floating-images2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/basic/inline-content-with-floating-images2.html	2018-10-29 14:19:09 UTC (rev 237548)
@@ -0,0 +1,3 @@
+<div style="overflow: hidden; text-align: left; width: 300px;">this<img style="float: left;" src="" height="30" width="20">is<img style="float: left;" src="" height="30" width="20">one run long long long long long long long long long long long long long long long text</div>
+<div style="overflow: hidden; text-align: right; width: 300px;">this<img style="float: right;" src="" height="30" width="20">is<img style="float: right;" src="" height="30" width="20">one run long long long long long long long long long long long long long long long text</div>
+<div style="overflow: hidden; text-align: right; width: 300px;">this<img style="float: left;" src="" height="30" width="20">is<img style="float: right;" src="" height="30" width="20">one run long long long long long long long long long long long long long long long text</div>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/ios/TestExpectations (237547 => 237548)


--- trunk/LayoutTests/platform/ios/TestExpectations	2018-10-29 13:16:03 UTC (rev 237547)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2018-10-29 14:19:09 UTC (rev 237548)
@@ -3108,6 +3108,7 @@
 fast/block/block-only/relative-auto-with-parent-offset.html [ Failure ]
 fast/block/block-only/absolute-position-min-max-height.html [ Failure ]
 fast/block/basic/inline-content-with-floating-image.html [ Failure ]
+fast/block/basic/inline-content-with-floating-images2.html [ Failure ]
 
 # Datalist
 webkit.org/b/186714 fast/forms/datalist/datalist-textinput-keydown.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (237547 => 237548)


--- trunk/Source/WebCore/ChangeLog	2018-10-29 13:16:03 UTC (rev 237547)
+++ trunk/Source/WebCore/ChangeLog	2018-10-29 14:19:09 UTC (rev 237548)
@@ -1,3 +1,21 @@
+2018-10-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Inline layout produces separate runs when float is present.
+        https://bugs.webkit.org/show_bug.cgi?id=190980
+
+        Reviewed by Antti Koivisto.
+
+        <div>foo<img src="" style="float: left">bar</div> produces 2 inline boxes (foo) and (bar) -> current inline code
+        while it is really just one continuous run (foobar) -> LFC
+        Adjust verification code to check for such runs.
+
+        * layout/Verification.cpp:
+        (WebCore::Layout::checkForMatchingNonTextRuns):
+        (WebCore::Layout::checkForMatchingTextRuns):
+        (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
+        * layout/inlineformatting/InlineRun.h:
+        (WebCore::Layout::InlineRun::textContext const):
+
 2018-10-29  Youenn Fablet  <[email protected]>
 
         [WebRTC] Enable VP8 by default

Modified: trunk/Source/WebCore/layout/Verification.cpp (237547 => 237548)


--- trunk/Source/WebCore/layout/Verification.cpp	2018-10-29 13:16:03 UTC (rev 237547)
+++ trunk/Source/WebCore/layout/Verification.cpp	2018-10-29 14:19:09 UTC (rev 237548)
@@ -84,6 +84,16 @@
     return mismatched;
 }
 
+static bool checkForMatchingNonTextRuns(const InlineRun& inlineRun, const WebCore::InlineBox& inlineBox)
+{
+    return areEssentiallyEqual(inlineBox.logicalLeft(), inlineRun.logicalLeft()) && areEssentiallyEqual(inlineBox.logicalRight(), inlineRun.logicalRight());
+}
+
+static bool checkForMatchingTextRuns(const InlineRun& inlineRun, float logicalLeft, float logicalRight, unsigned start, unsigned end)
+{
+    return areEssentiallyEqual(logicalLeft, inlineRun.logicalLeft()) && areEssentiallyEqual(logicalRight, inlineRun.logicalRight()) && start == inlineRun.textContext()->start() && (end == (inlineRun.textContext()->start() + inlineRun.textContext()->length()));
+}
+
 static bool outputMismatchingComplexLineInformationIfNeeded(TextStream& stream, const LayoutContext& layoutContext, const RenderBlockFlow& blockFlow, const Container& inlineFormattingRoot)
 {
     auto& inlineFormattingState = layoutContext.establishedFormattingState(inlineFormattingRoot);
@@ -90,42 +100,80 @@
     ASSERT(is<InlineFormattingState>(inlineFormattingState));
     auto& inlineRunList = downcast<InlineFormattingState>(inlineFormattingState).inlineRuns();
 
+    // Collect inlineboxes.
+    Vector<WebCore::InlineBox*> inlineBoxes;
+    for (auto* rootLine = blockFlow.firstRootBox(); rootLine; rootLine = rootLine->nextRootBox()) {
+        for (auto* inlineBox = rootLine->firstChild(); inlineBox; inlineBox = inlineBox->nextOnLine())
+            inlineBoxes.append(inlineBox);
+    }
+
     auto mismatched = false;
     unsigned runIndex = 0;
-    for (auto* rootLine = blockFlow.firstRootBox(); rootLine; rootLine = rootLine->nextRootBox()) {
-        for (auto* lineBox = rootLine->firstChild(); lineBox; lineBox = lineBox->nextOnLine()) {
-            if (runIndex >= inlineRunList.size()) {
-                // FIXME: <span>foobar</span>foobar generates 2 inline text boxes while we only generate one layout run (which is much better, since it enables us to do kerning across inline elements).
-                stream << "Mismatching number of runs: inline runs(" << inlineRunList.size() << ")";
-                stream.nextLine();
-                return true;
-            }
 
-            auto& inlineRun = inlineRunList[runIndex];
-            auto* inlineTextBox = is<InlineTextBox>(lineBox) ? downcast<InlineTextBox>(lineBox) : nullptr;
+    if (inlineBoxes.size() != inlineRunList.size()) {
+        stream << "Warning: mismatching number of runs: inlineboxes(" << inlineBoxes.size() << ") vs. inline runs(" << inlineRunList.size() << ")";
+        stream.nextLine();
+    }
 
-            auto matchingRuns = areEssentiallyEqual(lineBox->logicalLeft(), inlineRun.logicalLeft()) && areEssentiallyEqual(lineBox->logicalRight(), inlineRun.logicalRight());
-            if (matchingRuns && inlineTextBox) {
-                ASSERT(inlineRun.textContext());
-                matchingRuns = inlineTextBox->start() == inlineRun.textContext()->start() && inlineTextBox->end() + 1 == (inlineRun.textContext()->start() + inlineRun.textContext()->length());
+    for (unsigned inlineBoxIndex = 0; inlineBoxIndex < inlineBoxes.size() && runIndex < inlineRunList.size(); ++inlineBoxIndex) {
+        auto* inlineBox = inlineBoxes[inlineBoxIndex];
+        auto* inlineTextBox = is<InlineTextBox>(inlineBox) ? downcast<InlineTextBox>(inlineBox) : nullptr;
+
+        auto& inlineRun = inlineRunList[runIndex];
+        auto matchingRuns = false;
+        if (inlineTextBox) {
+            matchingRuns = checkForMatchingTextRuns(inlineRun, inlineTextBox->logicalLeft(), inlineTextBox->logicalRight(), inlineTextBox->start(), inlineTextBox->end() + 1);
+
+            // <span>foobar</span>foobar generates 2 inline text boxes while we only generate one inline run.
+            // also <div>foo<img style="float: left;">bar</div> too.
+            auto inlineRunEnd = inlineRun.textContext()->start() + inlineRun.textContext()->length();
+            auto textRunMightBeExtended = !matchingRuns && inlineTextBox->end() < inlineRunEnd && inlineBoxIndex < inlineBoxes.size() - 1;
+
+            if (textRunMightBeExtended) {
+                auto logicalLeft = inlineTextBox->logicalLeft();
+                auto logicalRight = inlineTextBox->logicalRight();
+                auto start = inlineTextBox->start();
+                auto end = inlineTextBox->end() + 1;
+                auto index = ++inlineBoxIndex;
+                for (; index < inlineBoxes.size(); ++index) {
+                    auto* inlineBox = inlineBoxes[index];
+                    auto* inlineTextBox = is<InlineTextBox>(inlineBox) ? downcast<InlineTextBox>(inlineBox) : nullptr;
+                    // Can't mix different inline boxes.
+                    if (!inlineTextBox)
+                        break;
+
+                    logicalRight = inlineTextBox->logicalRight();
+                    end += (inlineTextBox->end() + 1);
+                    if (checkForMatchingTextRuns(inlineRun, logicalLeft, logicalRight, start, end)) {
+                        matchingRuns = true;
+                        inlineBoxIndex = index;
+                        break;
+                    }
+
+                    // Went too far?
+                    if (end >= inlineRunEnd)
+                        break;
+                }
             }
+        } else
+            matchingRuns = checkForMatchingNonTextRuns(inlineRun, *inlineBox);
 
-            if (!matchingRuns) {
-                stream << "Mismatching: run ";
 
-                if (inlineTextBox)
-                    stream << "(" << inlineTextBox->start() << ", " << inlineTextBox->end() + 1 << ")";
-                stream << " (" << lineBox->logicalLeft() << ", " << lineBox->logicalRight() << ") ";
+        if (!matchingRuns) {
+            stream << "Mismatching: run ";
 
-                stream << "layout run ";
-                if (inlineRun.textContext())
-                    stream << "(" << inlineRun.textContext()->start() << ", " << inlineRun.textContext()->start() + inlineRun.textContext()->length() << ") ";
-                stream << "(" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ")";
-                stream.nextLine();
-                mismatched = true;
-            }
-            ++runIndex;
+            if (inlineTextBox)
+                stream << "(" << inlineTextBox->start() << ", " << inlineTextBox->end() + 1 << ")";
+            stream << " (" << inlineBox->logicalLeft() << ", " << inlineBox->logicalRight() << ") ";
+
+            stream << "inline run ";
+            if (inlineRun.textContext())
+                stream << "(" << inlineRun.textContext()->start() << ", " << inlineRun.textContext()->start() + inlineRun.textContext()->length() << ") ";
+            stream << "(" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ")";
+            stream.nextLine();
+            mismatched = true;
         }
+        ++runIndex;
     }
     return mismatched;
 }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineRun.h (237547 => 237548)


--- trunk/Source/WebCore/layout/inlineformatting/InlineRun.h	2018-10-29 13:16:03 UTC (rev 237547)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineRun.h	2018-10-29 14:19:09 UTC (rev 237548)
@@ -68,6 +68,7 @@
     };
     void setTextContext(TextContext textContext) { m_textContext.emplace(textContext); }
     std::optional<TextContext>& textContext() { return m_textContext; }
+    std::optional<TextContext> textContext() const { return m_textContext; }
 
     const InlineItem& inlineItem() const { return m_inlineItem; }
 

Modified: trunk/Tools/ChangeLog (237547 => 237548)


--- trunk/Tools/ChangeLog	2018-10-29 13:16:03 UTC (rev 237547)
+++ trunk/Tools/ChangeLog	2018-10-29 14:19:09 UTC (rev 237548)
@@ -1,3 +1,12 @@
+2018-10-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Inline layout produces separate runs when float is present.
+        https://bugs.webkit.org/show_bug.cgi?id=190980
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-10-29  Tadeu Zagallo  <[email protected]>
 
         New bytecode format for JSC

Modified: trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt (237547 => 237548)


--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2018-10-29 13:16:03 UTC (rev 237547)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2018-10-29 14:19:09 UTC (rev 237548)
@@ -63,3 +63,4 @@
 fast/block/block-only/float-min-max-height.html
 fast/block/block-only/min-max-height-percentage.html
 fast/block/basic/inline-content-with-floating-image.html
+fast/block/basic/inline-content-with-floating-images2.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to