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

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

Issue 2752123002: [LayoutNG] Move NGFloatingObject off Oilpan (Closed)
Patch Set: more comments 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 NGFloatingObject_h 5 #ifndef NGFloatingObject_h
6 #define NGFloatingObject_h 6 #define NGFloatingObject_h
7 7
8 #include "core/layout/ng/geometry/ng_box_strut.h" 8 #include "core/layout/ng/geometry/ng_box_strut.h"
9 #include "core/layout/ng/ng_block_node.h" 9 #include "core/layout/ng/ng_block_node.h"
10 #include "core/layout/ng/ng_constraint_space.h" 10 #include "core/layout/ng/ng_constraint_space.h"
11 #include "core/layout/ng/ng_exclusion.h" 11 #include "core/layout/ng/ng_exclusion.h"
12 #include "core/layout/ng/ng_physical_fragment.h"
12 #include "core/style/ComputedStyle.h" 13 #include "core/style/ComputedStyle.h"
13 #include "core/style/ComputedStyleConstants.h" 14 #include "core/style/ComputedStyleConstants.h"
14 #include "platform/heap/Handle.h" 15 #include "wtf/RefPtr.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 class NGPhysicalFragment;
19
20 // Struct that keeps all information needed to position floats in LayoutNG. 19 // Struct that keeps all information needed to position floats in LayoutNG.
21 struct CORE_EXPORT NGFloatingObject 20 struct CORE_EXPORT NGFloatingObject : public RefCounted<NGFloatingObject> {
22 : public GarbageCollectedFinalized<NGFloatingObject> { 21 public:
23 NGFloatingObject(const NGConstraintSpace* space, 22 static RefPtr<NGFloatingObject> Create(const NGConstraintSpace* space,
24 const NGConstraintSpace* parent_space, 23 const NGConstraintSpace* parent_space,
25 const ComputedStyle& style, 24 const ComputedStyle& style,
26 const NGBoxStrut& margins, 25 const NGBoxStrut& margins,
27 NGPhysicalFragment* fragment) 26 NGPhysicalFragment* fragment) {
28 : space(space), 27 return adoptRef(
29 original_parent_space(parent_space), 28 new NGFloatingObject(space, parent_space, style, margins, fragment));
30 margins(margins),
31 fragment(fragment) {
32 exclusion_type = NGExclusion::kFloatLeft;
33 if (style.floating() == EFloat::kRight)
34 exclusion_type = NGExclusion::kFloatRight;
35 clear_type = style.clear();
36 } 29 }
37 30
38 // Original constraint space of the float. 31 // Original constraint space of the float.
39 RefPtr<const NGConstraintSpace> space; 32 RefPtr<const NGConstraintSpace> space;
40 33
41 // Parent space is used so we can calculate the inline offset relative to 34 // Parent space is used so we can calculate the inline offset relative to
42 // the original parent of this float. 35 // the original parent of this float.
43 RefPtr<const NGConstraintSpace> original_parent_space; 36 RefPtr<const NGConstraintSpace> original_parent_space;
44 37
45 NGExclusion::Type exclusion_type; 38 NGExclusion::Type exclusion_type;
46 EClear clear_type; 39 EClear clear_type;
47 NGBoxStrut margins; 40 NGBoxStrut margins;
48 41
49 RefPtr<NGPhysicalFragment> fragment; 42 RefPtr<NGPhysicalFragment> fragment;
50 43
51 // In the case where a legacy FloatingObject is attached to not its own 44 // In the case where a legacy FloatingObject is attached to not its own
52 // parent, e.g. a float surrounded by a bunch of nested empty divs, 45 // parent, e.g. a float surrounded by a bunch of nested empty divs,
53 // NG float fragment's LeftOffset() cannot be used as legacy FloatingObject's 46 // NG float fragment's LeftOffset() cannot be used as legacy FloatingObject's
54 // left offset because that offset should be relative to the original float 47 // left offset because that offset should be relative to the original float
55 // parent. 48 // parent.
56 // {@code left_offset} is calculated when we know to which parent this float 49 // {@code left_offset} is calculated when we know to which parent this float
57 // would be attached. 50 // would be attached.
58 LayoutUnit left_offset; 51 LayoutUnit left_offset;
59 52
60 DEFINE_INLINE_TRACE() { 53 private:
54 NGFloatingObject(const NGConstraintSpace* space,
55 const NGConstraintSpace* parent_space,
56 const ComputedStyle& style,
57 const NGBoxStrut& margins,
58 NGPhysicalFragment* fragment)
59 : space(space),
60 original_parent_space(parent_space),
61 margins(margins),
62 fragment(fragment) {
63 exclusion_type = NGExclusion::kFloatLeft;
64 if (style.floating() == EFloat::kRight)
65 exclusion_type = NGExclusion::kFloatRight;
66 clear_type = style.clear();
61 } 67 }
62 }; 68 };
63 69
64 } // namespace blink 70 } // namespace blink
65 71
66 #endif // NGFloatingObject_h 72 #endif // NGFloatingObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698