| 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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 case WritingMode::kVerticalLr: | 632 case WritingMode::kVerticalLr: |
| 633 case WritingMode::kVerticalRl: | 633 case WritingMode::kVerticalRl: |
| 634 return Style()->IsLeftToRightDirection() | 634 return Style()->IsLeftToRightDirection() |
| 635 ? TransformedWritingMode::kTopToBottomWritingMode | 635 ? TransformedWritingMode::kTopToBottomWritingMode |
| 636 : TransformedWritingMode::kBottomToTopWritingMode; | 636 : TransformedWritingMode::kBottomToTopWritingMode; |
| 637 } | 637 } |
| 638 NOTREACHED(); | 638 NOTREACHED(); |
| 639 return TransformedWritingMode::kTopToBottomWritingMode; | 639 return TransformedWritingMode::kTopToBottomWritingMode; |
| 640 } | 640 } |
| 641 | 641 |
| 642 StyleContentAlignmentData LayoutFlexibleBox::ResolvedJustifyContent() const { |
| 643 ContentPosition position = StyleRef().ResolvedJustifyContentPosition( |
| 644 ContentAlignmentNormalBehavior()); |
| 645 ContentDistributionType distribution = |
| 646 StyleRef().ResolvedJustifyContentDistribution( |
| 647 ContentAlignmentNormalBehavior()); |
| 648 OverflowAlignment overflow = StyleRef().JustifyContentOverflowAlignment(); |
| 649 // For flex, justify-content: stretch behaves as flex-start: |
| 650 // https://drafts.csswg.org/css-align/#distribution-flex |
| 651 if (distribution == kContentDistributionStretch) { |
| 652 position = kContentPositionFlexStart; |
| 653 distribution = kContentDistributionDefault; |
| 654 } |
| 655 return StyleContentAlignmentData(position, distribution, overflow); |
| 656 } |
| 657 |
| 658 StyleContentAlignmentData LayoutFlexibleBox::ResolvedAlignContent() const { |
| 659 ContentPosition position = |
| 660 StyleRef().ResolvedAlignContentPosition(ContentAlignmentNormalBehavior()); |
| 661 ContentDistributionType distribution = |
| 662 StyleRef().ResolvedAlignContentDistribution( |
| 663 ContentAlignmentNormalBehavior()); |
| 664 OverflowAlignment overflow = StyleRef().AlignContentOverflowAlignment(); |
| 665 return StyleContentAlignmentData(position, distribution, overflow); |
| 666 } |
| 667 |
| 642 LayoutUnit LayoutFlexibleBox::FlowAwareBorderStart() const { | 668 LayoutUnit LayoutFlexibleBox::FlowAwareBorderStart() const { |
| 643 if (IsHorizontalFlow()) | 669 if (IsHorizontalFlow()) |
| 644 return IsLeftToRightFlow() ? BorderLeft() : BorderRight(); | 670 return IsLeftToRightFlow() ? BorderLeft() : BorderRight(); |
| 645 return IsLeftToRightFlow() ? BorderTop() : BorderBottom(); | 671 return IsLeftToRightFlow() ? BorderTop() : BorderBottom(); |
| 646 } | 672 } |
| 647 | 673 |
| 648 LayoutUnit LayoutFlexibleBox::FlowAwareBorderEnd() const { | 674 LayoutUnit LayoutFlexibleBox::FlowAwareBorderEnd() const { |
| 649 if (IsHorizontalFlow()) | 675 if (IsHorizontalFlow()) |
| 650 return IsLeftToRightFlow() ? BorderRight() : BorderLeft(); | 676 return IsLeftToRightFlow() ? BorderRight() : BorderLeft(); |
| 651 return IsLeftToRightFlow() ? BorderBottom() : BorderTop(); | 677 return IsLeftToRightFlow() ? BorderBottom() : BorderTop(); |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 if (total_violation) | 1520 if (total_violation) |
| 1495 FreezeViolations(total_violation < 0 ? max_violations : min_violations, | 1521 FreezeViolations(total_violation < 0 ? max_violations : min_violations, |
| 1496 remaining_free_space, total_flex_grow, total_flex_shrink, | 1522 remaining_free_space, total_flex_grow, total_flex_shrink, |
| 1497 total_weighted_flex_shrink); | 1523 total_weighted_flex_shrink); |
| 1498 else | 1524 else |
| 1499 remaining_free_space -= used_free_space; | 1525 remaining_free_space -= used_free_space; |
| 1500 | 1526 |
| 1501 return !total_violation; | 1527 return !total_violation; |
| 1502 } | 1528 } |
| 1503 | 1529 |
| 1504 static LayoutUnit InitialJustifyContentOffset( | 1530 static LayoutUnit InitialContentPositionOffset( |
| 1505 LayoutUnit available_free_space, | 1531 LayoutUnit available_free_space, |
| 1506 ContentPosition justify_content, | 1532 const StyleContentAlignmentData& data, |
| 1507 ContentDistributionType justify_content_distribution, | 1533 unsigned number_of_items) { |
| 1508 unsigned number_of_children) { | 1534 if (data.GetPosition() == kContentPositionFlexEnd) |
| 1509 if (justify_content == kContentPositionFlexEnd) | |
| 1510 return available_free_space; | 1535 return available_free_space; |
| 1511 if (justify_content == kContentPositionCenter) | 1536 if (data.GetPosition() == kContentPositionCenter) |
| 1512 return available_free_space / 2; | 1537 return available_free_space / 2; |
| 1513 if (justify_content_distribution == kContentDistributionSpaceAround) { | 1538 if (data.Distribution() == kContentDistributionSpaceAround) { |
| 1514 if (available_free_space > 0 && number_of_children) | 1539 if (available_free_space > 0 && number_of_items) |
| 1515 return available_free_space / (2 * number_of_children); | 1540 return available_free_space / (2 * number_of_items); |
| 1516 | 1541 |
| 1517 return available_free_space / 2; | 1542 return available_free_space / 2; |
| 1518 } | 1543 } |
| 1519 return LayoutUnit(); | 1544 return LayoutUnit(); |
| 1520 } | 1545 } |
| 1521 | 1546 |
| 1522 static LayoutUnit JustifyContentSpaceBetweenChildren( | 1547 static LayoutUnit ContentDistributionSpaceBetweenChildren( |
| 1523 LayoutUnit available_free_space, | 1548 LayoutUnit available_free_space, |
| 1524 ContentDistributionType justify_content_distribution, | 1549 const StyleContentAlignmentData& data, |
| 1525 unsigned number_of_children) { | 1550 unsigned number_of_items) { |
| 1526 if (available_free_space > 0 && number_of_children > 1) { | 1551 if (available_free_space > 0 && number_of_items > 1) { |
| 1527 if (justify_content_distribution == kContentDistributionSpaceBetween) | 1552 if (data.Distribution() == kContentDistributionSpaceBetween) |
| 1528 return available_free_space / (number_of_children - 1); | 1553 return available_free_space / (number_of_items - 1); |
| 1529 if (justify_content_distribution == kContentDistributionSpaceAround) | 1554 if (data.Distribution() == kContentDistributionSpaceAround || |
| 1530 return available_free_space / number_of_children; | 1555 data.Distribution() == kContentDistributionStretch) |
| 1556 return available_free_space / number_of_items; |
| 1531 } | 1557 } |
| 1532 return LayoutUnit(); | 1558 return LayoutUnit(); |
| 1533 } | 1559 } |
| 1534 | 1560 |
| 1535 static LayoutUnit AlignmentOffset(LayoutUnit available_free_space, | 1561 static LayoutUnit AlignmentOffset(LayoutUnit available_free_space, |
| 1536 ItemPosition position, | 1562 ItemPosition position, |
| 1537 LayoutUnit ascent, | 1563 LayoutUnit ascent, |
| 1538 LayoutUnit max_ascent, | 1564 LayoutUnit max_ascent, |
| 1539 bool is_wrap_reverse) { | 1565 bool is_wrap_reverse) { |
| 1540 switch (position) { | 1566 switch (position) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 else | 1613 else |
| 1588 child.SetOverrideLogicalContentWidth(child_preferred_size); | 1614 child.SetOverrideLogicalContentWidth(child_preferred_size); |
| 1589 } | 1615 } |
| 1590 | 1616 |
| 1591 LayoutUnit LayoutFlexibleBox::StaticMainAxisPositionForPositionedChild( | 1617 LayoutUnit LayoutFlexibleBox::StaticMainAxisPositionForPositionedChild( |
| 1592 const LayoutBox& child) { | 1618 const LayoutBox& child) { |
| 1593 const LayoutUnit available_space = | 1619 const LayoutUnit available_space = |
| 1594 MainAxisContentExtent(ContentLogicalHeight()) - | 1620 MainAxisContentExtent(ContentLogicalHeight()) - |
| 1595 MainAxisExtentForChild(child); | 1621 MainAxisExtentForChild(child); |
| 1596 | 1622 |
| 1597 ContentPosition position = StyleRef().ResolvedJustifyContentPosition( | 1623 LayoutUnit offset = InitialContentPositionOffset(available_space, |
| 1598 ContentAlignmentNormalBehavior()); | 1624 ResolvedJustifyContent(), 1); |
| 1599 ContentDistributionType distribution = | |
| 1600 StyleRef().ResolvedJustifyContentDistribution( | |
| 1601 ContentAlignmentNormalBehavior()); | |
| 1602 LayoutUnit offset = | |
| 1603 InitialJustifyContentOffset(available_space, position, distribution, 1); | |
| 1604 if (StyleRef().FlexDirection() == kFlowRowReverse || | 1625 if (StyleRef().FlexDirection() == kFlowRowReverse || |
| 1605 StyleRef().FlexDirection() == kFlowColumnReverse) | 1626 StyleRef().FlexDirection() == kFlowColumnReverse) |
| 1606 offset = available_space - offset; | 1627 offset = available_space - offset; |
| 1607 return offset; | 1628 return offset; |
| 1608 } | 1629 } |
| 1609 | 1630 |
| 1610 LayoutUnit LayoutFlexibleBox::StaticCrossAxisPositionForPositionedChild( | 1631 LayoutUnit LayoutFlexibleBox::StaticCrossAxisPositionForPositionedChild( |
| 1611 const LayoutBox& child) { | 1632 const LayoutBox& child) { |
| 1612 LayoutUnit available_space = | 1633 LayoutUnit available_space = |
| 1613 CrossAxisContentExtent() - CrossAxisExtentForChild(child); | 1634 CrossAxisContentExtent() - CrossAxisExtentForChild(child); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 } | 1786 } |
| 1766 | 1787 |
| 1767 DISABLE_CFI_PERF | 1788 DISABLE_CFI_PERF |
| 1768 void LayoutFlexibleBox::LayoutAndPlaceChildren( | 1789 void LayoutFlexibleBox::LayoutAndPlaceChildren( |
| 1769 LayoutUnit& cross_axis_offset, | 1790 LayoutUnit& cross_axis_offset, |
| 1770 Vector<FlexItem>& children, | 1791 Vector<FlexItem>& children, |
| 1771 LayoutUnit available_free_space, | 1792 LayoutUnit available_free_space, |
| 1772 bool relayout_children, | 1793 bool relayout_children, |
| 1773 SubtreeLayoutScope& layout_scope, | 1794 SubtreeLayoutScope& layout_scope, |
| 1774 Vector<LineContext>& line_contexts) { | 1795 Vector<LineContext>& line_contexts) { |
| 1775 ContentPosition position = StyleRef().ResolvedJustifyContentPosition( | 1796 const StyleContentAlignmentData justify_content = ResolvedJustifyContent(); |
| 1776 ContentAlignmentNormalBehavior()); | |
| 1777 ContentDistributionType distribution = | |
| 1778 StyleRef().ResolvedJustifyContentDistribution( | |
| 1779 ContentAlignmentNormalBehavior()); | |
| 1780 | 1797 |
| 1781 LayoutUnit auto_margin_offset = | 1798 LayoutUnit auto_margin_offset = |
| 1782 AutoMarginOffsetInMainAxis(children, available_free_space); | 1799 AutoMarginOffsetInMainAxis(children, available_free_space); |
| 1783 LayoutUnit main_axis_offset = | 1800 LayoutUnit main_axis_offset = |
| 1784 FlowAwareBorderStart() + FlowAwarePaddingStart(); | 1801 FlowAwareBorderStart() + FlowAwarePaddingStart(); |
| 1785 main_axis_offset += InitialJustifyContentOffset( | 1802 main_axis_offset += InitialContentPositionOffset( |
| 1786 available_free_space, position, distribution, children.size()); | 1803 available_free_space, justify_content, children.size()); |
| 1787 if (Style()->FlexDirection() == kFlowRowReverse && | 1804 if (Style()->FlexDirection() == kFlowRowReverse && |
| 1788 ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1805 ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 1789 main_axis_offset += IsHorizontalFlow() ? VerticalScrollbarWidth() | 1806 main_axis_offset += IsHorizontalFlow() ? VerticalScrollbarWidth() |
| 1790 : HorizontalScrollbarHeight(); | 1807 : HorizontalScrollbarHeight(); |
| 1791 | 1808 |
| 1792 LayoutUnit total_main_extent = MainAxisExtent(); | 1809 LayoutUnit total_main_extent = MainAxisExtent(); |
| 1793 if (!ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1810 if (!ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 1794 total_main_extent -= IsHorizontalFlow() ? VerticalScrollbarWidth() | 1811 total_main_extent -= IsHorizontalFlow() ? VerticalScrollbarWidth() |
| 1795 : HorizontalScrollbarHeight(); | 1812 : HorizontalScrollbarHeight(); |
| 1796 LayoutUnit max_ascent, max_descent; // Used when align-items: baseline. | 1813 LayoutUnit max_ascent, max_descent; // Used when align-items: baseline. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 LayoutPoint child_location( | 1890 LayoutPoint child_location( |
| 1874 should_flip_main_axis | 1891 should_flip_main_axis |
| 1875 ? total_main_extent - main_axis_offset - child_main_extent | 1892 ? total_main_extent - main_axis_offset - child_main_extent |
| 1876 : main_axis_offset, | 1893 : main_axis_offset, |
| 1877 cross_axis_offset + FlowAwareMarginBeforeForChild(*child)); | 1894 cross_axis_offset + FlowAwareMarginBeforeForChild(*child)); |
| 1878 SetFlowAwareLocationForChild(*child, child_location); | 1895 SetFlowAwareLocationForChild(*child, child_location); |
| 1879 main_axis_offset += child_main_extent + FlowAwareMarginEndForChild(*child); | 1896 main_axis_offset += child_main_extent + FlowAwareMarginEndForChild(*child); |
| 1880 | 1897 |
| 1881 if (i != children.size() - 1) { | 1898 if (i != children.size() - 1) { |
| 1882 // The last item does not get extra space added. | 1899 // The last item does not get extra space added. |
| 1883 main_axis_offset += JustifyContentSpaceBetweenChildren( | 1900 main_axis_offset += ContentDistributionSpaceBetweenChildren( |
| 1884 available_free_space, distribution, children.size()); | 1901 available_free_space, justify_content, children.size()); |
| 1885 } | 1902 } |
| 1886 | 1903 |
| 1887 if (is_paginated) | 1904 if (is_paginated) |
| 1888 UpdateFragmentationInfoForChild(*child); | 1905 UpdateFragmentationInfoForChild(*child); |
| 1889 } | 1906 } |
| 1890 | 1907 |
| 1891 if (IsColumnFlow()) | 1908 if (IsColumnFlow()) |
| 1892 SetLogicalHeight(std::max( | 1909 SetLogicalHeight(std::max( |
| 1893 LogicalHeight(), main_axis_offset + FlowAwareBorderEnd() + | 1910 LogicalHeight(), main_axis_offset + FlowAwareBorderEnd() + |
| 1894 FlowAwarePaddingEnd() + ScrollbarLogicalHeight())); | 1911 FlowAwarePaddingEnd() + ScrollbarLogicalHeight())); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1905 number_of_in_flow_children_on_first_line_ = children.size(); | 1922 number_of_in_flow_children_on_first_line_ = children.size(); |
| 1906 line_contexts.push_back(LineContext(cross_axis_offset, | 1923 line_contexts.push_back(LineContext(cross_axis_offset, |
| 1907 max_child_cross_axis_extent, max_ascent, | 1924 max_child_cross_axis_extent, max_ascent, |
| 1908 std::move(children))); | 1925 std::move(children))); |
| 1909 cross_axis_offset += max_child_cross_axis_extent; | 1926 cross_axis_offset += max_child_cross_axis_extent; |
| 1910 } | 1927 } |
| 1911 | 1928 |
| 1912 void LayoutFlexibleBox::LayoutColumnReverse(const Vector<FlexItem>& children, | 1929 void LayoutFlexibleBox::LayoutColumnReverse(const Vector<FlexItem>& children, |
| 1913 LayoutUnit cross_axis_offset, | 1930 LayoutUnit cross_axis_offset, |
| 1914 LayoutUnit available_free_space) { | 1931 LayoutUnit available_free_space) { |
| 1915 ContentPosition position = StyleRef().ResolvedJustifyContentPosition( | 1932 const StyleContentAlignmentData justify_content = ResolvedJustifyContent(); |
| 1916 ContentAlignmentNormalBehavior()); | |
| 1917 ContentDistributionType distribution = | |
| 1918 StyleRef().ResolvedJustifyContentDistribution( | |
| 1919 ContentAlignmentNormalBehavior()); | |
| 1920 | 1933 |
| 1921 // This is similar to the logic in layoutAndPlaceChildren, except we place | 1934 // This is similar to the logic in layoutAndPlaceChildren, except we place |
| 1922 // the children starting from the end of the flexbox. We also don't need to | 1935 // the children starting from the end of the flexbox. We also don't need to |
| 1923 // layout anything since we're just moving the children to a new position. | 1936 // layout anything since we're just moving the children to a new position. |
| 1924 LayoutUnit main_axis_offset = | 1937 LayoutUnit main_axis_offset = |
| 1925 LogicalHeight() - FlowAwareBorderEnd() - FlowAwarePaddingEnd(); | 1938 LogicalHeight() - FlowAwareBorderEnd() - FlowAwarePaddingEnd(); |
| 1926 main_axis_offset -= InitialJustifyContentOffset( | 1939 main_axis_offset -= InitialContentPositionOffset( |
| 1927 available_free_space, position, distribution, children.size()); | 1940 available_free_space, justify_content, children.size()); |
| 1928 main_axis_offset -= IsHorizontalFlow() ? VerticalScrollbarWidth() | 1941 main_axis_offset -= IsHorizontalFlow() ? VerticalScrollbarWidth() |
| 1929 : HorizontalScrollbarHeight(); | 1942 : HorizontalScrollbarHeight(); |
| 1930 | 1943 |
| 1931 for (size_t i = 0; i < children.size(); ++i) { | 1944 for (size_t i = 0; i < children.size(); ++i) { |
| 1932 LayoutBox* child = children[i].box; | 1945 LayoutBox* child = children[i].box; |
| 1933 | 1946 |
| 1934 DCHECK(!child->IsOutOfFlowPositioned()); | 1947 DCHECK(!child->IsOutOfFlowPositioned()); |
| 1935 | 1948 |
| 1936 main_axis_offset -= | 1949 main_axis_offset -= |
| 1937 MainAxisExtentForChild(*child) + FlowAwareMarginEndForChild(*child); | 1950 MainAxisExtentForChild(*child) + FlowAwareMarginEndForChild(*child); |
| 1938 | 1951 |
| 1939 SetFlowAwareLocationForChild( | 1952 SetFlowAwareLocationForChild( |
| 1940 *child, | 1953 *child, |
| 1941 LayoutPoint(main_axis_offset, | 1954 LayoutPoint(main_axis_offset, |
| 1942 cross_axis_offset + FlowAwareMarginBeforeForChild(*child))); | 1955 cross_axis_offset + FlowAwareMarginBeforeForChild(*child))); |
| 1943 | 1956 |
| 1944 main_axis_offset -= FlowAwareMarginStartForChild(*child); | 1957 main_axis_offset -= FlowAwareMarginStartForChild(*child); |
| 1945 | 1958 |
| 1946 main_axis_offset -= JustifyContentSpaceBetweenChildren( | 1959 main_axis_offset -= ContentDistributionSpaceBetweenChildren( |
| 1947 available_free_space, distribution, children.size()); | 1960 available_free_space, justify_content, children.size()); |
| 1948 } | 1961 } |
| 1949 } | 1962 } |
| 1950 | 1963 |
| 1951 static LayoutUnit InitialAlignContentOffset( | |
| 1952 LayoutUnit available_free_space, | |
| 1953 ContentPosition align_content, | |
| 1954 ContentDistributionType align_content_distribution, | |
| 1955 unsigned number_of_lines) { | |
| 1956 if (number_of_lines <= 1) | |
| 1957 return LayoutUnit(); | |
| 1958 if (align_content == kContentPositionFlexEnd) | |
| 1959 return available_free_space; | |
| 1960 if (align_content == kContentPositionCenter) | |
| 1961 return available_free_space / 2; | |
| 1962 if (align_content_distribution == kContentDistributionSpaceAround) { | |
| 1963 if (available_free_space > 0 && number_of_lines) | |
| 1964 return available_free_space / (2 * number_of_lines); | |
| 1965 if (available_free_space < 0) | |
| 1966 return available_free_space / 2; | |
| 1967 } | |
| 1968 return LayoutUnit(); | |
| 1969 } | |
| 1970 | |
| 1971 static LayoutUnit AlignContentSpaceBetweenChildren( | |
| 1972 LayoutUnit available_free_space, | |
| 1973 ContentDistributionType align_content_distribution, | |
| 1974 unsigned number_of_lines) { | |
| 1975 if (available_free_space > 0 && number_of_lines > 1) { | |
| 1976 if (align_content_distribution == kContentDistributionSpaceBetween) | |
| 1977 return available_free_space / (number_of_lines - 1); | |
| 1978 if (align_content_distribution == kContentDistributionSpaceAround || | |
| 1979 align_content_distribution == kContentDistributionStretch) | |
| 1980 return available_free_space / number_of_lines; | |
| 1981 } | |
| 1982 return LayoutUnit(); | |
| 1983 } | |
| 1984 | |
| 1985 void LayoutFlexibleBox::AlignFlexLines(Vector<LineContext>& line_contexts) { | 1964 void LayoutFlexibleBox::AlignFlexLines(Vector<LineContext>& line_contexts) { |
| 1986 ContentPosition position = | 1965 const StyleContentAlignmentData align_content = ResolvedAlignContent(); |
| 1987 StyleRef().ResolvedAlignContentPosition(ContentAlignmentNormalBehavior()); | |
| 1988 ContentDistributionType distribution = | |
| 1989 StyleRef().ResolvedAlignContentDistribution( | |
| 1990 ContentAlignmentNormalBehavior()); | |
| 1991 | 1966 |
| 1992 // If we have a single line flexbox or a multiline line flexbox with only one | 1967 // If we have a single line flexbox or a multiline line flexbox with only one |
| 1993 // flex line, the line height is all the available space. For | 1968 // flex line, the line height is all the available space. For |
| 1994 // flex-direction: row, this means we need to use the height, so we do this | 1969 // flex-direction: row, this means we need to use the height, so we do this |
| 1995 // after calling updateLogicalHeight. | 1970 // after calling updateLogicalHeight. |
| 1996 if (line_contexts.size() == 1) { | 1971 if (line_contexts.size() == 1) { |
| 1997 line_contexts[0].cross_axis_extent = CrossAxisContentExtent(); | 1972 line_contexts[0].cross_axis_extent = CrossAxisContentExtent(); |
| 1998 return; | 1973 return; |
| 1999 } | 1974 } |
| 2000 | 1975 |
| 2001 if (position == kContentPositionFlexStart) | 1976 if (align_content.GetPosition() == kContentPositionFlexStart) |
| 2002 return; | 1977 return; |
| 2003 | 1978 |
| 2004 LayoutUnit available_cross_axis_space = CrossAxisContentExtent(); | 1979 LayoutUnit available_cross_axis_space = CrossAxisContentExtent(); |
| 2005 for (size_t i = 0; i < line_contexts.size(); ++i) | 1980 for (size_t i = 0; i < line_contexts.size(); ++i) |
| 2006 available_cross_axis_space -= line_contexts[i].cross_axis_extent; | 1981 available_cross_axis_space -= line_contexts[i].cross_axis_extent; |
| 2007 | 1982 |
| 2008 LayoutUnit line_offset = InitialAlignContentOffset( | 1983 LayoutUnit line_offset; |
| 2009 available_cross_axis_space, position, distribution, line_contexts.size()); | 1984 if (line_contexts.size() > 1) { |
| 1985 line_offset = InitialContentPositionOffset( |
| 1986 available_cross_axis_space, align_content, line_contexts.size()); |
| 1987 } |
| 2010 for (unsigned line_number = 0; line_number < line_contexts.size(); | 1988 for (unsigned line_number = 0; line_number < line_contexts.size(); |
| 2011 ++line_number) { | 1989 ++line_number) { |
| 2012 LineContext& line_context = line_contexts[line_number]; | 1990 LineContext& line_context = line_contexts[line_number]; |
| 2013 line_context.cross_axis_offset += line_offset; | 1991 line_context.cross_axis_offset += line_offset; |
| 2014 for (size_t child_number = 0; child_number < line_context.flex_items.size(); | 1992 for (size_t child_number = 0; child_number < line_context.flex_items.size(); |
| 2015 ++child_number) { | 1993 ++child_number) { |
| 2016 FlexItem& flex_item = line_context.flex_items[child_number]; | 1994 FlexItem& flex_item = line_context.flex_items[child_number]; |
| 2017 AdjustAlignmentForChild(*flex_item.box, line_offset); | 1995 AdjustAlignmentForChild(*flex_item.box, line_offset); |
| 2018 } | 1996 } |
| 2019 | 1997 |
| 2020 if (distribution == kContentDistributionStretch && | 1998 if (align_content.Distribution() == kContentDistributionStretch && |
| 2021 available_cross_axis_space > 0) | 1999 available_cross_axis_space > 0) |
| 2022 line_contexts[line_number].cross_axis_extent += | 2000 line_contexts[line_number].cross_axis_extent += |
| 2023 available_cross_axis_space / | 2001 available_cross_axis_space / |
| 2024 static_cast<unsigned>(line_contexts.size()); | 2002 static_cast<unsigned>(line_contexts.size()); |
| 2025 | 2003 |
| 2026 line_offset += AlignContentSpaceBetweenChildren( | 2004 line_offset += ContentDistributionSpaceBetweenChildren( |
| 2027 available_cross_axis_space, distribution, line_contexts.size()); | 2005 available_cross_axis_space, align_content, line_contexts.size()); |
| 2028 } | 2006 } |
| 2029 } | 2007 } |
| 2030 | 2008 |
| 2031 void LayoutFlexibleBox::AdjustAlignmentForChild(LayoutBox& child, | 2009 void LayoutFlexibleBox::AdjustAlignmentForChild(LayoutBox& child, |
| 2032 LayoutUnit delta) { | 2010 LayoutUnit delta) { |
| 2033 DCHECK(!child.IsOutOfFlowPositioned()); | 2011 DCHECK(!child.IsOutOfFlowPositioned()); |
| 2034 | 2012 |
| 2035 SetFlowAwareLocationForChild(child, FlowAwareLocationForChild(child) + | 2013 SetFlowAwareLocationForChild(child, FlowAwareLocationForChild(child) + |
| 2036 LayoutSize(LayoutUnit(), delta)); | 2014 LayoutSize(LayoutUnit(), delta)); |
| 2037 } | 2015 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2202 LayoutUnit original_offset = | 2180 LayoutUnit original_offset = |
| 2203 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; | 2181 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; |
| 2204 LayoutUnit new_offset = | 2182 LayoutUnit new_offset = |
| 2205 content_extent - original_offset - line_cross_axis_extent; | 2183 content_extent - original_offset - line_cross_axis_extent; |
| 2206 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); | 2184 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); |
| 2207 } | 2185 } |
| 2208 } | 2186 } |
| 2209 } | 2187 } |
| 2210 | 2188 |
| 2211 } // namespace blink | 2189 } // namespace blink |
| OLD | NEW |