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

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

Issue 1824323002: [css-grid] Fix positioned children in RTL direction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use LayoutUnit() instead of LayoutUnit(0) Created 4 years, 9 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 | « third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-sizing-positioned-items-expected.txt ('k') | 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 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 1515
1516 bool startIsAuto = startPosition.isAuto() 1516 bool startIsAuto = startPosition.isAuto()
1517 || (startPosition.isNamedGridArea() && !GridPositionsResolver::isValidNa medLineOrArea(startPosition.namedGridLine(), styleRef(), GridPositionsResolver:: initialPositionSide(direction))) 1517 || (startPosition.isNamedGridArea() && !GridPositionsResolver::isValidNa medLineOrArea(startPosition.namedGridLine(), styleRef(), GridPositionsResolver:: initialPositionSide(direction)))
1518 || (startLine < firstExplicitLine) 1518 || (startLine < firstExplicitLine)
1519 || (startLine > lastExplicitLine); 1519 || (startLine > lastExplicitLine);
1520 bool endIsAuto = endPosition.isAuto() 1520 bool endIsAuto = endPosition.isAuto()
1521 || (endPosition.isNamedGridArea() && !GridPositionsResolver::isValidName dLineOrArea(endPosition.namedGridLine(), styleRef(), GridPositionsResolver::fina lPositionSide(direction))) 1521 || (endPosition.isNamedGridArea() && !GridPositionsResolver::isValidName dLineOrArea(endPosition.namedGridLine(), styleRef(), GridPositionsResolver::fina lPositionSide(direction)))
1522 || (endLine < firstExplicitLine) 1522 || (endLine < firstExplicitLine)
1523 || (endLine > lastExplicitLine); 1523 || (endLine > lastExplicitLine);
1524 1524
1525 LayoutUnit start = startIsAuto ? LayoutUnit() : isForColumns ? m_columnPosi tions[startLine] : m_rowPositions[startLine]; 1525 LayoutUnit start;
1526 LayoutUnit end = endIsAuto ? isForColumns ? logicalWidth() : logicalHeight() : isForColumns ? m_columnPositions[endLine] : m_rowPositions[endLine]; 1526 if (startIsAuto) {
1527 start = LayoutUnit();
1528 } else {
1529 start = isForColumns ? m_columnPositions[startLine] : m_rowPositions[sta rtLine];
1530 start -= isForColumns ? m_columnPositions[0] : m_rowPositions[0];
1531 start += isForColumns ? paddingStart() : paddingBefore();
svillar 2016/03/23 10:43:55 Better than the nested ternary but still difficult
Manuel Rego 2016/03/23 11:20:52 Done.
1532 }
1533
1534 LayoutUnit end;
1535 if (endIsAuto) {
1536 end = isForColumns ? clientLogicalWidth() : clientLogicalHeight();
1537 } else {
1538 end = isForColumns ? m_columnPositions[endLine] : m_rowPositions[endLine ];
1539 end -= isForColumns ? m_columnPositions[0] : m_rowPositions[0];
1540 end += isForColumns ? paddingStart() : paddingBefore();
1541 }
svillar 2016/03/23 10:43:55 Same comment than for the start block
Manuel Rego 2016/03/23 11:20:52 Done.
1527 1542
1528 breadth = end - start; 1543 breadth = end - start;
1544 offset = start;
1529 1545
1530 if (startIsAuto) 1546 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) {
1531 breadth -= isForColumns ? borderStart() : borderBefore(); 1547 // If the child doesn't have a static inline position, we need to calcul ate the offset from the left (even if we're in RTL).
1532 else 1548 if (endIsAuto) {
1533 start -= isForColumns ? borderStart() : borderBefore(); 1549 offset = LayoutUnit();
1534 1550 } else {
1535 if (endIsAuto) { 1551 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddin gStart();
1536 breadth -= isForColumns ? borderEnd() : borderAfter(); 1552 LayoutUnit offsetFromLastLine = m_columnPositions[m_columnPositions. size() - 1] - m_columnPositions[endLine];
1537 breadth -= scrollbarLogicalWidth(); 1553 offset = paddingLeft() + alignmentOffset + offsetFromLastLine;
1554 }
svillar 2016/03/23 10:43:55 I don't get this. This CL is about fixing the beha
Manuel Rego 2016/03/23 11:20:52 I think you're mixing concepts here. Of course th
1538 } 1555 }
1539 1556
1540 offset = start;
1541
1542 if (child.parent() == this && !startIsAuto) { 1557 if (child.parent() == this && !startIsAuto) {
1543 // If column/row start is "auto" the static position has been already se t in prepareChildForPositionedLayout(). 1558 // If column/row start is "auto" the static position has been already se t in prepareChildForPositionedLayout().
1544 PaintLayer* childLayer = child.layer(); 1559 PaintLayer* childLayer = child.layer();
1545 if (isForColumns) 1560 if (isForColumns)
1546 childLayer->setStaticInlinePosition(borderStart() + offset); 1561 childLayer->setStaticInlinePosition(borderStart() + offset);
1547 else 1562 else
1548 childLayer->setStaticBlockPosition(borderBefore() + offset); 1563 childLayer->setStaticBlockPosition(borderBefore() + offset);
1549 } 1564 }
1565
svillar 2016/03/23 10:43:55 Extra line.
Manuel Rego 2016/03/23 11:20:52 Acknowledged.
1550 } 1566 }
1551 1567
1552 GridArea LayoutGrid::cachedGridArea(const LayoutBox& gridItem) const 1568 GridArea LayoutGrid::cachedGridArea(const LayoutBox& gridItem) const
1553 { 1569 {
1554 ASSERT(m_gridItemArea.contains(&gridItem)); 1570 ASSERT(m_gridItemArea.contains(&gridItem));
1555 return m_gridItemArea.get(&gridItem); 1571 return m_gridItemArea.get(&gridItem);
1556 } 1572 }
1557 1573
1558 GridSpan LayoutGrid::cachedGridSpan(const LayoutBox& gridItem, GridTrackSizingDi rection direction) const 1574 GridSpan LayoutGrid::cachedGridSpan(const LayoutBox& gridItem, GridTrackSizingDi rection direction) const
1559 { 1575 {
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 2053
2038 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); 2054 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData ));
2039 } 2055 }
2040 2056
2041 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2057 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2042 { 2058 {
2043 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2059 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2044 } 2060 }
2045 2061
2046 } // namespace blink 2062 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-sizing-positioned-items-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698