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

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

Issue 2612103004: [ng_layout] Rename NGFragmentBase,NGFragment,NGPhysicalFragment (Closed)
Patch Set: CR: rename ifdef guards Created 3 years, 11 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 f4c5796f7bf2c51ea7860b1aaafb625fdfd0b89d..4a4c53363748653e878fd080ed91f521a4da1a6d 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
@@ -6,46 +6,95 @@
#define NGPhysicalFragment_h
#include "core/CoreExport.h"
-#include "core/layout/ng/ng_physical_fragment_base.h"
#include "core/layout/ng/ng_units.h"
+#include "platform/LayoutUnit.h"
#include "platform/heap/Handle.h"
+#include "wtf/Vector.h"
namespace blink {
class NGBlockNode;
+class NGBreakToken;
-class CORE_EXPORT NGPhysicalFragment final : public NGPhysicalFragmentBase {
+// The NGPhysicalFragmentBase contains the output information from layout. The
+// fragment stores all of its information in the physical coordinate system for
+// use by paint, hit-testing etc.
+//
+// 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> {
public:
- // This modifies the passed-in children vector.
+ enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 };
+
+ NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); }
+
+ // 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.
+
+ // Returns the border-box size.
+ NGPhysicalSize Size() const { return size_; }
+ LayoutUnit Width() const { return size_.width; }
+ LayoutUnit Height() const { return size_.height; }
+
+ // Returns the total size, including the contents outside of the border-box.
+ LayoutUnit WidthOverflow() const { return overflow_.width; }
+ LayoutUnit HeightOverflow() const { return overflow_.height; }
+
+ // Returns the offset relative to the parent fragement's content-box.
+ LayoutUnit LeftOffset() const {
+ DCHECK(has_been_placed_);
+ return offset_.left;
+ }
+
+ LayoutUnit TopOffset() const {
+ DCHECK(has_been_placed_);
+ return offset_.top;
+ }
+
+ // Should only be used by the parent fragement's layout.
+ void SetOffset(NGPhysicalOffset offset) {
+ DCHECK(!has_been_placed_);
+ offset_ = offset;
+ has_been_placed_ = true;
+ }
+
+ const HeapLinkedHashSet<WeakMember<NGBlockNode>>& OutOfFlowDescendants()
+ const {
+ return out_of_flow_descendants_;
+ }
+
+ const Vector<NGStaticPosition>& OutOfFlowPositions() const {
+ return out_of_flow_positions_;
+ }
+
+ DECLARE_TRACE_AFTER_DISPATCH();
+ DECLARE_TRACE();
+
+ void finalizeGarbageCollectedObject();
+
+ protected:
NGPhysicalFragment(
NGPhysicalSize size,
NGPhysicalSize overflow,
- HeapVector<Member<const NGPhysicalFragmentBase>>& children,
+ NGFragmentType type,
HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants,
- Vector<NGStaticPosition>& out_of_flow_positions,
- NGMarginStrut margin_strut);
-
- const HeapVector<Member<const NGPhysicalFragmentBase>>& Children() const {
- return children_;
- }
-
- NGMarginStrut MarginStrut() const { return margin_strut_; }
-
- DECLARE_TRACE_AFTER_DISPATCH();
-
- private:
- HeapVector<Member<const NGPhysicalFragmentBase>> children_;
- NGMarginStrut margin_strut_;
+ Vector<NGStaticPosition> out_of_flow_positions,
+ NGBreakToken* break_token = nullptr);
+
+ NGPhysicalSize size_;
+ NGPhysicalSize overflow_;
+ NGPhysicalOffset offset_;
+ Member<NGBreakToken> break_token_;
+ HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_;
+ Vector<NGStaticPosition> out_of_flow_positions_;
+
+ unsigned type_ : 1;
+ unsigned has_been_placed_ : 1;
};
-WILL_NOT_BE_EAGERLY_TRACED_CLASS(NGPhysicalFragment);
-
-DEFINE_TYPE_CASTS(NGPhysicalFragment,
- NGPhysicalFragmentBase,
- fragment,
- fragment->Type() == NGPhysicalFragmentBase::kFragmentBox,
- fragment.Type() == NGPhysicalFragmentBase::kFragmentBox);
-
} // namespace blink
#endif // NGPhysicalFragment_h

Powered by Google App Engine
This is Rietveld 408576698