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

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

Issue 2540653003: Implement collection of out-of-flow descendants (Closed)
Patch Set: Removed unused members from block_layout Created 4 years 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 f886a2951c332719281328db86467a8e4486901c..0291e9377420e0a817c74a287a486ca8d87ef577 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
@@ -44,11 +44,71 @@ NGFragmentBuilder& NGFragmentBuilder::SetBlockOverflow(LayoutUnit size) {
}
NGFragmentBuilder& NGFragmentBuilder::AddChild(NGFragmentBase* child,
- NGLogicalOffset offset) {
+ NGLogicalOffset child_offset) {
DCHECK_EQ(type_, NGPhysicalFragmentBase::kFragmentBox)
<< "Only box fragments can have children";
children_.append(child->PhysicalFragment());
- offsets_.append(offset);
+ offsets_.append(child_offset);
+ // Collect child's out of flow descendants
ikilpatrick 2016/12/02 17:47:06 .nit add period to end.
atotic 2016/12/02 19:55:15 done
+ if (child->PhysicalFragment()->Type() ==
+ NGPhysicalFragmentBase::kFragmentBox) {
ikilpatrick 2016/12/02 17:47:05 this can be fixed here or TODO+another patch, but
atotic 2016/12/02 19:55:15 To rephrase: All fragments can carry oof descenda
+ const NGPhysicalFragment* physical_child =
+ static_cast<const NGPhysicalFragment*>(&*child->PhysicalFragment());
+ Vector<NGCorner> block_offsets = physical_child->OutOfFlowOffsets();
+ size_t block_index = 0;
+ for (auto& block_node : physical_child->OutOfFlowDescendants()) {
+ NGCorner block_corner = block_offsets[block_index++];
+ out_of_flow_descendant_candidates_.add(block_node);
ikilpatrick 2016/12/02 17:47:06 can we do: s/block_/oof_/ here? block is a little
atotic 2016/12/02 19:55:15 done
+ oof_candidate_offsets_.append(
+ OutOfFlowOffset{child_offset, block_corner});
+ }
+ }
+ return *this;
+}
+
+NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowCandidateChild(
+ NGBlockNode* child,
+ NGLogicalOffset child_offset) {
+ out_of_flow_descendant_candidates_.add(child);
+ NGCorner child_corner =
+ NGCorner::Create(writing_mode_, direction_, NGPhysicalOffset());
+ oof_candidate_offsets_.append(OutOfFlowOffset{child_offset, child_corner});
+ return *this;
+}
+
+void NGFragmentBuilder::GetOutOfFlowDescendantCandidates(
+ WeakBoxList& descendants,
+ Vector<NGCorner>& descendant_corners) {
ikilpatrick 2016/12/02 17:47:06 change ref to pointer as out param: https://google
atotic 2016/12/02 19:55:15 done
+ descendants.clear();
+ descendant_corners.clear();
ikilpatrick 2016/12/02 17:47:06 I would do a: DCHECK(descendants->isEmpty()); DCHE
atotic 2016/12/02 19:55:15 done
+
+ DCHECK_GE(size_.inline_size, LayoutUnit(0));
+ DCHECK_GE(size_.block_size, LayoutUnit(0));
ikilpatrick 2016/12/02 17:47:05 just LayoutUnit() for above lines I think.
atotic 2016/12/02 19:55:15 done
+ NGPhysicalSize builder_physical_size{size_.ConvertToPhysical(writing_mode_)};
+
+ size_t offset_index = 0;
+ for (auto& block_node : out_of_flow_descendant_candidates_) {
ikilpatrick 2016/12/02 17:47:05 s/block_node/oof_node/
atotic 2016/12/02 19:55:15 done
+ OutOfFlowOffset oof_offset = oof_candidate_offsets_[offset_index++];
+
+ NGPhysicalOffset child_offset = oof_offset.child_offset.ConvertToPhysical(
+ writing_mode_, direction_, builder_physical_size, NGPhysicalSize());
+
+ NGCorner builder_relative_corner;
+ builder_relative_corner.type = oof_offset.descendant_corner.type;
+ builder_relative_corner.offset =
+ child_offset + oof_offset.descendant_corner.offset;
ikilpatrick 2016/12/02 17:47:06 This is great, a lot simpler :)
atotic 2016/12/02 19:55:15 yay
+ descendants.add(block_node);
+ descendant_corners.append(builder_relative_corner);
+ }
+ out_of_flow_descendant_candidates_.clear();
+ oof_candidate_offsets_.clear();
+}
+
+NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowDescendant(
+ NGBlockNode* descendant,
+ const NGCorner& corner) {
+ out_of_flow_descendants_.add(descendant);
+ out_of_flow_corners_.append(corner);
return *this;
}
@@ -83,11 +143,12 @@ NGPhysicalFragment* NGFragmentBuilder::ToFragment() {
}
return new NGPhysicalFragment(
physical_size, overflow_.ConvertToPhysical(writing_mode_), children,
- out_of_flow_descendants_, out_of_flow_offsets_, margin_strut_);
+ out_of_flow_descendants_, out_of_flow_corners_, margin_strut_);
}
DEFINE_TRACE(NGFragmentBuilder) {
visitor->trace(children_);
+ visitor->trace(out_of_flow_descendant_candidates_);
visitor->trace(out_of_flow_descendants_);
}

Powered by Google App Engine
This is Rietveld 408576698