OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/ng/ng_space_utils.h" | 5 #include "core/layout/ng/ng_space_utils.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 namespace { | 8 namespace { |
9 | 9 |
10 // Returns max of 2 {@code WTF::Optional} values. | 10 // Returns max of 2 {@code WTF::Optional} values. |
11 template <typename T> | 11 template <typename T> |
12 WTF::Optional<T> OptionalMax(const WTF::Optional<T>& value1, | 12 WTF::Optional<T> OptionalMax(const WTF::Optional<T>& value1, |
13 const WTF::Optional<T>& value2) { | 13 const WTF::Optional<T>& value2) { |
14 if (value1 && value2) { | 14 if (value1 && value2) { |
15 return std::max(value1.value(), value2.value()); | 15 return std::max(value1.value(), value2.value()); |
16 } else if (value1) { | 16 } else if (value1) { |
17 return value1; | 17 return value1; |
18 } | 18 } |
19 return value2; | 19 return value2; |
20 } | 20 } |
21 | 21 |
| 22 bool IsOutOfFlowPositioned(const EPosition& position) { |
| 23 return position == EPosition::kAbsolute || position == EPosition::kFixed; |
| 24 } |
| 25 |
22 } // namespace | 26 } // namespace |
23 | 27 |
24 bool IsNewFormattingContextForInFlowBlockLevelChild( | 28 bool IsNewFormattingContextForBlockLevelChild(const NGConstraintSpace& space, |
25 const NGConstraintSpace& space, | 29 const ComputedStyle& style) { |
26 const ComputedStyle& style) { | |
27 // TODO(layout-dev): This doesn't capture a few cases which can't be computed | 30 // TODO(layout-dev): This doesn't capture a few cases which can't be computed |
28 // directly from style yet: | 31 // directly from style yet: |
29 // - The child is a <fieldset>. | 32 // - The child is a <fieldset>. |
30 // - "column-span: all" is set on the child (requires knowledge that we are | 33 // - "column-span: all" is set on the child (requires knowledge that we are |
31 // in a multi-col formatting context). | 34 // in a multi-col formatting context). |
32 // (https://drafts.csswg.org/css-multicol-1/#valdef-column-span-all) | 35 // (https://drafts.csswg.org/css-multicol-1/#valdef-column-span-all) |
33 | 36 |
| 37 if (style.isFloating() || IsOutOfFlowPositioned(style.position())) |
| 38 return true; |
| 39 |
34 if (style.specifiesColumns() || style.containsPaint() || | 40 if (style.specifiesColumns() || style.containsPaint() || |
35 style.containsLayout()) | 41 style.containsLayout()) |
36 return true; | 42 return true; |
37 | 43 |
38 if (!style.isOverflowVisible()) | 44 if (!style.isOverflowVisible()) |
39 return true; | 45 return true; |
40 | 46 |
41 EDisplay display = style.display(); | 47 EDisplay display = style.display(); |
42 if (display == EDisplay::kGrid || display == EDisplay::kFlex || | 48 if (display == EDisplay::kGrid || display == EDisplay::kFlex || |
43 display == EDisplay::kWebkitBox) | 49 display == EDisplay::kWebkitBox) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Whether the child and the containing block are parallel to each other. | 92 // Whether the child and the containing block are parallel to each other. |
87 // Example: vertical-rl and vertical-lr | 93 // Example: vertical-rl and vertical-lr |
88 bool is_in_parallel_flow = | 94 bool is_in_parallel_flow = |
89 IsParallelWritingMode(parent_space.WritingMode(), child_writing_mode); | 95 IsParallelWritingMode(parent_space.WritingMode(), child_writing_mode); |
90 | 96 |
91 return style.display() == EDisplay::kInlineBlock || style.isFloating() || | 97 return style.display() == EDisplay::kInlineBlock || style.isFloating() || |
92 !is_in_parallel_flow; | 98 !is_in_parallel_flow; |
93 } | 99 } |
94 | 100 |
95 } // namespace blink | 101 } // namespace blink |
OLD | NEW |