| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_constraint_space_builder.h" | 5 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/ng_length_utils.h" | 7 #include "core/layout/ng/ng_length_utils.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return *this; | 67 return *this; |
| 68 } | 68 } |
| 69 | 69 |
| 70 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetMarginStrut( | 70 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetMarginStrut( |
| 71 const NGMarginStrut& margin_strut) { | 71 const NGMarginStrut& margin_strut) { |
| 72 margin_strut_ = margin_strut; | 72 margin_strut_ = margin_strut; |
| 73 return *this; | 73 return *this; |
| 74 } | 74 } |
| 75 | 75 |
| 76 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetBfcOffset( | 76 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetBfcOffset( |
| 77 const NGLogicalOffset& offset) { | 77 const NGLogicalOffset& bfc_offset) { |
| 78 bfc_offset_ = offset; | 78 bfc_offset_ = bfc_offset; |
| 79 return *this; | 79 return *this; |
| 80 } | 80 } |
| 81 | 81 |
| 82 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetFloatsBfcOffset( |
| 83 const WTF::Optional<NGLogicalOffset>& floats_bfc_offset) { |
| 84 floats_bfc_offset_ = floats_bfc_offset; |
| 85 return *this; |
| 86 } |
| 87 |
| 82 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetClearanceOffset( | 88 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetClearanceOffset( |
| 83 const WTF::Optional<LayoutUnit>& clearance_offset) { | 89 const WTF::Optional<LayoutUnit>& clearance_offset) { |
| 84 clearance_offset_ = clearance_offset; | 90 clearance_offset_ = clearance_offset; |
| 85 return *this; | 91 return *this; |
| 86 } | 92 } |
| 87 | 93 |
| 88 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetIsFixedSizeInline( | 94 NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetIsFixedSizeInline( |
| 89 bool is_fixed_size_inline) { | 95 bool is_fixed_size_inline) { |
| 90 is_fixed_size_inline_ = is_fixed_size_inline; | 96 is_fixed_size_inline_ = is_fixed_size_inline; |
| 91 return *this; | 97 return *this; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 187 |
| 182 // Reset things that do not pass the Formatting Context boundary. | 188 // Reset things that do not pass the Formatting Context boundary. |
| 183 std::shared_ptr<NGExclusions> exclusions( | 189 std::shared_ptr<NGExclusions> exclusions( |
| 184 is_new_fc_ ? std::make_shared<NGExclusions>() : exclusions_); | 190 is_new_fc_ ? std::make_shared<NGExclusions>() : exclusions_); |
| 185 if (is_new_fc_) | 191 if (is_new_fc_) |
| 186 DCHECK(unpositioned_floats_.IsEmpty()); | 192 DCHECK(unpositioned_floats_.IsEmpty()); |
| 187 NGLogicalOffset bfc_offset = is_new_fc_ ? NGLogicalOffset() : bfc_offset_; | 193 NGLogicalOffset bfc_offset = is_new_fc_ ? NGLogicalOffset() : bfc_offset_; |
| 188 NGMarginStrut margin_strut = is_new_fc_ ? NGMarginStrut() : margin_strut_; | 194 NGMarginStrut margin_strut = is_new_fc_ ? NGMarginStrut() : margin_strut_; |
| 189 WTF::Optional<LayoutUnit> clearance_offset = | 195 WTF::Optional<LayoutUnit> clearance_offset = |
| 190 is_new_fc_ ? WTF::nullopt : clearance_offset_; | 196 is_new_fc_ ? WTF::nullopt : clearance_offset_; |
| 197 WTF::Optional<NGLogicalOffset> floats_bfc_offset = |
| 198 is_new_fc_ ? WTF::nullopt : floats_bfc_offset_; |
| 199 |
| 200 // The inline_offsets of the bfc_offset and floats_bfc_offset should match. |
| 201 if (floats_bfc_offset) |
| 202 DCHECK_EQ(bfc_offset.inline_offset, |
| 203 floats_bfc_offset.value().inline_offset); |
| 191 | 204 |
| 192 if (is_in_parallel_flow) { | 205 if (is_in_parallel_flow) { |
| 193 return AdoptRef(new NGConstraintSpace( | 206 return AdoptRef(new NGConstraintSpace( |
| 194 static_cast<NGWritingMode>(out_writing_mode), | 207 static_cast<NGWritingMode>(out_writing_mode), |
| 195 static_cast<TextDirection>(text_direction_), available_size, | 208 static_cast<TextDirection>(text_direction_), available_size, |
| 196 percentage_resolution_size, initial_containing_block_size_, | 209 percentage_resolution_size, initial_containing_block_size_, |
| 197 fragmentainer_space_available_, is_fixed_size_inline_, | 210 fragmentainer_space_available_, is_fixed_size_inline_, |
| 198 is_fixed_size_block_, is_shrink_to_fit_, | 211 is_fixed_size_block_, is_shrink_to_fit_, |
| 199 is_inline_direction_triggers_scrollbar_, | 212 is_inline_direction_triggers_scrollbar_, |
| 200 is_block_direction_triggers_scrollbar_, | 213 is_block_direction_triggers_scrollbar_, |
| 201 static_cast<NGFragmentationType>(fragmentation_type_), is_new_fc_, | 214 static_cast<NGFragmentationType>(fragmentation_type_), is_new_fc_, |
| 202 is_anonymous_, margin_strut, bfc_offset, exclusions, | 215 is_anonymous_, margin_strut, bfc_offset, floats_bfc_offset, exclusions, |
| 203 unpositioned_floats_, clearance_offset)); | 216 unpositioned_floats_, clearance_offset)); |
| 204 } | 217 } |
| 205 return AdoptRef(new NGConstraintSpace( | 218 return AdoptRef(new NGConstraintSpace( |
| 206 out_writing_mode, static_cast<TextDirection>(text_direction_), | 219 out_writing_mode, static_cast<TextDirection>(text_direction_), |
| 207 available_size, percentage_resolution_size, | 220 available_size, percentage_resolution_size, |
| 208 initial_containing_block_size_, fragmentainer_space_available_, | 221 initial_containing_block_size_, fragmentainer_space_available_, |
| 209 is_fixed_size_block_, is_fixed_size_inline_, is_shrink_to_fit_, | 222 is_fixed_size_block_, is_fixed_size_inline_, is_shrink_to_fit_, |
| 210 is_block_direction_triggers_scrollbar_, | 223 is_block_direction_triggers_scrollbar_, |
| 211 is_inline_direction_triggers_scrollbar_, | 224 is_inline_direction_triggers_scrollbar_, |
| 212 static_cast<NGFragmentationType>(fragmentation_type_), is_new_fc_, | 225 static_cast<NGFragmentationType>(fragmentation_type_), is_new_fc_, |
| 213 is_anonymous_, margin_strut, bfc_offset, exclusions, unpositioned_floats_, | 226 is_anonymous_, margin_strut, bfc_offset, floats_bfc_offset, exclusions, |
| 214 clearance_offset)); | 227 unpositioned_floats_, clearance_offset)); |
| 215 } | 228 } |
| 216 | 229 |
| 217 } // namespace blink | 230 } // namespace blink |
| OLD | NEW |