| 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 #include "core/layout/ng/ng_block_node.h" | 7 #include "core/layout/ng/ng_block_node.h" |
| 8 #include "core/layout/ng/ng_exclusion.h" | 8 #include "core/layout/ng/ng_exclusion.h" |
| 9 #include "core/layout/ng/ng_layout_input_node.h" | 9 #include "core/layout/ng/ng_layout_input_node.h" |
| 10 #include "core/layout/ng/ng_writing_mode.h" | 10 #include "core/layout/ng/ng_writing_mode.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return true; | 59 return true; |
| 60 | 60 |
| 61 if (parent_style.GetWritingMode() != style.GetWritingMode()) | 61 if (parent_style.GetWritingMode() != style.GetWritingMode()) |
| 62 return true; | 62 return true; |
| 63 | 63 |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 | 66 |
| 67 WTF::Optional<LayoutUnit> GetClearanceOffset( | 67 WTF::Optional<LayoutUnit> GetClearanceOffset( |
| 68 const std::shared_ptr<NGExclusions>& exclusions, | 68 const std::shared_ptr<NGExclusions>& exclusions, |
| 69 const ComputedStyle& style) { | 69 EClear clear_type) { |
| 70 const NGExclusion* right_exclusion = exclusions->last_right_float; | 70 const NGExclusion* right_exclusion = exclusions->last_right_float; |
| 71 const NGExclusion* left_exclusion = exclusions->last_left_float; | 71 const NGExclusion* left_exclusion = exclusions->last_left_float; |
| 72 | 72 |
| 73 WTF::Optional<LayoutUnit> left_offset; | 73 WTF::Optional<LayoutUnit> left_offset; |
| 74 if (left_exclusion) { | 74 if (left_exclusion) { |
| 75 left_offset = left_exclusion->rect.BlockEndOffset(); | 75 left_offset = left_exclusion->rect.BlockEndOffset(); |
| 76 } | 76 } |
| 77 WTF::Optional<LayoutUnit> right_offset; | 77 WTF::Optional<LayoutUnit> right_offset; |
| 78 if (right_exclusion) { | 78 if (right_exclusion) { |
| 79 right_offset = right_exclusion->rect.BlockEndOffset(); | 79 right_offset = right_exclusion->rect.BlockEndOffset(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 switch (style.Clear()) { | 82 switch (clear_type) { |
| 83 case EClear::kNone: | 83 case EClear::kNone: |
| 84 return WTF::nullopt; // nothing to do here. | 84 return WTF::nullopt; // nothing to do here. |
| 85 case EClear::kLeft: | 85 case EClear::kLeft: |
| 86 return left_offset; | 86 return left_offset; |
| 87 case EClear::kRight: | 87 case EClear::kRight: |
| 88 return right_offset; | 88 return right_offset; |
| 89 case EClear::kBoth: | 89 case EClear::kBoth: |
| 90 return OptionalMax<LayoutUnit>(left_offset, right_offset); | 90 return OptionalMax<LayoutUnit>(left_offset, right_offset); |
| 91 default: | 91 default: |
| 92 NOTREACHED(); | 92 NOTREACHED(); |
| 93 } | 93 } |
| 94 return WTF::nullopt; | 94 return WTF::nullopt; |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool ShouldShrinkToFit(const ComputedStyle& parent_style, | 97 bool ShouldShrinkToFit(const ComputedStyle& parent_style, |
| 98 const ComputedStyle& style) { | 98 const ComputedStyle& style) { |
| 99 // Whether the child and the containing block are parallel to each other. | 99 // Whether the child and the containing block are parallel to each other. |
| 100 // Example: vertical-rl and vertical-lr | 100 // Example: vertical-rl and vertical-lr |
| 101 bool is_in_parallel_flow = IsParallelWritingMode( | 101 bool is_in_parallel_flow = IsParallelWritingMode( |
| 102 FromPlatformWritingMode(parent_style.GetWritingMode()), | 102 FromPlatformWritingMode(parent_style.GetWritingMode()), |
| 103 FromPlatformWritingMode(style.GetWritingMode())); | 103 FromPlatformWritingMode(style.GetWritingMode())); |
| 104 | 104 |
| 105 return style.Display() == EDisplay::kInlineBlock || style.IsFloating() || | 105 return style.Display() == EDisplay::kInlineBlock || style.IsFloating() || |
| 106 !is_in_parallel_flow; | 106 !is_in_parallel_flow; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void AdjustToClearance(const WTF::Optional<LayoutUnit>& clearance_offset, |
| 110 NGLogicalOffset* offset) { |
| 111 DCHECK(offset); |
| 112 if (clearance_offset) { |
| 113 offset->block_offset = |
| 114 std::max(clearance_offset.value(), offset->block_offset); |
| 115 } |
| 116 } |
| 117 |
| 109 } // namespace blink | 118 } // namespace blink |
| OLD | NEW |