| 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" |
| 10 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 9 #include "core/layout/ng/ng_layout_opportunity_iterator.h" | 11 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
| 10 #include "core/layout/ng/ng_units.h" | 12 #include "core/layout/ng/ng_units.h" |
| 11 | 13 |
| 12 namespace blink { | 14 namespace blink { |
| 13 | 15 |
| 14 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | 16 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
| 15 NGDirection direction, | 17 NGDirection direction, |
| 16 NGPhysicalConstraintSpace* physical_space) | 18 NGPhysicalConstraintSpace* physical_space) |
| 17 : physical_space_(physical_space), | 19 : physical_space_(physical_space), |
| 18 size_(physical_space->ContainerSize().ConvertToLogical(writing_mode)), | 20 size_(physical_space->ContainerSize().ConvertToLogical(writing_mode)), |
| 19 writing_mode_(writing_mode), | 21 writing_mode_(writing_mode), |
| 20 direction_(direction) {} | 22 direction_(direction) {} |
| 21 | 23 |
| 22 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | 24 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, |
| 23 NGDirection direction, | 25 NGDirection direction, |
| 24 NGLogicalSize container_size) | |
| 25 : physical_space_(new NGPhysicalConstraintSpace( | |
| 26 container_size.ConvertToPhysical(writing_mode))), | |
| 27 size_(container_size), | |
| 28 writing_mode_(writing_mode), | |
| 29 direction_(direction) {} | |
| 30 | |
| 31 NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode, | |
| 32 NGDirection direction, | |
| 33 const NGConstraintSpace& other, | 26 const NGConstraintSpace& other, |
| 34 NGLogicalSize size) | 27 NGLogicalSize size) |
| 35 : size_(size), writing_mode_(writing_mode), direction_(direction) { | 28 : size_(size), writing_mode_(writing_mode), direction_(direction) { |
| 36 physical_space_ = | 29 physical_space_ = |
| 37 new NGPhysicalConstraintSpace(size.ConvertToPhysical(writing_mode)); | 30 new NGPhysicalConstraintSpace(size.ConvertToPhysical(writing_mode)); |
| 38 for (const auto& exclusion : other.PhysicalSpace()->Exclusions()) { | 31 for (const auto& exclusion : other.PhysicalSpace()->Exclusions()) { |
| 39 physical_space_->AddExclusion(exclusion); | 32 physical_space_->AddExclusion(exclusion); |
| 40 } | 33 } |
| 41 } | 34 } |
| 42 | 35 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 63 } | 56 } |
| 64 if (box.hasOverrideLogicalContentHeight()) { | 57 if (box.hasOverrideLogicalContentHeight()) { |
| 65 container_logical_height = box.borderAndPaddingLogicalHeight() + | 58 container_logical_height = box.borderAndPaddingLogicalHeight() + |
| 66 box.overrideLogicalContentHeight(); | 59 box.overrideLogicalContentHeight(); |
| 67 fixed_block = true; | 60 fixed_block = true; |
| 68 } | 61 } |
| 69 | 62 |
| 70 if (box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext()) | 63 if (box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext()) |
| 71 is_new_fc = true; | 64 is_new_fc = true; |
| 72 | 65 |
| 73 NGConstraintSpace* derived_constraint_space = new NGConstraintSpace( | 66 NGConstraintSpaceBuilder builder( |
| 67 FromPlatformWritingMode(box.styleRef().getWritingMode())); |
| 68 builder |
| 69 .SetContainerSize( |
| 70 NGLogicalSize(container_logical_width, container_logical_height)) |
| 71 .SetIsInlineDirectionTriggersScrollbar( |
| 72 box.styleRef().overflowInlineDirection() == OverflowAuto) |
| 73 .SetIsBlockDirectionTriggersScrollbar( |
| 74 box.styleRef().overflowBlockDirection() == OverflowAuto) |
| 75 .SetIsFixedSizeInline(fixed_inline) |
| 76 .SetIsFixedSizeBlock(fixed_block) |
| 77 .SetIsNewFormattingContext(is_new_fc); |
| 78 |
| 79 return new NGConstraintSpace( |
| 74 FromPlatformWritingMode(box.styleRef().getWritingMode()), | 80 FromPlatformWritingMode(box.styleRef().getWritingMode()), |
| 75 FromPlatformDirection(box.styleRef().direction()), | 81 FromPlatformDirection(box.styleRef().direction()), |
| 76 NGLogicalSize(container_logical_width, container_logical_height)); | 82 builder.ToConstraintSpace()); |
| 77 derived_constraint_space->SetOverflowTriggersScrollbar( | |
| 78 box.styleRef().overflowInlineDirection() == OverflowAuto, | |
| 79 box.styleRef().overflowBlockDirection() == OverflowAuto); | |
| 80 derived_constraint_space->SetFixedSize(fixed_inline, fixed_block); | |
| 81 derived_constraint_space->SetIsNewFormattingContext(is_new_fc); | |
| 82 | |
| 83 return derived_constraint_space; | |
| 84 } | 83 } |
| 85 | 84 |
| 86 void NGConstraintSpace::AddExclusion(const NGExclusion* exclusion) const { | 85 void NGConstraintSpace::AddExclusion(const NGExclusion* exclusion) const { |
| 87 MutablePhysicalSpace()->AddExclusion(exclusion); | 86 MutablePhysicalSpace()->AddExclusion(exclusion); |
| 88 } | 87 } |
| 89 | 88 |
| 90 NGLogicalSize NGConstraintSpace::ContainerSize() const { | 89 NGLogicalSize NGConstraintSpace::ContainerSize() const { |
| 91 return physical_space_->container_size_.ConvertToLogical( | 90 return physical_space_->container_size_.ConvertToLogical( |
| 92 static_cast<NGWritingMode>(writing_mode_)); | 91 static_cast<NGWritingMode>(writing_mode_)); |
| 93 } | 92 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 176 |
| 178 String NGConstraintSpace::ToString() const { | 177 String NGConstraintSpace::ToString() const { |
| 179 return String::format("%s,%s %sx%s", | 178 return String::format("%s,%s %sx%s", |
| 180 offset_.inline_offset.toString().ascii().data(), | 179 offset_.inline_offset.toString().ascii().data(), |
| 181 offset_.block_offset.toString().ascii().data(), | 180 offset_.block_offset.toString().ascii().data(), |
| 182 size_.inline_size.toString().ascii().data(), | 181 size_.inline_size.toString().ascii().data(), |
| 183 size_.block_size.toString().ascii().data()); | 182 size_.block_size.toString().ascii().data()); |
| 184 } | 183 } |
| 185 | 184 |
| 186 } // namespace blink | 185 } // namespace blink |
| OLD | NEW |