Changeset 200427 in webkit


Ignore:
Timestamp:
May 4, 2016 1:32:06 PM (8 years ago)
Author:
Manuel Rego Casasnovas
Message:

[css-grid] Refactor information stored related to column positions
https://bugs.webkit.org/show_bug.cgi?id=157342

Reviewed by Darin Adler.

In m_columnPositions we were storing position of each column
including the alignment offset, always from the logical left,
and the border and padding, depending on the direction.

This was really confusing as in the case of RTL direction
we were adding the offset from the left and
the right border and padding.

This patches changes it to store always the info from the left,
so even in RTL direction we use the left border and padding.

This allows us to simplify translateRTLCoordinate() as
it doesn't need to care about border and padding anymore.
And also to refactor offsetAndBreadthForPositionedChild()
which became really complex after adding RTL support.

No new tests, no change of behavior.

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
(WebCore::RenderGrid::populateGridPositions):
(WebCore::RenderGrid::translateRTLCoordinate):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r200423 r200427  
     12016-05-04  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [css-grid] Refactor information stored related to column positions
     4        https://bugs.webkit.org/show_bug.cgi?id=157342
     5
     6        Reviewed by Darin Adler.
     7
     8        In m_columnPositions we were storing position of each column
     9        including the alignment offset, always from the logical left,
     10        and the border and padding, depending on the direction.
     11
     12        This was really confusing as in the case of RTL direction
     13        we were adding the offset from the left and
     14        the right border and padding.
     15
     16        This patches changes it to store always the info from the left,
     17        so even in RTL direction we use the left border and padding.
     18
     19        This allows us to simplify translateRTLCoordinate() as
     20        it doesn't need to care about border and padding anymore.
     21        And also to refactor offsetAndBreadthForPositionedChild()
     22        which became really complex after adding RTL support.
     23
     24        No new tests, no change of behavior.
     25
     26        * rendering/RenderGrid.cpp:
     27        (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
     28        (WebCore::RenderGrid::populateGridPositions):
     29        (WebCore::RenderGrid::translateRTLCoordinate):
     30
    1312016-05-04  Mark Lam  <mark.lam@apple.com>
    232
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r200368 r200427  
    15611561    LayoutUnit start;
    15621562    if (!startIsAuto) {
    1563         if (isRowAxis)
    1564             start = m_columnPositions[startLine] - m_columnPositions[0] + paddingStart();
    1565         else
    1566             start = m_rowPositions[startLine] - m_rowPositions[0] + paddingBefore();
     1563        if (isRowAxis) {
     1564            if (style().isLeftToRightDirection())
     1565                start = m_columnPositions[startLine] - borderLogicalLeft();
     1566            else
     1567                start = logicalWidth() - translateRTLCoordinate(m_columnPositions[startLine]) - borderLogicalRight();
     1568        } else
     1569            start = m_rowPositions[startLine] - borderBefore();
    15671570    }
    15681571
    15691572    LayoutUnit end = isRowAxis ? clientLogicalWidth() : clientLogicalHeight();
    15701573    if (!endIsAuto) {
    1571         if (isRowAxis)
    1572             end = m_columnPositions[endLine] - m_columnPositions[0] + paddingStart();
    1573         else
    1574             end = m_rowPositions[endLine] - m_rowPositions[0] + paddingBefore();
     1574        if (isRowAxis) {
     1575            if (style().isLeftToRightDirection())
     1576                end = m_columnPositions[endLine] - borderLogicalLeft();
     1577            else
     1578                end = logicalWidth() - translateRTLCoordinate(m_columnPositions[endLine]) - borderLogicalRight();
     1579        } else
     1580            end = m_rowPositions[endLine] - borderBefore();
    15751581
    15761582        // These vectors store line positions including gaps, but we shouldn't consider them for the edges of the grid.
     
    15801586        }
    15811587    }
    1582 
    1583     LayoutUnit alignmentOffset = isRowAxis ? m_columnPositions[0] - borderAndPaddingStart() : m_rowPositions[0] - borderAndPaddingBefore();
    1584     if (isRowAxis && !style().isLeftToRightDirection())
    1585         alignmentOffset = contentLogicalWidth() - (m_columnPositions[m_columnPositions.size() - 1] - borderAndPaddingStart());
    1586 
    1587     if (!startIsAuto)
    1588         start += alignmentOffset;
    1589     if (!endIsAuto)
    1590         end += alignmentOffset;
    15911588
    15921589    breadth = end - start;
     
    16731670    LayoutUnit trackGap = guttersSize(ForColumns, 2);
    16741671    m_columnPositions.resize(numberOfLines);
    1675     m_columnPositions[0] = borderAndPaddingStart() + offset.positionOffset;
     1672    m_columnPositions[0] = borderAndPaddingLogicalLeft() + offset.positionOffset;
    16761673    for (unsigned i = 0; i < nextToLastLine; ++i)
    16771674        m_columnPositions[i + 1] = m_columnPositions[i] + offset.distributionOffset + sizingData.columnTracks[i].baseSize() + trackGap;
     
    20992096    ASSERT(!style().isLeftToRightDirection());
    21002097
    2101     LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
     2098    LayoutUnit alignmentOffset = m_columnPositions[0];
    21022099    LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size() - 1];
    2103     return borderAndPaddingLogicalLeft() + rightGridEdgePosition + alignmentOffset - coordinate;
     2100    return rightGridEdgePosition + alignmentOffset - coordinate;
    21042101}
    21052102
Note: See TracChangeset for help on using the changeset viewer.