| Index: third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc
|
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc b/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc
|
| index dfbad215933f77e5736b1095a01879700ee78459..e9a0484f1aaddb4f8b401d4c6e76957b11b61bc8 100644
|
| --- a/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc
|
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc
|
| @@ -4,21 +4,26 @@
|
|
|
| #include "core/layout/ng/ng_fragment_builder.h"
|
|
|
| +#include "core/layout/ng/ng_block_break_token.h"
|
| #include "core/layout/ng/ng_block_node.h"
|
| #include "core/layout/ng/ng_break_token.h"
|
| #include "core/layout/ng/ng_fragment.h"
|
| #include "core/layout/ng/ng_physical_box_fragment.h"
|
| #include "core/layout/ng/ng_physical_text_fragment.h"
|
| +#include "platform/heap/Handle.h"
|
|
|
| namespace blink {
|
|
|
| // TODO(ikilpatrick): Make writing mode and direction be in the constructor.
|
| NGFragmentBuilder::NGFragmentBuilder(NGPhysicalFragment::NGFragmentType type,
|
| - LayoutObject* layout_object)
|
| + NGLayoutInputNode* node)
|
| : type_(type),
|
| writing_mode_(kHorizontalTopBottom),
|
| direction_(TextDirection::kLtr),
|
| - layout_object_(layout_object) {}
|
| + node_(node),
|
| + did_break_(false) {
|
| + child_break_tokens_ = new HeapVector<Member<NGBreakToken>>();
|
| +}
|
|
|
| NGFragmentBuilder& NGFragmentBuilder::SetWritingMode(
|
| NGWritingMode writing_mode) {
|
| @@ -67,6 +72,13 @@ NGFragmentBuilder& NGFragmentBuilder::AddChild(
|
| OutOfFlowPlacement{child_offset, oof_position});
|
| }
|
|
|
| + DCHECK(child->BreakToken());
|
| + if (!child->BreakToken()->IsFinished()) {
|
| + // We have an unfinished child, we must produce an unfinished break token.
|
| + did_break_ = true;
|
| + }
|
| +
|
| + child_break_tokens_->push_back(child->BreakToken());
|
| children_.push_back(std::move(child));
|
| offsets_.push_back(child_offset);
|
|
|
| @@ -148,9 +160,6 @@ RefPtr<NGPhysicalBoxFragment> NGFragmentBuilder::ToBoxFragment() {
|
| DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox);
|
| DCHECK_EQ(offsets_.size(), children_.size());
|
|
|
| - auto* break_token = break_token_.get();
|
| - break_token_ = nullptr;
|
| -
|
| NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
|
|
|
| for (size_t i = 0; i < children_.size(); ++i) {
|
| @@ -162,6 +171,20 @@ RefPtr<NGPhysicalBoxFragment> NGFragmentBuilder::ToBoxFragment() {
|
| Vector<Persistent<NGFloatingObject>> positioned_floats;
|
| positioned_floats.reserveCapacity(positioned_floats_.size());
|
|
|
| + Persistent<NGBreakToken> break_token;
|
| + if (did_break_) {
|
| + break_token =
|
| + new NGBlockBreakToken(toNGBlockNode(node_.get()), LayoutUnit(0),
|
| + used_block_size_, *child_break_tokens_.get());
|
| + } else {
|
| + if (node_->Type() == NGLayoutInputNode::kLegacyBlock) {
|
| + break_token = new NGBlockBreakToken(toNGBlockNode(node_.get()));
|
| + } else {
|
| + break_token =
|
| + new NGBreakToken(NGBreakToken::kTextBreakToken, true, node_);
|
| + }
|
| + }
|
| +
|
| for (size_t i = 0; i < positioned_floats_.size(); ++i) {
|
| Persistent<NGFloatingObject>& floating_object = positioned_floats_[i];
|
| NGPhysicalFragment* floating_fragment = floating_object->fragment.get();
|
| @@ -171,10 +194,10 @@ RefPtr<NGPhysicalBoxFragment> NGFragmentBuilder::ToBoxFragment() {
|
| }
|
|
|
| return adoptRef(new NGPhysicalBoxFragment(
|
| - layout_object_, physical_size, overflow_.ConvertToPhysical(writing_mode_),
|
| - children_, out_of_flow_descendants_, out_of_flow_positions_,
|
| - unpositioned_floats_, positioned_floats_, bfc_offset_, end_margin_strut_,
|
| - break_token));
|
| + node_->GetLayoutObject(), physical_size,
|
| + overflow_.ConvertToPhysical(writing_mode_), children_,
|
| + out_of_flow_descendants_, out_of_flow_positions_, unpositioned_floats_,
|
| + positioned_floats_, bfc_offset_, end_margin_strut_, break_token));
|
| }
|
|
|
| RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment(
|
| @@ -189,12 +212,15 @@ RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment(
|
| Vector<Persistent<NGFloatingObject>> empty_unpositioned_floats;
|
| Vector<Persistent<NGFloatingObject>> empty_positioned_floats;
|
|
|
| + Persistent<NGBreakToken> break_token =
|
| + new NGBreakToken(NGBreakToken::kTextBreakToken, true, node_);
|
| +
|
| return adoptRef(new NGPhysicalTextFragment(
|
| - layout_object_, node, index, start_offset, end_offset,
|
| + node_->GetLayoutObject(), node, index, start_offset, end_offset,
|
| size_.ConvertToPhysical(writing_mode_),
|
| overflow_.ConvertToPhysical(writing_mode_), out_of_flow_descendants_,
|
| out_of_flow_positions_, empty_unpositioned_floats,
|
| - empty_positioned_floats));
|
| + empty_positioned_floats, break_token));
|
| }
|
|
|
| } // namespace blink
|
|
|