| 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_layout_opportunity_iterator.h" | 9 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
| 10 #include "core/layout/ng/ng_units.h" | 10 #include "core/layout/ng/ng_units.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 // TODO: This should set the size of the NGPhysicalConstraintSpace. Or we could | |
| 15 // remove it requiring that a NGConstraintSpace is created from a | |
| 16 // NGPhysicalConstraintSpace. | |
| 17 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | 14 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
| 18 NGDirection direction, | 15 NGDirection direction, |
| 19 NGLogicalSize container_size) | 16 NGLogicalSize container_size) |
| 20 : physical_space_(new NGPhysicalConstraintSpace( | 17 : physical_space_(new NGPhysicalConstraintSpace( |
| 21 container_size.ConvertToPhysical(writing_mode))), | 18 container_size.ConvertToPhysical(writing_mode))), |
| 22 size_(container_size), | 19 size_(container_size), |
| 23 writing_mode_(writing_mode), | 20 writing_mode_(writing_mode), |
| 24 direction_(direction) {} | 21 direction_(direction) {} |
| 25 | 22 |
| 26 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | 23 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
| 27 NGDirection direction, | 24 NGDirection direction, |
| 28 NGPhysicalConstraintSpace* physical_space) | 25 NGPhysicalConstraintSpace* physical_space) |
| 29 : physical_space_(physical_space), | 26 : physical_space_(physical_space), |
| 30 size_(physical_space->ContainerSize().ConvertToLogical(writing_mode)), | 27 size_(physical_space->ContainerSize().ConvertToLogical(writing_mode)), |
| 31 writing_mode_(writing_mode), | 28 writing_mode_(writing_mode), |
| 32 direction_(direction) {} | 29 direction_(direction) {} |
| 33 | 30 |
| 34 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | 31 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
| 35 NGDirection direction, | 32 NGDirection direction, |
| 36 const NGConstraintSpace* constraint_space) | 33 const NGConstraintSpace* constraint_space) |
| 37 : physical_space_(constraint_space->PhysicalSpace()), | 34 : physical_space_(constraint_space->PhysicalSpace()), |
| 38 offset_(constraint_space->Offset()), | 35 offset_(constraint_space->Offset()), |
| 39 size_(constraint_space->Size()), | 36 size_(constraint_space->Size()), |
| 40 writing_mode_(writing_mode), | 37 writing_mode_(writing_mode), |
| 41 direction_(direction) {} | 38 direction_(direction) {} |
| 42 | 39 |
| 43 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | |
| 44 NGDirection direction, | |
| 45 const NGConstraintSpace& other, | |
| 46 NGLogicalOffset offset, | |
| 47 NGLogicalSize size) | |
| 48 : physical_space_(other.PhysicalSpace()), | |
| 49 offset_(offset), | |
| 50 size_(size), | |
| 51 writing_mode_(writing_mode), | |
| 52 direction_(direction) {} | |
| 53 | |
| 54 NGConstraintSpace::NGConstraintSpace(const NGConstraintSpace& other, | 40 NGConstraintSpace::NGConstraintSpace(const NGConstraintSpace& other, |
| 55 NGLogicalOffset offset, | 41 NGLogicalOffset offset, |
| 56 NGLogicalSize size) | 42 NGLogicalSize size) |
| 57 : physical_space_(other.PhysicalSpace()), | 43 : physical_space_(other.PhysicalSpace()), |
| 58 offset_(offset), | 44 offset_(offset), |
| 59 size_(size), | 45 size_(size), |
| 60 writing_mode_(other.WritingMode()), | 46 writing_mode_(other.WritingMode()), |
| 61 direction_(other.Direction()) {} | 47 direction_(other.Direction()) {} |
| 62 | 48 |
| 49 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
| 50 NGDirection direction, |
| 51 const NGConstraintSpace& other, |
| 52 NGLogicalSize size) |
| 53 : size_(size), writing_mode_(writing_mode), direction_(direction) { |
| 54 physical_space_ = |
| 55 new NGPhysicalConstraintSpace(size.ConvertToPhysical(writing_mode)); |
| 56 for (const NGExclusion& exclusion : other.PhysicalSpace()->Exclusions()) { |
| 57 physical_space_->AddExclusion(exclusion); |
| 58 } |
| 59 } |
| 60 |
| 63 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject( | 61 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject( |
| 64 const LayoutBox& box) { | 62 const LayoutBox& box) { |
| 65 bool fixed_inline = false, fixed_block = false; | 63 bool fixed_inline = false, fixed_block = false; |
| 66 // XXX for orthogonal writing mode this is not right | 64 // XXX for orthogonal writing mode this is not right |
| 67 LayoutUnit container_logical_width = | 65 LayoutUnit container_logical_width = |
| 68 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); | 66 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); |
| 69 LayoutUnit container_logical_height; | 67 LayoutUnit container_logical_height; |
| 70 if (!box.parent()) { | 68 if (!box.parent()) { |
| 71 container_logical_height = box.view()->viewLogicalHeightForPercentages(); | 69 container_logical_height = box.view()->viewLogicalHeightForPercentages(); |
| 72 } else if (box.containingBlock()) { | 70 } else if (box.containingBlock()) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 172 } |
| 175 } | 173 } |
| 176 | 174 |
| 177 String NGConstraintSpace::toString() const { | 175 String NGConstraintSpace::toString() const { |
| 178 return String::format("Size: %s, %s", | 176 return String::format("Size: %s, %s", |
| 179 size_.inline_size.toString().ascii().data(), | 177 size_.inline_size.toString().ascii().data(), |
| 180 size_.block_size.toString().ascii().data()); | 178 size_.block_size.toString().ascii().data()); |
| 181 } | 179 } |
| 182 | 180 |
| 183 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |