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/ng/ng_units.h" | 7 #include "core/layout/ng/ng_units.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
| 11 static inline NGLogicalSize LogicalSizeForWritingMode( |
| 12 NGWritingMode writing_mode, |
| 13 NGPhysicalConstraintSpace* physical_space) { |
| 14 return writing_mode == HorizontalTopBottom |
| 15 ? NGLogicalSize(physical_space->ContainerSize().width, |
| 16 physical_space->ContainerSize().height) |
| 17 : NGLogicalSize(physical_space->ContainerSize().height, |
| 18 physical_space->ContainerSize().width); |
| 19 } |
| 20 |
| 21 // TODO: This should set the size of the NGPhysicalConstraintSpace. Or we could |
| 22 // remove it requiring that a NGConstraintSpace is created from a |
| 23 // NGPhysicalConstraintSpace. |
11 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | 24 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
12 NGLogicalSize container_size) | 25 NGLogicalSize container_size) |
13 : physical_space_(new NGPhysicalConstraintSpace()), | 26 : physical_space_(new NGPhysicalConstraintSpace()), |
14 writing_mode_(writing_mode) { | 27 writing_mode_(writing_mode) { |
15 SetContainerSize(container_size); | 28 SetContainerSize(container_size); |
16 } | 29 } |
17 | 30 |
| 31 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
| 32 NGPhysicalConstraintSpace* physical_space) |
| 33 : physical_space_(physical_space), writing_mode_(writing_mode) { |
| 34 SetContainerSize(LogicalSizeForWritingMode(writing_mode, physical_space)); |
| 35 } |
| 36 |
18 NGConstraintSpace::NGConstraintSpace(const NGConstraintSpace& other, | 37 NGConstraintSpace::NGConstraintSpace(const NGConstraintSpace& other, |
19 NGLogicalSize container_size) | 38 NGLogicalSize container_size) |
20 : physical_space_(new NGPhysicalConstraintSpace(*other.physical_space_)), | 39 : physical_space_(*other.physical_space_), |
21 writing_mode_(other.writing_mode_) { | 40 writing_mode_(other.writing_mode_) { |
22 SetContainerSize(container_size); | 41 SetContainerSize(container_size); |
23 } | 42 } |
24 | 43 |
25 NGLogicalSize NGConstraintSpace::ContainerSize() const { | 44 NGLogicalSize NGConstraintSpace::ContainerSize() const { |
26 return writing_mode_ == HorizontalTopBottom | 45 return LogicalSizeForWritingMode(WritingMode(), physical_space_); |
27 ? NGLogicalSize(physical_space_->container_size_.width, | |
28 physical_space_->container_size_.height) | |
29 : NGLogicalSize(physical_space_->container_size_.height, | |
30 physical_space_->container_size_.width); | |
31 } | 46 } |
32 | 47 |
33 bool NGConstraintSpace::InlineTriggersScrollbar() const { | 48 bool NGConstraintSpace::InlineTriggersScrollbar() const { |
34 return writing_mode_ == HorizontalTopBottom | 49 return writing_mode_ == HorizontalTopBottom |
35 ? physical_space_->width_direction_triggers_scrollbar_ | 50 ? physical_space_->width_direction_triggers_scrollbar_ |
36 : physical_space_->height_direction_triggers_scrollbar_; | 51 : physical_space_->height_direction_triggers_scrollbar_; |
37 } | 52 } |
38 | 53 |
39 bool NGConstraintSpace::BlockTriggersScrollbar() const { | 54 bool NGConstraintSpace::BlockTriggersScrollbar() const { |
40 return writing_mode_ == HorizontalTopBottom | 55 return writing_mode_ == HorizontalTopBottom |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 physical_space_->height_direction_fragmentation_type_ = type; | 125 physical_space_->height_direction_fragmentation_type_ = type; |
111 } else { | 126 } else { |
112 DCHECK_EQ(static_cast<NGFragmentationType>( | 127 DCHECK_EQ(static_cast<NGFragmentationType>( |
113 physical_space_->height_direction_fragmentation_type_), | 128 physical_space_->height_direction_fragmentation_type_), |
114 FragmentNone); | 129 FragmentNone); |
115 physical_space_->width_direction_triggers_scrollbar_ = type; | 130 physical_space_->width_direction_triggers_scrollbar_ = type; |
116 } | 131 } |
117 } | 132 } |
118 | 133 |
119 } // namespace blink | 134 } // namespace blink |
OLD | NEW |