| 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 TextDirection direction, | 17 TextDirection direction, |
| 18 NGPhysicalConstraintSpace* physical_space) | 18 NGPhysicalConstraintSpace* physical_space) |
| 19 : physical_space_(physical_space), | 19 : physical_space_(physical_space), |
| 20 size_(physical_space->available_size_.ConvertToLogical(writing_mode)), |
| 20 writing_mode_(writing_mode), | 21 writing_mode_(writing_mode), |
| 21 direction_(direction) {} | 22 direction_(direction) {} |
| 22 | 23 |
| 23 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject( | 24 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject( |
| 24 const LayoutBox& box) { | 25 const LayoutBox& box) { |
| 25 bool fixed_inline = false, fixed_block = false; | 26 bool fixed_inline = false, fixed_block = false; |
| 26 // XXX for orthogonal writing mode this is not right | 27 // XXX for orthogonal writing mode this is not right |
| 27 LayoutUnit available_logical_width = | 28 LayoutUnit available_logical_width = |
| 28 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); | 29 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); |
| 29 LayoutUnit available_logical_height; | 30 LayoutUnit available_logical_height; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // TODO(layout-ng): Implement. | 136 // TODO(layout-ng): Implement. |
| 136 } | 137 } |
| 137 | 138 |
| 138 NGLayoutOpportunityIterator* NGConstraintSpace::LayoutOpportunities( | 139 NGLayoutOpportunityIterator* NGConstraintSpace::LayoutOpportunities( |
| 139 unsigned clear, | 140 unsigned clear, |
| 140 bool for_inline_or_bfc) { | 141 bool for_inline_or_bfc) { |
| 141 NGLayoutOpportunityIterator* iterator = new NGLayoutOpportunityIterator(this); | 142 NGLayoutOpportunityIterator* iterator = new NGLayoutOpportunityIterator(this); |
| 142 return iterator; | 143 return iterator; |
| 143 } | 144 } |
| 144 | 145 |
| 146 void NGConstraintSpace::SetOverflowTriggersScrollbar(bool inline_triggers, |
| 147 bool block_triggers) { |
| 148 if (writing_mode_ == HorizontalTopBottom) { |
| 149 physical_space_->width_direction_triggers_scrollbar_ = inline_triggers; |
| 150 physical_space_->height_direction_triggers_scrollbar_ = block_triggers; |
| 151 } else { |
| 152 physical_space_->width_direction_triggers_scrollbar_ = block_triggers; |
| 153 physical_space_->height_direction_triggers_scrollbar_ = inline_triggers; |
| 154 } |
| 155 } |
| 156 |
| 157 void NGConstraintSpace::SetFixedSize(bool inline_fixed, bool block_fixed) { |
| 158 if (writing_mode_ == HorizontalTopBottom) { |
| 159 physical_space_->fixed_width_ = inline_fixed; |
| 160 physical_space_->fixed_height_ = block_fixed; |
| 161 } else { |
| 162 physical_space_->fixed_width_ = block_fixed; |
| 163 physical_space_->fixed_height_ = inline_fixed; |
| 164 } |
| 165 } |
| 166 |
| 167 void NGConstraintSpace::SetFragmentationType(NGFragmentationType type) { |
| 168 if (writing_mode_ == HorizontalTopBottom) { |
| 169 DCHECK_EQ(static_cast<NGFragmentationType>( |
| 170 physical_space_->width_direction_fragmentation_type_), |
| 171 FragmentNone); |
| 172 physical_space_->height_direction_fragmentation_type_ = type; |
| 173 } else { |
| 174 DCHECK_EQ(static_cast<NGFragmentationType>( |
| 175 physical_space_->height_direction_fragmentation_type_), |
| 176 FragmentNone); |
| 177 physical_space_->width_direction_triggers_scrollbar_ = type; |
| 178 } |
| 179 } |
| 180 |
| 181 void NGConstraintSpace::SetIsNewFormattingContext(bool is_new_fc) { |
| 182 physical_space_->is_new_fc_ = is_new_fc; |
| 183 } |
| 184 |
| 145 NGConstraintSpace* NGConstraintSpace::ChildSpace( | 185 NGConstraintSpace* NGConstraintSpace::ChildSpace( |
| 146 const ComputedStyle* style) const { | 186 const ComputedStyle* style) const { |
| 147 return new NGConstraintSpace(FromPlatformWritingMode(style->getWritingMode()), | 187 return new NGConstraintSpace(FromPlatformWritingMode(style->getWritingMode()), |
| 148 style->direction(), MutablePhysicalSpace()); | 188 style->direction(), MutablePhysicalSpace()); |
| 149 } | 189 } |
| 150 | 190 |
| 151 String NGConstraintSpace::ToString() const { | 191 String NGConstraintSpace::ToString() const { |
| 152 return String::format("%s,%s %sx%s", | 192 return String::format("%s,%s %sx%s", |
| 153 offset_.inline_offset.toString().ascii().data(), | 193 offset_.inline_offset.toString().ascii().data(), |
| 154 offset_.block_offset.toString().ascii().data(), | 194 offset_.block_offset.toString().ascii().data(), |
| 155 AvailableSize().inline_size.toString().ascii().data(), | 195 size_.inline_size.toString().ascii().data(), |
| 156 AvailableSize().block_size.toString().ascii().data()); | 196 size_.block_size.toString().ascii().data()); |
| 157 } | 197 } |
| 158 | 198 |
| 159 } // namespace blink | 199 } // namespace blink |
| OLD | NEW |