Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc

Issue 2282213002: [LayoutNG] Introduce NGPhysicalFragment and make NGFragment a 'view' (Closed)
Patch Set: address comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 c2cd78d076505807f45c6463f56aa132689ab38f..7c8e546d99ba3e7126ce8b7dc1ee5248cdbe4cf1 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
@@ -6,7 +6,8 @@
namespace blink {
-NGFragmentBuilder::NGFragmentBuilder(NGFragmentBase::NGFragmentType type)
+NGFragmentBuilder::NGFragmentBuilder(
+ NGPhysicalFragmentBase::NGFragmentType type)
: type_(type),
writing_mode_(HorizontalTopBottom),
direction_(LeftToRight) {}
@@ -42,19 +43,32 @@ NGFragmentBuilder& NGFragmentBuilder::SetBlockOverflow(LayoutUnit size) {
return *this;
}
-NGFragmentBuilder& NGFragmentBuilder::AddChild(const NGFragment* child) {
- DCHECK_EQ(type_, NGFragmentBase::FragmentBox)
+NGFragmentBuilder& NGFragmentBuilder::AddChild(NGFragment* child,
+ NGLogicalOffset offset) {
+ DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox)
<< "Only box fragments can have children";
- children_.append(child);
+ children_.append(child->PhysicalFragment());
+ offsets_.append(offset);
return *this;
}
-NGFragment* NGFragmentBuilder::ToFragment() {
+NGPhysicalFragment* NGFragmentBuilder::ToFragment() {
// TODO(layout-ng): Support text fragments
- DCHECK_EQ(type_, NGFragmentBase::FragmentBox);
- NGFragment* fragment =
- new NGFragment(size_, overflow_, writing_mode_, direction_, children_);
- return fragment;
+ DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox);
+ DCHECK_EQ(offsets_.size(), children_.size());
+
+ NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
+ HeapVector<Member<const NGPhysicalFragmentBase>> children(children_.size());
+
+ for (size_t i = 0; i < children_.size(); ++i) {
+ NGPhysicalFragmentBase* child = children_[i].get();
+ child->SetOffset(offsets_[i].ConvertToPhysical(
+ writing_mode_, direction_, physical_size, child->Size()));
+ children.append(child);
+ }
+
+ return new NGPhysicalFragment(
+ physical_size, overflow_.ConvertToPhysical(writing_mode_), children);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698