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). |
328 void LayoutFlexibleBox::StyleDidChange(StyleDifference diff, | 331 void LayoutFlexibleBox::StyleDidChange(StyleDifference diff, |
329 const ComputedStyle* old_style) { | 332 const ComputedStyle* old_style) { |
330 LayoutBlock::StyleDidChange(diff, old_style); | 333 LayoutBlock::StyleDidChange(diff, old_style); |
331 | 334 |
332 if (old_style && | 335 if (old_style && old_style->AlignItemsPosition() == kItemPositionStretch && |
333 old_style->ResolvedAlignItems(SelfAlignmentNormalBehavior()) | |
334 .GetPosition() == kItemPositionStretch && | |
335 diff.NeedsFullLayout()) { | 336 diff.NeedsFullLayout()) { |
336 // Flex items that were previously stretching need to be relayed out so we | 337 // Flex items that were previously stretching need to be relayed out so we |
337 // can compute new available cross axis space. This is only necessary for | 338 // can compute new available cross axis space. This is only necessary for |
338 // stretching since other alignment values don't change the size of the | 339 // stretching since other alignment values don't change the size of the |
339 // box. | 340 // box. |
340 for (LayoutBox* child = FirstChildBox(); child; | 341 for (LayoutBox* child = FirstChildBox(); child; |
341 child = child->NextSiblingBox()) { | 342 child = child->NextSiblingBox()) { |
342 ItemPosition previous_alignment = | 343 ItemPosition previous_alignment = |
343 child->StyleRef() | 344 child->StyleRef() |
344 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), old_style) | 345 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), old_style) |
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 if (child.Style()->HasStaticBlockPosition( | 1699 if (child.Style()->HasStaticBlockPosition( |
1699 Style()->IsHorizontalWritingMode())) | 1700 Style()->IsHorizontalWritingMode())) |
1700 child.SetChildNeedsLayout(kMarkOnlyThis); | 1701 child.SetChildNeedsLayout(kMarkOnlyThis); |
1701 } | 1702 } |
1702 } | 1703 } |
1703 | 1704 |
1704 ItemPosition LayoutFlexibleBox::AlignmentForChild( | 1705 ItemPosition LayoutFlexibleBox::AlignmentForChild( |
1705 const LayoutBox& child) const { | 1706 const LayoutBox& child) const { |
1706 ItemPosition align = | 1707 ItemPosition align = |
1707 child.StyleRef() | 1708 child.StyleRef() |
1708 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), Style()) | 1709 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), |
| 1710 child.IsAnonymous() ? Style() : nullptr) |
1709 .GetPosition(); | 1711 .GetPosition(); |
1710 DCHECK_NE(align, kItemPositionAuto); | 1712 DCHECK_NE(align, kItemPositionAuto); |
1711 DCHECK_NE(align, kItemPositionNormal); | 1713 DCHECK_NE(align, kItemPositionNormal); |
1712 | 1714 |
1713 if (align == kItemPositionBaseline && HasOrthogonalFlow(child)) | 1715 if (align == kItemPositionBaseline && HasOrthogonalFlow(child)) |
1714 align = kItemPositionFlexStart; | 1716 align = kItemPositionFlexStart; |
1715 | 1717 |
1716 if (Style()->FlexWrap() == kFlexWrapReverse) { | 1718 if (Style()->FlexWrap() == kFlexWrapReverse) { |
1717 if (align == kItemPositionFlexStart) | 1719 if (align == kItemPositionFlexStart) |
1718 align = kItemPositionFlexEnd; | 1720 align = kItemPositionFlexEnd; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2184 LayoutUnit original_offset = | 2186 LayoutUnit original_offset = |
2185 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; | 2187 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; |
2186 LayoutUnit new_offset = | 2188 LayoutUnit new_offset = |
2187 content_extent - original_offset - line_cross_axis_extent; | 2189 content_extent - original_offset - line_cross_axis_extent; |
2188 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); | 2190 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); |
2189 } | 2191 } |
2190 } | 2192 } |
2191 } | 2193 } |
2192 | 2194 |
2193 } // namespace blink | 2195 } // namespace blink |
OLD | NEW |