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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 return kNotFinished; | 263 return kNotFinished; |
264 } | 264 } |
265 case kStateChildLayout: { | 265 case kStateChildLayout: { |
266 DCHECK(current_child_); | 266 DCHECK(current_child_); |
267 DCHECK(child_fragment); | 267 DCHECK(child_fragment); |
268 | 268 |
269 // TODO(layout_ng): Seems like a giant hack to call this here. | 269 // TODO(layout_ng): Seems like a giant hack to call this here. |
270 current_child_->UpdateLayoutBox(toNGPhysicalFragment(child_fragment), | 270 current_child_->UpdateLayoutBox(toNGPhysicalFragment(child_fragment), |
271 space_for_current_child_); | 271 space_for_current_child_); |
272 | 272 |
273 FinishCurrentChildLayout( | 273 FinishCurrentChildLayout(new NGFragment( |
274 new NGFragment(space_for_current_child_->WritingMode(), | 274 ConstraintSpace().WritingMode(), ConstraintSpace().Direction(), |
275 current_child_->Style()->direction(), | 275 toNGPhysicalFragment(child_fragment))); |
276 toNGPhysicalFragment(child_fragment))); | |
277 current_child_ = current_child_->NextSibling(); | 276 current_child_ = current_child_->NextSibling(); |
278 state_ = kStatePrepareForChildLayout; | 277 state_ = kStatePrepareForChildLayout; |
279 return kNotFinished; | 278 return kNotFinished; |
280 } | 279 } |
281 case kStateFinalize: { | 280 case kStateFinalize: { |
282 content_size_ += border_and_padding_.block_end; | 281 content_size_ += border_and_padding_.block_end; |
283 | 282 |
284 // Recompute the block-axis size now that we know our content size. | 283 // Recompute the block-axis size now that we know our content size. |
285 LayoutUnit block_size = ComputeBlockSizeForFragment( | 284 LayoutUnit block_size = ComputeBlockSizeForFragment( |
286 ConstraintSpace(), Style(), content_size_); | 285 ConstraintSpace(), Style(), content_size_); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 if (!is_fragment_margin_strut_block_start_updated_) { | 436 if (!is_fragment_margin_strut_block_start_updated_) { |
438 builder_->SetMarginStrutBlockStart(from); | 437 builder_->SetMarginStrutBlockStart(from); |
439 is_fragment_margin_strut_block_start_updated_ = true; | 438 is_fragment_margin_strut_block_start_updated_ = true; |
440 } | 439 } |
441 builder_->SetMarginStrutBlockEnd(from); | 440 builder_->SetMarginStrutBlockEnd(from); |
442 } | 441 } |
443 | 442 |
444 NGConstraintSpace* | 443 NGConstraintSpace* |
445 NGBlockLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { | 444 NGBlockLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { |
446 DCHECK(current_child_); | 445 DCHECK(current_child_); |
447 space_builder_->SetIsNewFormattingContext( | 446 space_builder_ |
448 IsNewFormattingContextForInFlowBlockLevelChild(ConstraintSpace(), | 447 ->SetIsNewFormattingContext( |
449 CurrentChildStyle())); | 448 IsNewFormattingContextForInFlowBlockLevelChild(ConstraintSpace(), |
| 449 CurrentChildStyle())) |
| 450 .SetWritingMode( |
| 451 FromPlatformWritingMode(CurrentChildStyle().getWritingMode())) |
| 452 .SetTextDirection(CurrentChildStyle().direction()); |
450 NGConstraintSpace* child_space = space_builder_->ToConstraintSpace(); | 453 NGConstraintSpace* child_space = space_builder_->ToConstraintSpace(); |
451 | 454 |
452 // TODO(layout-ng): Set offset through the space builder. | 455 // TODO(layout-ng): Set offset through the space builder. |
453 child_space->SetOffset(GetChildSpaceOffset()); | 456 child_space->SetOffset(GetChildSpaceOffset()); |
454 return child_space; | 457 return child_space; |
455 } | 458 } |
456 | 459 |
457 DEFINE_TRACE(NGBlockLayoutAlgorithm) { | 460 DEFINE_TRACE(NGBlockLayoutAlgorithm) { |
458 NGLayoutAlgorithm::trace(visitor); | 461 NGLayoutAlgorithm::trace(visitor); |
459 visitor->trace(first_child_); | 462 visitor->trace(first_child_); |
460 visitor->trace(constraint_space_); | 463 visitor->trace(constraint_space_); |
461 visitor->trace(break_token_); | 464 visitor->trace(break_token_); |
462 visitor->trace(builder_); | 465 visitor->trace(builder_); |
463 visitor->trace(space_builder_); | 466 visitor->trace(space_builder_); |
464 visitor->trace(space_for_current_child_); | 467 visitor->trace(space_for_current_child_); |
465 visitor->trace(current_child_); | 468 visitor->trace(current_child_); |
466 } | 469 } |
467 | 470 |
468 } // namespace blink | 471 } // namespace blink |
OLD | NEW |