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

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

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutGrid.h ('k') | Source/core/layout/LayoutImage.cpp » ('j') | 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 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/layout/LayoutGrid.h" 27 #include "core/layout/LayoutGrid.h"
28 28
29 #include "core/layout/LayoutView.h" 29 #include "core/layout/LayoutView.h"
30 #include "core/layout/TextAutosizer.h" 30 #include "core/layout/TextAutosizer.h"
31 #include "core/layout/style/GridCoordinate.h" 31 #include "core/layout/style/GridCoordinate.h"
32 #include "core/layout/style/LayoutStyle.h" 32 #include "core/layout/style/ComputedStyle.h"
33 #include "core/paint/DeprecatedPaintLayer.h" 33 #include "core/paint/DeprecatedPaintLayer.h"
34 #include "core/paint/GridPainter.h" 34 #include "core/paint/GridPainter.h"
35 #include "platform/LengthFunctions.h" 35 #include "platform/LengthFunctions.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 static const int infinity = -1; 39 static const int infinity = -1;
40 40
41 class GridTrack { 41 class GridTrack {
42 public: 42 public:
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 LayoutBlock::removeChild(child); 272 LayoutBlock::removeChild(child);
273 273
274 if (gridIsDirty()) 274 if (gridIsDirty())
275 return; 275 return;
276 276
277 // The grid needs to be recomputed as it might contain auto-placed items tha t will change their position. 277 // The grid needs to be recomputed as it might contain auto-placed items tha t will change their position.
278 dirtyGrid(); 278 dirtyGrid();
279 return; 279 return;
280 } 280 }
281 281
282 void LayoutGrid::styleDidChange(StyleDifference diff, const LayoutStyle* oldStyl e) 282 void LayoutGrid::styleDidChange(StyleDifference diff, const ComputedStyle* oldSt yle)
283 { 283 {
284 LayoutBlock::styleDidChange(diff, oldStyle); 284 LayoutBlock::styleDidChange(diff, oldStyle);
285 if (!oldStyle) 285 if (!oldStyle)
286 return; 286 return;
287 287
288 // FIXME: The following checks could be narrowed down if we kept track of wh ich type of grid items we have: 288 // FIXME: The following checks could be narrowed down if we kept track of wh ich type of grid items we have:
289 // - explicit grid size changes impact negative explicitely positioned and a uto-placed grid items. 289 // - explicit grid size changes impact negative explicitely positioned and a uto-placed grid items.
290 // - named grid lines only impact grid items with named grid lines. 290 // - named grid lines only impact grid items with named grid lines.
291 // - auto-flow changes only impacts auto-placed children. 291 // - auto-flow changes only impacts auto-placed children.
292 292
293 if (explicitGridDidResize(*oldStyle) 293 if (explicitGridDidResize(*oldStyle)
294 || namedGridLinesDefinitionDidChange(*oldStyle) 294 || namedGridLinesDefinitionDidChange(*oldStyle)
295 || oldStyle->gridAutoFlow() != styleRef().gridAutoFlow()) 295 || oldStyle->gridAutoFlow() != styleRef().gridAutoFlow())
296 dirtyGrid(); 296 dirtyGrid();
297 } 297 }
298 298
299 bool LayoutGrid::explicitGridDidResize(const LayoutStyle& oldStyle) const 299 bool LayoutGrid::explicitGridDidResize(const ComputedStyle& oldStyle) const
300 { 300 {
301 return oldStyle.gridTemplateColumns().size() != styleRef().gridTemplateColum ns().size() 301 return oldStyle.gridTemplateColumns().size() != styleRef().gridTemplateColum ns().size()
302 || oldStyle.gridTemplateRows().size() != styleRef().gridTemplateRows().s ize(); 302 || oldStyle.gridTemplateRows().size() != styleRef().gridTemplateRows().s ize();
303 } 303 }
304 304
305 bool LayoutGrid::namedGridLinesDefinitionDidChange(const LayoutStyle& oldStyle) const 305 bool LayoutGrid::namedGridLinesDefinitionDidChange(const ComputedStyle& oldStyle ) const
306 { 306 {
307 return oldStyle.namedGridRowLines() != styleRef().namedGridRowLines() 307 return oldStyle.namedGridRowLines() != styleRef().namedGridRowLines()
308 || oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines(); 308 || oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines();
309 } 309 }
310 310
311 void LayoutGrid::layoutBlock(bool relayoutChildren) 311 void LayoutGrid::layoutBlock(bool relayoutChildren)
312 { 312 {
313 ASSERT(needsLayout()); 313 ASSERT(needsLayout());
314 314
315 if (!relayoutChildren && simplifiedLayout()) 315 if (!relayoutChildren && simplifiedLayout())
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 // FIXME: This might not work as expected with orthogonal writing-modes. 1368 // FIXME: This might not work as expected with orthogonal writing-modes.
1369 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica lWidth() + child.marginLogicalWidth()); 1369 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica lWidth() + child.marginLogicalWidth());
1370 1370
1371 return columnPosition + offsetFromColumnPosition / 2; 1371 return columnPosition + offsetFromColumnPosition / 2;
1372 } 1372 }
1373 1373
1374 LayoutUnit LayoutGrid::columnPositionForChild(const LayoutBox& child) const 1374 LayoutUnit LayoutGrid::columnPositionForChild(const LayoutBox& child) const
1375 { 1375 {
1376 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1376 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1377 1377
1378 switch (LayoutStyle::resolveJustification(styleRef(), child.styleRef(), Item PositionStretch)) { 1378 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It emPositionStretch)) {
1379 case ItemPositionSelfStart: 1379 case ItemPositionSelfStart:
1380 // For orthogonal writing-modes, this computes to 'start' 1380 // For orthogonal writing-modes, this computes to 'start'
1381 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1381 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1382 if (hasOrthogonalWritingMode) 1382 if (hasOrthogonalWritingMode)
1383 return startOfColumnForChild(child); 1383 return startOfColumnForChild(child);
1384 1384
1385 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction. 1385 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction.
1386 if (child.style()->direction() != style()->direction()) 1386 if (child.style()->direction() != style()->direction())
1387 return endOfColumnForChild(child); 1387 return endOfColumnForChild(child);
1388 1388
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 } 1473 }
1474 1474
1475 bool LayoutGrid::allowedToStretchLogicalHeightForChild(const LayoutBox& child) c onst 1475 bool LayoutGrid::allowedToStretchLogicalHeightForChild(const LayoutBox& child) c onst
1476 { 1476 {
1477 return child.style()->logicalHeight().isAuto() && !child.style()->marginBefo reUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); 1477 return child.style()->logicalHeight().isAuto() && !child.style()->marginBefo reUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto();
1478 } 1478 }
1479 1479
1480 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1480 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1481 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const 1481 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const
1482 { 1482 {
1483 if (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosition Stretch) != ItemPositionStretch) 1483 if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositi onStretch) != ItemPositionStretch)
1484 return false; 1484 return false;
1485 1485
1486 return isHorizontalWritingMode() && child.style()->height().isAuto(); 1486 return isHorizontalWritingMode() && child.style()->height().isAuto();
1487 } 1487 }
1488 1488
1489 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1489 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1490 LayoutUnit LayoutGrid::childIntrinsicHeight(const LayoutBox& child) const 1490 LayoutUnit LayoutGrid::childIntrinsicHeight(const LayoutBox& child) const
1491 { 1491 {
1492 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child )) 1492 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child ))
1493 return constrainedChildIntrinsicContentLogicalHeight(child); 1493 return constrainedChildIntrinsicContentLogicalHeight(child);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 // compute margins in order to determine the available height before stretch ing. 1537 // compute margins in order to determine the available height before stretch ing.
1538 if (childMarginLogicalHeight == 0) 1538 if (childMarginLogicalHeight == 0)
1539 childMarginLogicalHeight = computeMarginLogicalHeightForChild(child); 1539 childMarginLogicalHeight = computeMarginLogicalHeightForChild(child);
1540 1540
1541 return gridAreaBreadthForChild - childMarginLogicalHeight; 1541 return gridAreaBreadthForChild - childMarginLogicalHeight;
1542 } 1542 }
1543 1543
1544 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1544 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1545 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUn it gridAreaBreadthForChild) 1545 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUn it gridAreaBreadthForChild)
1546 { 1546 {
1547 if (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosition Stretch) != ItemPositionStretch) 1547 if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositi onStretch) != ItemPositionStretch)
1548 return; 1548 return;
1549 1549
1550 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1550 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1551 if (allowedToStretchLogicalHeightForChild(child)) { 1551 if (allowedToStretchLogicalHeightForChild(child)) {
1552 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it. 1552 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it.
1553 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1553 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1554 if (!hasOrthogonalWritingMode) { 1554 if (!hasOrthogonalWritingMode) {
1555 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(gridAreaBreadthForChild, child); 1555 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(gridAreaBreadthForChild, child);
1556 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, -1); 1556 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, -1);
1557 1557
1558 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905. 1558 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905.
1559 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeigh t(); 1559 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeigh t();
1560 if (childNeedsRelayout || !child.hasOverrideHeight()) 1560 if (childNeedsRelayout || !child.hasOverrideHeight())
1561 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi ld.borderAndPaddingLogicalHeight()); 1561 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi ld.borderAndPaddingLogicalHeight());
1562 if (childNeedsRelayout) { 1562 if (childNeedsRelayout) {
1563 child.setLogicalHeight(0); 1563 child.setLogicalHeight(0);
1564 child.setNeedsLayout(); 1564 child.setNeedsLayout();
1565 } 1565 }
1566 } 1566 }
1567 } 1567 }
1568 } 1568 }
1569 1569
1570 LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const 1570 LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const
1571 { 1571 {
1572 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1572 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1573 switch (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosi tionStretch)) { 1573 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) {
1574 case ItemPositionSelfStart: 1574 case ItemPositionSelfStart:
1575 // If orthogonal writing-modes, this computes to 'start'. 1575 // If orthogonal writing-modes, this computes to 'start'.
1576 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1576 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1577 if (hasOrthogonalWritingMode) 1577 if (hasOrthogonalWritingMode)
1578 return startOfRowForChild(child); 1578 return startOfRowForChild(child);
1579 1579
1580 // self-start is based on the child's block axis direction. That's why w e need to check against the grid container's block flow. 1580 // self-start is based on the child's block axis direction. That's why w e need to check against the grid container's block flow.
1581 if (child.style()->writingMode() != style()->writingMode()) 1581 if (child.style()->writingMode() != style()->writingMode())
1582 return endOfRowForChild(child); 1582 return endOfRowForChild(child);
1583 1583
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 if (isFloating()) 1767 if (isFloating())
1768 return "LayoutGrid (floating)"; 1768 return "LayoutGrid (floating)";
1769 if (isAnonymous()) 1769 if (isAnonymous())
1770 return "LayoutGrid (anonymous)"; 1770 return "LayoutGrid (anonymous)";
1771 if (isRelPositioned()) 1771 if (isRelPositioned())
1772 return "LayoutGrid (relative positioned)"; 1772 return "LayoutGrid (relative positioned)";
1773 return "LayoutGrid"; 1773 return "LayoutGrid";
1774 } 1774 }
1775 1775
1776 } // namespace blink 1776 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutGrid.h ('k') | Source/core/layout/LayoutImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698