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

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

Issue 1838173002: [css-grid] Refactor positioned children code (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 | « 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 // We're normalizing the positions to avoid issues with RTL (as they're stor ed in the same order than LTR but adding an offset).
1526 LayoutUnit end = endIsAuto ? isForColumns ? logicalWidth() : logicalHeight() : isForColumns ? m_columnPositions[endLine] : m_rowPositions[endLine]; 1526 LayoutUnit start;
1527 if (!startIsAuto) {
1528 if (isForColumns)
jfernandez 2016/03/29 12:24:35 I think we must use an isXXAxis terminologym, inst
1529 start = m_columnPositions[startLine] - m_columnPositions[0] + paddin gStart();
1530 else
1531 start = m_rowPositions[startLine] - m_rowPositions[0] + paddingBefor e();
1532 }
1533
1534 LayoutUnit end = isForColumns ? clientLogicalWidth() : clientLogicalHeight() ;
1535 if (!endIsAuto) {
1536 if (isForColumns)
jfernandez 2016/03/29 12:24:35 Ditto
1537 end = m_columnPositions[endLine] - m_columnPositions[0] + paddingSta rt();
1538 else
1539 end = m_rowPositions[endLine] - m_rowPositions[0] + paddingBefore();
1540 }
1527 1541
1528 breadth = end - start; 1542 breadth = end - start;
1529
1530 if (startIsAuto)
1531 breadth -= isForColumns ? borderStart() : borderBefore();
1532 else
1533 start -= isForColumns ? borderStart() : borderBefore();
1534
1535 if (endIsAuto) {
1536 breadth -= isForColumns ? borderEnd() : borderAfter();
1537 breadth -= scrollbarLogicalWidth();
1538 }
1539
1540 offset = start; 1543 offset = start;
1541 1544
1542 if (child.parent() == this && !startIsAuto) { 1545 if (child.parent() == this && !startIsAuto) {
1543 // If column/row start is "auto" the static position has been already se t in prepareChildForPositionedLayout(). 1546 // If column/row start is "auto" the static position has been already se t in prepareChildForPositionedLayout().
1544 PaintLayer* childLayer = child.layer(); 1547 PaintLayer* childLayer = child.layer();
1545 if (isForColumns) 1548 if (isForColumns)
1546 childLayer->setStaticInlinePosition(borderStart() + offset); 1549 childLayer->setStaticInlinePosition(borderStart() + offset);
1547 else 1550 else
1548 childLayer->setStaticBlockPosition(borderBefore() + offset); 1551 childLayer->setStaticBlockPosition(borderBefore() + offset);
1549 } 1552 }
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 2040
2038 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); 2041 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData ));
2039 } 2042 }
2040 2043
2041 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2044 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2042 { 2045 {
2043 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2046 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2044 } 2047 }
2045 2048
2046 } // namespace blink 2049 } // 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