Index: third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
index a3d2251f604ddcf99a55b211e97605c555f5ae2a..7fc73fa0fb4ad9c87f35d65e03aabf709f273ee8 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
@@ -1483,11 +1483,12 @@ static LayoutUnit ComputeOverflowAlignmentOffset(OverflowAlignment overflow, |
return LayoutUnit(); |
} |
-// FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to |
-// LayoutBox. |
-LayoutUnit LayoutGrid::MarginLogicalHeightForChild( |
+LayoutUnit LayoutGrid::MarginLogicalSizeForChild( |
+ GridTrackSizingDirection direction, |
const LayoutBox& child) const { |
- return IsHorizontalWritingMode() ? child.MarginHeight() : child.MarginWidth(); |
+ return FlowAwareDirectionForChild(child, direction) == kForColumns |
+ ? child.MarginLogicalWidth() |
+ : child.MarginLogicalHeight(); |
} |
LayoutUnit LayoutGrid::ComputeMarginLogicalSizeForChild( |
@@ -1520,10 +1521,12 @@ LayoutUnit LayoutGrid::AvailableAlignmentSpaceForChildBeforeStretching( |
// performed before children are laid out, so we can't use the child cached |
// values. Hence, we need to compute margins in order to determine the |
// available height before stretching. |
+ GridTrackSizingDirection child_block_flow_direction = |
+ FlowAwareDirectionForChild(child, kForRows); |
return grid_area_breadth_for_child - |
(child.NeedsLayout() |
? ComputeMarginLogicalSizeForChild(kBlockDirection, child) |
- : MarginLogicalHeightForChild(child)); |
+ : MarginLogicalSizeForChild(child_block_flow_direction, child)); |
} |
StyleSelfAlignmentData LayoutGrid::AlignSelfForChild( |