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/geometry/ng_box_strut.h" | 8 #include "core/layout/ng/geometry/ng_box_strut.h" |
9 #include "core/layout/ng/geometry/ng_logical_size.h" | 9 #include "core/layout/ng/geometry/ng_logical_size.h" |
10 #include "core/layout/ng/ng_block_node.h" | 10 #include "core/layout/ng/ng_block_node.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 writing_mode, fragment)); | 32 writing_mode, fragment)); |
33 } | 33 } |
34 | 34 |
35 NGExclusion::Type exclusion_type; | 35 NGExclusion::Type exclusion_type; |
36 EClear clear_type; | 36 EClear clear_type; |
37 NGBoxStrut margins; | 37 NGBoxStrut margins; |
38 // Available size of the constraint space that will be used by | 38 // Available size of the constraint space that will be used by |
39 // NGLayoutOpportunityIterator to position this floating object. | 39 // NGLayoutOpportunityIterator to position this floating object. |
40 NGLogicalSize available_size; | 40 NGLogicalSize available_size; |
41 | 41 |
42 // To correctly position a float we need 2 offsets: | 42 // To correctly **position** a float we need 2 offsets: |
43 // - origin_offset which represents the layout point for this float. | 43 // - origin_offset which represents the layout point for this float. |
44 // - from_offset which represents the point from where we need to calculate | 44 // - from_offset which represents the point from where we need to calculate |
45 // the relative logical offset for this float. | 45 // the relative logical offset for this float. |
46 // Layout details: | 46 // Layout details: |
47 // At the time when this float is created only *inline* offsets are known. | 47 // At the time when this float is created only *inline* offsets are known. |
48 // Block offset will be set when we are about to place this float, i.e. when | 48 // Block offset will be set when we are about to place this float, i.e. when |
49 // we resolved MarginStrut, adjusted the offset to clearance line etc. | 49 // we resolved MarginStrut, adjusted the offset to clearance line etc. |
50 NGLogicalOffset origin_offset; | 50 NGLogicalOffset origin_offset; |
51 NGLogicalOffset from_offset; | 51 NGLogicalOffset from_offset; |
52 | 52 |
53 // To correctly **paint** a float we need to know the BFC offset of the | |
54 // container to which we are attaching this float. It's used to calculate | |
55 // {@code left_offset}, {@code top_offset}. | |
56 // In most situations {@code (left|top)_offset} equals to float's logical | |
57 // offset except the cases where a float needs to be re-attached to a non-zero | |
58 // height parent. | |
59 // | |
60 // Example: | |
61 // <body> | |
62 // <p style="height: 60px">Example</p> | |
63 // <div id="zero-height-div"><float></div> | |
64 // | |
65 // Here the float's logical offset is 0 relative to its #zero-height-div | |
66 // parent. Because of the "zero height" div this float is re-attached to the | |
67 // 1st non-empty parent => body. To paint this float correctly we provide the | |
68 // modified {@code (top|left)_offset} which is relative to the float's new | |
69 // parent. | |
70 // I.e. for our example {@code top_offset} == #zero-height-div's BFC offset | |
71 // - body's BFC offset + float's logical offset | |
72 // | |
73 // For code safety reasons {@code container_block_offset} is Optional here | |
74 // because the block's offset can be only determined before the actual float's | |
75 // placement event. | |
76 WTF::Optional<LayoutUnit> container_block_offset; | |
ikilpatrick
2017/05/09 22:45:23
is a better name for the bfc_block_offset? contain
Gleb Lanbin
2017/05/09 23:12:07
renamed to parent_bfc_block_offset
| |
77 | |
53 // Writing mode of the float's constraint space. | 78 // Writing mode of the float's constraint space. |
54 NGWritingMode writing_mode; | 79 NGWritingMode writing_mode; |
55 | 80 |
56 RefPtr<NGPhysicalFragment> fragment; | 81 RefPtr<NGPhysicalFragment> fragment; |
57 | 82 |
58 bool IsLeft() const { return exclusion_type == NGExclusion::kFloatLeft; } | 83 bool IsLeft() const { return exclusion_type == NGExclusion::kFloatLeft; } |
59 | 84 |
60 bool IsRight() const { return exclusion_type == NGExclusion::kFloatRight; } | 85 bool IsRight() const { return exclusion_type == NGExclusion::kFloatRight; } |
61 | 86 |
62 String ToString() const { | 87 String ToString() const { |
(...skipping 17 matching lines...) Expand all Loading... | |
80 exclusion_type = NGExclusion::kFloatLeft; | 105 exclusion_type = NGExclusion::kFloatLeft; |
81 if (style.Floating() == EFloat::kRight) | 106 if (style.Floating() == EFloat::kRight) |
82 exclusion_type = NGExclusion::kFloatRight; | 107 exclusion_type = NGExclusion::kFloatRight; |
83 clear_type = style.Clear(); | 108 clear_type = style.Clear(); |
84 } | 109 } |
85 }; | 110 }; |
86 | 111 |
87 } // namespace blink | 112 } // namespace blink |
88 | 113 |
89 #endif // NGFloatingObject_h | 114 #endif // NGFloatingObject_h |
OLD | NEW |