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

Side by Side 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 unified diff | Download patch
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 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 1621
1622 breadth = end - start; 1622 breadth = end - start;
1623 offset = start; 1623 offset = start;
1624 1624
1625 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) { 1625 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) {
1626 // If the child doesn't have a static inline position (i.e. "left" and/o r "right" aren't "auto", 1626 // If the child doesn't have a static inline position (i.e. "left" and/o r "right" aren't "auto",
1627 // we need to calculate the offset from the left (even if we're in RTL). 1627 // we need to calculate the offset from the left (even if we're in RTL).
1628 if (endIsAuto) { 1628 if (endIsAuto) {
1629 offset = LayoutUnit(); 1629 offset = LayoutUnit();
1630 } else { 1630 } else {
1631 alignmentOffset = m_columnPositions[0] - borderAndPaddingStart(); 1631 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border Left();
1632 LayoutUnit offsetFromLastLine = m_columnPositions[m_columnPositions. size() - 1] - m_columnPositions[endLine];
1633 offset = paddingLeft() + alignmentOffset + offsetFromLastLine;
1634 1632
1635 if (endLine > firstExplicitLine && endLine < lastExplicitLine) { 1633 if (endLine > firstExplicitLine && endLine < lastExplicitLine) {
1636 offset += guttersSize(direction, 2); 1634 offset += guttersSize(direction, 2);
1637 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetwee nRows; 1635 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetwee nRows;
1638 } 1636 }
1639 } 1637 }
1640 } 1638 }
1641 1639
1642 if (child.parent() == this && !startIsAuto) { 1640 if (child.parent() == this && !startIsAuto) {
1643 // If column/row start is "auto" the static position has been already se t in prepareChildForPositionedLayout(). 1641 // If column/row start is "auto" the static position has been already se t in prepareChildForPositionedLayout().
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 return {styleRef().isLeftToRightDirection() ? LayoutUnit() : availab leFreeSpace, LayoutUnit()}; 2116 return {styleRef().isLeftToRightDirection() ? LayoutUnit() : availab leFreeSpace, LayoutUnit()};
2119 return {LayoutUnit(), LayoutUnit()}; 2117 return {LayoutUnit(), LayoutUnit()};
2120 case ContentPositionNormal: 2118 case ContentPositionNormal:
2121 break; 2119 break;
2122 } 2120 }
2123 2121
2124 ASSERT_NOT_REACHED(); 2122 ASSERT_NOT_REACHED();
2125 return {LayoutUnit(), LayoutUnit()}; 2123 return {LayoutUnit(), LayoutUnit()};
2126 } 2124 }
2127 2125
2126 LayoutUnit LayoutGrid::translateRTLCoordinate(LayoutUnit coordinate) const
2127 {
2128 ASSERT(!styleRef().isLeftToRightDirection());
2129
2130 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
2131 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size( ) - 1];
2132 return borderAndPaddingLogicalLeft() + rightGridEdgePosition + alignmentOffs et - coordinate;
2133 }
2134
2128 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz ingData& sizingData) const 2135 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz ingData& sizingData) const
2129 { 2136 {
2130 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData); 2137 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData);
2131 // We stored m_columnPosition's data ignoring the direction, hence we might need now 2138 // We stored m_columnPosition's data ignoring the direction, hence we might need now
2132 // to translate positions from RTL to LTR, as it's more convenient for paint ing. 2139 // to translate positions from RTL to LTR, as it's more convenient for paint ing.
2133 if (!style()->isLeftToRightDirection()) { 2140 if (!style()->isLeftToRightDirection())
2134 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingSta rt(); 2141 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - child.logicalWid th();
2135 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.s ize() - 1] + alignmentOffset + borderAndPaddingLogicalLeft();
2136 rowAxisOffset = rightGridEdgePosition - (rowAxisOffset + child.logicalWi dth());
2137 }
2138 2142
2139 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); 2143 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData ));
2140 } 2144 }
2141 2145
2142 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2146 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2143 { 2147 {
2144 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2148 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2145 } 2149 }
2146 2150
2147 } // namespace blink 2151 } // namespace blink
OLDNEW
« 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