OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 return flex_direction == | 318 return flex_direction == |
319 (Style()->IsLeftToRightDirection() ? kFlowRowReverse : kFlowRow); | 319 (Style()->IsLeftToRightDirection() ? kFlowRowReverse : kFlowRow); |
320 return flex_direction == kFlowColumnReverse; | 320 return flex_direction == kFlowColumnReverse; |
321 } | 321 } |
322 | 322 |
323 void LayoutFlexibleBox::RemoveChild(LayoutObject* child) { | 323 void LayoutFlexibleBox::RemoveChild(LayoutObject* child) { |
324 LayoutBlock::RemoveChild(child); | 324 LayoutBlock::RemoveChild(child); |
325 intrinsic_size_along_main_axis_.erase(child); | 325 intrinsic_size_along_main_axis_.erase(child); |
326 } | 326 } |
327 | 327 |
328 // TODO (lajava): Is this function still needed ? Every time the flex | |
329 // container's align-items value changes we propagate the diff to its children | |
330 // (see ComputedStyle::stylePropagationDiff). | |
331 void LayoutFlexibleBox::StyleDidChange(StyleDifference diff, | 328 void LayoutFlexibleBox::StyleDidChange(StyleDifference diff, |
332 const ComputedStyle* old_style) { | 329 const ComputedStyle* old_style) { |
333 LayoutBlock::StyleDidChange(diff, old_style); | 330 LayoutBlock::StyleDidChange(diff, old_style); |
334 | 331 |
335 if (old_style && old_style->AlignItemsPosition() == kItemPositionStretch && | 332 if (old_style && |
| 333 old_style->ResolvedAlignItems(SelfAlignmentNormalBehavior()) |
| 334 .GetPosition() == kItemPositionStretch && |
336 diff.NeedsFullLayout()) { | 335 diff.NeedsFullLayout()) { |
337 // Flex items that were previously stretching need to be relayed out so we | 336 // Flex items that were previously stretching need to be relayed out so we |
338 // can compute new available cross axis space. This is only necessary for | 337 // can compute new available cross axis space. This is only necessary for |
339 // stretching since other alignment values don't change the size of the | 338 // stretching since other alignment values don't change the size of the |
340 // box. | 339 // box. |
341 for (LayoutBox* child = FirstChildBox(); child; | 340 for (LayoutBox* child = FirstChildBox(); child; |
342 child = child->NextSiblingBox()) { | 341 child = child->NextSiblingBox()) { |
343 ItemPosition previous_alignment = | 342 ItemPosition previous_alignment = |
344 child->StyleRef() | 343 child->StyleRef() |
345 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), old_style) | 344 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), old_style) |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 if (child.Style()->HasStaticBlockPosition( | 1690 if (child.Style()->HasStaticBlockPosition( |
1692 Style()->IsHorizontalWritingMode())) | 1691 Style()->IsHorizontalWritingMode())) |
1693 child.SetChildNeedsLayout(kMarkOnlyThis); | 1692 child.SetChildNeedsLayout(kMarkOnlyThis); |
1694 } | 1693 } |
1695 } | 1694 } |
1696 | 1695 |
1697 ItemPosition LayoutFlexibleBox::AlignmentForChild( | 1696 ItemPosition LayoutFlexibleBox::AlignmentForChild( |
1698 const LayoutBox& child) const { | 1697 const LayoutBox& child) const { |
1699 ItemPosition align = | 1698 ItemPosition align = |
1700 child.StyleRef() | 1699 child.StyleRef() |
1701 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), | 1700 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), Style()) |
1702 child.IsAnonymous() ? Style() : nullptr) | |
1703 .GetPosition(); | 1701 .GetPosition(); |
1704 DCHECK_NE(align, kItemPositionAuto); | 1702 DCHECK_NE(align, kItemPositionAuto); |
1705 DCHECK_NE(align, kItemPositionNormal); | 1703 DCHECK_NE(align, kItemPositionNormal); |
1706 | 1704 |
1707 if (align == kItemPositionBaseline && HasOrthogonalFlow(child)) | 1705 if (align == kItemPositionBaseline && HasOrthogonalFlow(child)) |
1708 align = kItemPositionFlexStart; | 1706 align = kItemPositionFlexStart; |
1709 | 1707 |
1710 if (Style()->FlexWrap() == kFlexWrapReverse) { | 1708 if (Style()->FlexWrap() == kFlexWrapReverse) { |
1711 if (align == kItemPositionFlexStart) | 1709 if (align == kItemPositionFlexStart) |
1712 align = kItemPositionFlexEnd; | 1710 align = kItemPositionFlexEnd; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 LayoutUnit original_offset = | 2176 LayoutUnit original_offset = |
2179 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; | 2177 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; |
2180 LayoutUnit new_offset = | 2178 LayoutUnit new_offset = |
2181 content_extent - original_offset - line_cross_axis_extent; | 2179 content_extent - original_offset - line_cross_axis_extent; |
2182 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); | 2180 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); |
2183 } | 2181 } |
2184 } | 2182 } |
2185 } | 2183 } |
2186 | 2184 |
2187 } // namespace blink | 2185 } // namespace blink |
OLD | NEW |