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

Side by Side Diff: Source/core/rendering/RenderGrid.cpp

Issue 547673002: Move resolveAlignment logic to RenderStyle (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 2 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 | « Source/core/rendering/RenderFlexibleBox.cpp ('k') | Source/core/rendering/style/RenderStyle.h » ('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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/rendering/RenderGrid.h" 27 #include "core/rendering/RenderGrid.h"
28 28
29 #include "core/paint/GridPainter.h" 29 #include "core/paint/GridPainter.h"
30 #include "core/rendering/RenderLayer.h" 30 #include "core/rendering/RenderLayer.h"
31 #include "core/rendering/RenderView.h" 31 #include "core/rendering/RenderView.h"
32 #include "core/rendering/TextAutosizer.h" 32 #include "core/rendering/TextAutosizer.h"
33 #include "core/rendering/style/GridCoordinate.h" 33 #include "core/rendering/style/GridCoordinate.h"
34 #include "core/rendering/style/RenderStyle.h"
34 #include "platform/LengthFunctions.h" 35 #include "platform/LengthFunctions.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 static const int infinity = -1; 39 static const int infinity = -1;
39 40
40 class GridTrack { 41 class GridTrack {
41 public: 42 public:
42 GridTrack() 43 GridTrack()
43 : m_usedBreadth(0) 44 : m_usedBreadth(0)
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1285 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1285 1286
1286 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. 1287 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1287 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()] + marginBeforeForChild(&child); 1288 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()] + marginBeforeForChild(&child);
1288 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()]; 1289 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()];
1289 1290
1290 // FIXME: This should account for the grid item's <overflow-position>. 1291 // FIXME: This should account for the grid item's <overflow-position>.
1291 return startOfRow + std::max<LayoutUnit>(0, endOfRow - startOfRow - child.lo gicalHeight()) / 2; 1292 return startOfRow + std::max<LayoutUnit>(0, endOfRow - startOfRow - child.lo gicalHeight()) / 2;
1292 } 1293 }
1293 1294
1294 // FIXME: We should move this logic to the StyleAdjuster or the StyleBuilder.
1295 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende rStyle* childStyle)
1296 {
1297 ItemPosition align = childStyle->alignSelf();
1298 // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto".
1299 if (align == ItemPositionAuto)
1300 align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt retch : parentStyle->alignItems();
1301 return align;
1302 }
1303
1304 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox& child) const 1295 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox& child) const
1305 { 1296 {
1306 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1297 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1307 ItemPosition alignSelf = resolveAlignment(style(), child.style()); 1298 ItemPosition alignSelf = RenderStyle::resolveAlignment(style(), child.style( ));
1308 1299
1309 switch (alignSelf) { 1300 switch (alignSelf) {
1310 case ItemPositionSelfStart: 1301 case ItemPositionSelfStart:
1311 // If orthogonal writing-modes, this computes to 'Start'. 1302 // If orthogonal writing-modes, this computes to 'Start'.
1312 // FIXME: grid track sizing and positioning does not support orthogonal modes yet. 1303 // FIXME: grid track sizing and positioning does not support orthogonal modes yet.
1313 if (hasOrthogonalWritingMode) 1304 if (hasOrthogonalWritingMode)
1314 return startOfRowForChild(child); 1305 return startOfRowForChild(child);
1315 1306
1316 // 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. 1307 // 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.
1317 if (child.style()->writingMode() != style()->writingMode()) 1308 if (child.style()->writingMode() != style()->writingMode())
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 if (isOutOfFlowPositioned()) 1381 if (isOutOfFlowPositioned())
1391 return "RenderGrid (positioned)"; 1382 return "RenderGrid (positioned)";
1392 if (isAnonymous()) 1383 if (isAnonymous())
1393 return "RenderGrid (generated)"; 1384 return "RenderGrid (generated)";
1394 if (isRelPositioned()) 1385 if (isRelPositioned())
1395 return "RenderGrid (relative positioned)"; 1386 return "RenderGrid (relative positioned)";
1396 return "RenderGrid"; 1387 return "RenderGrid";
1397 } 1388 }
1398 1389
1399 } // namespace blink 1390 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderFlexibleBox.cpp ('k') | Source/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698