Title: [286489] trunk/Source/WebCore
- Revision
- 286489
- Author
- za...@apple.com
- Date
- 2021-12-03 06:12:08 -0800 (Fri, 03 Dec 2021)
Log Message
[LFC][IFC] Move the (bidi)display boxes horizontally by the inline box margin, border and padding start as needed
https://bugs.webkit.org/show_bug.cgi?id=233742
Reviewed by Antti Koivisto.
Re-visit the newly constructed display boxes and move them horizontally using the inline box margin, border and padding start values.
Note that in this patch we don't yet handle the end side of the inline boxes.
* layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (286488 => 286489)
--- trunk/Source/WebCore/ChangeLog 2021-12-03 14:01:14 UTC (rev 286488)
+++ trunk/Source/WebCore/ChangeLog 2021-12-03 14:12:08 UTC (rev 286489)
@@ -1,3 +1,16 @@
+2021-12-03 Alan Bujtas <za...@apple.com>
+
+ [LFC][IFC] Move the (bidi)display boxes horizontally by the inline box margin, border and padding start as needed
+ https://bugs.webkit.org/show_bug.cgi?id=233742
+
+ Reviewed by Antti Koivisto.
+
+ Re-visit the newly constructed display boxes and move them horizontally using the inline box margin, border and padding start values.
+ Note that in this patch we don't yet handle the end side of the inline boxes.
+
+ * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
+ (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+
2021-12-03 Youenn Fablet <you...@apple.com>
Persist NavigationPreloadState in service worker registration database
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (286488 => 286489)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp 2021-12-03 14:01:14 UTC (rev 286488)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp 2021-12-03 14:12:08 UTC (rev 286489)
@@ -409,6 +409,7 @@
};
createDisplayBoxesInVisualOrderForContentRuns();
+ auto needsDisplayBoxHorizontalAdjustment = false;
auto createDisplayBoxesInVisualOrderForInlineBoxes = [&] {
// Visual order could introduce gaps and/or inject runs outside from the current inline box content.
// In such cases, we need to "close" and "open" display boxes for these inline box fragments
@@ -457,7 +458,8 @@
parentBoxStack.add(inlineBox);
auto createAndInsertDisplayBoxForInlineBoxFragment = [&] {
- auto visualRect = lineBox.logicalBorderBoxForInlineBox(*inlineBox, formattingState().boxGeometry(*inlineBox));
+ auto& boxGeometry = formattingState().boxGeometry(*inlineBox);
+ auto visualRect = lineBox.logicalBorderBoxForInlineBox(*inlineBox, boxGeometry);
// Use the current content left as the starting point for this display box.
visualRect.setLeft(boxes[index].logicalLeft());
visualRect.moveVertically(lineBoxLogicalTopLeft.y());
@@ -465,6 +467,12 @@
visualRect.setWidth({ });
insertInlineBoxDisplayBoxForBidiBoundary(lineBox.inlineLevelBoxForLayoutBox(*inlineBox), visualRect, index, boxes);
++index;
+ // Need to push the rest of the content when this inline box has margin/border/padding.
+ needsDisplayBoxHorizontalAdjustment = needsDisplayBoxHorizontalAdjustment
+ || boxGeometry.horizontalBorder()
+ || boxGeometry.horizontalPadding().value_or(0)
+ || boxGeometry.marginStart()
+ || boxGeometry.marginEnd();
};
createAndInsertDisplayBoxForInlineBoxFragment();
}
@@ -478,6 +486,27 @@
};
if (needsNonRootInlineBoxDisplayBox)
createDisplayBoxesInVisualOrderForInlineBoxes();
+
+ auto adjustVisualGeometryWithInlineBoxes = [&] {
+ auto accumulatedOffset = InlineLayoutUnit { };
+
+ ASSERT(boxes[0].isRootInlineBox());
+ for (size_t index = 1; index < boxes.size(); ++index) {
+ auto& displayBox = boxes[index];
+ displayBox.moveHorizontally(accumulatedOffset);
+
+ if (displayBox.isNonRootInlineBox() && displayBox.isFirstBox()) {
+ // FIXME: Add support for the 'end' side of the inline box.
+ auto& layoutBox = displayBox.layoutBox();
+ auto& boxGeometry = formattingState().boxGeometry(layoutBox);
+
+ displayBox.moveHorizontally(boxGeometry.marginStart());
+ accumulatedOffset += boxGeometry.marginStart() + boxGeometry.borderAndPaddingStart();
+ }
+ }
+ };
+ if (needsDisplayBoxHorizontalAdjustment)
+ adjustVisualGeometryWithInlineBoxes();
}
void InlineDisplayContentBuilder::processOverflownRunsForEllipsis(DisplayBoxes& boxes, InlineLayoutUnit lineBoxLogicalRight)
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBoxGeometry.h (286488 => 286489)
--- trunk/Source/WebCore/layout/layouttree/LayoutBoxGeometry.h 2021-12-03 14:01:14 UTC (rev 286488)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBoxGeometry.h 2021-12-03 14:12:08 UTC (rev 286489)
@@ -77,6 +77,8 @@
std::optional<LayoutUnit> verticalPadding() const;
std::optional<LayoutUnit> horizontalPadding() const;
+ LayoutUnit borderAndPaddingStart() const { return borderLeft() + paddingLeft().value_or(0); }
+
LayoutUnit contentBoxTop() const { return paddingBoxTop() + paddingTop().value_or(0); }
LayoutUnit contentBoxLeft() const { return paddingBoxLeft() + paddingLeft().value_or(0); }
LayoutUnit contentBoxBottom() const { return contentBoxTop() + contentBoxHeight(); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes