Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/ng/ng_box.cc |
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_box.cc b/third_party/WebKit/Source/core/layout/ng/ng_box.cc |
| index 3c9667beefb82b6b1d7eaa7eda8b6b979216f057..9c48f611a9dc8cba1307fe4b46dcf26739819567 100644 |
| --- a/third_party/WebKit/Source/core/layout/ng/ng_box.cc |
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_box.cc |
| @@ -24,10 +24,11 @@ NGBox::NGBox(ComputedStyle* style) : layout_box_(nullptr), style_(style) { |
| DCHECK(style_); |
| } |
| -bool NGBox::Layout(const NGConstraintSpace* constraint_space, |
| - NGFragment** out) { |
| +bool NGBox::Layout(const NGConstraintSpace* constraint_space) { |
| if (layout_box_ && layout_box_->isOutOfFlowPositioned()) |
| layout_box_->containingBlock()->insertPositionedObject(layout_box_); |
| + |
| + NGPhysicalFragment* physical_fragment = nullptr; |
| // We can either use the new layout code to do the layout and then copy the |
| // resulting size to the LayoutObject, or use the old layout code and |
| // synthesize a fragment. |
| @@ -35,32 +36,30 @@ bool NGBox::Layout(const NGConstraintSpace* constraint_space, |
| if (!algorithm_) |
| algorithm_ = new NGBlockLayoutAlgorithm(Style(), FirstChild()); |
| // Change the coordinate system of the constraint space. |
| - NGConstraintSpace* child_constraint_space = new NGConstraintSpace( |
| + NGConstraintSpace child_constraint_space( |
| FromPlatformWritingMode(Style()->getWritingMode()), |
| FromPlatformDirection(Style()->direction()), constraint_space); |
| - NGPhysicalFragment* fragment = nullptr; |
| - if (!algorithm_->Layout(child_constraint_space, &fragment)) |
| + if (!algorithm_->Layout(child_constraint_space, &physical_fragment)) |
| return false; |
| - fragment_ = fragment; |
| if (layout_box_) { |
| - layout_box_->setWidth(fragment_->Width()); |
| - layout_box_->setHeight(fragment_->Height()); |
| + layout_box_->setWidth(physical_fragment->Width()); |
| + layout_box_->setHeight(physical_fragment->Height()); |
| NGBoxStrut border_and_padding = |
| computeBorders(*Style()) + |
| computePadding(*constraint_space, *Style()); |
| LayoutUnit intrinsic_logical_height = |
| layout_box_->style()->isHorizontalWritingMode() |
| - ? fragment_->HeightOverflow() |
| - : fragment_->WidthOverflow(); |
| + ? physical_fragment->HeightOverflow() |
| + : physical_fragment->WidthOverflow(); |
| intrinsic_logical_height -= border_and_padding.BlockSum(); |
| layout_box_->setIntrinsicContentLogicalHeight(intrinsic_logical_height); |
| // Ensure the position of the children are copied across to the |
| // LayoutObject tree. |
| for (NGBox* box = FirstChild(); box; box = box->NextSibling()) { |
| - if (box->fragment_) |
| + if (box->Fragment()) |
| box->PositionUpdated(); |
| } |
| @@ -96,11 +95,11 @@ bool NGBox::Layout(const NGConstraintSpace* constraint_space, |
| FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) |
| .SetInlineOverflow(overflow.width()) |
| .SetBlockOverflow(overflow.height()); |
| - fragment_ = builder.ToFragment(); |
| + physical_fragment = builder.ToFragment(); |
| } |
| - *out = new NGFragment(constraint_space->WritingMode(), |
| - FromPlatformDirection(Style()->direction()), |
| - fragment_.get()); |
| + fragment_ = new NGFragment(constraint_space->WritingMode(), |
| + FromPlatformDirection(Style()->direction()), |
| + physical_fragment); |
| // Reset algorithm for future use |
| algorithm_ = nullptr; |
| return true; |
| @@ -141,9 +140,9 @@ void NGBox::SetFirstChild(NGBox* child) { |
| } |
| void NGBox::PositionUpdated() { |
| - if (layout_box_) { |
| - layout_box_->setX(fragment_->LeftOffset()); |
| - layout_box_->setY(fragment_->TopOffset()); |
| + if (layout_box_ && fragment_->PhysicalFragment()) { |
|
cbiesinger
2016/09/26 17:17:55
Can PhysicalFragment() ever be null?
|
| + layout_box_->setX(fragment_->PhysicalFragment()->LeftOffset()); |
| + layout_box_->setY(fragment_->PhysicalFragment()->TopOffset()); |
| } |
| } |