Changeset 189910 in webkit


Ignore:
Timestamp:
Sep 17, 2015 2:13:35 AM (9 years ago)
Author:
jfernandez@igalia.com
Message:

[CSS Grid Layout] Relayout whenever Box Alignment properties change
https://bugs.webkit.org/show_bug.cgi?id=148070

Reviewed by Darin Adler.

Source/WebCore:

We were Reattaching the styles to the RenderTree whenever Content Alignment
properties (align-items and justify-items) changed their values, since the
Self Alignment properties depend on such values to resolve 'auto' values
during layout.

This patch removes such restriction, since we resolve the auto values
whenever we access the alignment properties. The only thing we need to
do is to mark a grid item for layout whenever the Default Alignment
properties change from/to stretch, since it implies a resize of the grid
items using 'auto' values for the Self Alignment properties.

Tests: fast/css-grid-layout/relayout-align-items-changed.html

fast/css-grid-layout/relayout-align-self-changed.html
fast/css-grid-layout/relayout-justify-items-changed.html
fast/css-grid-layout/relayout-justify-self-changed.html
fast/repaint/align-items-change.html
fast/repaint/align-items-overflow-change.html
fast/repaint/align-self-change.html
fast/repaint/align-self-overflow-change.html
fast/repaint/justify-items-change.html
fast/repaint/justify-items-legacy-change.html
fast/repaint/justify-items-overflow-change.html
fast/repaint/justify-self-change.html
fast/repaint/justify-self-overflow-change.html

  • rendering/RenderGrid.cpp:

(WebCore::defaultAlignmentIsStretch):
(WebCore::RenderGrid::styleDidChange):

  • rendering/RenderGrid.h:
  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::resolveAlignmentOverflow):
(WebCore::RenderStyle::changeRequiresLayout):

  • style/StyleResolveTree.cpp:

(WebCore::Style::determineChange): Deleted.

LayoutTests:

Tests to verify we force a layout of grid container or grid items, as appropriated,
whenever Box Alignment properties change their value.

This patch also adds some repaint tests, so we can ensure we generate the correct
repaint rects as well.

  • fast/css-grid-layout/relayout-align-items-changed-expected.txt: Added.
  • fast/css-grid-layout/relayout-align-items-changed.html: Added.
  • fast/css-grid-layout/relayout-align-self-changed-expected.txt: Added.
  • fast/css-grid-layout/relayout-align-self-changed.html: Added.
  • fast/css-grid-layout/relayout-justify-items-changed-expected.txt: Added.
  • fast/css-grid-layout/relayout-justify-items-changed.html: Added.
  • fast/css-grid-layout/relayout-justify-self-changed-expected.txt: Added.
  • fast/css-grid-layout/relayout-justify-self-changed.html: Added.
  • fast/repaint/align-items-change-expected.txt: Added.
  • fast/repaint/align-items-change.html: Added.
  • fast/repaint/align-items-overflow-change-expected.txt: Added.
  • fast/repaint/align-items-overflow-change.html: Added.
  • fast/repaint/align-self-change-expected.txt: Added.
  • fast/repaint/align-self-change.html: Added.
  • fast/repaint/align-self-overflow-change-expected.txt: Added.
  • fast/repaint/align-self-overflow-change.html: Added.
  • fast/repaint/justify-items-change-expected.txt: Added.
  • fast/repaint/justify-items-change.html: Added.
  • fast/repaint/justify-items-legacy-change-expected.txt: Added.
  • fast/repaint/justify-items-legacy-change.html: Added.
  • fast/repaint/justify-items-overflow-change-expected.txt: Added.
  • fast/repaint/justify-items-overflow-change.html: Added.
  • fast/repaint/justify-self-change-expected.txt: Added.
  • fast/repaint/justify-self-change.html: Added.
  • fast/repaint/justify-self-overflow-change-expected.txt: Added.
  • fast/repaint/justify-self-overflow-change.html: Added.
Location:
trunk
Files:
26 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r189908 r189910  
     12015-09-17  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [CSS Grid Layout] Relayout whenever Box Alignment properties change
     4        https://bugs.webkit.org/show_bug.cgi?id=148070
     5
     6        Reviewed by Darin Adler.
     7
     8        Tests to verify we force a layout of grid container or grid items, as appropriated,
     9        whenever Box Alignment properties change their value.
     10
     11        This patch also adds some repaint tests, so we can ensure we generate the correct
     12        repaint rects as well.
     13
     14        * fast/css-grid-layout/relayout-align-items-changed-expected.txt: Added.
     15        * fast/css-grid-layout/relayout-align-items-changed.html: Added.
     16        * fast/css-grid-layout/relayout-align-self-changed-expected.txt: Added.
     17        * fast/css-grid-layout/relayout-align-self-changed.html: Added.
     18        * fast/css-grid-layout/relayout-justify-items-changed-expected.txt: Added.
     19        * fast/css-grid-layout/relayout-justify-items-changed.html: Added.
     20        * fast/css-grid-layout/relayout-justify-self-changed-expected.txt: Added.
     21        * fast/css-grid-layout/relayout-justify-self-changed.html: Added.
     22        * fast/repaint/align-items-change-expected.txt: Added.
     23        * fast/repaint/align-items-change.html: Added.
     24        * fast/repaint/align-items-overflow-change-expected.txt: Added.
     25        * fast/repaint/align-items-overflow-change.html: Added.
     26        * fast/repaint/align-self-change-expected.txt: Added.
     27        * fast/repaint/align-self-change.html: Added.
     28        * fast/repaint/align-self-overflow-change-expected.txt: Added.
     29        * fast/repaint/align-self-overflow-change.html: Added.
     30        * fast/repaint/justify-items-change-expected.txt: Added.
     31        * fast/repaint/justify-items-change.html: Added.
     32        * fast/repaint/justify-items-legacy-change-expected.txt: Added.
     33        * fast/repaint/justify-items-legacy-change.html: Added.
     34        * fast/repaint/justify-items-overflow-change-expected.txt: Added.
     35        * fast/repaint/justify-items-overflow-change.html: Added.
     36        * fast/repaint/justify-self-change-expected.txt: Added.
     37        * fast/repaint/justify-self-change.html: Added.
     38        * fast/repaint/justify-self-overflow-change-expected.txt: Added.
     39        * fast/repaint/justify-self-overflow-change.html: Added.
     40
    1412015-09-16  Carlos Garcia Campos  <cgarcia@igalia.com>
    242
  • trunk/Source/WebCore/ChangeLog

    r189908 r189910  
     12015-09-17  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [CSS Grid Layout] Relayout whenever Box Alignment properties change
     4        https://bugs.webkit.org/show_bug.cgi?id=148070
     5
     6        Reviewed by Darin Adler.
     7
     8        We were Reattaching the styles to the RenderTree whenever Content Alignment
     9        properties (align-items and justify-items) changed their values, since the
     10        Self Alignment properties depend on such values to resolve 'auto' values
     11        during layout.
     12
     13        This patch removes such restriction, since we resolve the auto values
     14        whenever we access the alignment properties. The only thing we need to
     15        do is to mark a grid item for layout whenever the Default Alignment
     16        properties change from/to stretch, since it implies a resize of the grid
     17        items using 'auto' values for the Self Alignment properties.
     18
     19        Tests: fast/css-grid-layout/relayout-align-items-changed.html
     20               fast/css-grid-layout/relayout-align-self-changed.html
     21               fast/css-grid-layout/relayout-justify-items-changed.html
     22               fast/css-grid-layout/relayout-justify-self-changed.html
     23               fast/repaint/align-items-change.html
     24               fast/repaint/align-items-overflow-change.html
     25               fast/repaint/align-self-change.html
     26               fast/repaint/align-self-overflow-change.html
     27               fast/repaint/justify-items-change.html
     28               fast/repaint/justify-items-legacy-change.html
     29               fast/repaint/justify-items-overflow-change.html
     30               fast/repaint/justify-self-change.html
     31               fast/repaint/justify-self-overflow-change.html
     32
     33        * rendering/RenderGrid.cpp:
     34        (WebCore::defaultAlignmentIsStretch):
     35        (WebCore::RenderGrid::styleDidChange):
     36        * rendering/RenderGrid.h:
     37        * rendering/style/RenderStyle.cpp:
     38        (WebCore::RenderStyle::resolveAlignmentOverflow):
     39        (WebCore::RenderStyle::changeRequiresLayout):
     40        * style/StyleResolveTree.cpp:
     41        (WebCore::Style::determineChange): Deleted.
     42
    1432015-09-16  Carlos Garcia Campos  <cgarcia@igalia.com>
    244
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r189860 r189910  
    241241RenderGrid::~RenderGrid()
    242242{
     243}
     244
     245static inline bool defaultAlignmentIsStretch(ItemPosition position)
     246{
     247    return position == ItemPositionStretch || position == ItemPositionAuto;
     248}
     249
     250static inline bool defaultAlignmentChangedToStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle)
     251{
     252    return !defaultAlignmentIsStretch(oldStyle.justifyItemsPosition()) && defaultAlignmentIsStretch(newStyle.justifyItemsPosition());
     253}
     254
     255static inline bool defaultAlignmentChangedFromStretchInColumnAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle)
     256{
     257    return defaultAlignmentIsStretch(oldStyle.alignItemsPosition()) && !defaultAlignmentIsStretch(newStyle.alignItemsPosition());
     258}
     259
     260static inline bool selfAlignmentChangedToStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderStyle& childStyle)
     261{
     262    return RenderStyle::resolveJustification(oldStyle, childStyle, ItemPositionStretch) != ItemPositionStretch
     263        && RenderStyle::resolveJustification(newStyle, childStyle, ItemPositionStretch) == ItemPositionStretch;
     264}
     265
     266static inline bool selfAlignmentChangedFromStretchInColumnAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderStyle& childStyle)
     267{
     268    return RenderStyle::resolveAlignment(oldStyle, childStyle, ItemPositionStretch) == ItemPositionStretch
     269        && RenderStyle::resolveAlignment(newStyle, childStyle, ItemPositionStretch) != ItemPositionStretch;
     270}
     271
     272void RenderGrid::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
     273{
     274    RenderBlock::styleDidChange(diff, oldStyle);
     275    if (!oldStyle || diff != StyleDifferenceLayout)
     276        return;
     277
     278    const RenderStyle& newStyle = style();
     279    if (defaultAlignmentChangedToStretchInRowAxis(*oldStyle, newStyle) || defaultAlignmentChangedFromStretchInColumnAxis(*oldStyle, newStyle)) {
     280        // Grid items that were not previously stretched in row-axis need to be relayed out so we can compute new available space.
     281        // Grid items that were previously stretching in column-axis need to be relayed out so we can compute new available space.
     282        // This is only necessary for stretching since other alignment values don't change the size of the box.
     283        for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
     284            if (child->isOutOfFlowPositioned())
     285                continue;
     286            if (selfAlignmentChangedToStretchInRowAxis(*oldStyle, newStyle, child->style()) || selfAlignmentChangedFromStretchInColumnAxis(*oldStyle, newStyle, child->style()))
     287                child->setChildNeedsLayout(MarkOnlyThis);
     288        }
     289    }
    243290}
    244291
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r189806 r189910  
    5050    Element& element() const { return downcast<Element>(nodeForNonAnonymous()); }
    5151
     52    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
    5253    virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) override;
    5354
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r189830 r189910  
    197197OverflowAlignment RenderStyle::resolveAlignmentOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle)
    198198{
    199     return resolveJustificationData(parentStyle, childStyle, ItemPositionStretch).overflow();
     199    return resolveAlignmentData(parentStyle, childStyle, ItemPositionStretch).overflow();
    200200}
    201201
     
    525525            || rareNonInheritedData->m_alignItems != other.rareNonInheritedData->m_alignItems
    526526            || rareNonInheritedData->m_alignSelf != other.rareNonInheritedData->m_alignSelf
    527             || rareNonInheritedData->m_justifyContent != other.rareNonInheritedData->m_justifyContent)
     527            || rareNonInheritedData->m_justifyContent != other.rareNonInheritedData->m_justifyContent
     528            || rareNonInheritedData->m_justifyItems != other.rareNonInheritedData->m_justifyItems
     529            || rareNonInheritedData->m_justifySelf != other.rareNonInheritedData->m_justifySelf)
    528530            return true;
    529531
  • trunk/Source/WebCore/style/StyleResolveTree.cpp

    r189836 r189910  
    9898    if (s1.hasFlowFrom() && (s1.specifiesColumns() != s2.specifiesColumns()))
    9999        return Detach;
    100     if (s1.alignItems() != s2.alignItems())
    101         return Detach;
    102100
    103101    if (s1 != s2) {
Note: See TracChangeset for help on using the changeset viewer.