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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 1873163002: [css-grid] Fix painting in RTL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Upload rebased version after r386952 has landed 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutGrid.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
index c289e73157282f2d53cb848b2e832d14ca529527..984d00f8c3eae23edefe228b088db895d240d23c 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -1628,9 +1628,7 @@ void LayoutGrid::offsetAndBreadthForPositionedChild(const LayoutBox& child, Grid
if (endIsAuto) {
offset = LayoutUnit();
} else {
- alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
- LayoutUnit offsetFromLastLine = m_columnPositions[m_columnPositions.size() - 1] - m_columnPositions[endLine];
- offset = paddingLeft() + alignmentOffset + offsetFromLastLine;
+ offset = translateRTLCoordinate(m_columnPositions[endLine]) - borderLeft();
if (endLine > firstExplicitLine && endLine < lastExplicitLine) {
offset += guttersSize(direction, 2);
@@ -2125,16 +2123,22 @@ ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri
return {LayoutUnit(), LayoutUnit()};
}
+LayoutUnit LayoutGrid::translateRTLCoordinate(LayoutUnit coordinate) const
+{
+ ASSERT(!styleRef().isLeftToRightDirection());
+
+ LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
+ LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size() - 1];
+ return borderAndPaddingLogicalLeft() + rightGridEdgePosition + alignmentOffset - coordinate;
+}
+
LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSizingData& sizingData) const
{
LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData);
// We stored m_columnPosition's data ignoring the direction, hence we might need now
// to translate positions from RTL to LTR, as it's more convenient for painting.
- if (!style()->isLeftToRightDirection()) {
- LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
- LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size() - 1] + alignmentOffset + borderAndPaddingLogicalLeft();
- rowAxisOffset = rightGridEdgePosition - (rowAxisOffset + child.logicalWidth());
- }
+ if (!style()->isLeftToRightDirection())
+ rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - child.logicalWidth();
return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData));
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | third_party/WebKit/Source/core/paint/GridPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698