OLD | NEW |
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 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 // If we overflow our alignment container and overflow is 'true' | 1476 // If we overflow our alignment container and overflow is 'true' |
1477 // (default), we ignore the overflow and just return the value regardless | 1477 // (default), we ignore the overflow and just return the value regardless |
1478 // (which may cause data loss as we overflow the 'start' edge). | 1478 // (which may cause data loss as we overflow the 'start' edge). |
1479 return offset; | 1479 return offset; |
1480 } | 1480 } |
1481 | 1481 |
1482 NOTREACHED(); | 1482 NOTREACHED(); |
1483 return LayoutUnit(); | 1483 return LayoutUnit(); |
1484 } | 1484 } |
1485 | 1485 |
1486 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to | 1486 LayoutUnit LayoutGrid::MarginLogicalSizeForChild( |
1487 // LayoutBox. | 1487 GridTrackSizingDirection direction, |
1488 LayoutUnit LayoutGrid::MarginLogicalHeightForChild( | |
1489 const LayoutBox& child) const { | 1488 const LayoutBox& child) const { |
1490 return IsHorizontalWritingMode() ? child.MarginHeight() : child.MarginWidth(); | 1489 return FlowAwareDirectionForChild(child, direction) == kForColumns |
| 1490 ? child.MarginLogicalWidth() |
| 1491 : child.MarginLogicalHeight(); |
1491 } | 1492 } |
1492 | 1493 |
1493 LayoutUnit LayoutGrid::ComputeMarginLogicalSizeForChild( | 1494 LayoutUnit LayoutGrid::ComputeMarginLogicalSizeForChild( |
1494 MarginDirection for_direction, | 1495 MarginDirection for_direction, |
1495 const LayoutBox& child) const { | 1496 const LayoutBox& child) const { |
1496 if (!child.StyleRef().HasMargin()) | 1497 if (!child.StyleRef().HasMargin()) |
1497 return LayoutUnit(); | 1498 return LayoutUnit(); |
1498 | 1499 |
1499 bool is_row_axis = for_direction == kInlineDirection; | 1500 bool is_row_axis = for_direction == kInlineDirection; |
1500 LayoutUnit margin_start; | 1501 LayoutUnit margin_start; |
(...skipping 12 matching lines...) Expand all Loading... |
1513 return margin_start + margin_end; | 1514 return margin_start + margin_end; |
1514 } | 1515 } |
1515 | 1516 |
1516 LayoutUnit LayoutGrid::AvailableAlignmentSpaceForChildBeforeStretching( | 1517 LayoutUnit LayoutGrid::AvailableAlignmentSpaceForChildBeforeStretching( |
1517 LayoutUnit grid_area_breadth_for_child, | 1518 LayoutUnit grid_area_breadth_for_child, |
1518 const LayoutBox& child) const { | 1519 const LayoutBox& child) const { |
1519 // Because we want to avoid multiple layouts, stretching logic might be | 1520 // Because we want to avoid multiple layouts, stretching logic might be |
1520 // performed before children are laid out, so we can't use the child cached | 1521 // performed before children are laid out, so we can't use the child cached |
1521 // values. Hence, we need to compute margins in order to determine the | 1522 // values. Hence, we need to compute margins in order to determine the |
1522 // available height before stretching. | 1523 // available height before stretching. |
| 1524 GridTrackSizingDirection child_block_flow_direction = |
| 1525 FlowAwareDirectionForChild(child, kForRows); |
1523 return grid_area_breadth_for_child - | 1526 return grid_area_breadth_for_child - |
1524 (child.NeedsLayout() | 1527 (child.NeedsLayout() |
1525 ? ComputeMarginLogicalSizeForChild(kBlockDirection, child) | 1528 ? ComputeMarginLogicalSizeForChild(kBlockDirection, child) |
1526 : MarginLogicalHeightForChild(child)); | 1529 : MarginLogicalSizeForChild(child_block_flow_direction, child)); |
1527 } | 1530 } |
1528 | 1531 |
1529 StyleSelfAlignmentData LayoutGrid::AlignSelfForChild( | 1532 StyleSelfAlignmentData LayoutGrid::AlignSelfForChild( |
1530 const LayoutBox& child) const { | 1533 const LayoutBox& child) const { |
1531 if (!child.IsAnonymous()) { | 1534 if (!child.IsAnonymous()) { |
1532 return child.StyleRef().ResolvedAlignSelf( | 1535 return child.StyleRef().ResolvedAlignSelf( |
1533 SelfAlignmentNormalBehavior(&child)); | 1536 SelfAlignmentNormalBehavior(&child)); |
1534 } | 1537 } |
1535 // All the 'auto' values has been solved by the StyleAdjuster, but it's | 1538 // All the 'auto' values has been solved by the StyleAdjuster, but it's |
1536 // possible that some grid items generate Anonymous boxes, which need to be | 1539 // possible that some grid items generate Anonymous boxes, which need to be |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 if (direction == kForRows) | 2391 if (direction == kForRows) |
2389 return grid.NumTracks(kForRows); | 2392 return grid.NumTracks(kForRows); |
2390 | 2393 |
2391 return grid.NumTracks(kForRows) | 2394 return grid.NumTracks(kForRows) |
2392 ? grid.NumTracks(kForColumns) | 2395 ? grid.NumTracks(kForColumns) |
2393 : GridPositionsResolver::ExplicitGridColumnCount( | 2396 : GridPositionsResolver::ExplicitGridColumnCount( |
2394 StyleRef(), grid.AutoRepeatTracks(kForColumns)); | 2397 StyleRef(), grid.AutoRepeatTracks(kForColumns)); |
2395 } | 2398 } |
2396 | 2399 |
2397 } // namespace blink | 2400 } // namespace blink |
OLD | NEW |