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.h" | 5 #include "core/layout/ng/ng_constraint_space.h" |
6 | 6 |
7 #include "core/layout/LayoutBlock.h" | 7 #include "core/layout/LayoutBlock.h" |
8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
9 #include "core/layout/ng/ng_constraint_space.h" | 9 #include "core/layout/ng/ng_constraint_space.h" |
10 #include "core/layout/ng/ng_constraint_space_builder.h" | 10 #include "core/layout/ng/ng_constraint_space_builder.h" |
11 #include "core/layout/ng/ng_layout_opportunity_iterator.h" | 11 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
12 #include "core/layout/ng/ng_units.h" | 12 #include "core/layout/ng/ng_units.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | 16 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
17 NGDirection direction, | 17 NGDirection direction, |
18 NGPhysicalConstraintSpace* physical_space) | 18 NGPhysicalConstraintSpace* physical_space) |
19 : physical_space_(physical_space), | 19 : physical_space_(physical_space), |
20 size_(physical_space->ContainerSize().ConvertToLogical(writing_mode)), | 20 size_(physical_space->ContainerSize().ConvertToLogical(writing_mode)), |
21 writing_mode_(writing_mode), | 21 writing_mode_(writing_mode), |
22 direction_(direction) {} | 22 direction_(direction) {} |
23 | 23 |
24 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | |
25 NGDirection direction, | |
26 const NGConstraintSpace& other, | |
27 NGLogicalSize size) | |
28 : size_(size), writing_mode_(writing_mode), direction_(direction) { | |
29 physical_space_ = | |
30 new NGPhysicalConstraintSpace(size.ConvertToPhysical(writing_mode)); | |
31 for (const auto& exclusion : other.PhysicalSpace()->Exclusions()) { | |
32 physical_space_->AddExclusion(exclusion); | |
33 } | |
34 } | |
35 | |
36 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject( | 24 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject( |
37 const LayoutBox& box) { | 25 const LayoutBox& box) { |
38 bool fixed_inline = false, fixed_block = false, is_new_fc = false; | 26 bool fixed_inline = false, fixed_block = false, is_new_fc = false; |
39 // XXX for orthogonal writing mode this is not right | 27 // XXX for orthogonal writing mode this is not right |
40 LayoutUnit container_logical_width = | 28 LayoutUnit container_logical_width = |
41 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); | 29 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); |
42 LayoutUnit container_logical_height; | 30 LayoutUnit container_logical_height; |
43 if (!box.parent()) { | 31 if (!box.parent()) { |
44 container_logical_height = box.view()->viewLogicalHeightForPercentages(); | 32 container_logical_height = box.view()->viewLogicalHeightForPercentages(); |
45 } else if (box.containingBlock()) { | 33 } else if (box.containingBlock()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 72 |
85 void NGConstraintSpace::AddExclusion(const NGExclusion* exclusion) const { | 73 void NGConstraintSpace::AddExclusion(const NGExclusion* exclusion) const { |
86 MutablePhysicalSpace()->AddExclusion(exclusion); | 74 MutablePhysicalSpace()->AddExclusion(exclusion); |
87 } | 75 } |
88 | 76 |
89 NGLogicalSize NGConstraintSpace::ContainerSize() const { | 77 NGLogicalSize NGConstraintSpace::ContainerSize() const { |
90 return physical_space_->container_size_.ConvertToLogical( | 78 return physical_space_->container_size_.ConvertToLogical( |
91 static_cast<NGWritingMode>(writing_mode_)); | 79 static_cast<NGWritingMode>(writing_mode_)); |
92 } | 80 } |
93 | 81 |
| 82 void NGConstraintSpace::SetSize(NGLogicalSize size) { |
| 83 size_ = size; |
| 84 } |
| 85 |
94 bool NGConstraintSpace::IsNewFormattingContext() const { | 86 bool NGConstraintSpace::IsNewFormattingContext() const { |
95 return physical_space_->is_new_fc_; | 87 return physical_space_->is_new_fc_; |
96 } | 88 } |
97 | 89 |
98 bool NGConstraintSpace::InlineTriggersScrollbar() const { | 90 bool NGConstraintSpace::InlineTriggersScrollbar() const { |
99 return writing_mode_ == HorizontalTopBottom | 91 return writing_mode_ == HorizontalTopBottom |
100 ? physical_space_->width_direction_triggers_scrollbar_ | 92 ? physical_space_->width_direction_triggers_scrollbar_ |
101 : physical_space_->height_direction_triggers_scrollbar_; | 93 : physical_space_->height_direction_triggers_scrollbar_; |
102 } | 94 } |
103 | 95 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 168 |
177 String NGConstraintSpace::ToString() const { | 169 String NGConstraintSpace::ToString() const { |
178 return String::format("%s,%s %sx%s", | 170 return String::format("%s,%s %sx%s", |
179 offset_.inline_offset.toString().ascii().data(), | 171 offset_.inline_offset.toString().ascii().data(), |
180 offset_.block_offset.toString().ascii().data(), | 172 offset_.block_offset.toString().ascii().data(), |
181 size_.inline_size.toString().ascii().data(), | 173 size_.inline_size.toString().ascii().data(), |
182 size_.block_size.toString().ascii().data()); | 174 size_.block_size.toString().ascii().data()); |
183 } | 175 } |
184 | 176 |
185 } // namespace blink | 177 } // namespace blink |
OLD | NEW |