Changeset 199657 in webkit


Ignore:
Timestamp:
Apr 18, 2016 1:20:08 AM (8 years ago)
Author:
Manuel Rego Casasnovas
Message:

[css-grid] Fix positioned items with content alignment
https://bugs.webkit.org/show_bug.cgi?id=156597

Reviewed by Darin Adler.

Source/WebCore:

Like for the case of gaps we need to take into account
the content alignment in order to properly place and size
the positioned items.

Regarding content alignment we need to care about 2 values:
the position offset and the distribution offset.
The position offset can be extracted from m_column|rowPositions,
but the distribution offset is stored in 2 new variables called
m_offsetBetweenColumns|Rows.

Tests: fast/css-grid-layout/grid-positioned-items-content-alignment.html

fast/css-grid-layout/grid-positioned-items-content-alignment-rtl.html

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
(WebCore::RenderGrid::populateGridPositions):
(WebCore::RenderGrid::columnAxisOffsetForChild):
(WebCore::RenderGrid::rowAxisOffsetForChild):
(WebCore::RenderGrid::rowAxisPositionForChild): Deleted.

  • rendering/RenderGrid.h:

LayoutTests:

  • fast/css-grid-layout/grid-positioned-items-content-alignment-expected.txt: Added.
  • fast/css-grid-layout/grid-positioned-items-content-alignment-rtl-expected.txt: Added.
  • fast/css-grid-layout/grid-positioned-items-content-alignment-rtl.html: Added.
  • fast/css-grid-layout/grid-positioned-items-content-alignment.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r199654 r199657  
     12016-04-18  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [css-grid] Fix positioned items with content alignment
     4        https://bugs.webkit.org/show_bug.cgi?id=156597
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/css-grid-layout/grid-positioned-items-content-alignment-expected.txt: Added.
     9        * fast/css-grid-layout/grid-positioned-items-content-alignment-rtl-expected.txt: Added.
     10        * fast/css-grid-layout/grid-positioned-items-content-alignment-rtl.html: Added.
     11        * fast/css-grid-layout/grid-positioned-items-content-alignment.html: Added.
     12
    1132016-04-18  Yusuke Suzuki  <utatane.tea@gmail.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r199655 r199657  
     12016-04-18  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [css-grid] Fix positioned items with content alignment
     4        https://bugs.webkit.org/show_bug.cgi?id=156597
     5
     6        Reviewed by Darin Adler.
     7
     8        Like for the case of gaps we need to take into account
     9        the content alignment in order to properly place and size
     10        the positioned items.
     11
     12        Regarding content alignment we need to care about 2 values:
     13        the position offset and the distribution offset.
     14        The position offset can be extracted from m_column|rowPositions,
     15        but the distribution offset is stored in 2 new variables called
     16        m_offsetBetweenColumns|Rows.
     17
     18        Tests: fast/css-grid-layout/grid-positioned-items-content-alignment.html
     19               fast/css-grid-layout/grid-positioned-items-content-alignment-rtl.html
     20
     21        * rendering/RenderGrid.cpp:
     22        (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
     23        (WebCore::RenderGrid::populateGridPositions):
     24        (WebCore::RenderGrid::columnAxisOffsetForChild):
     25        (WebCore::RenderGrid::rowAxisOffsetForChild):
     26        (WebCore::RenderGrid::rowAxisPositionForChild): Deleted.
     27        * rendering/RenderGrid.h:
     28
    1292016-04-18  Manuel Rego Casasnovas  <rego@igalia.com>
    230
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r199655 r199657  
    15351535
    15361536        // These vectors store line positions including gaps, but we shouldn't consider them for the edges of the grid.
    1537         if (endLine > firstExplicitLine && endLine < lastExplicitLine)
     1537        if (endLine > firstExplicitLine && endLine < lastExplicitLine) {
    15381538            end -= guttersSize(direction, 2);
    1539     }
     1539            end -= isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows;
     1540        }
     1541    }
     1542
     1543    LayoutUnit alignmentOffset = isRowAxis ? m_columnPositions[0] - borderAndPaddingStart() : m_rowPositions[0] - borderAndPaddingBefore();
     1544    if (isRowAxis && !style().isLeftToRightDirection())
     1545        alignmentOffset = contentLogicalWidth() - (m_columnPositions[m_columnPositions.size() - 1] - borderAndPaddingStart());
     1546
     1547    if (!startIsAuto)
     1548        start += alignmentOffset;
     1549    if (!endIsAuto)
     1550        end += alignmentOffset;
    15401551
    15411552    breadth = end - start;
     
    15501561            offset = translateRTLCoordinate(m_columnPositions[endLine]) - borderLeft();
    15511562
    1552             if (endLine > firstExplicitLine && endLine < lastExplicitLine)
     1563            if (endLine > firstExplicitLine && endLine < lastExplicitLine) {
    15531564                offset += guttersSize(direction, 2);
     1565                offset += isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows;
     1566            }
    15541567        }
    15551568    }
     
    16261639        m_columnPositions[i + 1] = m_columnPositions[i] + offset.distributionOffset + sizingData.columnTracks[i].baseSize() + trackGap;
    16271640    m_columnPositions[lastLine] = m_columnPositions[nextToLastLine] + sizingData.columnTracks[nextToLastLine].baseSize();
     1641    m_offsetBetweenColumns = offset.distributionOffset;
    16281642
    16291643    numberOfTracks = sizingData.rowTracks.size();
     
    16381652        m_rowPositions[i + 1] = m_rowPositions[i] + offset.distributionOffset + sizingData.rowTracks[i].baseSize() + trackGap;
    16391653    m_rowPositions[lastLine] = m_rowPositions[nextToLastLine] + sizingData.rowTracks[nextToLastLine].baseSize();
     1654    m_offsetBetweenRows = offset.distributionOffset;
    16401655}
    16411656
     
    18751890}
    18761891
    1877 static inline LayoutUnit offsetBetweenTracks(ContentDistributionType distribution, const Vector<LayoutUnit>& trackPositions, const LayoutUnit& childBreadth)
    1878 {
    1879     return (distribution == ContentDistributionStretch || ContentDistributionStretch == ContentDistributionDefault) ? LayoutUnit() : trackPositions[1] - trackPositions[0] - childBreadth;
    1880 }
    1881 
    18821892LayoutUnit RenderGrid::columnAxisOffsetForChild(const RenderBox& child) const
    18831893{
     
    19031913        // In order to properly adjust the Self Alignment values we need to consider the offset between tracks.
    19041914        if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.size() - 1)
    1905             endOfRow -= offsetBetweenTracks(style().resolvedAlignContentDistribution(normalValueBehaviorGrid()), m_rowPositions, childBreadth);
     1915            endOfRow -= m_offsetBetweenRows;
    19061916        LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(RenderStyle::resolveAlignmentOverflow(style(), child.style()), endOfRow - startOfRow, childBreadth);
    19071917        return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2);
     
    19371947        // In order to properly adjust the Self Alignment values we need to consider the offset between tracks.
    19381948        if (childEndLine - childStartLine > 1 && childEndLine < m_columnPositions.size() - 1)
    1939             endOfColumn -= offsetBetweenTracks(style().resolvedJustifyContentDistribution(normalValueBehaviorGrid()), m_columnPositions, childBreadth);
     1949            endOfColumn -= m_offsetBetweenColumns;
    19401950        LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(RenderStyle::resolveJustificationOverflow(style(), child.style()), endOfColumn - startOfColumn, childBreadth);
    19411951        return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2);
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r199655 r199657  
    187187    Vector<LayoutUnit> m_columnPositions;
    188188    Vector<LayoutUnit> m_rowPositions;
     189    LayoutUnit m_offsetBetweenColumns;
     190    LayoutUnit m_offsetBetweenRows;
    189191    HashMap<const RenderBox*, GridArea> m_gridItemArea;
    190192    OrderIterator m_orderIterator;
Note: See TracChangeset for help on using the changeset viewer.