⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287062 in webkit


Ignore:
Timestamp:
Dec 14, 2021, 9:44:52 PM (5 years ago)
Author:
Alan Bujtas
Message:

[IFC][Integration] Use logical margin/border/padding values in layout
https://bugs.webkit.org/show_bug.cgi?id=234305

Reviewed by Antti Koivisto.

Can't use RenderBoxModelObject::borderStart/End logical values as they return values based on the _renderer_'s
direction and not the direction the renderer is aligned within.

  • layout/integration/LayoutIntegrationLineLayout.cpp:

(WebCore::LayoutIntegration::LineLayout::updateLayoutBoxDimensions):
(WebCore::LayoutIntegration::LineLayout::updateInlineBoxDimensions):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287059 r287062  
     12021-12-14  Alan Bujtas  <zalan@apple.com>
     2
     3        [IFC][Integration] Use logical margin/border/padding values in layout
     4        https://bugs.webkit.org/show_bug.cgi?id=234305
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Can't use RenderBoxModelObject::borderStart/End logical values as they return values based on the _renderer_'s
     9        direction and not the direction the renderer is aligned within.
     10
     11        * layout/integration/LayoutIntegrationLineLayout.cpp:
     12        (WebCore::LayoutIntegration::LineLayout::updateLayoutBoxDimensions):
     13        (WebCore::LayoutIntegration::LineLayout::updateInlineBoxDimensions):
     14
    1152021-12-14  Jean-Yves Avenard  <jya@apple.com>
    216
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

    r286957 r287062  
    149149}
    150150
     151static inline Layout::BoxGeometry::HorizontalMargin logicalMargin(const RenderBoxModelObject& renderer, bool isLeftToRightDirection, bool retainMarginStart = true, bool retainMarginEnd = true)
     152{
     153    auto marginStart = LayoutUnit { 0_lu };
     154    auto marginEnd = LayoutUnit { 0_lu };
     155    if (retainMarginStart)
     156        marginStart = isLeftToRightDirection ? renderer.marginLeft() : renderer.marginRight();
     157    if (retainMarginEnd)
     158        marginEnd = isLeftToRightDirection ? renderer.marginRight() : renderer.marginLeft();
     159    return { marginStart, marginEnd };
     160}
     161
     162static inline Layout::Edges logicalBorder(const RenderBoxModelObject& renderer, bool isLeftToRightDirection, bool retainBorderStart = true, bool retainBorderEnd = true)
     163{
     164    auto borderStart = LayoutUnit { 0_lu };
     165    auto borderEnd = LayoutUnit { 0_lu };
     166    if (retainBorderStart)
     167        borderStart = isLeftToRightDirection ? renderer.borderLeft() : renderer.borderRight();
     168    if (retainBorderEnd)
     169        borderEnd = isLeftToRightDirection ? renderer.borderRight() : renderer.borderLeft();
     170    return { { borderStart, borderEnd }, { renderer.borderTop(), renderer.borderBottom() } };
     171}
     172
     173static inline Layout::Edges logicalPadding(const RenderBoxModelObject& renderer, bool isLeftToRightDirection, bool retainPaddingStart = true, bool retainPaddingEnd = true)
     174{
     175    auto paddingStart = LayoutUnit { 0_lu };
     176    auto paddingEnd = LayoutUnit { 0_lu };
     177    if (retainPaddingStart)
     178        paddingStart = isLeftToRightDirection ? renderer.paddingLeft() : renderer.paddingRight();
     179    if (retainPaddingEnd)
     180        paddingEnd = isLeftToRightDirection ? renderer.paddingRight() : renderer.paddingLeft();
     181    return Layout::Edges { { paddingStart, paddingEnd }, { renderer.paddingTop(), renderer.paddingBottom() } };
     182}
     183
    151184void LineLayout::updateLayoutBoxDimensions(const RenderBox& replacedOrInlineBlock)
    152185{
     
    170203    replacedBoxGeometry.setContentBoxHeight(replacedOrInlineBlock.contentHeight());
    171204
    172     replacedBoxGeometry.setBorder({ { replacedOrInlineBlock.borderLeft(), replacedOrInlineBlock.borderRight() }, { replacedOrInlineBlock.borderTop(), replacedOrInlineBlock.borderBottom() } });
    173     replacedBoxGeometry.setPadding(Layout::Edges { { replacedOrInlineBlock.paddingLeft(), replacedOrInlineBlock.paddingRight() }, { replacedOrInlineBlock.paddingTop(), replacedOrInlineBlock.paddingBottom() } });
    174 
    175     replacedBoxGeometry.setHorizontalMargin({ replacedOrInlineBlock.marginLeft(), replacedOrInlineBlock.marginRight() });
    176205    replacedBoxGeometry.setVerticalMargin({ replacedOrInlineBlock.marginTop(), replacedOrInlineBlock.marginBottom() });
     206    auto isLeftToRightDirection = flow().style().isLeftToRightDirection();
     207    replacedBoxGeometry.setHorizontalMargin(logicalMargin(replacedOrInlineBlock, isLeftToRightDirection));
     208    replacedBoxGeometry.setBorder(logicalBorder(replacedOrInlineBlock, isLeftToRightDirection));
     209    replacedBoxGeometry.setPadding(logicalPadding(replacedOrInlineBlock, isLeftToRightDirection));
    177210
    178211    auto baseline = replacedOrInlineBlock.baselinePosition(AlphabeticBaseline, false /* firstLine */, HorizontalLine, PositionOnContainingLine);
     
    199232    auto shouldNotRetainBorderPaddingAndMarginStart = renderInline.parent()->isAnonymousBlock() && renderInline.isContinuation();
    200233    auto shouldNotRetainBorderPaddingAndMarginEnd = renderInline.parent()->isAnonymousBlock() && !renderInline.isContinuation() && renderInline.inlineContinuation();
    201    
    202     auto horizontalMargin = Layout::BoxGeometry::HorizontalMargin { shouldNotRetainBorderPaddingAndMarginStart ? 0_lu : renderInline.marginLeft(), shouldNotRetainBorderPaddingAndMarginEnd ? 0_lu : renderInline.marginRight() };
    203     auto horizontalBorder = Layout::HorizontalEdges { shouldNotRetainBorderPaddingAndMarginStart ? 0_lu : renderInline.borderLeft(), shouldNotRetainBorderPaddingAndMarginEnd ? 0_lu : renderInline.borderRight() };
    204     auto horizontalPadding = Layout::HorizontalEdges { shouldNotRetainBorderPaddingAndMarginStart ? 0_lu : renderInline.paddingLeft(), shouldNotRetainBorderPaddingAndMarginEnd ? 0_lu : renderInline.paddingRight() };
    205    
    206     boxGeometry.setPadding(Layout::Edges { horizontalPadding, { renderInline.paddingTop(), renderInline.paddingBottom() } });
    207     boxGeometry.setBorder({ horizontalBorder, { renderInline.borderTop(), renderInline.borderBottom() } });
    208     boxGeometry.setHorizontalMargin(horizontalMargin);
     234
    209235    boxGeometry.setVerticalMargin({ });
     236    auto isLeftToRightDirection = flow().style().isLeftToRightDirection();
     237    boxGeometry.setHorizontalMargin(logicalMargin(renderInline, isLeftToRightDirection, !shouldNotRetainBorderPaddingAndMarginStart, !shouldNotRetainBorderPaddingAndMarginEnd));
     238    boxGeometry.setBorder(logicalBorder(renderInline, isLeftToRightDirection, !shouldNotRetainBorderPaddingAndMarginStart, !shouldNotRetainBorderPaddingAndMarginEnd));
     239    boxGeometry.setPadding(logicalPadding(renderInline, isLeftToRightDirection, !shouldNotRetainBorderPaddingAndMarginStart, !shouldNotRetainBorderPaddingAndMarginEnd));
    210240}
    211241
Note: See TracChangeset for help on using the changeset viewer.