Title: [253251] trunk/Source/WebCore
Revision
253251
Author
[email protected]
Date
2019-12-07 05:56:51 -0800 (Sat, 07 Dec 2019)

Log Message

[LFC][Integration] Layout test assert and crash fixes
https://bugs.webkit.org/show_bug.cgi?id=204982

Reviewed by Zalan Bujtas.

* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::firstLineBaseline const):
(WebCore::LayoutIntegration::LineLayout::lastLineBaseline const):
(WebCore::LayoutIntegration::LineLayout::textBoxesFor const):

Don't 0-initialize Optional.

* layout/integration/LayoutIntegrationLineLayout.h:
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createLayoutBox):

Remember to add line break renderer to the renderer->layout box map.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::markLinesDirtyInBlockRange):

Invalidate layout path with LFC.

(WebCore::RenderBlockFlow::firstLineBaseline const):
(WebCore::RenderBlockFlow::inlineBlockBaseline const):

Call LFC baseline functions.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (253250 => 253251)


--- trunk/Source/WebCore/ChangeLog	2019-12-07 13:46:48 UTC (rev 253250)
+++ trunk/Source/WebCore/ChangeLog	2019-12-07 13:56:51 UTC (rev 253251)
@@ -1,3 +1,33 @@
+2019-12-07  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Layout test assert and crash fixes
+        https://bugs.webkit.org/show_bug.cgi?id=204982
+
+        Reviewed by Zalan Bujtas.
+
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::firstLineBaseline const):
+        (WebCore::LayoutIntegration::LineLayout::lastLineBaseline const):
+        (WebCore::LayoutIntegration::LineLayout::textBoxesFor const):
+
+        Don't 0-initialize Optional.
+
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createLayoutBox):
+
+        Remember to add line break renderer to the renderer->layout box map.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::markLinesDirtyInBlockRange):
+
+        Invalidate layout path with LFC.
+
+        (WebCore::RenderBlockFlow::firstLineBaseline const):
+        (WebCore::RenderBlockFlow::inlineBlockBaseline const):
+
+        Call LFC baseline functions.
+
 2019-12-07  Tim Horton  <[email protected]>
 
         Implement encoding for DrawImage and DrawRoundedRect display list items

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (253250 => 253251)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2019-12-07 13:46:48 UTC (rev 253250)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2019-12-07 13:56:51 UTC (rev 253251)
@@ -108,6 +108,30 @@
     return inlineContent ? inlineContent->lineBoxes.size() : 0;
 }
 
+LayoutUnit LineLayout::firstLineBaseline() const
+{
+    auto* inlineContent = displayInlineContent();
+    if (!inlineContent) {
+        ASSERT_NOT_REACHED();
+        return 0_lu;
+    }
+
+    auto& firstLineBox = inlineContent->lineBoxes.first();
+    return firstLineBox.logicalTop() + firstLineBox.baselineOffset();
+}
+
+LayoutUnit LineLayout::lastLineBaseline() const
+{
+    auto* inlineContent = displayInlineContent();
+    if (!inlineContent) {
+        ASSERT_NOT_REACHED();
+        return 0_lu;
+    }
+
+    auto& lastLineBox = inlineContent->lineBoxes.last();
+    return lastLineBox.logicalTop() + lastLineBox.baselineOffset();
+}
+
 const Display::InlineContent* LineLayout::displayInlineContent() const
 {
     return downcast<Layout::InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent();
@@ -121,15 +145,16 @@
     auto* layoutBox = m_treeContent->layoutBoxForRenderer(renderText);
     ASSERT(layoutBox);
 
-    Optional<size_t> firstIndex = 0;
+    Optional<size_t> firstIndex;
     size_t lastIndex = 0;
     for (size_t i = 0; i < inlineContent->runs.size(); ++i) {
-        auto& run =  inlineContent->runs[i];
+        auto& run = inlineContent->runs[i];
         if (&run.layoutBox() == layoutBox) {
             if (!firstIndex)
                 firstIndex = i;
             lastIndex = i;
-        }
+        } else if (firstIndex)
+            break;
     }
     if (!firstIndex)
         return { };

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (253250 => 253251)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2019-12-07 13:46:48 UTC (rev 253250)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2019-12-07 13:56:51 UTC (rev 253251)
@@ -60,6 +60,8 @@
 
     LayoutUnit contentLogicalHeight() const { return m_contentLogicalHeight; }
     size_t lineCount() const;
+    LayoutUnit firstLineBaseline() const;
+    LayoutUnit lastLineBaseline() const;
 
     const Display::InlineContent* displayInlineContent() const;
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (253250 => 253251)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2019-12-07 13:46:48 UTC (rev 253250)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2019-12-07 13:56:51 UTC (rev 253251)
@@ -194,9 +194,8 @@
         auto& renderer = downcast<RenderElement>(childRenderer);
         auto displayType = renderer.style().display();
         if (is<RenderLineBreak>(renderer))
-            return makeUnique<Box>(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
-
-        if (is<RenderTable>(renderer)) {
+            childLayoutBox = makeUnique<Box>(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
+        else if (is<RenderTable>(renderer)) {
             // Construct the principal table wrapper box (and not the table box itself).
             childLayoutBox = makeUnique<Container>(Box::ElementAttributes { Box::ElementType::TableWrapperBox }, RenderStyle::clone(renderer.style()));
             childLayoutBox->setIsAnonymous();

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (253250 => 253251)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2019-12-07 13:46:48 UTC (rev 253250)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2019-12-07 13:56:51 UTC (rev 253251)
@@ -3050,12 +3050,19 @@
     if (logicalTop >= logicalBottom)
         return;
 
-    // Floats currently affect the choice whether to use simple line layout path.
+    // Floats currently affect the choice of layout path.
     if (simpleLineLayout()) {
         invalidateLineLayoutPath();
         return;
     }
 
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+    if (layoutFormattingContextLineLayout()) {
+        invalidateLineLayoutPath();
+        return;
+    }
+#endif
+
     RootInlineBox* lowestDirtyLine = lastRootBox();
     RootInlineBox* afterLowest = lowestDirtyLine;
     while (lowestDirtyLine && lowestDirtyLine->lineBottomWithLeading() >= logicalBottom && logicalBottom < LayoutUnit::max()) {
@@ -3080,9 +3087,14 @@
     if (!hasLines())
         return WTF::nullopt;
 
-    if (auto simpleLineLayout = this->simpleLineLayout())
-        return Optional<int>(SimpleLineLayout::computeFlowFirstLineBaseline(*this, *simpleLineLayout));
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+    if (layoutFormattingContextLineLayout())
+        return floorToInt(layoutFormattingContextLineLayout()->firstLineBaseline());
+#endif
 
+    if (simpleLineLayout())
+        return { SimpleLineLayout::computeFlowFirstLineBaseline(*this, *simpleLineLayout()) };
+
     ASSERT(firstRootBox());
     if (style().isFlippedLinesWritingMode())
         return firstRootBox()->logicalTop() + firstLineStyle().fontMetrics().descent(firstRootBox()->baselineType());
@@ -3112,8 +3124,12 @@
                 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()));
         }
 
-        if (auto simpleLineLayout = this->simpleLineLayout())
-            lastBaseline = SimpleLineLayout::computeFlowLastLineBaseline(*this, *simpleLineLayout);
+        if (simpleLineLayout())
+            lastBaseline = SimpleLineLayout::computeFlowLastLineBaseline(*this, *simpleLineLayout());
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+        else if (layoutFormattingContextLineLayout())
+            lastBaseline = floorToInt(layoutFormattingContextLineLayout()->lastLineBaseline());
+#endif
         else {
             bool isFirstLine = lastRootBox() == firstRootBox();
             const auto& style = isFirstLine ? firstLineStyle() : this->style();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to