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> { |
ikilpatrick
2017/02/10 01:53:41
Also I assume we are performing copies of this obj
Gleb Lanbin
2017/02/10 20:11:12
yes, we're copying heap pointers
| |
22 NGFloatingObject(NGPhysicalFragment* fragment, | 22 NGFloatingObject(NGPhysicalFragment* fragment, |
23 NGConstraintSpace* space, | 23 NGConstraintSpace* space, |
24 const NGConstraintSpace* parent_space, | |
24 NGBlockNode* node, | 25 NGBlockNode* node, |
25 const ComputedStyle& style, | 26 const ComputedStyle& style, |
26 const NGBoxStrut& margins) | 27 const NGBoxStrut& margins) |
27 : fragment(fragment), space(space), node(node), margins(margins) { | 28 : fragment(fragment), |
29 space(space), | |
30 parent_space(parent_space), | |
31 node(node), | |
32 margins(margins) { | |
28 exclusion_type = NGExclusion::kFloatLeft; | 33 exclusion_type = NGExclusion::kFloatLeft; |
29 if (style.floating() == EFloat::kRight) | 34 if (style.floating() == EFloat::kRight) |
30 exclusion_type = NGExclusion::kFloatRight; | 35 exclusion_type = NGExclusion::kFloatRight; |
31 clear_type = style.clear(); | 36 clear_type = style.clear(); |
32 } | 37 } |
33 | 38 |
34 RefPtr<NGPhysicalFragment> fragment; | 39 RefPtr<NGPhysicalFragment> fragment; |
35 // TODO(glebl): Constraint space should be const here. | 40 // TODO(glebl): Constraint space should be const here. |
36 Member<NGConstraintSpace> space; | 41 Member<NGConstraintSpace> space; |
42 | |
43 // Parent space is used so we can calculate the inline offset relative to | |
44 // the genuine parent of this float. | |
45 Member<const NGConstraintSpace> parent_space; | |
ikilpatrick
2017/02/10 01:53:41
This doesn't need to be stored here right?
Gleb Lanbin
2017/02/10 20:11:12
we use the original parent's inline BFC offset in
| |
37 Member<NGBlockNode> node; | 46 Member<NGBlockNode> node; |
38 NGExclusion::Type exclusion_type; | 47 NGExclusion::Type exclusion_type; |
39 EClear clear_type; | 48 EClear clear_type; |
40 NGBoxStrut margins; | 49 NGBoxStrut margins; |
41 | 50 |
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, | |
53 // NG float fragment's LeftOffset() cannot be used as legacy FloatingObject's | |
54 // left offset because that offset should be relative to the genuine float | |
55 // parent. | |
56 // {@code left_offset} is calculated when we know to which parent this float | |
57 // would be attached. | |
58 LayoutUnit left_offset; | |
59 | |
42 DEFINE_INLINE_TRACE() { | 60 DEFINE_INLINE_TRACE() { |
43 visitor->trace(space); | 61 visitor->trace(space); |
62 visitor->trace(parent_space); | |
44 visitor->trace(node); | 63 visitor->trace(node); |
45 } | 64 } |
46 }; | 65 }; |
47 | 66 |
48 } // namespace blink | 67 } // namespace blink |
49 | 68 |
50 #endif // NGFloatingObject_h | 69 #endif // NGFloatingObject_h |
OLD | NEW |