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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NGPhysicalFragment_h 5 #ifndef NGPhysicalFragment_h
6 #define NGPhysicalFragment_h 6 #define NGPhysicalFragment_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/ng_physical_fragment_base.h"
10 #include "core/layout/ng/ng_units.h" 9 #include "core/layout/ng/ng_units.h"
10 #include "platform/LayoutUnit.h"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "wtf/Vector.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 class NGBlockNode; 16 class NGBlockNode;
17 class NGBreakToken;
16 18
17 class CORE_EXPORT NGPhysicalFragment final : public NGPhysicalFragmentBase { 19 // The NGPhysicalFragmentBase contains the output information from layout. The
20 // fragment stores all of its information in the physical coordinate system for
21 // use by paint, hit-testing etc.
22 //
23 // Layout code should only access output layout information through the
24 // NGFragmentBase classes which transforms information into the logical
25 // coordinate system.
26 class CORE_EXPORT NGPhysicalFragment
27 : public GarbageCollectedFinalized<NGPhysicalFragment> {
18 public: 28 public:
19 // This modifies the passed-in children vector. 29 enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 };
30
31 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); }
32
33 // The accessors in this class shouldn't be used by layout code directly,
34 // instead should be accessed by the NGFragmentBase classes. These accessors
35 // exist for paint, hit-testing, etc.
36
37 // Returns the border-box size.
38 NGPhysicalSize Size() const { return size_; }
39 LayoutUnit Width() const { return size_.width; }
40 LayoutUnit Height() const { return size_.height; }
41
42 // Returns the total size, including the contents outside of the border-box.
43 LayoutUnit WidthOverflow() const { return overflow_.width; }
44 LayoutUnit HeightOverflow() const { return overflow_.height; }
45
46 // Returns the offset relative to the parent fragement's content-box.
47 LayoutUnit LeftOffset() const {
48 DCHECK(has_been_placed_);
49 return offset_.left;
50 }
51
52 LayoutUnit TopOffset() const {
53 DCHECK(has_been_placed_);
54 return offset_.top;
55 }
56
57 // Should only be used by the parent fragement's layout.
58 void SetOffset(NGPhysicalOffset offset) {
59 DCHECK(!has_been_placed_);
60 offset_ = offset;
61 has_been_placed_ = true;
62 }
63
64 const HeapLinkedHashSet<WeakMember<NGBlockNode>>& OutOfFlowDescendants()
65 const {
66 return out_of_flow_descendants_;
67 }
68
69 const Vector<NGStaticPosition>& OutOfFlowPositions() const {
70 return out_of_flow_positions_;
71 }
72
73 DECLARE_TRACE_AFTER_DISPATCH();
74 DECLARE_TRACE();
75
76 void finalizeGarbageCollectedObject();
77
78 protected:
20 NGPhysicalFragment( 79 NGPhysicalFragment(
21 NGPhysicalSize size, 80 NGPhysicalSize size,
22 NGPhysicalSize overflow, 81 NGPhysicalSize overflow,
23 HeapVector<Member<const NGPhysicalFragmentBase>>& children, 82 NGFragmentType type,
24 HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants, 83 HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants,
25 Vector<NGStaticPosition>& out_of_flow_positions, 84 Vector<NGStaticPosition> out_of_flow_positions,
26 NGMarginStrut margin_strut); 85 NGBreakToken* break_token = nullptr);
27 86
28 const HeapVector<Member<const NGPhysicalFragmentBase>>& Children() const { 87 NGPhysicalSize size_;
29 return children_; 88 NGPhysicalSize overflow_;
30 } 89 NGPhysicalOffset offset_;
90 Member<NGBreakToken> break_token_;
91 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_;
92 Vector<NGStaticPosition> out_of_flow_positions_;
31 93
32 NGMarginStrut MarginStrut() const { return margin_strut_; } 94 unsigned type_ : 1;
33 95 unsigned has_been_placed_ : 1;
34 DECLARE_TRACE_AFTER_DISPATCH();
35
36 private:
37 HeapVector<Member<const NGPhysicalFragmentBase>> children_;
38 NGMarginStrut margin_strut_;
39 }; 96 };
40 97
41 WILL_NOT_BE_EAGERLY_TRACED_CLASS(NGPhysicalFragment);
42
43 DEFINE_TYPE_CASTS(NGPhysicalFragment,
44 NGPhysicalFragmentBase,
45 fragment,
46 fragment->Type() == NGPhysicalFragmentBase::kFragmentBox,
47 fragment.Type() == NGPhysicalFragmentBase::kFragmentBox);
48
49 } // namespace blink 98 } // namespace blink
50 99
51 #endif // NGPhysicalFragment_h 100 #endif // NGPhysicalFragment_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698