Changeset 213480 in webkit


Ignore:
Timestamp:
Mar 6, 2017 5:29:19 PM (7 years ago)
Author:
hyatt@apple.com
Message:

REGRESSION: Block no longer shrinks to preferred width in this flex box layout
https://bugs.webkit.org/show_bug.cgi?id=169203
<rdar://problem/30873895>

Reviewed by Simon Fraser.

Source/WebCore:

Added new test in css3/flexbox.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::adjustRenderStyle):
(WebCore::StyleResolver::adjustStyleForAlignment):

  • html/shadow/TextControlInnerElements.cpp:

(WebCore::TextControlInnerElement::resolveCustomStyle):
Resolve auto alignment values by adjusting the render style as needed. Make a helper
function for adjusting only alignment that can be called from the inner text control
custom style creation.

  • rendering/GridTrackSizingAlgorithm.cpp:

(WebCore::GridTrackSizingAlgorithmStrategy::minSizeForChild):
Replaced items in grids should not stretch by default.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::hasStretchedLogicalWidth):
Patched to properly check the default alignment for the child, making sure
that if it's a replacd item inside a grid, that the default is start and not
stretch.

  • rendering/RenderBox.h:

(WebCore::RenderBox::selfAlignmentNormalBehavior):
Self-alignment function now takes an optional child argument, since the behavior
varies in grids depending on the child being replaced or not.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::alignmentForChild):
Fixed to do the right thing when the child is anonymous.

(WebCore::RenderFlexibleBox::styleDidChange): Deleted.

  • rendering/RenderFlexibleBox.h:

Deleted, since alignment changes are handled at the style diff level now.

  • rendering/RenderFullScreen.h:

Patched the selfAlignmentNormalBehavior method to take an optional child argument.

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::styleDidChange):
(WebCore::RenderGrid::alignSelfForChild):
(WebCore::RenderGrid::justifySelfForChild):
(WebCore::RenderGrid::columnAxisPositionForChild):
(WebCore::RenderGrid::rowAxisPositionForChild):
(WebCore::RenderGrid::columnAxisOffsetForChild):
(WebCore::RenderGrid::rowAxisOffsetForChild):
(WebCore::defaultAlignmentIsStretch): Deleted.
(WebCore::defaultAlignmentChangedToStretchInRowAxis): Deleted.
(WebCore::defaultAlignmentChangedFromStretchInRowAxis): Deleted.
(WebCore::defaultAlignmentChangedFromStretchInColumnAxis): Deleted.
(WebCore::selfAlignmentChangedToStretchInRowAxis): Deleted.
(WebCore::selfAlignmentChangedFromStretchInRowAxis): Deleted.
(WebCore::selfAlignmentChangedFromStretchInColumnAxis): Deleted.

  • rendering/RenderGrid.h:

Removed the alignment change logic in styleDidChange for grids, since style diffing handles
it now. Updated all selfAlignmentForNormalBehavior queries to pass in the child so that
replaced elements are handled properly.

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyle::overflowInlineDirection):
(WebCore::RenderStyle::overflowBlockDirection):
(WebCore::RenderStyle::setJustifySelfPosition):
New helpers used by grid and by adjustRenderStyle.

  • style/StyleChange.cpp:

(WebCore::Style::determineChange):
If alignment or justification changes occur on a parent that could affect the child (e.g., align-items)
return Inherit so the child render styles get adjusted properly.

LayoutTests:

  • css3/flexbox/column-inside-normal-block-preferred-width-expected.html: Added.
  • css3/flexbox/column-inside-normal-block-preferred-width.html: Added.
  • fast/css-grid-layout/grid-align-stretching-replaced-items-expected.txt:
  • fast/css-grid-layout/grid-align-stretching-replaced-items.html:
  • fast/repaint/align-items-change-expected.txt:
  • fast/repaint/align-items-overflow-change-expected.txt:
  • fast/repaint/justify-items-change-expected.txt:
  • fast/repaint/justify-items-legacy-change-expected.txt:
  • fast/repaint/justify-items-overflow-change-expected.txt:
Location:
trunk
Files:
2 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r213477 r213480  
     12017-03-06  Dave Hyatt  <hyatt@apple.com>
     2
     3        REGRESSION: Block no longer shrinks to preferred width in this flex box layout
     4        https://bugs.webkit.org/show_bug.cgi?id=169203
     5        <rdar://problem/30873895>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * css3/flexbox/column-inside-normal-block-preferred-width-expected.html: Added.
     10        * css3/flexbox/column-inside-normal-block-preferred-width.html: Added.
     11        * fast/css-grid-layout/grid-align-stretching-replaced-items-expected.txt:
     12        * fast/css-grid-layout/grid-align-stretching-replaced-items.html:
     13        * fast/repaint/align-items-change-expected.txt:
     14        * fast/repaint/align-items-overflow-change-expected.txt:
     15        * fast/repaint/justify-items-change-expected.txt:
     16        * fast/repaint/justify-items-legacy-change-expected.txt:
     17        * fast/repaint/justify-items-overflow-change-expected.txt:
     18
    1192017-03-06  Ryan Haddad  <ryanhaddad@apple.com>
    220
  • trunk/LayoutTests/fast/css-grid-layout/grid-align-stretching-replaced-items-expected.txt

    r195284 r213480  
    11This test checks that the alignment properties align-self and justify-self apply the 'stretch' value correctly on replaced elements.
    22
    3 The blue image's original size is 100px x 100px, but it should be stretched to fill the 500px x 500px grid area it's placed into
     3The blue image's original size is 100px x 100px, default alignment is resolved as 'start' for replaced elements so it prevents stretching to be applied.
     4
     5
     6PASS
     7The blue image's original size is 100px x 100px, 'normal' is resolved as 'start' for replaced elements so it prevents stretching to be applied.
     8
     9
     10PASS
     11The blue image's original size is 100px x 100px, but it should be stretched to fill the 500px x 500px grid area it's placed into.
    412
    513
  • trunk/LayoutTests/fast/css-grid-layout/grid-align-stretching-replaced-items.html

    r200510 r213480  
    1818
    1919<body onload="checkLayout('.grid')">
    20 
    21 <p>This test checks that the alignment properties align-self and justify-self apply the 'stretch' value correctly on replaced elements.</p>
    22 
    23 <div style="position: relative">
    24     <p>The blue image's original size is 100px x 100px, but it should be stretched to fill the 500px x 500px grid area it's placed into</p>
    25     <div class="grid">
    26         <img src="../../css3/images/resources/blue-100.png" data-expected-width="500" data-expected-height="500"/>
     20   
     21    <p>This test checks that the alignment properties align-self and justify-self apply the 'stretch' value correctly on replaced elements.</p>
     22   
     23    <div style="position: relative">
     24        <p>The blue image's original size is 100px x 100px, default alignment is resolved as 'start' for replaced elements so it prevents stretching to be applied.</p>
     25        <div class="grid">
     26            <img src="../../css3/images/resources/blue-100.png" data-expected-width="100" data-expected-height="100"/>
     27        </div>
    2728    </div>
    28 </div>
    29 
    30 <div style="position: relative">
    31     <p>The blue image's original size is 100px x 100px, non-stretch values prevent stretching to be applied.</p>
    32     <div class="grid itemsCenter">
    33         <img src="../../css3/images/resources/blue-100.png" data-expected-width="100" data-expected-height="100"/>
     29   
     30    <div style="position: relative">
     31        <p>The blue image's original size is 100px x 100px, 'normal' is resolved as 'start' for replaced elements so it prevents stretching to be applied.</p>
     32        <div class="grid itemsNormal">
     33            <img src="../../css3/images/resources/blue-100.png" data-expected-width="100" data-expected-height="100"/>
     34        </div>
    3435    </div>
    35 </div>
    36 
    37 <div style="position: relative">
    38     <p>The blue image's original size is 100px x 100px, non-auto sizes prevent stretching to be applied.</p>
    39     <div class="grid">
    40         <img class="fixedSizes" src="../../css3/images/resources/blue-100.png" data-expected-width="150" data-expected-height="150"/>
     36   
     37    <div style="position: relative">
     38        <p>The blue image's original size is 100px x 100px, but it should be stretched to fill the 500px x 500px grid area it's placed into.</p>
     39        <div class="grid alignItemsStretch justifyItemsStretch">
     40            <img src="../../css3/images/resources/blue-100.png" data-expected-width="500" data-expected-height="500"/>
     41        </div>
    4142    </div>
    42 </div>
    43 
    44 <div style="position: relative">
    45     <p>The blue image's original size is 100px x 100px, auto-margins prevent stretching to be applied.</p>
    46     <div class="grid">
    47         <img class="autoMargins" src="../../css3/images/resources/blue-100.png" data-expected-width="100" data-expected-height="100"/>
     43   
     44    <div style="position: relative">
     45        <p>The blue image's original size is 100px x 100px, non-stretch values prevent stretching to be applied.</p>
     46        <div class="grid itemsCenter">
     47            <img src="../../css3/images/resources/blue-100.png" data-expected-width="100" data-expected-height="100"/>
     48        </div>
    4849    </div>
    49 </div>
    50 
     50   
     51    <div style="position: relative">
     52        <p>The blue image's original size is 100px x 100px, non-auto sizes prevent stretching to be applied.</p>
     53        <div class="grid">
     54            <img class="fixedSizes" src="../../css3/images/resources/blue-100.png" data-expected-width="150" data-expected-height="150"/>
     55        </div>
     56    </div>
     57   
     58    <div style="position: relative">
     59        <p>The blue image's original size is 100px x 100px, auto-margins prevent stretching to be applied.</p>
     60        <div class="grid">
     61            <img class="autoMargins" src="../../css3/images/resources/blue-100.png" data-expected-width="100" data-expected-height="100"/>
     62        </div>
     63    </div>
    5164</body>
  • trunk/LayoutTests/fast/repaint/align-items-change-expected.txt

    r189910 r213480  
    22
    33(repaint rects
     4  (rect 0 52 100 102)
     5  (rect 100 52 100 152)
    46  (rect 0 52 100 300)
    57  (rect 0 51 100 1)
  • trunk/LayoutTests/fast/repaint/align-items-overflow-change-expected.txt

    r189910 r213480  
    22
    33(repaint rects
     4  (rect 0 2 200 200)
     5  (rect 0 252 200 100)
    46  (rect 0 2 200 350)
    57  (rect 0 52 200 300)
  • trunk/LayoutTests/fast/repaint/justify-items-change-expected.txt

    r189910 r213480  
    22
    33(repaint rects
    4   (rect 200 52 150 300)
     4  (rect 150 52 50 300)
     5  (rect 150 52 200 300)
    56  (rect 0 52 200 300)
    67)
  • trunk/LayoutTests/fast/repaint/justify-items-legacy-change-expected.txt

    r189910 r213480  
    22
    33(repaint rects
     4  (rect 1 53 50 50)
     5  (rect 0 52 52 100)
     6  (rect 151 53 50 50)
     7  (rect 150 52 52 100)
     8  (rect 0 52 202 300)
     9  (rect 0 52 251 300)
    410  (rect 0 52 300 400)
    511)
  • trunk/LayoutTests/fast/repaint/justify-items-overflow-change-expected.txt

    r189910 r213480  
    22
    33(repaint rects
     4  (rect -60 52 160 300)
     5  (rect 150 52 50 300)
    46  (rect -60 52 260 300)
    57  (rect 0 52 200 300)
  • trunk/Source/WebCore/ChangeLog

    r213478 r213480  
     12017-03-06  Dave Hyatt  <hyatt@apple.com>
     2
     3        REGRESSION: Block no longer shrinks to preferred width in this flex box layout
     4        https://bugs.webkit.org/show_bug.cgi?id=169203
     5        <rdar://problem/30873895>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Added new test in css3/flexbox.
     10
     11        * css/StyleResolver.cpp:
     12        (WebCore::StyleResolver::adjustRenderStyle):
     13        (WebCore::StyleResolver::adjustStyleForAlignment):
     14        * html/shadow/TextControlInnerElements.cpp:
     15        (WebCore::TextControlInnerElement::resolveCustomStyle):
     16        Resolve auto alignment values by adjusting the render style as needed. Make a helper
     17        function for adjusting only alignment that can be called from the inner text control
     18        custom style creation.
     19
     20        * rendering/GridTrackSizingAlgorithm.cpp:
     21        (WebCore::GridTrackSizingAlgorithmStrategy::minSizeForChild):
     22        Replaced items in grids should not stretch by default.
     23
     24        * rendering/RenderBox.cpp:
     25        (WebCore::RenderBox::hasStretchedLogicalWidth):
     26        Patched to properly check the default alignment for the child, making sure
     27        that if it's a replacd item inside a grid, that the default is start and not
     28        stretch.
     29
     30        * rendering/RenderBox.h:
     31        (WebCore::RenderBox::selfAlignmentNormalBehavior):
     32        Self-alignment function now takes an optional child argument, since the behavior
     33        varies in grids depending on the child being replaced or not.
     34
     35        * rendering/RenderFlexibleBox.cpp:
     36        (WebCore::RenderFlexibleBox::alignmentForChild):
     37        Fixed to do the right thing when the child is anonymous.
     38
     39        (WebCore::RenderFlexibleBox::styleDidChange): Deleted.
     40        * rendering/RenderFlexibleBox.h:
     41        Deleted, since alignment changes are handled at the style diff level now.
     42
     43        * rendering/RenderFullScreen.h:
     44        Patched the selfAlignmentNormalBehavior method to take an optional child argument.
     45
     46        * rendering/RenderGrid.cpp:
     47        (WebCore::RenderGrid::styleDidChange):
     48        (WebCore::RenderGrid::alignSelfForChild):
     49        (WebCore::RenderGrid::justifySelfForChild):
     50        (WebCore::RenderGrid::columnAxisPositionForChild):
     51        (WebCore::RenderGrid::rowAxisPositionForChild):
     52        (WebCore::RenderGrid::columnAxisOffsetForChild):
     53        (WebCore::RenderGrid::rowAxisOffsetForChild):
     54        (WebCore::defaultAlignmentIsStretch): Deleted.
     55        (WebCore::defaultAlignmentChangedToStretchInRowAxis): Deleted.
     56        (WebCore::defaultAlignmentChangedFromStretchInRowAxis): Deleted.
     57        (WebCore::defaultAlignmentChangedFromStretchInColumnAxis): Deleted.
     58        (WebCore::selfAlignmentChangedToStretchInRowAxis): Deleted.
     59        (WebCore::selfAlignmentChangedFromStretchInRowAxis): Deleted.
     60        (WebCore::selfAlignmentChangedFromStretchInColumnAxis): Deleted.
     61        * rendering/RenderGrid.h:
     62        Removed the alignment change logic in styleDidChange for grids, since style diffing handles
     63        it now. Updated all selfAlignmentForNormalBehavior queries to pass in the child so that
     64        replaced elements are handled properly.
     65
     66        * rendering/style/RenderStyle.h:
     67        (WebCore::RenderStyle::overflowInlineDirection):
     68        (WebCore::RenderStyle::overflowBlockDirection):
     69        (WebCore::RenderStyle::setJustifySelfPosition):
     70        New helpers used by grid and by adjustRenderStyle.
     71
     72        * style/StyleChange.cpp:
     73        (WebCore::Style::determineChange):
     74        If alignment or justification changes occur on a parent that could affect the child (e.g., align-items)
     75        return Inherit so the child render styles get adjusted properly.
     76
    1772017-03-06  Youenn Fablet  <youenn@apple.com>
    278
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r212629 r213480  
    10291029            style.setDisplay(BLOCK);
    10301030    }
     1031   
     1032    adjustStyleForAlignment(style, parentStyle);
     1033}
     1034   
     1035void StyleResolver::adjustStyleForAlignment(RenderStyle& style, const RenderStyle& parentStyle)
     1036{
     1037    // To avoid needing to copy the StyleRareNonInheritedData, we repurpose the 'auto'
     1038    // flag to not just mean 'auto' prior to running adjustRenderStyle but also
     1039    // mean 'normal' after running it.
     1040   
     1041    // If the inherited value of justify-items includes the 'legacy' keyword,
     1042    // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to
     1043    // 'normal'.
     1044    if (style.justifyItems().position() == ItemPositionAuto) {
     1045        if (parentStyle.justifyItems().positionType() == LegacyPosition)
     1046            style.setJustifyItems(parentStyle.justifyItems());
     1047    }
     1048   
     1049    // The 'auto' keyword computes the computed value of justify-items on the
     1050    // parent (minus any legacy keywords), or 'normal' if the box has no parent.
     1051    if (style.justifySelf().position() == ItemPositionAuto) {
     1052        if (parentStyle.justifyItems().positionType() == LegacyPosition)
     1053            style.setJustifySelfPosition(parentStyle.justifyItems().position());
     1054        else if (parentStyle.justifyItems().position() != ItemPositionAuto)
     1055            style.setJustifySelf(parentStyle.justifyItems());
     1056    }
     1057   
     1058    // The 'auto' keyword computes the computed value of align-items on the parent
     1059    // or 'normal' if the box has no parent.
     1060    if (style.alignSelf().position() == ItemPositionAuto && parentStyle.alignItems().position() != RenderStyle::initialDefaultAlignment().position())
     1061        style.setAlignSelf(parentStyle.alignItems());
    10311062}
    10321063
  • trunk/Source/WebCore/css/StyleResolver.h

    r212629 r213480  
    309309    };
    310310
     311    // FIXME: Should make a StyleAdjuster class (like Blink has) that handles all RenderStyle
     312    // adjustments. For now put this function on StyleResolver, since adjustRenderStyle is here.
     313    static void adjustStyleForAlignment(RenderStyle&, const RenderStyle& parentStyle);
     314   
    311315private:
    312316    // This function fixes up the default font size if it detects that the current generic font family has changed. -dwh
  • trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp

    r209756 r213480  
    7676}
    7777
    78 std::optional<ElementStyle> TextControlInnerElement::resolveCustomStyle(const RenderStyle&, const RenderStyle* shadowHostStyle)
     78std::optional<ElementStyle> TextControlInnerElement::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle)
    7979{
    8080    auto innerContainerStyle = RenderStyle::createPtr();
     
    8989    // We don't want the shadow dom to be editable, so we set this block to read-only in case the input itself is editable.
    9090    innerContainerStyle->setUserModify(READ_ONLY);
     91
     92    StyleResolver::adjustStyleForAlignment(*innerContainerStyle, parentStyle);
    9193
    9294    return ElementStyle(WTFMove(innerContainerStyle));
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp

    r213149 r213480  
    794794    const Length& childMinSize = isRowAxis ? child.style().logicalMinWidth() : child.style().logicalMinHeight();
    795795    const Length& childSize = isRowAxis ? child.style().logicalWidth() : child.style().logicalHeight();
    796     if (!childSize.isAuto() || childMinSize.isAuto())
     796
     797    bool overflowIsVisible = isRowAxis ? child.style().overflowInlineDirection() == OVISIBLE : child.style().overflowBlockDirection() == OVISIBLE;
     798    if (!childSize.isAuto() || (childMinSize.isAuto() && overflowIsVisible)) {
     799        if (child.isRenderReplaced() && childSize.isAuto()) {
     800            // If the box has an aspect ratio and no specified size, its automatic
     801            // minimum size is the smaller of its content size and its transferred
     802            // size.
     803            return isRowAxis ? std::min(child.intrinsicLogicalWidth(), minContentForChild(child)) : std::min(child.intrinsicLogicalHeight(), minContentForChild(child));
     804        }
    797805        return minContentForChild(child);
     806    }
    798807
    799808    bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChild(child, childInlineDirection);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r213455 r213480  
    25662566        return false;
    25672567    }
     2568    const auto* parentStyle = isAnonymous() ? &containingBlock->style() : nullptr;
    25682569    if (containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
    2569         return style.resolvedAlignSelf(&containingBlock->style(), ItemPositionStretch).position() == ItemPositionStretch;
    2570     return style.resolvedJustifySelf(&containingBlock->style(), ItemPositionStretch).position() == ItemPositionStretch;
     2570        return style.resolvedAlignSelf(parentStyle, containingBlock->selfAlignmentNormalBehavior(this)).position() == ItemPositionStretch;
     2571    return style.resolvedJustifySelf(parentStyle, containingBlock->selfAlignmentNormalBehavior(this)).position() == ItemPositionStretch;
    25712572}
    25722573
  • trunk/Source/WebCore/rendering/RenderBox.h

    r213455 r213480  
    638638    bool createsNewFormattingContext() const;
    639639
    640     virtual ItemPosition selfAlignmentNormalBehavior() const { return ItemPositionStretch; }
     640    virtual ItemPosition selfAlignmentNormalBehavior(const RenderBox* = nullptr) const { return ItemPositionStretch; }
    641641
    642642    // Returns false if it could not cheaply compute the extent (e.g. fixed background), in which case the returned rect may be incorrect.
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r213455 r213480  
    234234    static const StyleContentAlignmentData normalBehavior = { ContentPositionNormal, ContentDistributionStretch};
    235235    return normalBehavior;
    236 }
    237 
    238 void RenderFlexibleBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
    239 {
    240     RenderBlock::styleDidChange(diff, oldStyle);
    241 
    242     if (oldStyle && oldStyle->resolvedAlignItems(selfAlignmentNormalBehavior()).position() == ItemPositionStretch && diff == StyleDifferenceLayout) {
    243         // Flex items that were previously stretching need to be relayed out so we can compute new available cross axis space.
    244         // This is only necessary for stretching since other alignment values don't change the size of the box.
    245         auto& newStyle = style();
    246         for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
    247             auto& childStyle = child->style();
    248             auto previousAlignment = childStyle.resolvedAlignSelf(oldStyle, selfAlignmentNormalBehavior()).position();
    249             if (previousAlignment == ItemPositionStretch && previousAlignment != childStyle.resolvedAlignSelf(&newStyle, selfAlignmentNormalBehavior()).position())
    250                 child->setChildNeedsLayout(MarkOnlyThis);
    251         }
    252     }
    253236}
    254237
     
    14491432ItemPosition RenderFlexibleBox::alignmentForChild(const RenderBox& child) const
    14501433{
    1451     ItemPosition align = child.style().resolvedAlignSelf(&style(), selfAlignmentNormalBehavior()).position();
     1434    ItemPosition align = child.style().resolvedAlignSelf(child.isAnonymous() ? &style() : nullptr, selfAlignmentNormalBehavior()).position();
    14521435    ASSERT(align != ItemPositionAuto && align != ItemPositionNormal);
    14531436
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r213149 r213480  
    9090    void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
    9191    void computePreferredLogicalWidths() override;
    92 
    93     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
    9492
    9593private:
  • trunk/Source/WebCore/rendering/RenderFullScreen.h

    r213149 r213480  
    4545    void unwrapRenderer(bool& requiresRenderTreeRebuild);
    4646
    47     ItemPosition selfAlignmentNormalBehavior() const override { return ItemPositionCenter; }
     47    ItemPosition selfAlignmentNormalBehavior(const RenderBox* = nullptr) const override { return ItemPositionCenter; }
    4848   
    4949private:
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r213455 r213480  
    6666}
    6767
    68 static inline bool defaultAlignmentIsStretch(ItemPosition position)
    69 {
    70     return position == ItemPositionStretch || position == ItemPositionAuto;
    71 }
    72 
    73 static inline bool defaultAlignmentChangedToStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle)
    74 {
    75     return !defaultAlignmentIsStretch(oldStyle.justifyItems().position()) && defaultAlignmentIsStretch(newStyle.justifyItems().position());
    76 }
    77 
    78 static inline bool defaultAlignmentChangedFromStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle)
    79 {
    80     return defaultAlignmentIsStretch(oldStyle.justifyItems().position()) && !defaultAlignmentIsStretch(newStyle.justifyItems().position());
    81 }
    82 
    83 static inline bool defaultAlignmentChangedFromStretchInColumnAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle)
    84 {
    85     return defaultAlignmentIsStretch(oldStyle.alignItems().position()) && !defaultAlignmentIsStretch(newStyle.alignItems().position());
    86 }
    87 
    88 static inline bool selfAlignmentChangedToStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderStyle& childStyle, ItemPosition selfAlignNormalBehavior)
    89 {
    90     return childStyle.resolvedJustifySelf(&oldStyle, selfAlignNormalBehavior).position() != ItemPositionStretch && childStyle.resolvedJustifySelf(&newStyle, selfAlignNormalBehavior).position() == ItemPositionStretch;
    91 }
    92 
    93 static inline bool selfAlignmentChangedFromStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderStyle& childStyle, ItemPosition selfAlignNormalBehavior)
    94 {
    95     return childStyle.resolvedJustifySelf(&oldStyle, selfAlignNormalBehavior).position() == ItemPositionStretch && childStyle.resolvedJustifySelf(&newStyle, selfAlignNormalBehavior).position() != ItemPositionStretch;
    96 }
    97 
    98 static inline bool selfAlignmentChangedFromStretchInColumnAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderStyle& childStyle, ItemPosition selfAlignNormalBehavior)
    99 {
    100     return childStyle.resolvedAlignSelf(&oldStyle, selfAlignNormalBehavior).position() == ItemPositionStretch && childStyle.resolvedAlignSelf(&newStyle, selfAlignNormalBehavior).position() != ItemPositionStretch;
    101 }
    102 
    10368void RenderGrid::addChild(RenderObject* newChild, RenderObject* beforeChild)
    10469{
     
    12489    if (!oldStyle || diff != StyleDifferenceLayout)
    12590        return;
    126 
    127     const RenderStyle& newStyle = style();
    128     if (defaultAlignmentChangedToStretchInRowAxis(*oldStyle, newStyle) || defaultAlignmentChangedFromStretchInRowAxis(*oldStyle, newStyle)
    129         || defaultAlignmentChangedFromStretchInColumnAxis(*oldStyle, newStyle)) {
    130         // Grid items that were not previously stretched in row-axis need to be relayed out so we can compute new available space.
    131         // Grid items that were previously stretching in column-axis need to be relayed out so we can compute new available space.
    132         // This is only necessary for stretching since other alignment values don't change the size of the box.
    133         for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
    134             if (child->isOutOfFlowPositioned())
    135                 continue;
    136             if (selfAlignmentChangedToStretchInRowAxis(*oldStyle, newStyle, child->style(), selfAlignmentNormalBehavior()) || selfAlignmentChangedFromStretchInRowAxis(*oldStyle, newStyle, child->style(), selfAlignmentNormalBehavior())
    137                 || selfAlignmentChangedFromStretchInColumnAxis(*oldStyle, newStyle, child->style(), selfAlignmentNormalBehavior())) {
    138                 child->setChildNeedsLayout(MarkOnlyThis);
    139             }
    140         }
    141     }
    14291
    14392    if (explicitGridDidResize(*oldStyle) || namedGridLinesDefinitionDidChange(*oldStyle) || oldStyle->gridAutoFlow() != style().gridAutoFlow()
     
    11801129StyleSelfAlignmentData RenderGrid::alignSelfForChild(const RenderBox& child) const
    11811130{
    1182     return child.style().resolvedAlignSelf(&style(), selfAlignmentNormalBehavior());
     1131    if (!child.isAnonymous())
     1132        return child.style().resolvedAlignSelf(nullptr, selfAlignmentNormalBehavior(&child));
     1133
     1134    // All the 'auto' values have been resolved by the StyleAdjuster, but it's
     1135    // possible that some grid items generate Anonymous boxes, which need to be
     1136    // solved during layout.
     1137    return child.style().resolvedAlignSelf(&style(), selfAlignmentNormalBehavior(&child));
    11831138}
    11841139
    11851140StyleSelfAlignmentData RenderGrid::justifySelfForChild(const RenderBox& child) const
    11861141{
    1187     return child.style().resolvedJustifySelf(&style(), selfAlignmentNormalBehavior());
     1142    if (!child.isAnonymous())
     1143        return child.style().resolvedJustifySelf(nullptr, selfAlignmentNormalBehavior(&child));
     1144   
     1145    // All the 'auto' values have been resolved by the StyleAdjuster, but it's
     1146    // possible that some grid items generate Anonymous boxes, which need to be
     1147    // solved during layout.
     1148    return child.style().resolvedJustifySelf(&style(), selfAlignmentNormalBehavior(&child));
    11881149}
    11891150
     
    13461307    bool childIsLTR = child.style().isLeftToRightDirection();
    13471308
    1348     switch (child.style().resolvedAlignSelf(&style(), selfAlignmentNormalBehavior()).position()) {
     1309    switch (alignSelfForChild(child).position()) {
    13491310    case ItemPositionSelfStart:
    13501311        // FIXME: Should we implement this logic in a generic utility function ?
     
    14111372    bool gridIsLTR = style().isLeftToRightDirection();
    14121373
    1413     switch (child.style().resolvedJustifySelf(&style(), selfAlignmentNormalBehavior()).position()) {
     1374    switch (justifySelfForChild(child).position()) {
    14141375    case ItemPositionSelfStart:
    14151376        // FIXME: Should we implement this logic in a generic utility function ?
     
    14931454            endOfRow -= gridGapForDirection(ForRows, TrackSizing) + m_offsetBetweenRows;
    14941455        LayoutUnit columnAxisChildSize = isOrthogonalChild(child) ? child.logicalWidth() + child.marginLogicalWidth() : child.logicalHeight() + child.marginLogicalHeight();
    1495         auto overflow = child.style().resolvedAlignSelf(&style(), selfAlignmentNormalBehavior()).overflow();
     1456        auto overflow = alignSelfForChild(child).overflow();
    14961457        LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(overflow, endOfRow - startOfRow, columnAxisChildSize);
    14971458        return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2);
     
    15251486            endOfColumn -= gridGapForDirection(ForColumns, TrackSizing) + m_offsetBetweenColumns;
    15261487        LayoutUnit rowAxisChildSize = isOrthogonalChild(child) ? child.logicalHeight() + child.marginLogicalHeight() : child.logicalWidth() + child.marginLogicalWidth();
    1527         auto overflow = child.style().resolvedJustifySelf(&style(), selfAlignmentNormalBehavior()).overflow();
     1488        auto overflow = justifySelfForChild(child).overflow();
    15281489        LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(overflow, endOfColumn - startOfColumn, rowAxisChildSize);
    15291490        return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2);
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r213149 r213480  
    6464    bool isOrthogonalChild(const RenderBox&) const;
    6565    LayoutUnit guttersSize(const Grid&, GridTrackSizingDirection, unsigned startLine, unsigned span, SizingOperation) const;
     66   
     67protected:
     68    ItemPosition selfAlignmentNormalBehavior(const RenderBox* child = nullptr) const override
     69    {
     70        ASSERT(child);
     71        return child->isRenderReplaced() ? ItemPositionStart : ItemPositionStretch;
     72    }
     73
    6674private:
    6775    const char* renderName() const override;
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r213149 r213480  
    324324    EOverflow overflowX() const { return m_nonInheritedFlags.overflowX(); }
    325325    EOverflow overflowY() const { return m_nonInheritedFlags.overflowY(); }
    326 
     326    EOverflow overflowInlineDirection() const { return isHorizontalWritingMode() ? overflowX() : overflowY(); }
     327    EOverflow overflowBlockDirection() const { return isHorizontalWritingMode() ? overflowY() : overflowX(); }
     328   
    327329    EVisibility visibility() const { return static_cast<EVisibility>(m_inheritedFlags.visibility); }
    328330    EVerticalAlign verticalAlign() const { return m_nonInheritedFlags.verticalAlign(); }
     
    10561058    void setJustifyItems(const StyleSelfAlignmentData& data) { SET_VAR(m_rareNonInheritedData, justifyItems, data); }
    10571059    void setJustifySelf(const StyleSelfAlignmentData& data) { SET_VAR(m_rareNonInheritedData, justifySelf, data); }
     1060    void setJustifySelfPosition(ItemPosition position) { m_rareNonInheritedData.access().justifySelf.setPosition(position); }
    10581061
    10591062#if ENABLE(CSS_BOX_DECORATION_BREAK)
  • trunk/Source/WebCore/style/StyleChange.cpp

    r201159 r213480  
    6565            return Inherit;
    6666
     67        if (s1.alignItems() != s2.alignItems() || s1.justifyItems() != s2.justifyItems())
     68            return Inherit;
     69
    6770        return NoInherit;
    6871    }
     72
    6973    // If the pseudoStyles have changed, we want any StyleChange that is not NoChange
    7074    // because setStyle will do the right thing with anything else.
Note: See TracChangeset for help on using the changeset viewer.