| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 IntSize size; | 268 IntSize size; |
| 269 int adjustment_width = VerticalScrollbarWidth(); | 269 int adjustment_width = VerticalScrollbarWidth(); |
| 270 int adjustment_height = HorizontalScrollbarHeight(); | 270 int adjustment_height = HorizontalScrollbarHeight(); |
| 271 if (!adjustment_width && !adjustment_height) | 271 if (!adjustment_width && !adjustment_height) |
| 272 return size; | 272 return size; |
| 273 | 273 |
| 274 EFlexDirection flex_direction = Style()->FlexDirection(); | 274 EFlexDirection flex_direction = Style()->FlexDirection(); |
| 275 TextDirection text_direction = Style()->Direction(); | 275 TextDirection text_direction = Style()->Direction(); |
| 276 WritingMode writing_mode = Style()->GetWritingMode(); | 276 WritingMode writing_mode = Style()->GetWritingMode(); |
| 277 | 277 |
| 278 if (flex_direction == kFlowRow) { | 278 if (flex_direction == EFlexDirection::kRow) { |
| 279 if (text_direction == TextDirection::kRtl) { | 279 if (text_direction == TextDirection::kRtl) { |
| 280 if (blink::IsHorizontalWritingMode(writing_mode)) | 280 if (blink::IsHorizontalWritingMode(writing_mode)) |
| 281 size.Expand(adjustment_width, 0); | 281 size.Expand(adjustment_width, 0); |
| 282 else | 282 else |
| 283 size.Expand(0, adjustment_height); | 283 size.Expand(0, adjustment_height); |
| 284 } | 284 } |
| 285 if (IsFlippedBlocksWritingMode(writing_mode)) | 285 if (IsFlippedBlocksWritingMode(writing_mode)) |
| 286 size.Expand(adjustment_width, 0); | 286 size.Expand(adjustment_width, 0); |
| 287 } else if (flex_direction == kFlowRowReverse) { | 287 } else if (flex_direction == EFlexDirection::kRowReverse) { |
| 288 if (text_direction == TextDirection::kLtr) { | 288 if (text_direction == TextDirection::kLtr) { |
| 289 if (blink::IsHorizontalWritingMode(writing_mode)) | 289 if (blink::IsHorizontalWritingMode(writing_mode)) |
| 290 size.Expand(adjustment_width, 0); | 290 size.Expand(adjustment_width, 0); |
| 291 else | 291 else |
| 292 size.Expand(0, adjustment_height); | 292 size.Expand(0, adjustment_height); |
| 293 } | 293 } |
| 294 if (IsFlippedBlocksWritingMode(writing_mode)) | 294 if (IsFlippedBlocksWritingMode(writing_mode)) |
| 295 size.Expand(adjustment_width, 0); | 295 size.Expand(adjustment_width, 0); |
| 296 } else if (flex_direction == kFlowColumn) { | 296 } else if (flex_direction == EFlexDirection::kColumn) { |
| 297 if (IsFlippedBlocksWritingMode(writing_mode)) | 297 if (IsFlippedBlocksWritingMode(writing_mode)) |
| 298 size.Expand(adjustment_width, 0); | 298 size.Expand(adjustment_width, 0); |
| 299 } else { | 299 } else { |
| 300 if (blink::IsHorizontalWritingMode(writing_mode)) | 300 if (blink::IsHorizontalWritingMode(writing_mode)) |
| 301 size.Expand(0, adjustment_height); | 301 size.Expand(0, adjustment_height); |
| 302 else if (IsFlippedLinesWritingMode(writing_mode)) | 302 else if (IsFlippedLinesWritingMode(writing_mode)) |
| 303 size.Expand(adjustment_width, 0); | 303 size.Expand(adjustment_width, 0); |
| 304 } | 304 } |
| 305 return size; | 305 return size; |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool LayoutFlexibleBox::HasTopOverflow() const { | 308 bool LayoutFlexibleBox::HasTopOverflow() const { |
| 309 EFlexDirection flex_direction = Style()->FlexDirection(); | 309 EFlexDirection flex_direction = Style()->FlexDirection(); |
| 310 if (IsHorizontalWritingMode()) | 310 if (IsHorizontalWritingMode()) |
| 311 return flex_direction == kFlowColumnReverse; | 311 return flex_direction == EFlexDirection::kColumnReverse; |
| 312 return flex_direction == | 312 return flex_direction == (Style()->IsLeftToRightDirection() |
| 313 (Style()->IsLeftToRightDirection() ? kFlowRowReverse : kFlowRow); | 313 ? EFlexDirection::kRowReverse |
| 314 : EFlexDirection::kRow); |
| 314 } | 315 } |
| 315 | 316 |
| 316 bool LayoutFlexibleBox::HasLeftOverflow() const { | 317 bool LayoutFlexibleBox::HasLeftOverflow() const { |
| 317 EFlexDirection flex_direction = Style()->FlexDirection(); | 318 EFlexDirection flex_direction = Style()->FlexDirection(); |
| 318 if (IsHorizontalWritingMode()) | 319 if (IsHorizontalWritingMode()) { |
| 319 return flex_direction == | 320 return flex_direction == (Style()->IsLeftToRightDirection() |
| 320 (Style()->IsLeftToRightDirection() ? kFlowRowReverse : kFlowRow); | 321 ? EFlexDirection::kRowReverse |
| 321 return flex_direction == kFlowColumnReverse; | 322 : EFlexDirection::kRow); |
| 323 } |
| 324 return flex_direction == EFlexDirection::kColumnReverse; |
| 322 } | 325 } |
| 323 | 326 |
| 324 void LayoutFlexibleBox::RemoveChild(LayoutObject* child) { | 327 void LayoutFlexibleBox::RemoveChild(LayoutObject* child) { |
| 325 LayoutBlock::RemoveChild(child); | 328 LayoutBlock::RemoveChild(child); |
| 326 intrinsic_size_along_main_axis_.erase(child); | 329 intrinsic_size_along_main_axis_.erase(child); |
| 327 } | 330 } |
| 328 | 331 |
| 329 void LayoutFlexibleBox::StyleDidChange(StyleDifference diff, | 332 void LayoutFlexibleBox::StyleDidChange(StyleDifference diff, |
| 330 const ComputedStyle* old_style) { | 333 const ComputedStyle* old_style) { |
| 331 LayoutBlock::StyleDidChange(diff, old_style); | 334 LayoutBlock::StyleDidChange(diff, old_style); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 return !IsColumnFlow(); | 466 return !IsColumnFlow(); |
| 464 return IsColumnFlow(); | 467 return IsColumnFlow(); |
| 465 } | 468 } |
| 466 | 469 |
| 467 bool LayoutFlexibleBox::IsLeftToRightFlow() const { | 470 bool LayoutFlexibleBox::IsLeftToRightFlow() const { |
| 468 if (IsColumnFlow()) { | 471 if (IsColumnFlow()) { |
| 469 return blink::IsHorizontalWritingMode(Style()->GetWritingMode()) || | 472 return blink::IsHorizontalWritingMode(Style()->GetWritingMode()) || |
| 470 IsFlippedLinesWritingMode(Style()->GetWritingMode()); | 473 IsFlippedLinesWritingMode(Style()->GetWritingMode()); |
| 471 } | 474 } |
| 472 return Style()->IsLeftToRightDirection() ^ | 475 return Style()->IsLeftToRightDirection() ^ |
| 473 (Style()->FlexDirection() == kFlowRowReverse); | 476 (Style()->FlexDirection() == EFlexDirection::kRowReverse); |
| 474 } | 477 } |
| 475 | 478 |
| 476 bool LayoutFlexibleBox::IsMultiline() const { | 479 bool LayoutFlexibleBox::IsMultiline() const { |
| 477 return Style()->FlexWrap() != kFlexNoWrap; | 480 return Style()->FlexWrap() != kFlexNoWrap; |
| 478 } | 481 } |
| 479 | 482 |
| 480 Length LayoutFlexibleBox::FlexBasisForChild(const LayoutBox& child) const { | 483 Length LayoutFlexibleBox::FlexBasisForChild(const LayoutBox& child) const { |
| 481 Length flex_length = child.Style()->FlexBasis(); | 484 Length flex_length = child.Style()->FlexBasis(); |
| 482 if (flex_length.IsAuto()) | 485 if (flex_length.IsAuto()) |
| 483 flex_length = | 486 flex_length = |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 } | 1624 } |
| 1622 | 1625 |
| 1623 LayoutUnit LayoutFlexibleBox::StaticMainAxisPositionForPositionedChild( | 1626 LayoutUnit LayoutFlexibleBox::StaticMainAxisPositionForPositionedChild( |
| 1624 const LayoutBox& child) { | 1627 const LayoutBox& child) { |
| 1625 const LayoutUnit available_space = | 1628 const LayoutUnit available_space = |
| 1626 MainAxisContentExtent(ContentLogicalHeight()) - | 1629 MainAxisContentExtent(ContentLogicalHeight()) - |
| 1627 MainAxisExtentForChild(child); | 1630 MainAxisExtentForChild(child); |
| 1628 | 1631 |
| 1629 LayoutUnit offset = InitialContentPositionOffset(available_space, | 1632 LayoutUnit offset = InitialContentPositionOffset(available_space, |
| 1630 ResolvedJustifyContent(), 1); | 1633 ResolvedJustifyContent(), 1); |
| 1631 if (StyleRef().FlexDirection() == kFlowRowReverse || | 1634 if (StyleRef().FlexDirection() == EFlexDirection::kRowReverse || |
| 1632 StyleRef().FlexDirection() == kFlowColumnReverse) | 1635 StyleRef().FlexDirection() == EFlexDirection::kColumnReverse) |
| 1633 offset = available_space - offset; | 1636 offset = available_space - offset; |
| 1634 return offset; | 1637 return offset; |
| 1635 } | 1638 } |
| 1636 | 1639 |
| 1637 LayoutUnit LayoutFlexibleBox::StaticCrossAxisPositionForPositionedChild( | 1640 LayoutUnit LayoutFlexibleBox::StaticCrossAxisPositionForPositionedChild( |
| 1638 const LayoutBox& child) { | 1641 const LayoutBox& child) { |
| 1639 LayoutUnit available_space = | 1642 LayoutUnit available_space = |
| 1640 CrossAxisContentExtent() - CrossAxisExtentForChild(child); | 1643 CrossAxisContentExtent() - CrossAxisExtentForChild(child); |
| 1641 return AlignmentOffset(available_space, AlignmentForChild(child), | 1644 return AlignmentOffset(available_space, AlignmentForChild(child), |
| 1642 LayoutUnit(), LayoutUnit(), | 1645 LayoutUnit(), LayoutUnit(), |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1799 SubtreeLayoutScope& layout_scope, | 1802 SubtreeLayoutScope& layout_scope, |
| 1800 Vector<LineContext>& line_contexts) { | 1803 Vector<LineContext>& line_contexts) { |
| 1801 const StyleContentAlignmentData justify_content = ResolvedJustifyContent(); | 1804 const StyleContentAlignmentData justify_content = ResolvedJustifyContent(); |
| 1802 | 1805 |
| 1803 LayoutUnit auto_margin_offset = | 1806 LayoutUnit auto_margin_offset = |
| 1804 AutoMarginOffsetInMainAxis(children, available_free_space); | 1807 AutoMarginOffsetInMainAxis(children, available_free_space); |
| 1805 LayoutUnit main_axis_offset = | 1808 LayoutUnit main_axis_offset = |
| 1806 FlowAwareBorderStart() + FlowAwarePaddingStart(); | 1809 FlowAwareBorderStart() + FlowAwarePaddingStart(); |
| 1807 main_axis_offset += InitialContentPositionOffset( | 1810 main_axis_offset += InitialContentPositionOffset( |
| 1808 available_free_space, justify_content, children.size()); | 1811 available_free_space, justify_content, children.size()); |
| 1809 if (Style()->FlexDirection() == kFlowRowReverse && | 1812 if (Style()->FlexDirection() == EFlexDirection::kRowReverse && |
| 1810 ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1813 ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 1811 main_axis_offset += IsHorizontalFlow() ? VerticalScrollbarWidth() | 1814 main_axis_offset += IsHorizontalFlow() ? VerticalScrollbarWidth() |
| 1812 : HorizontalScrollbarHeight(); | 1815 : HorizontalScrollbarHeight(); |
| 1813 | 1816 |
| 1814 LayoutUnit total_main_extent = MainAxisExtent(); | 1817 LayoutUnit total_main_extent = MainAxisExtent(); |
| 1815 if (!ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1818 if (!ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 1816 total_main_extent -= IsHorizontalFlow() ? VerticalScrollbarWidth() | 1819 total_main_extent -= IsHorizontalFlow() ? VerticalScrollbarWidth() |
| 1817 : HorizontalScrollbarHeight(); | 1820 : HorizontalScrollbarHeight(); |
| 1818 LayoutUnit max_ascent, max_descent; // Used when align-items: baseline. | 1821 LayoutUnit max_ascent, max_descent; // Used when align-items: baseline. |
| 1819 LayoutUnit max_child_cross_axis_extent; | 1822 LayoutUnit max_child_cross_axis_extent; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 | 1911 |
| 1909 if (is_paginated) | 1912 if (is_paginated) |
| 1910 UpdateFragmentationInfoForChild(*child); | 1913 UpdateFragmentationInfoForChild(*child); |
| 1911 } | 1914 } |
| 1912 | 1915 |
| 1913 if (IsColumnFlow()) | 1916 if (IsColumnFlow()) |
| 1914 SetLogicalHeight(std::max( | 1917 SetLogicalHeight(std::max( |
| 1915 LogicalHeight(), main_axis_offset + FlowAwareBorderEnd() + | 1918 LogicalHeight(), main_axis_offset + FlowAwareBorderEnd() + |
| 1916 FlowAwarePaddingEnd() + ScrollbarLogicalHeight())); | 1919 FlowAwarePaddingEnd() + ScrollbarLogicalHeight())); |
| 1917 | 1920 |
| 1918 if (Style()->FlexDirection() == kFlowColumnReverse) { | 1921 if (Style()->FlexDirection() == EFlexDirection::kColumnReverse) { |
| 1919 // We have to do an extra pass for column-reverse to reposition the flex | 1922 // We have to do an extra pass for column-reverse to reposition the flex |
| 1920 // items since the start depends on the height of the flexbox, which we | 1923 // items since the start depends on the height of the flexbox, which we |
| 1921 // only know after we've positioned all the flex items. | 1924 // only know after we've positioned all the flex items. |
| 1922 UpdateLogicalHeight(); | 1925 UpdateLogicalHeight(); |
| 1923 LayoutColumnReverse(children, cross_axis_offset, available_free_space); | 1926 LayoutColumnReverse(children, cross_axis_offset, available_free_space); |
| 1924 } | 1927 } |
| 1925 | 1928 |
| 1926 if (number_of_in_flow_children_on_first_line_ == -1) | 1929 if (number_of_in_flow_children_on_first_line_ == -1) |
| 1927 number_of_in_flow_children_on_first_line_ = children.size(); | 1930 number_of_in_flow_children_on_first_line_ = children.size(); |
| 1928 line_contexts.push_back(LineContext(cross_axis_offset, | 1931 line_contexts.push_back(LineContext(cross_axis_offset, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 LayoutUnit original_offset = | 2188 LayoutUnit original_offset = |
| 2186 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; | 2189 line_contexts[line_number].cross_axis_offset - cross_axis_start_edge; |
| 2187 LayoutUnit new_offset = | 2190 LayoutUnit new_offset = |
| 2188 content_extent - original_offset - line_cross_axis_extent; | 2191 content_extent - original_offset - line_cross_axis_extent; |
| 2189 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); | 2192 AdjustAlignmentForChild(*flex_item.box, new_offset - original_offset); |
| 2190 } | 2193 } |
| 2191 } | 2194 } |
| 2192 } | 2195 } |
| 2193 | 2196 |
| 2194 } // namespace blink | 2197 } // namespace blink |
| OLD | NEW |