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

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

Issue 2228843003: [LayoutNG] Change core/layout/ng to Chromium style and rename files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NGConstraintSpace_h
6 #define NGConstraintSpace_h
7
8 #include "core/CoreExport.h"
9 #include "platform/LayoutUnit.h"
10 #include "wtf/DoublyLinkedList.h"
11
12 namespace blink {
13
14 class NGConstraintSpace;
15 class NGDerivedConstraintSpace;
16 class NGExclusion;
17 class NGFragment;
18 class NGLayoutOpportunityIterator;
19 class LayoutBox;
20
21 enum NGExclusionType {
22 NGClearNone = 0,
23 NGClearFloatLeft = 1,
24 NGClearFloatRight = 2,
25 NGClearFragment = 4
26 };
27
28 enum NGFragmentationType {
29 FragmentNone,
30 FragmentPage,
31 FragmentColumn,
32 FragmentRegion
33 };
34
35 enum NGExclusionFlowType {
36 ExcludeNone,
37 ExcludeInlineFlow,
38 ExcludeInlineStart,
39 ExcludeInlineEnd,
40 ExcludeInlineBoth
41 };
42
43 class NGExclusion {
44 public:
45 NGExclusion();
46 ~NGExclusion() {}
47 };
48
49 class CORE_EXPORT NGConstraintSpace {
50 public:
51 NGConstraintSpace(LayoutUnit inlineContainerSize,
52 LayoutUnit blockContainerSize);
53 ~NGConstraintSpace() {}
54
55 // Constructs Layout NG constraint space from legacy layout object.
56 static NGConstraintSpace fromLayoutObject(const LayoutBox&);
57
58 void addExclusion(const NGExclusion, unsigned options = 0);
59 void setOverflowTriggersScrollbar(bool inlineTriggers, bool blockTriggers);
60 void setFixedSize(bool inlineFixed, bool blockFixed);
61 void setFragmentationType(NGFragmentationType);
62
63 // Size of the container in each direction. Used for the following
64 // three cases:
65 // 1) Percentage resolution.
66 // 2) Resolving absolute positions of children.
67 // 3) Defining the threashold that triggers the presence of a scrollbar. Only
68 // applies if the corresponding scrollbarTrigger flag has been set for the
69 // direction.
70 LayoutUnit inlineContainerSize() const { return m_inlineContainerSize; }
71 LayoutUnit blockContainerSize() const { return m_blockContainerSize; }
72
73 // Whether exceeding the containerSize triggers the presence of a scrollbar
74 // for the indicated direction.
75 // If exceeded the current layout should be aborted and invoked again with a
76 // constraint space modified to reserve space for a scrollbar.
77 bool inlineTriggersScrollbar() const { return m_inlineTriggersScrollbar; }
78 bool blockTriggersScrollbar() const { return m_blockTriggersScrollbar; }
79
80 // Some layout modes “stretch” their children to a fixed size (e.g. flex,
81 // grid). These flags represented whether a layout needs to produce a
82 // fragment that satisfies a fixed constraint in the inline and block
83 // direction respectively.
84 bool fixedInlineSize() const { return m_fixedInlineSize; }
85 bool fixedBlockSize() const { return m_fixedBlockSize; }
86
87 // If specified a layout should produce a Fragment which fragments at the
88 // blockSize if possible.
89 NGFragmentationType blockFragmentationType() const {
90 return static_cast<NGFragmentationType>(m_blockFragmentationType);
91 }
92
93 DoublyLinkedList<const NGExclusion> exclusions(unsigned options = 0) const;
94
95 NGLayoutOpportunityIterator layoutOpportunities(
96 unsigned clear = NGClearNone,
97 NGExclusionFlowType avoid = ExcludeNone) const;
98
99 // Modifies constraint space to account for a placed fragment. Depending on
100 // the shape of the fragment this will either modify the inline or block
101 // size, or add an exclusion.
102 void subtract(const NGFragment);
103
104 private:
105 LayoutUnit m_inlineContainerSize;
106 LayoutUnit m_blockContainerSize;
107
108 unsigned m_fixedInlineSize : 1;
109 unsigned m_fixedBlockSize : 1;
110 unsigned m_inlineTriggersScrollbar : 1;
111 unsigned m_blockTriggersScrollbar : 1;
112 unsigned m_blockFragmentationType : 2;
113
114 DoublyLinkedList<const NGExclusion> m_exclusions;
115 };
116
117 class CORE_EXPORT NGLayoutOpportunityIterator final {
118 public:
119 NGLayoutOpportunityIterator(const NGConstraintSpace* space,
120 unsigned clear,
121 NGExclusionFlowType avoid)
122 : m_constraintSpace(space), m_clear(clear), m_avoid(avoid) {}
123 ~NGLayoutOpportunityIterator() {}
124
125 const NGDerivedConstraintSpace* next();
126
127 private:
128 const NGConstraintSpace* m_constraintSpace;
129 unsigned m_clear;
130 NGExclusionFlowType m_avoid;
131 };
132
133 class CORE_EXPORT NGDerivedConstraintSpace final : NGConstraintSpace {
134 public:
135 ~NGDerivedConstraintSpace();
136
137 LayoutUnit inlineOffset() const;
138 LayoutUnit blockOffset() const;
139 LayoutUnit inlineSize() const;
140 LayoutUnit blockSize() const;
141
142 private:
143 NGDerivedConstraintSpace();
144
145 LayoutUnit m_inlineOffset;
146 LayoutUnit m_blockOffset;
147 LayoutUnit m_inlineSize;
148 LayoutUnit m_blockSize;
149 NGConstraintSpace* m_original;
150 };
151
152 } // namespace blink
153
154 #endif // NGConstraintSpace_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698