Changeset 269826 in webkit


Ignore:
Timestamp:
Nov 15, 2020 6:25:42 AM (3 years ago)
Author:
Alan Bujtas
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269825 r269826  
     12020-11-15  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC] Do not use RenderStyle's logical margin API
     4        https://bugs.webkit.org/show_bug.cgi?id=218948
     5
     6        Reviewed by Antti Koivisto.
     7
     8        https://www.w3.org/TR/css-writing-modes-4/#logical-direction-layout
     9
     10        "Flow-relative directions are calculated with respect to the writing mode of the containing block of the box
     11        and used to abstract layout rules related to the box properties (margins, borders, padding)
     12        and any properties related to positioning the box within its containing block
     13        (float, clear, top, bottom, left, right, caption-side).
     14        For inline-level boxes, the writing mode of the parent box is used instead."
     15
     16        RenderStyle::marginStart/End/Before/After flips these values based on the box's own writing mode.
     17
     18        * layout/FormattingContextGeometry.cpp:
     19        (WebCore::Layout::usedWritingMode):
     20        (WebCore::Layout::FormattingContext::Geometry::computedHorizontalMargin const):
     21        (WebCore::Layout::FormattingContext::Geometry::computedVerticalMargin const):
     22
    1232020-11-15  Zalan Bujtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/layout/FormattingContextGeometry.cpp

    r269744 r269826  
    11231123}
    11241124
     1125inline static WritingMode usedWritingMode(const Box& layoutBox)
     1126{
     1127    // https://www.w3.org/TR/css-writing-modes-4/#logical-direction-layout
     1128    // Flow-relative directions are calculated with respect to the writing mode of the containing block of the box.
     1129    // For inline-level boxes, the writing mode of the parent box is used instead.
     1130    return layoutBox.isInlineLevelBox() ? layoutBox.parent().style().writingMode() : layoutBox.containingBlock().style().writingMode();
     1131}
     1132
    11251133Edges FormattingContext::Geometry::computedBorder(const Box& layoutBox) const
    11261134{
     
    11501158    auto& style = layoutBox.style();
    11511159    auto containingBlockWidth = horizontalConstraints.logicalWidth;
    1152     return { computedValue(style.marginStart(), containingBlockWidth), computedValue(style.marginEnd(), containingBlockWidth) };
     1160    if (isHorizontalWritingMode(usedWritingMode(layoutBox)))
     1161        return { computedValue(style.marginLeft(), containingBlockWidth), computedValue(style.marginRight(), containingBlockWidth) };
     1162    return { computedValue(style.marginTop(), containingBlockWidth), computedValue(style.marginBottom(), containingBlockWidth) };
    11531163}
    11541164
     
    11571167    auto& style = layoutBox.style();
    11581168    auto containingBlockWidth = horizontalConstraints.logicalWidth;
    1159     return { computedValue(style.marginBefore(), containingBlockWidth), computedValue(style.marginAfter(), containingBlockWidth) };
     1169    if (isHorizontalWritingMode(usedWritingMode(layoutBox)))
     1170        return { computedValue(style.marginTop(), containingBlockWidth), computedValue(style.marginBottom(), containingBlockWidth) };
     1171    return { computedValue(style.marginLeft(), containingBlockWidth), computedValue(style.marginRight(), containingBlockWidth) };
    11601172}
    11611173
Note: See TracChangeset for help on using the changeset viewer.