Changeset 278659 in webkit


Ignore:
Timestamp:
Jun 9, 2021, 7:47:55 AM (4 years ago)
Author:
Alan Bujtas
Message:

[Flexbox] FlexItem stays invisible after initial layout
https://bugs.webkit.org/show_bug.cgi?id=226778

Reviewed by Simon Fraser.

Source/WebCore:

RenderFlexibleBox::layoutAndPlaceChildren() initiates repaint() on newly constructed flex items by checking their everHadLayout bit.
This is similar to what we do for regular block layout when block level boxes appear.
However flexitems are laid out multiple times, first right after they are constructed in constructFlexItem. This initial layout
sets everHadLayout bit to true which makes the check in layoutAndPlaceChildren somewhat late.

Test: fast/flexbox/repaint-issue-when-flex-item-appears.html

  • rendering/FlexibleBoxAlgorithm.cpp:

(WebCore::FlexItem::FlexItem):

  • rendering/FlexibleBoxAlgorithm.h:
  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::constructFlexItem):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren):

LayoutTests:

  • fast/flexbox/repaint-issue-when-flex-item-appears-expected.txt: Added.
  • fast/flexbox/repaint-issue-when-flex-item-appears.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r278654 r278659  
     12021-06-09  Alan Bujtas  <zalan@apple.com>
     2
     3        [Flexbox] FlexItem stays invisible after initial layout
     4        https://bugs.webkit.org/show_bug.cgi?id=226778
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/flexbox/repaint-issue-when-flex-item-appears-expected.txt: Added.
     9        * fast/flexbox/repaint-issue-when-flex-item-appears.html: Added.
     10
    1112021-06-09  Diego Pino Garcia  <dpino@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r278657 r278659  
     12021-06-09  Alan Bujtas  <zalan@apple.com>
     2
     3        [Flexbox] FlexItem stays invisible after initial layout
     4        https://bugs.webkit.org/show_bug.cgi?id=226778
     5
     6        Reviewed by Simon Fraser.
     7
     8        RenderFlexibleBox::layoutAndPlaceChildren() initiates repaint() on newly constructed flex items by checking their everHadLayout bit.
     9        This is similar to what we do for regular block layout when block level boxes appear.
     10        However flexitems are laid out multiple times, first right after they are constructed in constructFlexItem. This initial layout
     11        sets everHadLayout bit to true which makes the check in layoutAndPlaceChildren somewhat late.
     12
     13        Test: fast/flexbox/repaint-issue-when-flex-item-appears.html
     14
     15        * rendering/FlexibleBoxAlgorithm.cpp:
     16        (WebCore::FlexItem::FlexItem):
     17        * rendering/FlexibleBoxAlgorithm.h:
     18        * rendering/RenderFlexibleBox.cpp:
     19        (WebCore::RenderFlexibleBox::constructFlexItem):
     20        (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
     21
    1222021-06-09  Alexander Mikhaylenko  <alexm@gnome.org>
    223
  • trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.cpp

    r267829 r278659  
    3636namespace WebCore {
    3737
    38 FlexItem::FlexItem(RenderBox& box, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin)
     38FlexItem::FlexItem(RenderBox& box, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin, bool everHadLayout)
    3939    : box(box)
    4040    , flexBaseContentSize(flexBaseContentSize)
     
    4242    , mainAxisBorderAndPadding(mainAxisBorderAndPadding)
    4343    , mainAxisMargin(mainAxisMargin)
    44     , frozen(false)
     44    , everHadLayout(everHadLayout)
    4545{
    4646    ASSERT(!box.isOutOfFlowPositioned());
  • trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.h

    r267829 r278659  
    4242class FlexItem {
    4343public:
    44     FlexItem(RenderBox&, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin);
     44    FlexItem(RenderBox&, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin, bool everHadLayout);
    4545
    4646    LayoutUnit hypotheticalMainAxisMarginBoxSize() const
     
    6565    const LayoutUnit mainAxisMargin;
    6666    LayoutUnit flexedContentSize;
    67     bool frozen;
     67    bool frozen { false };
     68    bool everHadLayout { false };
    6869};
    6970
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r278450 r278659  
    13091309FlexItem RenderFlexibleBox::constructFlexItem(RenderBox& child, bool relayoutChildren)
    13101310{
     1311    auto childHadLayout = child.everHadLayout();
    13111312    child.clearOverridingContentSize();
    13121313    if (childHasIntrinsicMainAxisSize(child)) {
     
    13361337    LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(child, childInnerFlexBaseSize);
    13371338    LayoutUnit margin = isHorizontalFlow() ? child.horizontalMarginExtent() : child.verticalMarginExtent();
    1338     return FlexItem(child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisExtent, borderAndPadding, margin);
     1339    return FlexItem(child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisExtent, borderAndPadding, margin, childHadLayout);
    13391340}
    13401341   
     
    17381739        const auto& flexItem = children[i];
    17391740        auto& child = flexItem.box;
    1740         bool childHadLayout = child.everHadLayout();
    17411741
    17421742        ASSERT(!flexItem.box.isOutOfFlowPositioned());
     
    17691769            m_relaidOutChildren.add(&child);
    17701770        child.layoutIfNeeded();
    1771         if (!childHadLayout && child.checkForRepaintDuringLayout()) {
     1771        if (!flexItem.everHadLayout && child.checkForRepaintDuringLayout()) {
    17721772            child.repaint();
    17731773            child.repaintOverhangingFloats(true);
Note: See TracChangeset for help on using the changeset viewer.