Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1650)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_constraint_space.cc

Issue 2515923002: Remove redundant 'derived constraint space' setters from NGConstraintSpace (Closed)
Patch Set: sync to the head Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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)),
21 writing_mode_(writing_mode), 20 writing_mode_(writing_mode),
22 direction_(direction) {} 21 direction_(direction) {}
23 22
24 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject( 23 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject(
25 const LayoutBox& box) { 24 const LayoutBox& box) {
26 bool fixed_inline = false, fixed_block = false; 25 bool fixed_inline = false, fixed_block = false;
27 // XXX for orthogonal writing mode this is not right 26 // XXX for orthogonal writing mode this is not right
28 LayoutUnit available_logical_width = 27 LayoutUnit available_logical_width =
29 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); 28 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent());
30 LayoutUnit available_logical_height; 29 LayoutUnit available_logical_height;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // TODO(layout-ng): Implement. 135 // TODO(layout-ng): Implement.
137 } 136 }
138 137
139 NGLayoutOpportunityIterator* NGConstraintSpace::LayoutOpportunities( 138 NGLayoutOpportunityIterator* NGConstraintSpace::LayoutOpportunities(
140 unsigned clear, 139 unsigned clear,
141 bool for_inline_or_bfc) { 140 bool for_inline_or_bfc) {
142 NGLayoutOpportunityIterator* iterator = new NGLayoutOpportunityIterator(this); 141 NGLayoutOpportunityIterator* iterator = new NGLayoutOpportunityIterator(this);
143 return iterator; 142 return iterator;
144 } 143 }
145 144
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
185 NGConstraintSpace* NGConstraintSpace::ChildSpace( 145 NGConstraintSpace* NGConstraintSpace::ChildSpace(
186 const ComputedStyle* style) const { 146 const ComputedStyle* style) const {
187 return new NGConstraintSpace(FromPlatformWritingMode(style->getWritingMode()), 147 return new NGConstraintSpace(FromPlatformWritingMode(style->getWritingMode()),
188 style->direction(), MutablePhysicalSpace()); 148 style->direction(), MutablePhysicalSpace());
189 } 149 }
190 150
191 String NGConstraintSpace::ToString() const { 151 String NGConstraintSpace::ToString() const {
192 return String::format("%s,%s %sx%s", 152 return String::format("%s,%s %sx%s",
193 offset_.inline_offset.toString().ascii().data(), 153 offset_.inline_offset.toString().ascii().data(),
194 offset_.block_offset.toString().ascii().data(), 154 offset_.block_offset.toString().ascii().data(),
195 size_.inline_size.toString().ascii().data(), 155 AvailableSize().inline_size.toString().ascii().data(),
196 size_.block_size.toString().ascii().data()); 156 AvailableSize().block_size.toString().ascii().data());
197 } 157 }
198 158
199 } // namespace blink 159 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698