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

Side by Side Diff: third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp

Issue 2803323002: Avoiding name collisions between flexbox and grid (Closed)
Patch Set: Moved functions around. Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "core/layout/GridTrackSizingAlgorithm.h" 5 #include "core/layout/GridTrackSizingAlgorithm.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/layout/Grid.h" 8 #include "core/layout/Grid.h"
9 #include "core/layout/LayoutGrid.h" 9 #include "core/layout/LayoutGrid.h"
10 #include "platform/LengthFunctions.h" 10 #include "platform/LengthFunctions.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 bool recomputeUsedFlexFractionIfNeeded( 118 bool recomputeUsedFlexFractionIfNeeded(
119 Vector<size_t>& flexibleSizedTracksIndex, 119 Vector<size_t>& flexibleSizedTracksIndex,
120 double& flexFraction, 120 double& flexFraction,
121 Vector<LayoutUnit>& increments, 121 Vector<LayoutUnit>& increments,
122 LayoutUnit& totalGrowth) const override { 122 LayoutUnit& totalGrowth) const override {
123 return false; 123 return false;
124 } 124 }
125 }; 125 };
126 126
127 // TODO(svillar): Repeated in LayoutGrid. 127 // TODO(svillar): Repeated in LayoutGrid.
128 static LayoutUnit computeMarginLogicalSizeForChild(MarginDirection forDirection, 128 LayoutUnit GridTrackSizingAlgorithmStrategy::computeMarginLogicalSizeForChild(
129 const LayoutGrid* grid, 129 MarginDirection forDirection,
130 const LayoutBox& child) { 130 const LayoutGrid* grid,
131 const LayoutBox& child) {
131 if (!child.styleRef().hasMargin()) 132 if (!child.styleRef().hasMargin())
132 return LayoutUnit(); 133 return LayoutUnit();
133 134
134 bool isRowAxis = forDirection == InlineDirection; 135 bool isRowAxis = forDirection == InlineDirection;
135 LayoutUnit marginStart; 136 LayoutUnit marginStart;
136 LayoutUnit marginEnd; 137 LayoutUnit marginEnd;
137 LayoutUnit logicalSize = 138 LayoutUnit logicalSize =
138 isRowAxis ? child.logicalWidth() : child.logicalHeight(); 139 isRowAxis ? child.logicalWidth() : child.logicalHeight();
139 Length marginStartLength = isRowAxis ? child.styleRef().marginStart() 140 Length marginStartLength = isRowAxis ? child.styleRef().marginStart()
140 : child.styleRef().marginBefore(); 141 : child.styleRef().marginBefore();
141 Length marginEndLength = 142 Length marginEndLength =
142 isRowAxis ? child.styleRef().marginEnd() : child.styleRef().marginAfter(); 143 isRowAxis ? child.styleRef().marginEnd() : child.styleRef().marginAfter();
143 child.computeMarginsForDirection( 144 child.computeMarginsForDirection(
144 forDirection, grid, child.containingBlockLogicalWidthForContent(), 145 forDirection, grid, child.containingBlockLogicalWidthForContent(),
145 logicalSize, marginStart, marginEnd, marginStartLength, marginEndLength); 146 logicalSize, marginStart, marginEnd, marginStartLength, marginEndLength);
146 147
147 return marginStart + marginEnd; 148 return marginStart + marginEnd;
148 } 149 }
149 150
150 static bool hasOverrideContainingBlockContentSizeForChild( 151 bool GridTrackSizingAlgorithmStrategy::
151 const LayoutBox& child, 152 hasOverrideContainingBlockContentSizeForChild(
152 GridTrackSizingDirection direction) { 153 const LayoutBox& child,
154 GridTrackSizingDirection direction) {
153 return direction == ForColumns 155 return direction == ForColumns
154 ? child.hasOverrideContainingBlockLogicalWidth() 156 ? child.hasOverrideContainingBlockLogicalWidth()
155 : child.hasOverrideContainingBlockLogicalHeight(); 157 : child.hasOverrideContainingBlockLogicalHeight();
156 } 158 }
157 159
158 static LayoutUnit overrideContainingBlockContentSizeForChild( 160 LayoutUnit
161 GridTrackSizingAlgorithmStrategy::overrideContainingBlockContentSizeForChild(
159 const LayoutBox& child, 162 const LayoutBox& child,
160 GridTrackSizingDirection direction) { 163 GridTrackSizingDirection direction) {
161 return direction == ForColumns 164 return direction == ForColumns
162 ? child.overrideContainingBlockContentLogicalWidth() 165 ? child.overrideContainingBlockContentLogicalWidth()
163 : child.overrideContainingBlockContentLogicalHeight(); 166 : child.overrideContainingBlockContentLogicalHeight();
164 } 167 }
165 168
166 static bool shouldClearOverrideContainingBlockContentSizeForChild( 169 bool GridTrackSizingAlgorithmStrategy::
167 const LayoutBox& child, 170 shouldClearOverrideContainingBlockContentSizeForChild(
168 GridTrackSizingDirection direction) { 171 const LayoutBox& child,
172 GridTrackSizingDirection direction) {
169 if (direction == ForColumns) { 173 if (direction == ForColumns) {
170 return child.hasRelativeLogicalWidth() || 174 return child.hasRelativeLogicalWidth() ||
171 child.styleRef().logicalWidth().isIntrinsicOrAuto(); 175 child.styleRef().logicalWidth().isIntrinsicOrAuto();
172 } 176 }
173 return child.hasRelativeLogicalHeight() || 177 return child.hasRelativeLogicalHeight() ||
174 child.styleRef().logicalHeight().isIntrinsicOrAuto(); 178 child.styleRef().logicalHeight().isIntrinsicOrAuto();
175 } 179 }
176 180
177 static void setOverrideContainingBlockContentSizeForChild( 181 void GridTrackSizingAlgorithmStrategy::
178 LayoutBox& child, 182 setOverrideContainingBlockContentSizeForChild(
179 GridTrackSizingDirection direction, 183 LayoutBox& child,
180 LayoutUnit size) { 184 GridTrackSizingDirection direction,
185 LayoutUnit size) {
181 if (direction == ForColumns) 186 if (direction == ForColumns)
182 child.setOverrideContainingBlockContentLogicalWidth(size); 187 child.setOverrideContainingBlockContentLogicalWidth(size);
183 else 188 else
184 child.setOverrideContainingBlockContentLogicalHeight(size); 189 child.setOverrideContainingBlockContentLogicalHeight(size);
185 } 190 }
186 191
187 static GridTrackSizingDirection flowAwareDirectionForChild( 192 GridTrackSizingDirection
193 GridTrackSizingAlgorithmStrategy::flowAwareDirectionForChild(
188 const LayoutGrid* layoutGrid, 194 const LayoutGrid* layoutGrid,
189 const LayoutBox& child, 195 const LayoutBox& child,
190 GridTrackSizingDirection direction) { 196 GridTrackSizingDirection direction) {
191 return child.isHorizontalWritingMode() == 197 return child.isHorizontalWritingMode() ==
192 layoutGrid->isHorizontalWritingMode() 198 layoutGrid->isHorizontalWritingMode()
193 ? direction 199 ? direction
194 : (direction == ForColumns ? ForRows : ForColumns); 200 : (direction == ForColumns ? ForRows : ForColumns);
195 } 201 }
196 202
197 LayoutUnit GridTrackSizingAlgorithm::assumedRowsSizeForOrthogonalChild( 203 LayoutUnit GridTrackSizingAlgorithm::assumedRowsSizeForOrthogonalChild(
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 DCHECK(m_algorithm.isValidTransition()); 1446 DCHECK(m_algorithm.isValidTransition());
1441 DCHECK(!m_algorithm.m_needsSetup); 1447 DCHECK(!m_algorithm.m_needsSetup);
1442 } 1448 }
1443 1449
1444 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { 1450 GridTrackSizingAlgorithm::StateMachine::~StateMachine() {
1445 m_algorithm.advanceNextState(); 1451 m_algorithm.advanceNextState();
1446 m_algorithm.m_needsSetup = true; 1452 m_algorithm.m_needsSetup = true;
1447 } 1453 }
1448 1454
1449 } // namespace blink 1455 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698