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

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

Issue 2346403002: [layoutng] Create correct constraint spaces for children (Closed)
Patch Set: fix assert failures Created 4 years, 3 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 NGConstraintSpace_h 5 #ifndef NGConstraintSpace_h
6 #define NGConstraintSpace_h 6 #define NGConstraintSpace_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/ng_physical_constraint_space.h" 9 #include "core/layout/ng/ng_physical_constraint_space.h"
10 #include "core/layout/ng/ng_writing_mode.h" 10 #include "core/layout/ng/ng_writing_mode.h"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "wtf/text/WTFString.h" 12 #include "wtf/text/WTFString.h"
13 #include "wtf/Vector.h" 13 #include "wtf/Vector.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class LayoutBox; 17 class LayoutBox;
18 class NGFragment; 18 class NGFragment;
19 class NGLayoutOpportunityIterator; 19 class NGLayoutOpportunityIterator;
20 20
21 // The NGConstraintSpace represents a set of constraints and available space 21 // The NGConstraintSpace represents a set of constraints and available space
22 // which a layout algorithm may produce a NGFragment within. It is a view on 22 // which a layout algorithm may produce a NGFragment within. It is a view on
23 // top of a NGPhysicalConstraintSpace and provides accessor methods in the 23 // top of a NGPhysicalConstraintSpace and provides accessor methods in the
24 // logical coordinate system defined by the writing mode given. 24 // logical coordinate system defined by the writing mode given.
25 class CORE_EXPORT NGConstraintSpace final 25 class CORE_EXPORT NGConstraintSpace final
26 : public GarbageCollected<NGConstraintSpace> { 26 : public GarbageCollected<NGConstraintSpace> {
27 public: 27 public:
28 // Constructs a constraint space with a new backing NGPhysicalConstraintSpace. 28 // Constructs a constraint space with a new backing NGPhysicalConstraintSpace.
29 // The size will be used for both for the physical constraint space's
30 // container size and this constraint space's Size().
29 NGConstraintSpace(NGWritingMode, NGDirection, NGLogicalSize); 31 NGConstraintSpace(NGWritingMode, NGDirection, NGLogicalSize);
30 32
31 // Constructs a constraint space based on an existing backing 33 // Constructs a constraint space based on an existing backing
32 // NGPhysicalConstraintSpace. 34 // NGPhysicalConstraintSpace. Sets this constraint space's size to the
35 // physical constraint space's container size, converted to logical
36 // coordinates.
37 // TODO(layout-ng): Do we need this constructor?
33 NGConstraintSpace(NGWritingMode, NGDirection, NGPhysicalConstraintSpace*); 38 NGConstraintSpace(NGWritingMode, NGDirection, NGPhysicalConstraintSpace*);
34 39
35 // Constructs a constraint space with a different NGWritingMode and 40 // Constructs a constraint space with a different NGWritingMode and
36 // NGDirection. 41 // NGDirection that's otherwise identical.
37 NGConstraintSpace(NGWritingMode, NGDirection, const NGConstraintSpace*); 42 NGConstraintSpace(NGWritingMode, NGDirection, const NGConstraintSpace*);
38 43
39 // Constructs a derived constraint space sharing the same backing 44 // Constructs a derived constraint space sharing the same backing
40 // NGPhysicalConstraintSpace, NGWritingMode and NGDirection. 45 // NGPhysicalConstraintSpace, NGWritingMode and NGDirection. Primarily for use
46 // by NGLayoutOpportunityIterator.
41 NGConstraintSpace(const NGConstraintSpace& other, 47 NGConstraintSpace(const NGConstraintSpace& other,
42 NGLogicalOffset, 48 NGLogicalOffset,
43 NGLogicalSize); 49 NGLogicalSize);
44 50
45 // Constructs a derived constraint space sharing the same backing 51 // Constructs a derived constraint space that shares the exclusions of the
46 // NGPhysicalConstraintSpace, a different NGWritingMode and NGDirection. 52 // input constraint space, but has a different container size, writing mode
53 // and direction. Sets the offset to zero. For use by layout algorithms
54 // to use as the basis to find layout opportunities for children.
47 NGConstraintSpace(NGWritingMode, 55 NGConstraintSpace(NGWritingMode,
48 NGDirection, 56 NGDirection,
49 const NGConstraintSpace& other, 57 const NGConstraintSpace& other,
50 NGLogicalOffset,
51 NGLogicalSize); 58 NGLogicalSize);
52 59
53 // This should live on NGBox or another layout bridge and probably take a root 60 // This should live on NGBox or another layout bridge and probably take a root
54 // NGConstraintSpace or a NGPhysicalConstraintSpace. 61 // NGConstraintSpace or a NGPhysicalConstraintSpace.
55 static NGConstraintSpace* CreateFromLayoutObject(const LayoutBox&); 62 static NGConstraintSpace* CreateFromLayoutObject(const LayoutBox&);
56 63
57 NGPhysicalConstraintSpace* PhysicalSpace() const { return physical_space_; } 64 NGPhysicalConstraintSpace* PhysicalSpace() const { return physical_space_; }
58 65
59 NGDirection Direction() const { return static_cast<NGDirection>(direction_); } 66 NGDirection Direction() const { return static_cast<NGDirection>(direction_); }
60 67
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 }; 131 };
125 132
126 inline std::ostream& operator<<(std::ostream& stream, 133 inline std::ostream& operator<<(std::ostream& stream,
127 const NGConstraintSpace& value) { 134 const NGConstraintSpace& value) {
128 return stream << value.toString(); 135 return stream << value.toString();
129 } 136 }
130 137
131 } // namespace blink 138 } // namespace blink
132 139
133 #endif // NGConstraintSpace_h 140 #endif // NGConstraintSpace_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698