Diff
Modified: trunk/Source/WebCore/ChangeLog (271084 => 271085)
--- trunk/Source/WebCore/ChangeLog 2020-12-25 17:53:55 UTC (rev 271084)
+++ trunk/Source/WebCore/ChangeLog 2020-12-25 21:46:14 UTC (rev 271085)
@@ -1,5 +1,30 @@
2020-12-25 Zalan Bujtas <[email protected]>
+ [LFC][Integration] Use the pre-computed geometries for the inline level boxes
+ https://bugs.webkit.org/show_bug.cgi?id=220135
+ <rdar://problem/72642850>
+
+ Reviewed by Antti Koivisto.
+
+ Let's skip the tree traversal and recomputing the box geometries in InlineFormattingContext::layoutInFlowContent.
+
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedContentHeightAndMargin const):
+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedContentWidthAndMargin):
+ * layout/inlineformatting/InlineFormattingContext.h:
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::updateLayoutBoxDimensions):
+ (WebCore::LayoutIntegration::LineLayout::updateLineBreakBoxDimensions):
+ (WebCore::LayoutIntegration::LineLayout::layout):
+ * layout/integration/LayoutIntegrationLineLayout.h:
+ * layout/layouttree/LayoutReplacedBox.h:
+ (WebCore::Layout::ReplacedBox::contentSizeForIntegration const): Deleted.
+ (WebCore::Layout::ReplacedBox::setContentSizeForIntegration): Deleted.
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::layoutModernLines):
+
+2020-12-25 Zalan Bujtas <[email protected]>
+
[LFC][IFC] Fast vertical alignment should work with line-height
https://bugs.webkit.org/show_bug.cgi?id=220131
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (271084 => 271085)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2020-12-25 17:53:55 UTC (rev 271084)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2020-12-25 21:46:14 UTC (rev 271085)
@@ -903,9 +903,6 @@
auto usedVerticalMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
auto& style = replacedBox.style();
- if (replacedBox.contentSizeForIntegration())
- return { replacedBox.contentSizeForIntegration()->height(), usedVerticalMargin };
-
auto height = overriddenVerticalValues.height ? overriddenVerticalValues.height.value() : computedHeight(replacedBox, verticalConstraints ? verticalConstraints->logicalHeight : WTF::nullopt);
auto heightIsAuto = !overriddenVerticalValues.height && isHeightAuto(replacedBox);
auto widthIsAuto = style.logicalWidth().isAuto();
@@ -966,9 +963,6 @@
return computedHorizontalMargin.end.valueOr(0_lu);
};
- if (replacedBox.contentSizeForIntegration())
- return { replacedBox.contentSizeForIntegration()->width(), { usedMarginStart(), usedMarginEnd() } };
-
auto width = overriddenHorizontalValues.width ? overriddenHorizontalValues.width : computedWidth(replacedBox, horizontalConstraints.logicalWidth);
auto heightIsAuto = isHeightAuto(replacedBox);
auto height = computedHeight(replacedBox, verticalConstraints ? verticalConstraints->logicalHeight : WTF::nullopt);
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (271084 => 271085)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-12-25 17:53:55 UTC (rev 271084)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-12-25 21:46:14 UTC (rev 271085)
@@ -141,6 +141,14 @@
LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> inline formatting context -> formatting root(" << &root() << ")");
}
+void InlineFormattingContext::lineLayoutForIntergration(InvalidationState& invalidationState, const ConstraintsForInFlowContent& constraints)
+{
+ invalidateFormattingState(invalidationState);
+ collectInlineContentIfNeeded();
+ auto& inlineItems = formattingState().inlineItems();
+ lineLayout(inlineItems, { 0, inlineItems.size() }, constraints);
+}
+
LayoutUnit InlineFormattingContext::usedContentHeight() const
{
// 10.6.7 'Auto' heights for block formatting context roots
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (271084 => 271085)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2020-12-25 17:53:55 UTC (rev 271084)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2020-12-25 21:46:14 UTC (rev 271085)
@@ -65,6 +65,8 @@
const InlineFormattingState& formattingState() const { return downcast<InlineFormattingState>(FormattingContext::formattingState()); }
InlineFormattingState& formattingState() { return downcast<InlineFormattingState>(FormattingContext::formattingState()); }
+ void lineLayoutForIntergration(InvalidationState&, const ConstraintsForInFlowContent&);
+
private:
IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override;
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (271084 => 271085)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2020-12-25 17:53:55 UTC (rev 271084)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2020-12-25 21:46:14 UTC (rev 271085)
@@ -136,8 +136,6 @@
auto& replacedBox = downcast<Layout::ReplacedBox>(layoutBox);
// Always use the physical size here for inline level boxes (this is where the logical vs. physical coords flip happens).
- replacedBox.setContentSizeForIntegration({ replacedOrInlineBlock.contentWidth(), replacedOrInlineBlock.contentHeight() });
-
auto& replacedBoxGeometry = m_layoutState.ensureGeometryForBox(replacedBox);
// Scrollbars are placed "between" the border and the padding box and they never stretch the border box. They may shrink the padding box though.
auto horizontalSpaceReservedForScrollbar = std::min(replacedOrInlineBlock.width() - replacedOrInlineBlock.paddingBoxWidth(), LayoutUnit(replacedOrInlineBlock.verticalScrollbarWidth()));
@@ -146,10 +144,31 @@
auto verticalSpaceReservedForScrollbar = std::min(replacedOrInlineBlock.height() - replacedOrInlineBlock.paddingBoxHeight(), LayoutUnit(replacedOrInlineBlock.horizontalScrollbarHeight()));
replacedBoxGeometry.setVerticalSpaceForScrollbar(verticalSpaceReservedForScrollbar);
+ replacedBoxGeometry.setContentBoxWidth(replacedOrInlineBlock.contentWidth());
+ replacedBoxGeometry.setContentBoxHeight(replacedOrInlineBlock.contentHeight());
+
+ replacedBoxGeometry.setBorder({ { replacedOrInlineBlock.borderLeft(), replacedOrInlineBlock.borderRight() }, { replacedOrInlineBlock.borderTop(), replacedOrInlineBlock.borderBottom() } });
+ replacedBoxGeometry.setPadding(Layout::Edges { { replacedOrInlineBlock.paddingLeft(), replacedOrInlineBlock.paddingRight() }, { replacedOrInlineBlock.paddingTop(), replacedOrInlineBlock.paddingBottom() } });
+
+ replacedBoxGeometry.setHorizontalMargin({ replacedOrInlineBlock.marginLeft(), replacedOrInlineBlock.marginRight() });
+ replacedBoxGeometry.setVerticalMargin({ replacedOrInlineBlock.marginTop(), replacedOrInlineBlock.marginBottom() });
+
auto baseline = replacedOrInlineBlock.baselinePosition(AlphabeticBaseline, false /* firstLine */, HorizontalLine, PositionOnContainingLine);
replacedBox.setBaseline(roundToInt(baseline));
}
+void LineLayout::updateLineBreakBoxDimensions(const RenderLineBreak& lineBreakBox)
+{
+ // This is just a box geometry reset (see InlineFormattingContext::layoutInFlowContent).
+ auto& boxGeometry = m_layoutState.ensureGeometryForBox(m_boxTree.layoutBoxForRenderer(lineBreakBox));
+
+ boxGeometry.setHorizontalMargin({ });
+ boxGeometry.setBorder({ });
+ boxGeometry.setPadding({ });
+ boxGeometry.setContentBoxWidth({ });
+ boxGeometry.setVerticalMargin({ });
+}
+
void LineLayout::updateStyle(const RenderBoxModelObject& renderer)
{
m_boxTree.updateStyle(renderer);
@@ -170,7 +189,8 @@
auto horizontalConstraints = Layout::HorizontalConstraints { flow().borderAndPaddingStart(), flow().contentSize().width() };
auto verticalConstraints = Layout::VerticalConstraints { flow().borderAndPaddingBefore(), { } };
- inlineFormattingContext.layoutInFlowContent(invalidationState, { horizontalConstraints, verticalConstraints });
+ inlineFormattingContext.lineLayoutForIntergration(invalidationState, { horizontalConstraints, verticalConstraints });
+
constructContent();
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (271084 => 271085)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2020-12-25 17:53:55 UTC (rev 271084)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2020-12-25 21:46:14 UTC (rev 271085)
@@ -44,6 +44,7 @@
class RenderBlockFlow;
class RenderBox;
class RenderBoxModelObject;
+class RenderLineBreak;
struct PaintInfo;
namespace LayoutIntegration {
@@ -66,6 +67,7 @@
void updateReplacedDimensions(const RenderBox&);
void updateInlineBlockDimensions(const RenderBlock&);
+ void updateLineBreakBoxDimensions(const RenderLineBreak&);
void updateStyle(const RenderBoxModelObject&);
void layout();
Modified: trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.h (271084 => 271085)
--- trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.h 2020-12-25 17:53:55 UTC (rev 271084)
+++ trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.h 2020-12-25 21:46:14 UTC (rev 271085)
@@ -50,9 +50,6 @@
void setIntrinsicSize(LayoutSize size) { m_intrinsicSize = size; }
void setIntrinsicRatio(LayoutUnit ratio) { m_intrinsicRatio = ratio; };
- Optional<LayoutSize> contentSizeForIntegration() const { return m_contentSizeForIntegration; }
- void setContentSizeForIntegration(LayoutSize size) { m_contentSizeForIntegration = size; }
-
bool hasIntrinsicWidth() const;
bool hasIntrinsicHeight() const;
bool hasIntrinsicRatio() const;
@@ -68,7 +65,6 @@
Optional<LayoutSize> m_intrinsicSize;
Optional<LayoutUnit> m_intrinsicRatio;
- Optional<LayoutSize> m_contentSizeForIntegration;
Optional<LayoutUnit> m_baseline;
CachedImage* m_cachedImage { nullptr };
};
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (271084 => 271085)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2020-12-25 17:53:55 UTC (rev 271084)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2020-12-25 21:46:14 UTC (rev 271085)
@@ -3638,6 +3638,12 @@
continue;
}
+ if (is<RenderLineBreak>(renderer)) {
+ layoutFormattingContextLineLayout.updateLineBreakBoxDimensions(downcast<RenderLineBreak>(renderer));
+ renderer.clearNeedsLayout();
+ continue;
+ }
+
renderer.clearNeedsLayout();
}