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

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

Issue 2872593003: [LayoutNG] Introduce NGPositionedFloat. (Closed)
Patch Set: address comments. Created 3 years, 7 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/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Calculated logical offset. It's never {@code nullopt} for a positioned
54 // float.
55 WTF::Optional<NGLogicalOffset> logical_offset;
56
57 // Writing mode of the float's constraint space. 53 // Writing mode of the float's constraint space.
58 NGWritingMode writing_mode; 54 NGWritingMode writing_mode;
59 55
60 RefPtr<NGPhysicalFragment> fragment; 56 RefPtr<NGPhysicalFragment> fragment;
61 57
62 // In the case where a legacy FloatingObject is attached to not its own
63 // parent, e.g. a float surrounded by a bunch of nested empty divs,
64 // NG float fragment's LeftOffset() cannot be used as legacy FloatingObject's
65 // left offset because that offset should be relative to the original float
66 // parent.
67 // {@code left_offset} is calculated when we know to which parent this float
68 // would be attached.
69 LayoutUnit left_offset;
70
71 bool IsLeft() const { return exclusion_type == NGExclusion::kFloatLeft; } 58 bool IsLeft() const { return exclusion_type == NGExclusion::kFloatLeft; }
72 59
73 bool IsRight() const { return exclusion_type == NGExclusion::kFloatRight; } 60 bool IsRight() const { return exclusion_type == NGExclusion::kFloatRight; }
74 61
75 String ToString() const { 62 String ToString() const {
76 return String::Format("Type: '%d' Fragment: '%s'", exclusion_type, 63 return String::Format("Type: '%d'", exclusion_type);
77 fragment->ToString().Ascii().data());
78 } 64 }
79 65
80 private: 66 private:
81 NGFloatingObject(const ComputedStyle& style, 67 NGFloatingObject(const ComputedStyle& style,
82 const NGBoxStrut& margins, 68 const NGBoxStrut& margins,
83 const NGLogicalSize& available_size, 69 const NGLogicalSize& available_size,
84 const NGLogicalOffset& origin_offset, 70 const NGLogicalOffset& origin_offset,
85 const NGLogicalOffset& from_offset, 71 const NGLogicalOffset& from_offset,
86 NGWritingMode writing_mode, 72 NGWritingMode writing_mode,
87 NGPhysicalFragment* fragment) 73 NGPhysicalFragment* fragment)
88 : margins(margins), 74 : margins(margins),
89 available_size(available_size), 75 available_size(available_size),
90 origin_offset(origin_offset), 76 origin_offset(origin_offset),
91 from_offset(from_offset), 77 from_offset(from_offset),
92 writing_mode(writing_mode), 78 writing_mode(writing_mode),
93 fragment(fragment) { 79 fragment(fragment) {
94 exclusion_type = NGExclusion::kFloatLeft; 80 exclusion_type = NGExclusion::kFloatLeft;
95 if (style.Floating() == EFloat::kRight) 81 if (style.Floating() == EFloat::kRight)
96 exclusion_type = NGExclusion::kFloatRight; 82 exclusion_type = NGExclusion::kFloatRight;
97 clear_type = style.Clear(); 83 clear_type = style.Clear();
98 } 84 }
99 }; 85 };
100 86
101 } // namespace blink 87 } // namespace blink
102 88
103 #endif // NGFloatingObject_h 89 #endif // NGFloatingObject_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_node.cc ('k') | third_party/WebKit/Source/core/layout/ng/ng_floats_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698