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

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

Issue 2764753007: [LayoutNG] Add NGLineBoxFragment (Closed)
Patch Set: Rebase again as other CLs landed faster Created 3 years, 9 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/geometry/ng_physical_offset.h" 9 #include "core/layout/ng/geometry/ng_physical_offset.h"
10 #include "core/layout/ng/geometry/ng_physical_size.h" 10 #include "core/layout/ng/geometry/ng_physical_size.h"
(...skipping 14 matching lines...) Expand all
25 // 25 //
26 // The fragment keeps a pointer back to the LayoutObject which generated it. 26 // The fragment keeps a pointer back to the LayoutObject which generated it.
27 // Once we have transitioned fully to LayoutNG it should be a const pointer 27 // Once we have transitioned fully to LayoutNG it should be a const pointer
28 // such that paint/hit-testing/etc don't modify it. 28 // such that paint/hit-testing/etc don't modify it.
29 // 29 //
30 // Layout code should only access geometry information through the 30 // Layout code should only access geometry information through the
31 // NGFragment wrapper classes which transforms information into the logical 31 // NGFragment wrapper classes which transforms information into the logical
32 // coordinate system. 32 // coordinate system.
33 class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment> { 33 class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment> {
34 public: 34 public:
35 enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 }; 35 enum NGFragmentType {
36 kFragmentBox = 0,
37 kFragmentText = 1,
38 kFragmentLineBox = 2
39 // When adding new values, make sure the bit size of |type_| is large
40 // enough to store.
41 };
36 42
37 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); } 43 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); }
38 bool IsBox() const { return Type() == NGFragmentType::kFragmentBox; } 44 bool IsBox() const { return Type() == NGFragmentType::kFragmentBox; }
39 bool IsText() const { return Type() == NGFragmentType::kFragmentText; } 45 bool IsText() const { return Type() == NGFragmentType::kFragmentText; }
46 bool IsLineBox() const { return Type() == NGFragmentType::kFragmentLineBox; }
40 47
41 // Override RefCounted's deref() to ensure operator delete is called on the 48 // Override RefCounted's deref() to ensure operator delete is called on the
42 // appropriate subclass type. 49 // appropriate subclass type.
43 void deref() const { 50 void deref() const {
44 if (derefBase()) 51 if (derefBase())
45 destroy(); 52 destroy();
46 } 53 }
47 54
48 // The accessors in this class shouldn't be used by layout code directly, 55 // The accessors in this class shouldn't be used by layout code directly,
49 // instead should be accessed by the NGFragmentBase classes. These accessors 56 // instead should be accessed by the NGFragmentBase classes. These accessors
50 // exist for paint, hit-testing, etc. 57 // exist for paint, hit-testing, etc.
51 58
52 // Returns the border-box size. 59 // Returns the border-box size.
53 NGPhysicalSize Size() const { return size_; } 60 NGPhysicalSize Size() const { return size_; }
54 LayoutUnit Width() const { return size_.width; } 61 LayoutUnit Width() const { return size_.width; }
55 LayoutUnit Height() const { return size_.height; } 62 LayoutUnit Height() const { return size_.height; }
56 63
57 // Returns the total size, including the contents outside of the border-box.
58 LayoutUnit WidthOverflow() const { return overflow_.width; }
59 LayoutUnit HeightOverflow() const { return overflow_.height; }
60
61 // Returns the offset relative to the parent fragment's content-box. 64 // Returns the offset relative to the parent fragment's content-box.
62 LayoutUnit LeftOffset() const { 65 LayoutUnit LeftOffset() const {
63 DCHECK(is_placed_); 66 DCHECK(is_placed_);
64 return offset_.left; 67 return offset_.left;
65 } 68 }
66 69
67 LayoutUnit TopOffset() const { 70 LayoutUnit TopOffset() const {
68 DCHECK(is_placed_); 71 DCHECK(is_placed_);
69 return offset_.top; 72 return offset_.top;
70 } 73 }
(...skipping 18 matching lines...) Expand all
89 // with LegacyLayout. 92 // with LegacyLayout.
90 LayoutObject* GetLayoutObject() const { return layout_object_; } 93 LayoutObject* GetLayoutObject() const { return layout_object_; }
91 94
92 bool IsPlaced() const { return is_placed_; } 95 bool IsPlaced() const { return is_placed_; }
93 96
94 String ToString() const; 97 String ToString() const;
95 98
96 protected: 99 protected:
97 NGPhysicalFragment(LayoutObject* layout_object, 100 NGPhysicalFragment(LayoutObject* layout_object,
98 NGPhysicalSize size, 101 NGPhysicalSize size,
99 NGPhysicalSize overflow,
100 NGFragmentType type, 102 NGFragmentType type,
101 RefPtr<NGBreakToken> break_token = nullptr); 103 RefPtr<NGBreakToken> break_token = nullptr);
102 104
103 LayoutObject* layout_object_; 105 LayoutObject* layout_object_;
104 NGPhysicalSize size_; 106 NGPhysicalSize size_;
105 NGPhysicalSize overflow_;
106 NGPhysicalOffset offset_; 107 NGPhysicalOffset offset_;
107 RefPtr<NGBreakToken> break_token_; 108 RefPtr<NGBreakToken> break_token_;
108 109
109 unsigned type_ : 1; 110 unsigned type_ : 2;
110 unsigned is_placed_ : 1; 111 unsigned is_placed_ : 1;
111 112
112 private: 113 private:
113 void destroy() const; 114 void destroy() const;
114 }; 115 };
115 116
116 } // namespace blink 117 } // namespace blink
117 118
118 #endif // NGPhysicalFragment_h 119 #endif // NGPhysicalFragment_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698