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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 NGLayoutStatus NGBlockLayoutAlgorithm::Layout( | 193 NGLayoutStatus NGBlockLayoutAlgorithm::Layout( |
194 NGPhysicalFragmentBase* child_fragment, | 194 NGPhysicalFragmentBase* child_fragment, |
195 NGPhysicalFragmentBase** fragment_out, | 195 NGPhysicalFragmentBase** fragment_out, |
196 NGLayoutAlgorithm** algorithm_out) { | 196 NGLayoutAlgorithm** algorithm_out) { |
197 switch (state_) { | 197 switch (state_) { |
198 case kStateInit: { | 198 case kStateInit: { |
199 border_and_padding_ = | 199 border_and_padding_ = |
200 ComputeBorders(Style()) + ComputePadding(ConstraintSpace(), Style()); | 200 ComputeBorders(Style()) + ComputePadding(ConstraintSpace(), Style()); |
201 | 201 |
202 WTF::Optional<MinAndMaxContentSizes> sizes; | 202 WTF::Optional<MinAndMaxContentSizes> sizes; |
203 if (NeedMinAndMaxContentSizes(Style())) { | 203 if (NeedMinAndMaxContentSizes(ConstraintSpace(), Style())) { |
204 // TODOO(layout-ng): Implement | 204 // TODOO(layout-ng): Implement |
205 sizes = MinAndMaxContentSizes(); | 205 sizes = MinAndMaxContentSizes(); |
206 } | 206 } |
207 LayoutUnit inline_size = | 207 LayoutUnit inline_size = |
208 ComputeInlineSizeForFragment(ConstraintSpace(), Style(), sizes); | 208 ComputeInlineSizeForFragment(ConstraintSpace(), Style(), sizes); |
209 LayoutUnit adjusted_inline_size = | 209 LayoutUnit adjusted_inline_size = |
210 inline_size - border_and_padding_.InlineSum(); | 210 inline_size - border_and_padding_.InlineSum(); |
211 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of | 211 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of |
212 // -1? | 212 // -1? |
213 LayoutUnit block_size = ComputeBlockSizeForFragment( | 213 LayoutUnit block_size = ComputeBlockSizeForFragment( |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 void NGBlockLayoutAlgorithm::UpdateMarginStrut(const NGMarginStrut& from) { | 435 void NGBlockLayoutAlgorithm::UpdateMarginStrut(const NGMarginStrut& from) { |
436 if (!is_fragment_margin_strut_block_start_updated_) { | 436 if (!is_fragment_margin_strut_block_start_updated_) { |
437 builder_->SetMarginStrutBlockStart(from); | 437 builder_->SetMarginStrutBlockStart(from); |
438 is_fragment_margin_strut_block_start_updated_ = true; | 438 is_fragment_margin_strut_block_start_updated_ = true; |
439 } | 439 } |
440 builder_->SetMarginStrutBlockEnd(from); | 440 builder_->SetMarginStrutBlockEnd(from); |
441 } | 441 } |
442 | 442 |
443 NGConstraintSpace* | 443 NGConstraintSpace* |
444 NGBlockLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { | 444 NGBlockLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { |
| 445 // TODO(layout-ng): Orthogonal children should also shrink to fit (in *their* |
| 446 // inline axis) |
| 447 // We have to keep this commented out for now until we correctly compute |
| 448 // min/max content sizes in Layout(). |
| 449 // bool shrink_to_fit = CurrentChildStyle().display() == EDisplay::InlineBlock |
| 450 // || CurrentChildStyle().isFloating(); |
| 451 bool shrink_to_fit = false; |
445 DCHECK(current_child_); | 452 DCHECK(current_child_); |
446 space_builder_ | 453 space_builder_ |
447 ->SetIsNewFormattingContext( | 454 ->SetIsNewFormattingContext( |
448 IsNewFormattingContextForInFlowBlockLevelChild(ConstraintSpace(), | 455 IsNewFormattingContextForInFlowBlockLevelChild(ConstraintSpace(), |
449 CurrentChildStyle())) | 456 CurrentChildStyle())) |
| 457 .SetIsShrinkToFit(shrink_to_fit) |
450 .SetWritingMode( | 458 .SetWritingMode( |
451 FromPlatformWritingMode(CurrentChildStyle().getWritingMode())) | 459 FromPlatformWritingMode(CurrentChildStyle().getWritingMode())) |
452 .SetTextDirection(CurrentChildStyle().direction()); | 460 .SetTextDirection(CurrentChildStyle().direction()); |
453 NGConstraintSpace* child_space = space_builder_->ToConstraintSpace(); | 461 NGConstraintSpace* child_space = space_builder_->ToConstraintSpace(); |
454 | 462 |
455 // TODO(layout-ng): Set offset through the space builder. | 463 // TODO(layout-ng): Set offset through the space builder. |
456 child_space->SetOffset(GetChildSpaceOffset()); | 464 child_space->SetOffset(GetChildSpaceOffset()); |
457 return child_space; | 465 return child_space; |
458 } | 466 } |
459 | 467 |
460 DEFINE_TRACE(NGBlockLayoutAlgorithm) { | 468 DEFINE_TRACE(NGBlockLayoutAlgorithm) { |
461 NGLayoutAlgorithm::trace(visitor); | 469 NGLayoutAlgorithm::trace(visitor); |
462 visitor->trace(first_child_); | 470 visitor->trace(first_child_); |
463 visitor->trace(constraint_space_); | 471 visitor->trace(constraint_space_); |
464 visitor->trace(break_token_); | 472 visitor->trace(break_token_); |
465 visitor->trace(builder_); | 473 visitor->trace(builder_); |
466 visitor->trace(space_builder_); | 474 visitor->trace(space_builder_); |
467 visitor->trace(space_for_current_child_); | 475 visitor->trace(space_for_current_child_); |
468 visitor->trace(current_child_); | 476 visitor->trace(current_child_); |
469 } | 477 } |
470 | 478 |
471 } // namespace blink | 479 } // namespace blink |
OLD | NEW |