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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 if (data.GetPosition() == kContentPositionFlexEnd) | 1532 if (data.GetPosition() == kContentPositionFlexEnd) |
1533 return available_free_space; | 1533 return available_free_space; |
1534 if (data.GetPosition() == kContentPositionCenter) | 1534 if (data.GetPosition() == kContentPositionCenter) |
1535 return available_free_space / 2; | 1535 return available_free_space / 2; |
1536 if (data.Distribution() == kContentDistributionSpaceAround) { | 1536 if (data.Distribution() == kContentDistributionSpaceAround) { |
1537 if (available_free_space > 0 && number_of_items) | 1537 if (available_free_space > 0 && number_of_items) |
1538 return available_free_space / (2 * number_of_items); | 1538 return available_free_space / (2 * number_of_items); |
1539 | 1539 |
1540 return available_free_space / 2; | 1540 return available_free_space / 2; |
1541 } | 1541 } |
| 1542 if (data.Distribution() == kContentDistributionSpaceEvenly) { |
| 1543 if (available_free_space > 0 && number_of_items) |
| 1544 return available_free_space / (number_of_items + 1); |
| 1545 // Fallback to 'center' |
| 1546 return available_free_space / 2; |
| 1547 } |
1542 return LayoutUnit(); | 1548 return LayoutUnit(); |
1543 } | 1549 } |
1544 | 1550 |
1545 static LayoutUnit ContentDistributionSpaceBetweenChildren( | 1551 static LayoutUnit ContentDistributionSpaceBetweenChildren( |
1546 LayoutUnit available_free_space, | 1552 LayoutUnit available_free_space, |
1547 const StyleContentAlignmentData& data, | 1553 const StyleContentAlignmentData& data, |
1548 unsigned number_of_items) { | 1554 unsigned number_of_items) { |
1549 if (available_free_space > 0 && number_of_items > 1) { | 1555 if (available_free_space > 0 && number_of_items > 1) { |
1550 if (data.Distribution() == kContentDistributionSpaceBetween) | 1556 if (data.Distribution() == kContentDistributionSpaceBetween) |
1551 return available_free_space / (number_of_items - 1); | 1557 return available_free_space / (number_of_items - 1); |
1552 if (data.Distribution() == kContentDistributionSpaceAround || | 1558 if (data.Distribution() == kContentDistributionSpaceAround || |
1553 data.Distribution() == kContentDistributionStretch) | 1559 data.Distribution() == kContentDistributionStretch) |
1554 return available_free_space / number_of_items; | 1560 return available_free_space / number_of_items; |
| 1561 if (data.Distribution() == kContentDistributionSpaceEvenly) |
| 1562 return available_free_space / (number_of_items + 1); |
1555 } | 1563 } |
1556 return LayoutUnit(); | 1564 return LayoutUnit(); |
1557 } | 1565 } |
1558 | 1566 |
1559 static LayoutUnit AlignmentOffset(LayoutUnit available_free_space, | 1567 static LayoutUnit AlignmentOffset(LayoutUnit available_free_space, |
1560 ItemPosition position, | 1568 ItemPosition position, |
1561 LayoutUnit ascent, | 1569 LayoutUnit ascent, |
1562 LayoutUnit max_ascent, | 1570 LayoutUnit max_ascent, |
1563 bool is_wrap_reverse) { | 1571 bool is_wrap_reverse) { |
1564 switch (position) { | 1572 switch (position) { |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 LayoutUnit original_offset = | 2186 LayoutUnit original_offset = |
2179 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; | 2187 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; |
2180 LayoutUnit new_offset = | 2188 LayoutUnit new_offset = |
2181 content_extent - original_offset - line_cross_axis_extent; | 2189 content_extent - original_offset - line_cross_axis_extent; |
2182 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); | 2190 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); |
2183 } | 2191 } |
2184 } | 2192 } |
2185 } | 2193 } |
2186 | 2194 |
2187 } // namespace blink | 2195 } // namespace blink |
OLD | NEW |