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 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1699 if (child.Style()->HasStaticBlockPosition( | 1698 if (child.Style()->HasStaticBlockPosition( |
1700 Style()->IsHorizontalWritingMode())) | 1699 Style()->IsHorizontalWritingMode())) |
1701 child.SetChildNeedsLayout(kMarkOnlyThis); | 1700 child.SetChildNeedsLayout(kMarkOnlyThis); |
1702 } | 1701 } |
1703 } | 1702 } |
1704 | 1703 |
1705 ItemPosition LayoutFlexibleBox::AlignmentForChild( | 1704 ItemPosition LayoutFlexibleBox::AlignmentForChild( |
1706 const LayoutBox& child) const { | 1705 const LayoutBox& child) const { |
1707 ItemPosition align = | 1706 ItemPosition align = |
1708 child.StyleRef() | 1707 child.StyleRef() |
1709 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), | 1708 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), Style()) |
1710 child.IsAnonymous() ? Style() : nullptr) | |
1711 .GetPosition(); | 1709 .GetPosition(); |
1712 DCHECK_NE(align, kItemPositionAuto); | 1710 DCHECK_NE(align, kItemPositionAuto); |
1713 DCHECK_NE(align, kItemPositionNormal); | 1711 DCHECK_NE(align, kItemPositionNormal); |
1714 | 1712 |
1715 if (align == kItemPositionBaseline && HasOrthogonalFlow(child)) | 1713 if (align == kItemPositionBaseline && HasOrthogonalFlow(child)) |
1716 align = kItemPositionFlexStart; | 1714 align = kItemPositionFlexStart; |
1717 | 1715 |
1718 if (Style()->FlexWrap() == kFlexWrapReverse) { | 1716 if (Style()->FlexWrap() == kFlexWrapReverse) { |
1719 if (align == kItemPositionFlexStart) | 1717 if (align == kItemPositionFlexStart) |
1720 align = kItemPositionFlexEnd; | 1718 align = kItemPositionFlexEnd; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2186 LayoutUnit original_offset = | 2184 LayoutUnit original_offset = |
2187 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; | 2185 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; |
2188 LayoutUnit new_offset = | 2186 LayoutUnit new_offset = |
2189 content_extent - original_offset - line_cross_axis_extent; | 2187 content_extent - original_offset - line_cross_axis_extent; |
2190 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); | 2188 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); |
2191 } | 2189 } |
2192 } | 2190 } |
2193 } | 2191 } |
2194 | 2192 |
2195 } // namespace blink | 2193 } // namespace blink |
OLD | NEW |