Changeset 183660 in webkit


Ignore:
Timestamp:
Apr 30, 2015 6:14:20 PM (9 years ago)
Author:
jfernandez@igalia.com
Message:

[CSS Grid Layout] overflow-position keyword for align and justify properties.
https://bugs.webkit.org/show_bug.cgi?id=144235

Reviewed by Sergio Villar Senin.

Source/WebCore:

When the alignment subject is larger than the alignment container,
it will overflow. Some alignment modes, if honored in this
situation, may cause data loss; an overflow alignment mode can be
explicitly specified to avoid this.

This patch implements overflow-keyword handling for Grid Layout on
align-self and justify-self properties.

Test: fast/css-grid-layout/grid-align-justify-overflow.html

  • rendering/RenderGrid.cpp:

(WebCore::computeOverflowAlignmentOffset):
(WebCore::RenderGrid::rowPositionForChild):
(WebCore::RenderGrid::columnPositionForChild):
(WebCore::RenderGrid::rowAxisPositionForChild): Deleted.

  • rendering/style/RenderStyle.cpp:

(WebCore::resolveAlignmentData):
(WebCore::resolveJustificationData):
(WebCore::RenderStyle::resolveAlignment):
(WebCore::RenderStyle::resolveAlignmentOverflow):
(WebCore::RenderStyle::resolveJustification):
(WebCore::RenderStyle::resolveJustificationOverflow):

  • rendering/style/RenderStyle.h:

LayoutTests:

Implementation of overflow-keyword handling for Grid Layout on
align-self and justify-self properties.

  • fast/css-grid-layout/grid-align-justify-overflow-expected.txt: Added.
  • fast/css-grid-layout/grid-align-justify-overflow.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183659 r183660  
     12015-04-30  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [CSS Grid Layout] overflow-position keyword for align and justify properties.
     4        https://bugs.webkit.org/show_bug.cgi?id=144235
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        Implementation of overflow-keyword handling for Grid Layout on
     9        align-self and justify-self properties.
     10
     11        * fast/css-grid-layout/grid-align-justify-overflow-expected.txt: Added.
     12        * fast/css-grid-layout/grid-align-justify-overflow.html: Added.
     13
    1142015-04-30  Jon Davis  <jond@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r183657 r183660  
     12015-04-30  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [CSS Grid Layout] overflow-position keyword for align and justify properties.
     4        https://bugs.webkit.org/show_bug.cgi?id=144235
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        When the alignment subject is larger than the alignment container,
     9        it will overflow. Some alignment modes, if honored in this
     10        situation, may cause data loss; an overflow alignment mode can be
     11        explicitly specified to avoid this.
     12
     13        This patch implements overflow-keyword handling for Grid Layout on
     14        align-self and justify-self properties.
     15
     16        Test: fast/css-grid-layout/grid-align-justify-overflow.html
     17
     18        * rendering/RenderGrid.cpp:
     19        (WebCore::computeOverflowAlignmentOffset):
     20        (WebCore::RenderGrid::rowPositionForChild):
     21        (WebCore::RenderGrid::columnPositionForChild):
     22        (WebCore::RenderGrid::rowAxisPositionForChild): Deleted.
     23        * rendering/style/RenderStyle.cpp:
     24        (WebCore::resolveAlignmentData):
     25        (WebCore::resolveJustificationData):
     26        (WebCore::RenderStyle::resolveAlignment):
     27        (WebCore::RenderStyle::resolveAlignmentOverflow):
     28        (WebCore::RenderStyle::resolveJustification):
     29        (WebCore::RenderStyle::resolveJustificationOverflow):
     30        * rendering/style/RenderStyle.h:
     31
    1322015-04-30  Jon Honeycutt  <jhoneycutt@apple.com>
    233
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r183399 r183660  
    12371237    for (unsigned i = 0; i < m_rowPositions.size() - 1; ++i)
    12381238        m_rowPositions[i + 1] = m_rowPositions[i] + sizingData.rowTracks[i].baseSize();
     1239}
     1240
     1241static inline LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, LayoutUnit trackBreadth, LayoutUnit childBreadth)
     1242{
     1243    LayoutUnit offset = trackBreadth - childBreadth;
     1244    switch (overflow) {
     1245    case OverflowAlignmentSafe:
     1246        // If overflow is 'safe', we have to make sure we don't overflow the 'start'
     1247        // edge (potentially cause some data loss as the overflow is unreachable).
     1248        return std::max<LayoutUnit>(0, offset);
     1249    case OverflowAlignmentTrue:
     1250    case OverflowAlignmentDefault:
     1251        // If we overflow our alignment container and overflow is 'true' (default), we
     1252        // ignore the overflow and just return the value regardless (which may cause data
     1253        // loss as we overflow the 'start' edge).
     1254        return offset;
     1255    }
     1256
     1257    ASSERT_NOT_REACHED();
     1258    return 0;
    12391259}
    12401260
     
    13861406    LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.next().toInt()];
    13871407    LayoutUnit startPosition = startOfRow + marginBeforeForChild(child);
    1388     // FIXME: This should account for the grid item's <overflow-position>.
    1389     LayoutUnit offsetFromStartPosition = endOfRow - startOfRow - child.logicalHeight() - child.marginLogicalHeight();
     1408    LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(RenderStyle::resolveAlignmentOverflow(style(), child.style()), endOfRow - startOfRow, child.logicalHeight() + child.marginLogicalHeight());
    13901409
    13911410    switch (columnAxisPositionForChild(child)) {
     
    14091428    LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalPosition.next().toInt()];
    14101429    LayoutUnit startPosition = startOfColumn + marginStartForChild(child);
    1411     // FIXME: This should account for the grid item's <overflow-position>.
    1412     LayoutUnit offsetFromStartPosition = endOfColumn - startOfColumn - child.logicalWidth() - child.marginLogicalWidth();
     1430    LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(RenderStyle::resolveJustificationOverflow(style(), child.style()), endOfColumn - startOfColumn, child.logicalWidth() + child.marginLogicalWidth());
    14131431
    14141432    switch (rowAxisPositionForChild(child)) {
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r183591 r183660  
    4040#include "StyleResolver.h"
    4141#include "StyleScrollSnapPoints.h"
     42#include "StyleSelfAlignmentData.h"
    4243#include <wtf/MathExtras.h>
    4344#include <wtf/StdLibExtras.h>
     
    172173}
    173174
    174 ItemPosition RenderStyle::resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
     175static inline StyleSelfAlignmentData resolveAlignmentData(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
    175176{
    176177    // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto".
    177178    if (childStyle.alignSelfPosition() == ItemPositionAuto)
    178         return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolvedAutoPositionForRenderer : parentStyle.alignItemsPosition();
    179     return childStyle.alignSelfPosition();
    180 }
    181 
    182 ItemPosition RenderStyle::resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject)
    183 {
     179        return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? StyleSelfAlignmentData(resolvedAutoPositionForRenderer, OverflowAlignmentDefault) : parentStyle.alignItems();
     180    return childStyle.alignSelf();
     181}
     182
     183static inline StyleSelfAlignmentData resolveJustificationData(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
     184{
     185    // The auto keyword computes to the parent's justify-items computed value, or to "stretch", if not set or "auto".
    184186    if (childStyle.justifySelfPosition() == ItemPositionAuto)
    185         return (parentStyle.justifyItemsPosition() == ItemPositionAuto) ? resolvedAutoPositionForLayoutObject : parentStyle.justifyItemsPosition();
    186     return childStyle.justifySelfPosition();
     187        return (parentStyle.justifyItemsPosition() == ItemPositionAuto) ? StyleSelfAlignmentData(resolvedAutoPositionForRenderer, OverflowAlignmentDefault) : parentStyle.justifyItems();
     188    return childStyle.justifySelf();
     189}
     190
     191ItemPosition RenderStyle::resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
     192{
     193    return resolveAlignmentData(parentStyle, childStyle, resolvedAutoPositionForRenderer).position();
     194}
     195
     196OverflowAlignment RenderStyle::resolveAlignmentOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle)
     197{
     198    return resolveJustificationData(parentStyle, childStyle, ItemPositionStretch).overflow();
     199}
     200
     201ItemPosition RenderStyle::resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
     202{
     203    return resolveJustificationData(parentStyle, childStyle, resolvedAutoPositionForRenderer).position();
     204}
     205
     206OverflowAlignment RenderStyle::resolveJustificationOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle)
     207{
     208    return resolveJustificationData(parentStyle, childStyle, ItemPositionStretch).overflow();
    187209}
    188210
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r183591 r183660  
    493493
    494494    static ItemPosition resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer);
    495     static ItemPosition resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject);
     495    static OverflowAlignment resolveAlignmentOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle);
     496    static ItemPosition resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer);
     497    static OverflowAlignment resolveJustificationOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle);
    496498
    497499    enum IsAtShadowBoundary {
Note: See TracChangeset for help on using the changeset viewer.