Title: [269826] trunk/Source/WebCore
Revision
269826
Author
[email protected]
Date
2020-11-15 06:25:42 -0800 (Sun, 15 Nov 2020)

Log Message

[LFC] Do not use RenderStyle's logical margin API
https://bugs.webkit.org/show_bug.cgi?id=218948

Reviewed by Antti Koivisto.

https://www.w3.org/TR/css-writing-modes-4/#logical-direction-layout

"Flow-relative directions are calculated with respect to the writing mode of the containing block of the box
and used to abstract layout rules related to the box properties (margins, borders, padding)
and any properties related to positioning the box within its containing block
(float, clear, top, bottom, left, right, caption-side).
For inline-level boxes, the writing mode of the parent box is used instead."

RenderStyle::marginStart/End/Before/After flips these values based on the box's own writing mode.

* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::usedWritingMode):
(WebCore::Layout::FormattingContext::Geometry::computedHorizontalMargin const):
(WebCore::Layout::FormattingContext::Geometry::computedVerticalMargin const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269825 => 269826)


--- trunk/Source/WebCore/ChangeLog	2020-11-15 14:23:23 UTC (rev 269825)
+++ trunk/Source/WebCore/ChangeLog	2020-11-15 14:25:42 UTC (rev 269826)
@@ -1,5 +1,27 @@
 2020-11-15  Zalan Bujtas  <[email protected]>
 
+        [LFC] Do not use RenderStyle's logical margin API
+        https://bugs.webkit.org/show_bug.cgi?id=218948
+
+        Reviewed by Antti Koivisto.
+
+        https://www.w3.org/TR/css-writing-modes-4/#logical-direction-layout
+
+        "Flow-relative directions are calculated with respect to the writing mode of the containing block of the box
+        and used to abstract layout rules related to the box properties (margins, borders, padding)
+        and any properties related to positioning the box within its containing block
+        (float, clear, top, bottom, left, right, caption-side).
+        For inline-level boxes, the writing mode of the parent box is used instead."
+
+        RenderStyle::marginStart/End/Before/After flips these values based on the box's own writing mode.
+
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::usedWritingMode):
+        (WebCore::Layout::FormattingContext::Geometry::computedHorizontalMargin const):
+        (WebCore::Layout::FormattingContext::Geometry::computedVerticalMargin const):
+
+2020-11-15  Zalan Bujtas  <[email protected]>
+
         [LFC][Geometry] Add support for horizontal/vertical scrollbar spacing
         https://bugs.webkit.org/show_bug.cgi?id=218950
 

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (269825 => 269826)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2020-11-15 14:23:23 UTC (rev 269825)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2020-11-15 14:25:42 UTC (rev 269826)
@@ -1122,6 +1122,14 @@
     return { leftPositionOffset, topPositionOffset };
 }
 
+inline static WritingMode usedWritingMode(const Box& layoutBox)
+{
+    // https://www.w3.org/TR/css-writing-modes-4/#logical-direction-layout
+    // Flow-relative directions are calculated with respect to the writing mode of the containing block of the box.
+    // For inline-level boxes, the writing mode of the parent box is used instead.
+    return layoutBox.isInlineLevelBox() ? layoutBox.parent().style().writingMode() : layoutBox.containingBlock().style().writingMode();
+}
+
 Edges FormattingContext::Geometry::computedBorder(const Box& layoutBox) const
 {
     auto& style = layoutBox.style();
@@ -1149,7 +1157,9 @@
 {
     auto& style = layoutBox.style();
     auto containingBlockWidth = horizontalConstraints.logicalWidth;
-    return { computedValue(style.marginStart(), containingBlockWidth), computedValue(style.marginEnd(), containingBlockWidth) };
+    if (isHorizontalWritingMode(usedWritingMode(layoutBox)))
+        return { computedValue(style.marginLeft(), containingBlockWidth), computedValue(style.marginRight(), containingBlockWidth) };
+    return { computedValue(style.marginTop(), containingBlockWidth), computedValue(style.marginBottom(), containingBlockWidth) };
 }
 
 ComputedVerticalMargin FormattingContext::Geometry::computedVerticalMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints) const
@@ -1156,7 +1166,9 @@
 {
     auto& style = layoutBox.style();
     auto containingBlockWidth = horizontalConstraints.logicalWidth;
-    return { computedValue(style.marginBefore(), containingBlockWidth), computedValue(style.marginAfter(), containingBlockWidth) };
+    if (isHorizontalWritingMode(usedWritingMode(layoutBox)))
+        return { computedValue(style.marginTop(), containingBlockWidth), computedValue(style.marginBottom(), containingBlockWidth) };
+    return { computedValue(style.marginLeft(), containingBlockWidth), computedValue(style.marginRight(), containingBlockWidth) };
 }
 
 FormattingContext::IntrinsicWidthConstraints FormattingContext::Geometry::constrainByMinMaxWidth(const Box& layoutBox, IntrinsicWidthConstraints intrinsicWidth) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to