Changeset 294193 in webkit


Ignore:
Timestamp:
May 14, 2022 6:59:52 AM (2 years ago)
Author:
Alan Bujtas
Message:

[FFC][Integration] Add updateFormattingRootGeometryAndInvalidate/updateRenderers
https://bugs.webkit.org/show_bug.cgi?id=240413

Reviewed by Antti Koivisto.

Make sure that the layout box/renderer geometries are all up-to-date.

  • layout/integration/flex/LayoutIntegrationFlexLayout.cpp:

(WebCore::LayoutIntegration::logicalBorder):
(WebCore::LayoutIntegration::logicalPadding):
(WebCore::LayoutIntegration::FlexLayout::updateFormattingRootGeometryAndInvalidate):
(WebCore::LayoutIntegration::FlexLayout::layout):
(WebCore::LayoutIntegration::FlexLayout::updateRenderers const):

  • layout/integration/flex/LayoutIntegrationFlexLayout.h:

(WebCore::LayoutIntegration::FlexLayout::flexBoxRenderer const):
(WebCore::LayoutIntegration::FlexLayout::flexBoxRenderer):

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutUsingFlexFormattingContext):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r294192 r294193  
     12022-05-14  Alan Bujtas  <zalan@apple.com>
     2
     3        [FFC][Integration] Add updateFormattingRootGeometryAndInvalidate/updateRenderers
     4        https://bugs.webkit.org/show_bug.cgi?id=240413
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Make sure that the layout box/renderer geometries are all up-to-date.
     9
     10        * layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
     11        (WebCore::LayoutIntegration::logicalBorder):
     12        (WebCore::LayoutIntegration::logicalPadding):
     13        (WebCore::LayoutIntegration::FlexLayout::updateFormattingRootGeometryAndInvalidate):
     14        (WebCore::LayoutIntegration::FlexLayout::layout):
     15        (WebCore::LayoutIntegration::FlexLayout::updateRenderers const):
     16        * layout/integration/flex/LayoutIntegrationFlexLayout.h:
     17        (WebCore::LayoutIntegration::FlexLayout::flexBoxRenderer const):
     18        (WebCore::LayoutIntegration::FlexLayout::flexBoxRenderer):
     19        * rendering/RenderFlexibleBox.cpp:
     20        (WebCore::RenderFlexibleBox::layoutUsingFlexFormattingContext):
     21
    1222022-05-14  Alan Bujtas  <zalan@apple.com>
    223
  • trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp

    r294191 r294193  
    4646}
    4747
     48// FIXME: Merge these with the other integration layout functions.
     49static inline Layout::Edges logicalBorder(const RenderBoxModelObject& renderer, bool isLeftToRightInlineDirection, WritingMode writingMode)
     50{
     51    UNUSED_PARAM(isLeftToRightInlineDirection);
     52    UNUSED_PARAM(writingMode);
     53
     54    auto borderLeft = renderer.borderLeft();
     55    auto borderRight = renderer.borderRight();
     56    auto borderTop = renderer.borderTop();
     57    auto borderBottom = renderer.borderBottom();
     58
     59    return { { borderLeft, borderRight }, { borderTop, borderBottom } };
     60}
     61
     62static inline Layout::Edges logicalPadding(const RenderBoxModelObject& renderer, bool isLeftToRightInlineDirection, WritingMode writingMode)
     63{
     64    UNUSED_PARAM(isLeftToRightInlineDirection);
     65    UNUSED_PARAM(writingMode);
     66
     67    auto paddingLeft = renderer.paddingLeft();
     68    auto paddingRight = renderer.paddingRight();
     69    auto paddingTop = renderer.paddingTop();
     70    auto paddingBottom = renderer.paddingBottom();
     71
     72    return { { paddingLeft, paddingRight }, { paddingTop, paddingBottom } };
     73}
     74
    4875void FlexLayout::updateFormattingRootGeometryAndInvalidate()
    4976{
     77    auto& flexBoxRenderer = this->flexBoxRenderer();
     78
     79    auto updateGeometry = [&](auto& root) {
     80        auto isLeftToRightInlineDirection = flexBoxRenderer.style().isLeftToRightDirection();
     81        auto writingMode = flexBoxRenderer.style().writingMode();
     82
     83        root.setContentBoxWidth(writingMode == WritingMode::TopToBottom ? flexBoxRenderer.contentWidth() : flexBoxRenderer.contentHeight());
     84        root.setPadding(logicalPadding(flexBoxRenderer, isLeftToRightInlineDirection, writingMode));
     85        root.setBorder(logicalBorder(flexBoxRenderer, isLeftToRightInlineDirection, writingMode));
     86        root.setHorizontalMargin({ });
     87        root.setVerticalMargin({ });
     88    };
     89    return updateGeometry(m_layoutState.ensureGeometryForBox(rootLayoutBox()));
    5090}
    5191
     
    81121
    82122    flexFormattingContext.layoutInFlowContentForIntegration({ horizontalConstraints, rootGeometry.contentBoxTop() });
     123
     124    updateRenderers();
     125}
     126
     127void FlexLayout::updateRenderers() const
     128{
     129    auto& boxAndRendererList = m_boxTree.boxAndRendererList();
     130    for (auto& boxAndRenderer : boxAndRendererList) {
     131        auto& layoutBox = boxAndRenderer.box.get();
     132
     133        auto& renderer = downcast<RenderBox>(*boxAndRenderer.renderer);
     134        renderer.setLocation(Layout::BoxGeometry::borderBoxTopLeft(m_flexFormattingState.boxGeometry(layoutBox)));
     135    }
    83136}
    84137
  • trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h

    r293297 r294193  
    6565
    6666private:
     67    void updateRenderers() const;
     68
    6769    const Layout::ContainerBox& rootLayoutBox() const { return m_boxTree.rootLayoutBox(); }
    6870    Layout::ContainerBox& rootLayoutBox() { return m_boxTree.rootLayoutBox(); }
     71
     72    const RenderFlexibleBox& flexBoxRenderer() const { return downcast<RenderFlexibleBox>(m_boxTree.rootRenderer()); }
     73    RenderFlexibleBox& flexBoxRenderer() { return downcast<RenderFlexibleBox>(m_boxTree.rootRenderer()); }
    6974
    7075    BoxTree m_boxTree;
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r293943 r294193  
    23482348        m_flexLayout = makeUnique<LayoutIntegration::FlexLayout>(*this);
    23492349
     2350    m_flexLayout->updateFormattingRootGeometryAndInvalidate();
     2351
    23502352    for (auto& flexItem : childrenOfType<RenderBlock>(*this)) {
    23512353        flexItem.layoutIfNeeded();
Note: See TracChangeset for help on using the changeset viewer.