| 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 void LayoutFlexibleBox::RepositionLogicalHeightDependentFlexItems( | 422 void LayoutFlexibleBox::RepositionLogicalHeightDependentFlexItems( |
| 423 Vector<LineContext>& line_contexts) { | 423 Vector<LineContext>& line_contexts) { |
| 424 LayoutUnit cross_axis_start_edge = line_contexts.IsEmpty() | 424 LayoutUnit cross_axis_start_edge = line_contexts.IsEmpty() |
| 425 ? LayoutUnit() | 425 ? LayoutUnit() |
| 426 : line_contexts[0].cross_axis_offset; | 426 : line_contexts[0].cross_axis_offset; |
| 427 AlignFlexLines(line_contexts); | 427 AlignFlexLines(line_contexts); |
| 428 | 428 |
| 429 AlignChildren(line_contexts); | 429 AlignChildren(line_contexts); |
| 430 | 430 |
| 431 if (Style()->FlexWrap() == kFlexWrapReverse) | 431 if (Style()->FlexWrap() == EFlexWrap::kWrapReverse) |
| 432 FlipForWrapReverse(line_contexts, cross_axis_start_edge); | 432 FlipForWrapReverse(line_contexts, cross_axis_start_edge); |
| 433 | 433 |
| 434 // direction:rtl + flex-direction:column means the cross-axis direction is | 434 // direction:rtl + flex-direction:column means the cross-axis direction is |
| 435 // flipped. | 435 // flipped. |
| 436 FlipForRightToLeftColumn(line_contexts); | 436 FlipForRightToLeftColumn(line_contexts); |
| 437 } | 437 } |
| 438 | 438 |
| 439 DISABLE_CFI_PERF | 439 DISABLE_CFI_PERF |
| 440 LayoutUnit LayoutFlexibleBox::ClientLogicalBottomAfterRepositioning() { | 440 LayoutUnit LayoutFlexibleBox::ClientLogicalBottomAfterRepositioning() { |
| 441 LayoutUnit max_child_logical_bottom; | 441 LayoutUnit max_child_logical_bottom; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 470 bool LayoutFlexibleBox::IsLeftToRightFlow() const { | 470 bool LayoutFlexibleBox::IsLeftToRightFlow() const { |
| 471 if (IsColumnFlow()) { | 471 if (IsColumnFlow()) { |
| 472 return blink::IsHorizontalWritingMode(Style()->GetWritingMode()) || | 472 return blink::IsHorizontalWritingMode(Style()->GetWritingMode()) || |
| 473 IsFlippedLinesWritingMode(Style()->GetWritingMode()); | 473 IsFlippedLinesWritingMode(Style()->GetWritingMode()); |
| 474 } | 474 } |
| 475 return Style()->IsLeftToRightDirection() ^ | 475 return Style()->IsLeftToRightDirection() ^ |
| 476 (Style()->FlexDirection() == EFlexDirection::kRowReverse); | 476 (Style()->FlexDirection() == EFlexDirection::kRowReverse); |
| 477 } | 477 } |
| 478 | 478 |
| 479 bool LayoutFlexibleBox::IsMultiline() const { | 479 bool LayoutFlexibleBox::IsMultiline() const { |
| 480 return Style()->FlexWrap() != kFlexNoWrap; | 480 return Style()->FlexWrap() != EFlexWrap::kNowrap; |
| 481 } | 481 } |
| 482 | 482 |
| 483 Length LayoutFlexibleBox::FlexBasisForChild(const LayoutBox& child) const { | 483 Length LayoutFlexibleBox::FlexBasisForChild(const LayoutBox& child) const { |
| 484 Length flex_length = child.Style()->FlexBasis(); | 484 Length flex_length = child.Style()->FlexBasis(); |
| 485 if (flex_length.IsAuto()) | 485 if (flex_length.IsAuto()) |
| 486 flex_length = | 486 flex_length = |
| 487 IsHorizontalFlow() ? child.Style()->Width() : child.Style()->Height(); | 487 IsHorizontalFlow() ? child.Style()->Width() : child.Style()->Height(); |
| 488 return flex_length; | 488 return flex_length; |
| 489 } | 489 } |
| 490 | 490 |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 offset = available_space - offset; | 1636 offset = available_space - offset; |
| 1637 return offset; | 1637 return offset; |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 LayoutUnit LayoutFlexibleBox::StaticCrossAxisPositionForPositionedChild( | 1640 LayoutUnit LayoutFlexibleBox::StaticCrossAxisPositionForPositionedChild( |
| 1641 const LayoutBox& child) { | 1641 const LayoutBox& child) { |
| 1642 LayoutUnit available_space = | 1642 LayoutUnit available_space = |
| 1643 CrossAxisContentExtent() - CrossAxisExtentForChild(child); | 1643 CrossAxisContentExtent() - CrossAxisExtentForChild(child); |
| 1644 return AlignmentOffset(available_space, AlignmentForChild(child), | 1644 return AlignmentOffset(available_space, AlignmentForChild(child), |
| 1645 LayoutUnit(), LayoutUnit(), | 1645 LayoutUnit(), LayoutUnit(), |
| 1646 StyleRef().FlexWrap() == kFlexWrapReverse); | 1646 StyleRef().FlexWrap() == EFlexWrap::kWrapReverse); |
| 1647 } | 1647 } |
| 1648 | 1648 |
| 1649 LayoutUnit LayoutFlexibleBox::StaticInlinePositionForPositionedChild( | 1649 LayoutUnit LayoutFlexibleBox::StaticInlinePositionForPositionedChild( |
| 1650 const LayoutBox& child) { | 1650 const LayoutBox& child) { |
| 1651 return StartOffsetForContent() + | 1651 return StartOffsetForContent() + |
| 1652 (IsColumnFlow() ? StaticCrossAxisPositionForPositionedChild(child) | 1652 (IsColumnFlow() ? StaticCrossAxisPositionForPositionedChild(child) |
| 1653 : StaticMainAxisPositionForPositionedChild(child)); | 1653 : StaticMainAxisPositionForPositionedChild(child)); |
| 1654 } | 1654 } |
| 1655 | 1655 |
| 1656 LayoutUnit LayoutFlexibleBox::StaticBlockPositionForPositionedChild( | 1656 LayoutUnit LayoutFlexibleBox::StaticBlockPositionForPositionedChild( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 ItemPosition align = | 1710 ItemPosition align = |
| 1711 child.StyleRef() | 1711 child.StyleRef() |
| 1712 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), Style()) | 1712 .ResolvedAlignSelf(SelfAlignmentNormalBehavior(), Style()) |
| 1713 .GetPosition(); | 1713 .GetPosition(); |
| 1714 DCHECK_NE(align, kItemPositionAuto); | 1714 DCHECK_NE(align, kItemPositionAuto); |
| 1715 DCHECK_NE(align, kItemPositionNormal); | 1715 DCHECK_NE(align, kItemPositionNormal); |
| 1716 | 1716 |
| 1717 if (align == kItemPositionBaseline && HasOrthogonalFlow(child)) | 1717 if (align == kItemPositionBaseline && HasOrthogonalFlow(child)) |
| 1718 align = kItemPositionFlexStart; | 1718 align = kItemPositionFlexStart; |
| 1719 | 1719 |
| 1720 if (Style()->FlexWrap() == kFlexWrapReverse) { | 1720 if (Style()->FlexWrap() == EFlexWrap::kWrapReverse) { |
| 1721 if (align == kItemPositionFlexStart) | 1721 if (align == kItemPositionFlexStart) |
| 1722 align = kItemPositionFlexEnd; | 1722 align = kItemPositionFlexEnd; |
| 1723 else if (align == kItemPositionFlexEnd) | 1723 else if (align == kItemPositionFlexEnd) |
| 1724 align = kItemPositionFlexStart; | 1724 align = kItemPositionFlexStart; |
| 1725 } | 1725 } |
| 1726 | 1726 |
| 1727 return align; | 1727 return align; |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 void LayoutFlexibleBox::ResetAutoMarginsAndLogicalTopInCrossAxis( | 1730 void LayoutFlexibleBox::ResetAutoMarginsAndLogicalTopInCrossAxis( |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 *flex_item.box)))) | 2048 *flex_item.box)))) |
| 2049 continue; | 2049 continue; |
| 2050 | 2050 |
| 2051 ItemPosition position = AlignmentForChild(*flex_item.box); | 2051 ItemPosition position = AlignmentForChild(*flex_item.box); |
| 2052 if (position == kItemPositionStretch) | 2052 if (position == kItemPositionStretch) |
| 2053 ApplyStretchAlignmentToChild(*flex_item.box, line_cross_axis_extent); | 2053 ApplyStretchAlignmentToChild(*flex_item.box, line_cross_axis_extent); |
| 2054 LayoutUnit available_space = AvailableAlignmentSpaceForChild( | 2054 LayoutUnit available_space = AvailableAlignmentSpaceForChild( |
| 2055 line_cross_axis_extent, *flex_item.box); | 2055 line_cross_axis_extent, *flex_item.box); |
| 2056 LayoutUnit offset = AlignmentOffset( | 2056 LayoutUnit offset = AlignmentOffset( |
| 2057 available_space, position, MarginBoxAscentForChild(*flex_item.box), | 2057 available_space, position, MarginBoxAscentForChild(*flex_item.box), |
| 2058 max_ascent, StyleRef().FlexWrap() == kFlexWrapReverse); | 2058 max_ascent, StyleRef().FlexWrap() == EFlexWrap::kWrapReverse); |
| 2059 AdjustAlignmentForChild(*flex_item.box, offset); | 2059 AdjustAlignmentForChild(*flex_item.box, offset); |
| 2060 if (position == kItemPositionBaseline && | 2060 if (position == kItemPositionBaseline && |
| 2061 StyleRef().FlexWrap() == kFlexWrapReverse) { | 2061 StyleRef().FlexWrap() == EFlexWrap::kWrapReverse) { |
| 2062 min_margin_after_baseline = | 2062 min_margin_after_baseline = |
| 2063 std::min(min_margin_after_baseline, | 2063 std::min(min_margin_after_baseline, |
| 2064 AvailableAlignmentSpaceForChild(line_cross_axis_extent, | 2064 AvailableAlignmentSpaceForChild(line_cross_axis_extent, |
| 2065 *flex_item.box) - | 2065 *flex_item.box) - |
| 2066 offset); | 2066 offset); |
| 2067 } | 2067 } |
| 2068 } | 2068 } |
| 2069 min_margin_after_baselines.push_back(min_margin_after_baseline); | 2069 min_margin_after_baselines.push_back(min_margin_after_baseline); |
| 2070 } | 2070 } |
| 2071 | 2071 |
| 2072 if (Style()->FlexWrap() != kFlexWrapReverse) | 2072 if (Style()->FlexWrap() != EFlexWrap::kWrapReverse) |
| 2073 return; | 2073 return; |
| 2074 | 2074 |
| 2075 // wrap-reverse flips the cross axis start and end. For baseline alignment, | 2075 // wrap-reverse flips the cross axis start and end. For baseline alignment, |
| 2076 // this means we need to align the after edge of baseline elements with the | 2076 // this means we need to align the after edge of baseline elements with the |
| 2077 // after edge of the flex line. | 2077 // after edge of the flex line. |
| 2078 for (size_t line_number = 0; line_number < line_contexts.size(); | 2078 for (size_t line_number = 0; line_number < line_contexts.size(); |
| 2079 ++line_number) { | 2079 ++line_number) { |
| 2080 const LineContext& line_context = line_contexts[line_number]; | 2080 const LineContext& line_context = line_contexts[line_number]; |
| 2081 LayoutUnit min_margin_after_baseline = | 2081 LayoutUnit min_margin_after_baseline = |
| 2082 min_margin_after_baselines[line_number]; | 2082 min_margin_after_baselines[line_number]; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2188 LayoutUnit original_offset = | 2188 LayoutUnit original_offset = |
| 2189 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; | 2189 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; |
| 2190 LayoutUnit new_offset = | 2190 LayoutUnit new_offset = |
| 2191 content_extent - original_offset - line_cross_axis_extent; | 2191 content_extent - original_offset - line_cross_axis_extent; |
| 2192 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); | 2192 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); |
| 2193 } | 2193 } |
| 2194 } | 2194 } |
| 2195 } | 2195 } |
| 2196 | 2196 |
| 2197 } // namespace blink | 2197 } // namespace blink |
| OLD | NEW |