Title: [283699] trunk/Source/WebCore
Revision
283699
Author
[email protected]
Date
2021-10-06 21:02:03 -0700 (Wed, 06 Oct 2021)

Log Message

[LFC][IFC] InlineDisplay::Box should not hold on to RenderStyle&
https://bugs.webkit.org/show_bug.cgi?id=231325
<rdar://83925737>

Reviewed by Simon Fraser.

In the long run InlineDisplay::Box should retain the style so that we could paint the content independently, but for now
let's just consult the layout box for the style information.

* 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): The assumption here was that the style object stays around for the lifecycle of the display box (i.e. style object is destroyed -> layout -> new set of display boxes).
(WebCore::InlineDisplay::Box::Box):
* layout/integration/LayoutIntegrationPagination.cpp:
(WebCore::LayoutIntegration::makeAdjustedContent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283698 => 283699)


--- trunk/Source/WebCore/ChangeLog	2021-10-07 03:54:03 UTC (rev 283698)
+++ trunk/Source/WebCore/ChangeLog	2021-10-07 04:02:03 UTC (rev 283699)
@@ -1,3 +1,24 @@
+2021-10-06  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] InlineDisplay::Box should not hold on to RenderStyle&
+        https://bugs.webkit.org/show_bug.cgi?id=231325
+        <rdar://83925737>
+
+        Reviewed by Simon Fraser.
+
+        In the long run InlineDisplay::Box should retain the style so that we could paint the content independently, but for now
+        let's just consult the layout box for the style information.
+
+        * 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): The assumption here was that the style object stays around for the lifecycle of the display box (i.e. style object is destroyed -> layout -> new set of display boxes).
+        (WebCore::InlineDisplay::Box::Box):
+        * layout/integration/LayoutIntegrationPagination.cpp:
+        (WebCore::LayoutIntegration::makeAdjustedContent):
+
 2021-10-06  Simon Fraser  <[email protected]>
 
         Rename the AnimatedScroll enum to ScrollIsAnimated for consistency

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-10-07 03:54:03 UTC (rev 283698)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-10-07 04:02:03 UTC (rev 283699)
@@ -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(), !lineIndex ? root().firstLineStyle() : root().style(), rootInlineBoxRect, rootInlineBoxRect, { }, { },  lineBox.rootInlineBox().hasContent()});
+    boxes.append({ lineIndex, InlineDisplay::Box::Type::RootInlineBox, root(), rootInlineBoxRect, rootInlineBoxRect, { }, { },  lineBox.rootInlineBox().hasContent()});
 
     createBoxesAndUpdateGeometryForLineSpanningInlineBoxes(lineBox, lineBoxLogicalTopLeft, lineIndex, boxes);
     createBoxesAndUpdateGeometryForLineContent(lineContent, lineBox, lineBoxLogicalTopLeft, lineIndex, boxes);
@@ -96,7 +96,6 @@
             boxes.append({ lineIndex
                 , InlineDisplay::Box::Type::Text
                 , layoutBox
-                , style
                 , textRunRect
                 , inkOverflow()
                 , lineRun.expansion()
@@ -112,7 +111,6 @@
             boxes.append({ lineIndex
                 , InlineDisplay::Box::Type::SoftLineBreak
                 , layoutBox
-                , style
                 , softLineBreakRunRect
                 , softLineBreakRunRect
                 , lineRun.expansion()
@@ -123,7 +121,7 @@
             // Only hard linebreaks have associated layout boxes.
             auto lineBreakBoxRect = lineBox.logicalRectForLineBreakBox(layoutBox);
             lineBreakBoxRect.moveBy(lineBoxLogicalTopLeft);
-            boxes.append({ lineIndex, InlineDisplay::Box::Type::LineBreakBox, layoutBox, style, lineBreakBoxRect, lineBreakBoxRect, lineRun.expansion(), { } });
+            boxes.append({ lineIndex, InlineDisplay::Box::Type::LineBreakBox, layoutBox, lineBreakBoxRect, lineBreakBoxRect, lineRun.expansion(), { } });
 
             auto& boxGeometry = formattingState.boxGeometry(layoutBox);
             boxGeometry.setLogicalTopLeft(toLayoutPoint(lineBreakBoxRect.topLeft()));
@@ -136,7 +134,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, style, logicalBorderBox, logicalBorderBox, lineRun.expansion(), { } });
+            boxes.append({ lineIndex, InlineDisplay::Box::Type::AtomicInlineLevelBox, layoutBox, logicalBorderBox, logicalBorderBox, lineRun.expansion(), { } });
 
             auto borderBoxLogicalTopLeft = logicalBorderBox.topLeft();
             // Note that inline boxes are relative to the line and their top position can be negative.
@@ -163,7 +161,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, style, inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, lineBox.inlineLevelBoxForLayoutBox(layoutBox).hasContent() });
+                boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, lineBox.inlineLevelBoxForLayoutBox(layoutBox).hasContent() });
             }
 
             auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
@@ -196,9 +194,6 @@
         if (!inlineLevelBox.isLineSpanningInlineBox())
             continue;
         auto& layoutBox = inlineLevelBox.layoutBox();
-        auto& style = [&] () -> const RenderStyle& {
-            return !lineIndex ? layoutBox.firstLineStyle() : 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);
@@ -205,7 +200,7 @@
         inlineBoxBorderBox.moveBy(lineBoxLogicalTopLeft);
 
         m_inlineBoxIndexMap.add(&layoutBox, boxes.size());
-        boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, style, inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineLevelBox.hasContent() });
+        boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, 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 (283698 => 283699)


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h	2021-10-07 03:54:03 UTC (rev 283698)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h	2021-10-07 04:02:03 UTC (rev 283699)
@@ -67,7 +67,7 @@
         GenericInlineLevelBox
     };
     struct Expansion;
-    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);
+    Box(size_t lineIndex, Type, const Layout::Box&, 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 m_style; }
+    const RenderStyle& style() const { return !lineIndex() ? layoutBox().firstLineStyle() : layoutBox().style(); }
 
     size_t lineIndex() const { return m_lineIndex; }
 
@@ -116,7 +116,6 @@
     const size_t m_lineIndex { 0 };
     const Type m_type { Type::GenericInlineLevelBox };
     CheckedRef<const Layout::Box> m_layoutBox;
-    const RenderStyle& m_style;
     Layout::InlineRect m_logicalRect;
     Layout::InlineRect m_inkOverflow;
     bool m_hasContent { true };
@@ -124,11 +123,10 @@
     std::optional<Text> m_text;
 };
 
-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)
+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)
     : m_lineIndex(lineIndex)
     , m_type(type)
     , m_layoutBox(layoutBox)
-    , m_style(style)
     , m_logicalRect(logicalRect)
     , m_inkOverflow(inkOverflow)
     , m_hasContent(hasContent)

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp (283698 => 283699)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp	2021-10-07 03:54:03 UTC (rev 283698)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp	2021-10-07 04:02:03 UTC (rev 283699)
@@ -146,7 +146,6 @@
             box.lineIndex(),
             box.type(),
             box.layoutBox(),
-            box.style(),
             moveVertically(box.logicalRect(), offset),
             moveVertically(box.inkOverflow(), offset),
             box.expansion(),
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to