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

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: Created 6 years, 3 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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/rendering/RenderGrid.h" 27 #include "core/rendering/RenderGrid.h"
28 28
29 #include "core/css/resolver/StyleAdjuster.h"
29 #include "core/rendering/RenderLayer.h" 30 #include "core/rendering/RenderLayer.h"
30 #include "core/rendering/RenderView.h" 31 #include "core/rendering/RenderView.h"
31 #include "core/rendering/TextAutosizer.h" 32 #include "core/rendering/TextAutosizer.h"
32 #include "core/rendering/style/GridCoordinate.h" 33 #include "core/rendering/style/GridCoordinate.h"
33 #include "platform/LengthFunctions.h" 34 #include "platform/LengthFunctions.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 static const int infinity = -1; 38 static const int infinity = -1;
38 39
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1278 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1278 1279
1279 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. 1280 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1280 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()] + marginBeforeForChild(child); 1281 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()] + marginBeforeForChild(child);
1281 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()]; 1282 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()];
1282 1283
1283 // FIXME: This should account for the grid item's <overflow-position>. 1284 // FIXME: This should account for the grid item's <overflow-position>.
1284 return startOfRow + std::max<LayoutUnit>(0, endOfRow - startOfRow - child->l ogicalHeight()) / 2; 1285 return startOfRow + std::max<LayoutUnit>(0, endOfRow - startOfRow - child->l ogicalHeight()) / 2;
1285 } 1286 }
1286 1287
1287 // FIXME: We should move this logic to the StyleAdjuster or the StyleBuilder.
1288 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende rStyle* childStyle)
1289 {
1290 ItemPosition align = childStyle->alignSelf();
1291 // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto".
1292 if (align == ItemPositionAuto)
1293 align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt retch : parentStyle->alignItems();
1294 return align;
1295 }
1296
1297 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox* child) const 1288 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox* child) const
1298 { 1289 {
1299 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo ntalWritingMode(); 1290 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo ntalWritingMode();
1300 ItemPosition alignSelf = resolveAlignment(style(), child->style()); 1291 ItemPosition alignSelf = StyleAdjuster::resolveAlignment(style(), child->sty le());
esprehn 2014/09/09 10:10:51 This is backwards, the StyleAdjuster should call s
Sunil Ratnu 2014/09/09 10:33:08 Thanks esprehn for review. Maybe not in StyleAdjus
1301 1292
1302 switch (alignSelf) { 1293 switch (alignSelf) {
1303 case ItemPositionSelfStart: 1294 case ItemPositionSelfStart:
1304 // If orthogonal writing-modes, this computes to 'Start'. 1295 // If orthogonal writing-modes, this computes to 'Start'.
1305 // FIXME: grid track sizing and positioning does not support orthogonal modes yet. 1296 // FIXME: grid track sizing and positioning does not support orthogonal modes yet.
1306 if (hasOrthogonalWritingMode) 1297 if (hasOrthogonalWritingMode)
1307 return startOfRowForChild(child); 1298 return startOfRowForChild(child);
1308 1299
1309 // 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. 1300 // 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.
1310 if (child->style()->writingMode() != style()->writingMode()) 1301 if (child->style()->writingMode() != style()->writingMode())
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 if (isOutOfFlowPositioned()) 1438 if (isOutOfFlowPositioned())
1448 return "RenderGrid (positioned)"; 1439 return "RenderGrid (positioned)";
1449 if (isAnonymous()) 1440 if (isAnonymous())
1450 return "RenderGrid (generated)"; 1441 return "RenderGrid (generated)";
1451 if (isRelPositioned()) 1442 if (isRelPositioned())
1452 return "RenderGrid (relative positioned)"; 1443 return "RenderGrid (relative positioned)";
1453 return "RenderGrid"; 1444 return "RenderGrid";
1454 } 1445 }
1455 1446
1456 } // namespace blink 1447 } // namespace blink
OLDNEW
« Source/core/css/resolver/StyleAdjuster.cpp ('K') | « Source/core/rendering/RenderFlexibleBox.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698