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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |