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_block_layout_algorithm.h" | 5 #include "core/layout/ng/ng_block_layout_algorithm.h" |
6 | 6 |
7 #include "core/layout/ng/ng_break_token.h" | 7 #include "core/layout/ng/ng_break_token.h" |
8 #include "core/layout/ng/ng_constraint_space.h" | 8 #include "core/layout/ng/ng_constraint_space.h" |
9 #include "core/layout/ng/ng_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
10 #include "core/layout/ng/ng_fragment_base.h" | 10 #include "core/layout/ng/ng_fragment_base.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 // (https://drafts.csswg.org/css-multicol-1/#valdef-column-span-all) | 156 // (https://drafts.csswg.org/css-multicol-1/#valdef-column-span-all) |
157 | 157 |
158 if (style.specifiesColumns() || style.containsPaint() || | 158 if (style.specifiesColumns() || style.containsPaint() || |
159 style.containsLayout()) | 159 style.containsLayout()) |
160 return true; | 160 return true; |
161 | 161 |
162 if (!style.isOverflowVisible()) | 162 if (!style.isOverflowVisible()) |
163 return true; | 163 return true; |
164 | 164 |
165 EDisplay display = style.display(); | 165 EDisplay display = style.display(); |
166 | |
ikilpatrick
2016/12/02 17:47:05
remove from this patch.
atotic
2016/12/02 19:55:15
done
| |
166 if (display == EDisplay::Grid || display == EDisplay::Flex || | 167 if (display == EDisplay::Grid || display == EDisplay::Flex || |
167 display == EDisplay::WebkitBox) | 168 display == EDisplay::WebkitBox) |
168 return true; | 169 return true; |
169 | 170 |
170 if (space.WritingMode() != FromPlatformWritingMode(style.getWritingMode())) | 171 if (space.WritingMode() != FromPlatformWritingMode(style.getWritingMode())) |
171 return true; | 172 return true; |
172 | 173 |
173 return false; | 174 return false; |
174 } | 175 } |
175 | 176 |
(...skipping 14 matching lines...) Expand all Loading... | |
190 } | 191 } |
191 | 192 |
192 NGLayoutStatus NGBlockLayoutAlgorithm::Layout( | 193 NGLayoutStatus NGBlockLayoutAlgorithm::Layout( |
193 NGFragmentBase*, | 194 NGFragmentBase*, |
194 NGPhysicalFragmentBase** fragment_out, | 195 NGPhysicalFragmentBase** fragment_out, |
195 NGLayoutAlgorithm**) { | 196 NGLayoutAlgorithm**) { |
196 switch (state_) { | 197 switch (state_) { |
197 case kStateInit: { | 198 case kStateInit: { |
198 border_and_padding_ = | 199 border_and_padding_ = |
199 ComputeBorders(Style()) + ComputePadding(ConstraintSpace(), Style()); | 200 ComputeBorders(Style()) + ComputePadding(ConstraintSpace(), Style()); |
200 | |
ikilpatrick
2016/12/02 17:47:05
remove from this patch.
atotic
2016/12/02 19:55:15
done
| |
201 WTF::Optional<MinAndMaxContentSizes> sizes; | 201 WTF::Optional<MinAndMaxContentSizes> sizes; |
202 if (NeedMinAndMaxContentSizes(Style())) { | 202 if (NeedMinAndMaxContentSizes(Style())) { |
203 // TODOO(layout-ng): Implement | 203 // TODOO(layout-ng): Implement |
204 sizes = MinAndMaxContentSizes(); | 204 sizes = MinAndMaxContentSizes(); |
205 } | 205 } |
206 LayoutUnit inline_size = | 206 LayoutUnit inline_size = |
207 ComputeInlineSizeForFragment(ConstraintSpace(), Style(), sizes); | 207 ComputeInlineSizeForFragment(ConstraintSpace(), Style(), sizes); |
208 LayoutUnit adjusted_inline_size = | 208 LayoutUnit adjusted_inline_size = |
209 inline_size - border_and_padding_.InlineSum(); | 209 inline_size - border_and_padding_.InlineSum(); |
210 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of | 210 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of |
(...skipping 27 matching lines...) Expand all Loading... | |
238 builder_->SetInlineSize(inline_size).SetBlockSize(block_size); | 238 builder_->SetInlineSize(inline_size).SetBlockSize(block_size); |
239 current_child_ = first_child_; | 239 current_child_ = first_child_; |
240 if (current_child_) | 240 if (current_child_) |
241 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); | 241 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); |
242 | 242 |
243 state_ = kStateChildLayout; | 243 state_ = kStateChildLayout; |
244 return kNotFinished; | 244 return kNotFinished; |
245 } | 245 } |
246 case kStateChildLayout: { | 246 case kStateChildLayout: { |
247 if (current_child_) { | 247 if (current_child_) { |
248 // TODO(atotic): uncomment this code when implementing oof layout. | |
249 // This code cannot be turned on because it prevents layout of | |
250 // oof children, and non-layedout objects trigger a DCHECK. | |
251 // EPosition position = current_child_->Style()->position(); | |
252 // if ((position == AbsolutePosition || position == FixedPosition)) { | |
253 // builder_->AddOutOfFlowCandidateChild(current_child_, | |
254 // GetChildSpaceOffset()); | |
255 // } | |
256 // else | |
248 if (!LayoutCurrentChild()) | 257 if (!LayoutCurrentChild()) |
249 return kNotFinished; | 258 return kNotFinished; |
250 current_child_ = current_child_->NextSibling(); | 259 current_child_ = current_child_->NextSibling(); |
251 if (current_child_) { | 260 if (current_child_) { |
252 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); | 261 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); |
253 return kNotFinished; | 262 return kNotFinished; |
254 } | 263 } |
255 } | 264 } |
256 state_ = kStateFinalize; | 265 state_ = kStateFinalize; |
257 return kNotFinished; | 266 return kNotFinished; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
427 NGBlockLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { | 436 NGBlockLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { |
428 DCHECK(current_child_); | 437 DCHECK(current_child_); |
429 space_builder_->SetIsNewFormattingContext( | 438 space_builder_->SetIsNewFormattingContext( |
430 IsNewFormattingContextForInFlowBlockLevelChild(ConstraintSpace(), | 439 IsNewFormattingContextForInFlowBlockLevelChild(ConstraintSpace(), |
431 CurrentChildStyle())); | 440 CurrentChildStyle())); |
432 NGConstraintSpace* child_space = new NGConstraintSpace( | 441 NGConstraintSpace* child_space = new NGConstraintSpace( |
433 constraint_space_->WritingMode(), constraint_space_->Direction(), | 442 constraint_space_->WritingMode(), constraint_space_->Direction(), |
434 space_builder_->ToConstraintSpace()); | 443 space_builder_->ToConstraintSpace()); |
435 | 444 |
436 // TODO(layout-ng): Set offset through the space builder. | 445 // TODO(layout-ng): Set offset through the space builder. |
437 child_space->SetOffset( | 446 child_space->SetOffset(GetChildSpaceOffset()); |
438 NGLogicalOffset(border_and_padding_.inline_start, content_size_)); | |
439 | 447 |
440 // TODO(layout-ng): avoid copying here. A child and parent constraint spaces | 448 // TODO(layout-ng): avoid copying here. A child and parent constraint spaces |
441 // should share the same backing space. | 449 // should share the same backing space. |
442 for (const auto& exclusion : constraint_space_->Exclusions()) { | 450 for (const auto& exclusion : constraint_space_->Exclusions()) { |
443 child_space->AddExclusion(*exclusion.get()); | 451 child_space->AddExclusion(*exclusion.get()); |
444 } | 452 } |
445 return child_space; | 453 return child_space; |
446 } | 454 } |
447 | 455 |
448 DEFINE_TRACE(NGBlockLayoutAlgorithm) { | 456 DEFINE_TRACE(NGBlockLayoutAlgorithm) { |
449 NGLayoutAlgorithm::trace(visitor); | 457 NGLayoutAlgorithm::trace(visitor); |
450 visitor->trace(first_child_); | 458 visitor->trace(first_child_); |
451 visitor->trace(constraint_space_); | 459 visitor->trace(constraint_space_); |
452 visitor->trace(break_token_); | 460 visitor->trace(break_token_); |
453 visitor->trace(builder_); | 461 visitor->trace(builder_); |
454 visitor->trace(space_builder_); | 462 visitor->trace(space_builder_); |
455 visitor->trace(space_for_current_child_); | 463 visitor->trace(space_for_current_child_); |
456 visitor->trace(current_child_); | 464 visitor->trace(current_child_); |
457 } | 465 } |
458 | 466 |
459 } // namespace blink | 467 } // namespace blink |
OLD | NEW |