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

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h

Issue 2676533003: [LayoutNG] Convert physical fragments to being RefCounted. (Closed)
Patch Set: address comments. Created 3 years, 10 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_physical_fragment.h
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h b/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h
index bb69c7f0085242b8d3cf600c0327b304edee6cf2..5c157e3030736ec256a9a8e199e541e9bf609da6 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h
+++ b/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h
@@ -29,13 +29,19 @@ struct NGFloatingObject;
// Layout code should only access output layout information through the
// NGFragmentBase classes which transforms information into the logical
// coordinate system.
-class CORE_EXPORT NGPhysicalFragment
- : public GarbageCollectedFinalized<NGPhysicalFragment> {
+class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment> {
public:
enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 };
NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); }
+ // Override RefCounted's deref() to ensure operator delete is called on the
+ // appropriate subclass type.
+ void deref() const {
+ if (derefBase())
+ destroy();
+ }
+
// The accessors in this class shouldn't be used by layout code directly,
// instead should be accessed by the NGFragmentBase classes. These accessors
// exist for paint, hit-testing, etc.
@@ -90,46 +96,44 @@ class CORE_EXPORT NGPhysicalFragment
// The float cannot be positioned right away inside of the 1st div because
// the vertical position is not known at that moment. It will be known only
// after the 2nd div collapses its margin with its parent.
- const HeapVector<Member<NGFloatingObject>>& UnpositionedFloats() const {
+ const Vector<Persistent<NGFloatingObject>>& UnpositionedFloats() const {
return unpositioned_floats_;
}
// List of positioned float that need to be copied to the old layout tree.
// TODO(layout-ng): remove this once we change painting code to handle floats
// differently.
- const HeapVector<Member<NGFloatingObject>>& PositionedFloats() const {
+ const Vector<Persistent<NGFloatingObject>>& PositionedFloats() const {
return positioned_floats_;
}
- DECLARE_TRACE_AFTER_DISPATCH();
- DECLARE_TRACE();
-
- void finalizeGarbageCollectedObject();
-
protected:
- NGPhysicalFragment(
- LayoutObject* layout_object,
- NGPhysicalSize size,
- NGPhysicalSize overflow,
- NGFragmentType type,
- HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants,
- Vector<NGStaticPosition> out_of_flow_positions,
- HeapVector<Member<NGFloatingObject>>& unpositioned_floats,
- HeapVector<Member<NGFloatingObject>>& positioned_floats,
- NGBreakToken* break_token = nullptr);
+ NGPhysicalFragment(LayoutObject* layout_object,
+ NGPhysicalSize size,
+ NGPhysicalSize overflow,
+ NGFragmentType type,
+ PersistentHeapLinkedHashSet<WeakMember<NGBlockNode>>&
+ out_of_flow_descendants,
+ Vector<NGStaticPosition> out_of_flow_positions,
+ Vector<Persistent<NGFloatingObject>>& unpositioned_floats,
+ Vector<Persistent<NGFloatingObject>>& positioned_floats,
+ NGBreakToken* break_token = nullptr);
LayoutObject* layout_object_;
NGPhysicalSize size_;
NGPhysicalSize overflow_;
NGPhysicalOffset offset_;
- Member<NGBreakToken> break_token_;
- HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_;
+ Persistent<NGBreakToken> break_token_;
+ PersistentHeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_;
Vector<NGStaticPosition> out_of_flow_positions_;
- HeapVector<Member<NGFloatingObject>> unpositioned_floats_;
- HeapVector<Member<NGFloatingObject>> positioned_floats_;
+ Vector<Persistent<NGFloatingObject>> unpositioned_floats_;
+ Vector<Persistent<NGFloatingObject>> positioned_floats_;
unsigned type_ : 1;
unsigned is_placed_ : 1;
+
+ private:
+ void destroy() const;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698