OLD | NEW |
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/ng_block_node.h" | 8 #include "core/layout/ng/ng_block_node.h" |
9 #include "core/layout/ng/ng_constraint_space.h" | 9 #include "core/layout/ng/ng_constraint_space.h" |
10 #include "core/layout/ng/ng_units.h" | 10 #include "core/layout/ng/ng_units.h" |
11 #include "core/style/ComputedStyle.h" | 11 #include "core/style/ComputedStyle.h" |
12 #include "core/style/ComputedStyleConstants.h" | 12 #include "core/style/ComputedStyleConstants.h" |
13 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class NGPhysicalFragment; | 17 class NGPhysicalFragment; |
18 | 18 |
19 // Struct that keeps all information needed to position floats in LayoutNG. | 19 // Struct that keeps all information needed to position floats in LayoutNG. |
20 struct CORE_EXPORT NGFloatingObject | 20 struct CORE_EXPORT NGFloatingObject |
21 : public GarbageCollectedFinalized<NGFloatingObject> { | 21 : public GarbageCollectedFinalized<NGFloatingObject> { |
22 NGFloatingObject(NGPhysicalFragment* fragment, | 22 NGFloatingObject(NGPhysicalFragment* fragment, |
23 NGConstraintSpace* space, | 23 NGConstraintSpace* space, |
24 const NGConstraintSpace* parent_space, | 24 const NGConstraintSpace* parent_space, |
25 NGBlockNode* node, | 25 NGBlockNode* node, |
26 const ComputedStyle& style, | 26 const ComputedStyle& style, |
27 const NGBoxStrut& margins) | 27 const NGBoxStrut& margins) |
28 : fragment(fragment), | 28 : fragment(fragment), |
29 space(space), | 29 space(space), |
30 parent_space(parent_space), | 30 original_parent_space(parent_space), |
31 node(node), | 31 node(node), |
32 margins(margins) { | 32 margins(margins) { |
33 exclusion_type = NGExclusion::kFloatLeft; | 33 exclusion_type = NGExclusion::kFloatLeft; |
34 if (style.floating() == EFloat::kRight) | 34 if (style.floating() == EFloat::kRight) |
35 exclusion_type = NGExclusion::kFloatRight; | 35 exclusion_type = NGExclusion::kFloatRight; |
36 clear_type = style.clear(); | 36 clear_type = style.clear(); |
37 } | 37 } |
38 | 38 |
39 RefPtr<NGPhysicalFragment> fragment; | 39 RefPtr<NGPhysicalFragment> fragment; |
40 // TODO(glebl): Constraint space should be const here. | 40 // TODO(glebl): Constraint space should be const here. |
41 Member<NGConstraintSpace> space; | 41 Member<NGConstraintSpace> space; |
42 | 42 |
43 // Parent space is used so we can calculate the inline offset relative to | 43 // Parent space is used so we can calculate the inline offset relative to |
44 // the original parent of this float. | 44 // the original parent of this float. |
45 Member<const NGConstraintSpace> parent_space; | 45 Member<const NGConstraintSpace> original_parent_space; |
46 Member<NGBlockNode> node; | 46 Member<NGBlockNode> node; |
47 NGExclusion::Type exclusion_type; | 47 NGExclusion::Type exclusion_type; |
48 EClear clear_type; | 48 EClear clear_type; |
49 NGBoxStrut margins; | 49 NGBoxStrut margins; |
50 | 50 |
51 // In the case where a legacy FloatingObject is attached to not its own | 51 // 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, | 52 // 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 | 53 // 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 | 54 // left offset because that offset should be relative to the original float |
55 // parent. | 55 // parent. |
56 // {@code left_offset} is calculated when we know to which parent this float | 56 // {@code left_offset} is calculated when we know to which parent this float |
57 // would be attached. | 57 // would be attached. |
58 LayoutUnit left_offset; | 58 LayoutUnit left_offset; |
59 | 59 |
60 DEFINE_INLINE_TRACE() { | 60 DEFINE_INLINE_TRACE() { |
61 visitor->trace(space); | 61 visitor->trace(space); |
62 visitor->trace(parent_space); | 62 visitor->trace(original_parent_space); |
63 visitor->trace(node); | 63 visitor->trace(node); |
64 } | 64 } |
65 }; | 65 }; |
66 | 66 |
67 } // namespace blink | 67 } // namespace blink |
68 | 68 |
69 #endif // NGFloatingObject_h | 69 #endif // NGFloatingObject_h |
OLD | NEW |