Title: [283038] trunk/Source/WebCore
Revision
283038
Author
za...@apple.com
Date
2021-09-24 06:23:47 -0700 (Fri, 24 Sep 2021)

Log Message

[LFC][IFC] InlineDisplay::Box should be able to provide first-line style when applicable
https://bugs.webkit.org/show_bug.cgi?id=230709

Reviewed by Antti Koivisto.

This is in preparation for supporting first-line style. The idea here is that the run/box objects we construct after line breaking should
retain the applicable style.

* layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::build):
(WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent):
(WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineSpanningInlineBoxes):
* layout/formattingContexts/inline/display/InlineDisplayBox.h:
(WebCore::InlineDisplay::Box::style const):
(WebCore::InlineDisplay::Box::Box):
* layout/integration/LayoutIntegrationPagination.cpp:
(WebCore::LayoutIntegration::makeAdjustedContent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283037 => 283038)


--- trunk/Source/WebCore/ChangeLog	2021-09-24 12:58:41 UTC (rev 283037)
+++ trunk/Source/WebCore/ChangeLog	2021-09-24 13:23:47 UTC (rev 283038)
@@ -1,3 +1,23 @@
+2021-09-24  Alan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] InlineDisplay::Box should be able to provide first-line style when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=230709
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for supporting first-line style. The idea here is that the run/box objects we construct after line breaking should
+        retain the applicable style.
+
+        * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::build):
+        (WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent):
+        (WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineSpanningInlineBoxes):
+        * layout/formattingContexts/inline/display/InlineDisplayBox.h:
+        (WebCore::InlineDisplay::Box::style const):
+        (WebCore::InlineDisplay::Box::Box):
+        * layout/integration/LayoutIntegrationPagination.cpp:
+        (WebCore::LayoutIntegration::makeAdjustedContent):
+
 2021-09-24  Kimmo Kinnunen  <kkinnu...@apple.com>
 
         Add utility to create CVPixelBuffers from IOSurfaces

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (283037 => 283038)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-09-24 12:58:41 UTC (rev 283037)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-09-24 13:23:47 UTC (rev 283038)
@@ -50,7 +50,7 @@
     // Every line starts with a root box, even the empty ones.
     auto rootInlineBoxRect = lineBox.logicalRectForRootInlineBox();
     rootInlineBoxRect.moveBy(lineBoxLogicalTopLeft);
-    boxes.append({ lineIndex, InlineDisplay::Box::Type::RootInlineBox, root(), rootInlineBoxRect, rootInlineBoxRect, { }, { },  lineBox.rootInlineBox().hasContent()});
+    boxes.append({ lineIndex, InlineDisplay::Box::Type::RootInlineBox, root(), root().style(), rootInlineBoxRect, rootInlineBoxRect, { }, { },  lineBox.rootInlineBox().hasContent()});
 
     createBoxesAndUpdateGeometryForLineSpanningInlineBoxes(lineBox, lineBoxLogicalTopLeft, lineIndex, boxes);
     createBoxesAndUpdateGeometryForLineContent(lineContent, lineBox, lineBoxLogicalTopLeft, lineIndex, boxes);
@@ -64,12 +64,14 @@
     // Create the inline boxes on the current line. This is mostly text and atomic inline boxes.
     for (auto& lineRun : lineContent.runs) {
         auto& layoutBox = lineRun.layoutBox();
+        // FIXME: This should be lineIndex dependent to support first-line style.
+        auto& style = layoutBox.style();
+
         switch (lineRun.type()) {
         case InlineItem::Type::Text: {
             auto textRunRect = lineBox.logicalRectForTextRun(lineRun);
             textRunRect.moveBy(lineBoxLogicalTopLeft);
 
-            auto& style = layoutBox.style();
             auto inkOverflow = [&] {
                 auto initialContaingBlockSize = RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()
                     ? formattingState.layoutState().viewportSize()
@@ -93,6 +95,7 @@
             boxes.append({ lineIndex
                 , InlineDisplay::Box::Type::Text
                 , layoutBox
+                , style
                 , textRunRect
                 , inkOverflow()
                 , lineRun.expansion()
@@ -108,6 +111,7 @@
             boxes.append({ lineIndex
                 , InlineDisplay::Box::Type::SoftLineBreak
                 , layoutBox
+                , style
                 , softLineBreakRunRect
                 , softLineBreakRunRect
                 , lineRun.expansion()
@@ -118,7 +122,7 @@
             // Only hard linebreaks have associated layout boxes.
             auto lineBreakBoxRect = lineBox.logicalRectForLineBreakBox(layoutBox);
             lineBreakBoxRect.moveBy(lineBoxLogicalTopLeft);
-            boxes.append({ lineIndex, InlineDisplay::Box::Type::LineBreakBox, layoutBox, lineBreakBoxRect, lineBreakBoxRect, lineRun.expansion(), { } });
+            boxes.append({ lineIndex, InlineDisplay::Box::Type::LineBreakBox, layoutBox, style, lineBreakBoxRect, lineBreakBoxRect, lineRun.expansion(), { } });
 
             auto& boxGeometry = formattingState.boxGeometry(layoutBox);
             boxGeometry.setLogicalTopLeft(toLayoutPoint(lineBreakBoxRect.topLeft()));
@@ -131,7 +135,7 @@
             auto logicalBorderBox = lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, boxGeometry);
             logicalBorderBox.moveBy(lineBoxLogicalTopLeft);
             // FIXME: Add ink overflow support for atomic inline level boxes (e.g. box shadow).
-            boxes.append({ lineIndex, InlineDisplay::Box::Type::AtomicInlineLevelBox, layoutBox, logicalBorderBox, logicalBorderBox, lineRun.expansion(), { } });
+            boxes.append({ lineIndex, InlineDisplay::Box::Type::AtomicInlineLevelBox, layoutBox, style, logicalBorderBox, logicalBorderBox, lineRun.expansion(), { } });
 
             auto borderBoxLogicalTopLeft = logicalBorderBox.topLeft();
             // Note that inline boxes are relative to the line and their top position can be negative.
@@ -158,7 +162,7 @@
             if (lineBox.hasContent()) {
                 // FIXME: It's expected to not have any boxes on empty lines. We should reconsider this.
                 m_inlineBoxIndexMap.add(&layoutBox, boxes.size());
-                boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, lineBox.inlineLevelBoxForLayoutBox(layoutBox).hasContent() });
+                boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, style, inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, lineBox.inlineLevelBoxForLayoutBox(layoutBox).hasContent() });
             }
 
             auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
@@ -191,6 +195,8 @@
         if (!inlineLevelBox.isLineSpanningInlineBox())
             continue;
         auto& layoutBox = inlineLevelBox.layoutBox();
+        // FIXME: This should be lineIndex dependent to support first-line style.
+        auto& style = layoutBox.style();
         auto& boxGeometry = formattingState.boxGeometry(layoutBox);
         // Inline boxes may or may not be wrapped and have boxes on multiple lines (e.g. <span>first line<br>second line<br>third line</span>)
         auto inlineBoxBorderBox = lineBox.logicalBorderBoxForInlineBox(layoutBox, boxGeometry);
@@ -197,7 +203,7 @@
         inlineBoxBorderBox.moveBy(lineBoxLogicalTopLeft);
 
         m_inlineBoxIndexMap.add(&layoutBox, boxes.size());
-        boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineLevelBox.hasContent() });
+        boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, style, inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineLevelBox.hasContent() });
 
         auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
         auto logicalRect = Rect { LayoutPoint { inlineBoxBorderBox.topLeft() }, inlineBoxSize };

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h (283037 => 283038)


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h	2021-09-24 12:58:41 UTC (rev 283037)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h	2021-09-24 13:23:47 UTC (rev 283038)
@@ -67,7 +67,7 @@
         GenericInlineLevelBox
     };
     struct Expansion;
-    Box(size_t lineIndex, Type, const Layout::Box&, const Layout::InlineRect&, const Layout::InlineRect& inkOverflow, Expansion, std::optional<Text> = std::nullopt, bool hasContent = true);
+    Box(size_t lineIndex, Type, const Layout::Box&, const RenderStyle&, const Layout::InlineRect&, const Layout::InlineRect& inkOverflow, Expansion, std::optional<Text> = std::nullopt, bool hasContent = true);
 
     bool isText() const { return m_type == Type::Text; }
     bool isSoftLineBreak() const { return m_type == Type::SoftLineBreak; }
@@ -108,7 +108,7 @@
     Expansion expansion() const { return m_expansion; }
 
     const Layout::Box& layoutBox() const { return *m_layoutBox; }
-    const RenderStyle& style() const { return layoutBox().style(); }
+    const RenderStyle& style() const { return m_style; }
 
     size_t lineIndex() const { return m_lineIndex; }
 
@@ -116,6 +116,7 @@
     const size_t m_lineIndex { 0 };
     const Type m_type { Type::GenericInlineLevelBox };
     WeakPtr<const Layout::Box> m_layoutBox;
+    const RenderStyle& m_style;
     Layout::InlineRect m_logicalRect;
     Layout::InlineRect m_inkOverflow;
     bool m_hasContent { true };
@@ -123,10 +124,11 @@
     std::optional<Text> m_text;
 };
 
-inline Box::Box(size_t lineIndex, Type type, const Layout::Box& layoutBox, const Layout::InlineRect& logicalRect, const Layout::InlineRect& inkOverflow, Expansion expansion, std::optional<Text> text, bool hasContent)
+inline Box::Box(size_t lineIndex, Type type, const Layout::Box& layoutBox, const RenderStyle& style, const Layout::InlineRect& logicalRect, const Layout::InlineRect& inkOverflow, Expansion expansion, std::optional<Text> text, bool hasContent)
     : m_lineIndex(lineIndex)
     , m_type(type)
     , m_layoutBox(makeWeakPtr(layoutBox))
+    , m_style(style)
     , m_logicalRect(logicalRect)
     , m_inkOverflow(inkOverflow)
     , m_hasContent(hasContent)

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp (283037 => 283038)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp	2021-09-24 12:58:41 UTC (rev 283037)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp	2021-09-24 13:23:47 UTC (rev 283038)
@@ -146,6 +146,7 @@
             box.lineIndex(),
             box.type(),
             box.layoutBox(),
+            box.style(),
             moveVertically(box.logicalRect(), offset),
             moveVertically(box.inkOverflow(), offset),
             box.expansion(),
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to