Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 1915903002: [css-grid] Refactor information stored related to column positions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 else 1607 else
1608 end = m_rowPositions[endLine] - m_rowPositions[0] + paddingBefore(); 1608 end = m_rowPositions[endLine] - m_rowPositions[0] + paddingBefore();
1609 1609
1610 // These vectors store line positions including gaps, but we shouldn't c onsider them for the edges of the grid. 1610 // These vectors store line positions including gaps, but we shouldn't c onsider them for the edges of the grid.
1611 if (endLine > firstExplicitLine && endLine < lastExplicitLine) { 1611 if (endLine > firstExplicitLine && endLine < lastExplicitLine) {
1612 end -= guttersSize(direction, 2); 1612 end -= guttersSize(direction, 2);
1613 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; 1613 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows;
1614 } 1614 }
1615 } 1615 }
1616 1616
1617 LayoutUnit alignmentOffset = isForColumns ? m_columnPositions[0] - borderAnd PaddingStart() : m_rowPositions[0] - borderAndPaddingBefore(); 1617 LayoutUnit alignmentOffset = isForColumns ? m_columnPositions[0] - borderAnd PaddingLogicalLeft() : m_rowPositions[0] - borderAndPaddingBefore();
1618 if (isForColumns && !styleRef().isLeftToRightDirection()) 1618 if (isForColumns && !styleRef().isLeftToRightDirection())
1619 alignmentOffset = contentLogicalWidth() - (m_columnPositions[m_columnPos itions.size() - 1] - borderAndPaddingStart()); 1619 alignmentOffset = contentLogicalWidth() - (m_columnPositions[m_columnPos itions.size() - 1] - borderAndPaddingLogicalLeft());
1620 1620
1621 if (!startIsAuto) 1621 if (!startIsAuto)
1622 start += alignmentOffset; 1622 start += alignmentOffset;
1623 if (!endIsAuto) 1623 if (!endIsAuto)
1624 end += alignmentOffset; 1624 end += alignmentOffset;
1625 1625
1626 breadth = end - start; 1626 breadth = end - start;
1627 offset = start; 1627 offset = start;
1628 1628
1629 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) { 1629 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 // The grid container's frame elements (border, padding and <content-positio n> offset) are sensible to the 1698 // The grid container's frame elements (border, padding and <content-positio n> offset) are sensible to the
1699 // inline-axis flow direction. However, column lines positions are 'directio n' unaware. This simplification 1699 // inline-axis flow direction. However, column lines positions are 'directio n' unaware. This simplification
1700 // allows us to use the same indexes to identify the columns independently o n the inline-axis direction. 1700 // allows us to use the same indexes to identify the columns independently o n the inline-axis direction.
1701 unsigned numberOfTracks = sizingData.columnTracks.size(); 1701 unsigned numberOfTracks = sizingData.columnTracks.size();
1702 unsigned numberOfLines = numberOfTracks + 1; 1702 unsigned numberOfLines = numberOfTracks + 1;
1703 unsigned lastLine = numberOfLines - 1; 1703 unsigned lastLine = numberOfLines - 1;
1704 unsigned nextToLastLine = numberOfLines - 2; 1704 unsigned nextToLastLine = numberOfLines - 2;
1705 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(Fo rColumns, sizingData.freeSpaceForDirection(ForColumns), numberOfTracks); 1705 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(Fo rColumns, sizingData.freeSpaceForDirection(ForColumns), numberOfTracks);
1706 LayoutUnit trackGap = guttersSize(ForColumns, 2); 1706 LayoutUnit trackGap = guttersSize(ForColumns, 2);
1707 m_columnPositions.resize(numberOfLines); 1707 m_columnPositions.resize(numberOfLines);
1708 m_columnPositions[0] = borderAndPaddingStart() + offset.positionOffset; 1708 m_columnPositions[0] = borderAndPaddingLogicalLeft() + offset.positionOffset ;
1709 for (unsigned i = 0; i < nextToLastLine; ++i) 1709 for (unsigned i = 0; i < nextToLastLine; ++i)
1710 m_columnPositions[i + 1] = m_columnPositions[i] + offset.distributionOff set + sizingData.columnTracks[i].baseSize() + trackGap; 1710 m_columnPositions[i + 1] = m_columnPositions[i] + offset.distributionOff set + sizingData.columnTracks[i].baseSize() + trackGap;
1711 m_columnPositions[lastLine] = m_columnPositions[nextToLastLine] + sizingData .columnTracks[nextToLastLine].baseSize(); 1711 m_columnPositions[lastLine] = m_columnPositions[nextToLastLine] + sizingData .columnTracks[nextToLastLine].baseSize();
1712 m_offsetBetweenColumns = offset.distributionOffset; 1712 m_offsetBetweenColumns = offset.distributionOffset;
1713 1713
1714 numberOfTracks = sizingData.rowTracks.size(); 1714 numberOfTracks = sizingData.rowTracks.size();
1715 numberOfLines = numberOfTracks + 1; 1715 numberOfLines = numberOfTracks + 1;
1716 lastLine = numberOfLines - 1; 1716 lastLine = numberOfLines - 1;
1717 nextToLastLine = numberOfLines - 2; 1717 nextToLastLine = numberOfLines - 2;
1718 offset = computeContentPositionAndDistributionOffset(ForRows, sizingData.fre eSpaceForDirection(ForRows), numberOfTracks); 1718 offset = computeContentPositionAndDistributionOffset(ForRows, sizingData.fre eSpaceForDirection(ForRows), numberOfTracks);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 } 2118 }
2119 2119
2120 ASSERT_NOT_REACHED(); 2120 ASSERT_NOT_REACHED();
2121 return {LayoutUnit(), LayoutUnit()}; 2121 return {LayoutUnit(), LayoutUnit()};
2122 } 2122 }
2123 2123
2124 LayoutUnit LayoutGrid::translateRTLCoordinate(LayoutUnit coordinate) const 2124 LayoutUnit LayoutGrid::translateRTLCoordinate(LayoutUnit coordinate) const
2125 { 2125 {
2126 ASSERT(!styleRef().isLeftToRightDirection()); 2126 ASSERT(!styleRef().isLeftToRightDirection());
2127 2127
2128 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart(); 2128 LayoutUnit alignmentOffset = m_columnPositions[0];
2129 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size( ) - 1]; 2129 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size( ) - 1];
2130 return borderAndPaddingLogicalLeft() + rightGridEdgePosition + alignmentOffs et - coordinate; 2130 return rightGridEdgePosition + alignmentOffset - coordinate;
2131 } 2131 }
2132 2132
2133 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz ingData& sizingData) const 2133 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz ingData& sizingData) const
2134 { 2134 {
2135 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData); 2135 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData);
2136 // We stored m_columnPosition's data ignoring the direction, hence we might need now 2136 // We stored m_columnPosition's data ignoring the direction, hence we might need now
2137 // to translate positions from RTL to LTR, as it's more convenient for paint ing. 2137 // to translate positions from RTL to LTR, as it's more convenient for paint ing.
2138 if (!style()->isLeftToRightDirection()) 2138 if (!style()->isLeftToRightDirection())
2139 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - child.logicalWid th(); 2139 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - child.logicalWid th();
2140 2140
2141 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); 2141 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData ));
2142 } 2142 }
2143 2143
2144 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2144 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2145 { 2145 {
2146 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2146 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2147 } 2147 }
2148 2148
2149 } // namespace blink 2149 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698