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

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

Issue 1407633003: [css-grid] Implementation of Baseline Self-Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improving the skipped tesst by solving some rounding issues 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 LayoutUnit(-1)); 269 LayoutUnit(-1));
270 setGridItemNeedsLayout(child); 270 setGridItemNeedsLayout(child);
271 } 271 }
272 272
273 // We need to clear the stretched height to properly compute logical height 273 // We need to clear the stretched height to properly compute logical height
274 // during layout. 274 // during layout.
275 if (child.needsLayout()) 275 if (child.needsLayout())
276 child.clearOverrideLogicalContentHeight(); 276 child.clearOverrideLogicalContentHeight();
277 277
278 child.layoutIfNeeded(); 278 child.layoutIfNeeded();
279 GridAxis baselineAxis =
280 layoutGrid()->isOrthogonalChild(child) ? GridRowAxis : GridColumnAxis;
281 if (layoutGrid()->isBaselineAlignmentForChild(child, baselineAxis) &&
282 layoutGrid()->isBaselineContextComputed(baselineAxis)) {
283 auto& group = layoutGrid()->getBaselineGroupForChild(child, baselineAxis);
284 return group.maxAscent() + group.maxDescent();
285 }
279 return child.logicalHeight() + child.marginLogicalHeight(); 286 return child.logicalHeight() + child.marginLogicalHeight();
280 } 287 }
281 288
282 DISABLE_CFI_PERF 289 DISABLE_CFI_PERF
283 LayoutUnit GridTrackSizingAlgorithmStrategy::minContentForChild( 290 LayoutUnit GridTrackSizingAlgorithmStrategy::minContentForChild(
284 LayoutBox& child) const { 291 LayoutBox& child) const {
285 GridTrackSizingDirection childInlineDirection = 292 GridTrackSizingDirection childInlineDirection =
286 flowAwareDirectionForChild(layoutGrid(), child, ForColumns); 293 flowAwareDirectionForChild(layoutGrid(), child, ForColumns);
287 if (direction() == childInlineDirection) { 294 if (direction() == childInlineDirection) {
288 // If |child| has a relative logical width, we shouldn't let it override its 295 // If |child| has a relative logical width, we shouldn't let it override its
289 // intrinsic width, which is what we are interested in here. Thus we need to 296 // intrinsic width, which is what we are interested in here. Thus we need to
290 // set the inline-axis override size to -1 (no possible resolution). 297 // set the inline-axis override size to -1 (no possible resolution).
291 if (shouldClearOverrideContainingBlockContentSizeForChild(child, 298 if (shouldClearOverrideContainingBlockContentSizeForChild(child,
292 ForColumns)) { 299 ForColumns)) {
293 setOverrideContainingBlockContentSizeForChild(child, childInlineDirection, 300 setOverrideContainingBlockContentSizeForChild(child, childInlineDirection,
294 LayoutUnit(-1)); 301 LayoutUnit(-1));
295 } 302 }
296 303
297 // FIXME: It's unclear if we should return the intrinsic width or the 304 // FIXME: It's unclear if we should return the intrinsic width or the
298 // preferred width. 305 // preferred width.
299 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 306 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
300 LayoutUnit marginLogicalWidth = 307 LayoutUnit marginLogicalWidth =
301 child.needsLayout() ? computeMarginLogicalSizeForChild( 308 child.needsLayout() ? computeMarginLogicalSizeForChild(
302 InlineDirection, layoutGrid(), child) 309 InlineDirection, layoutGrid(), child)
303 : child.marginLogicalWidth(); 310 : child.marginLogicalWidth();
304 return child.minPreferredLogicalWidth() + marginLogicalWidth; 311 return child.minPreferredLogicalWidth() + marginLogicalWidth;
305 } 312 }
306 313
314 if (direction() == ForColumns &&
315 m_algorithm.m_sizingOperation == IntrinsicSizeComputation) {
316 DCHECK(layoutGrid()->isOrthogonalChild(child));
317 if (layoutGrid()->isBaselineAlignmentForChild(child, GridRowAxis) &&
318 layoutGrid()->isBaselineContextComputed(GridRowAxis)) {
319 auto& group = layoutGrid()->getBaselineGroupForChild(child, GridRowAxis);
320 return group.maxAscent() + group.maxDescent();
321 }
322 }
323
307 if (updateOverrideContainingBlockContentSizeForChild(child, 324 if (updateOverrideContainingBlockContentSizeForChild(child,
308 childInlineDirection)) 325 childInlineDirection))
309 setGridItemNeedsLayout(child); 326 setGridItemNeedsLayout(child);
310 return logicalHeightForChild(child); 327 return logicalHeightForChild(child);
311 } 328 }
312 329
313 DISABLE_CFI_PERF 330 DISABLE_CFI_PERF
314 LayoutUnit GridTrackSizingAlgorithmStrategy::maxContentForChild( 331 LayoutUnit GridTrackSizingAlgorithmStrategy::maxContentForChild(
315 LayoutBox& child) const { 332 LayoutBox& child) const {
316 GridTrackSizingDirection childInlineDirection = 333 GridTrackSizingDirection childInlineDirection =
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 DCHECK(m_algorithm.isValidTransition()); 1440 DCHECK(m_algorithm.isValidTransition());
1424 DCHECK(!m_algorithm.m_needsSetup); 1441 DCHECK(!m_algorithm.m_needsSetup);
1425 } 1442 }
1426 1443
1427 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { 1444 GridTrackSizingAlgorithm::StateMachine::~StateMachine() {
1428 m_algorithm.advanceNextState(); 1445 m_algorithm.advanceNextState();
1429 m_algorithm.m_needsSetup = true; 1446 m_algorithm.m_needsSetup = true;
1430 } 1447 }
1431 1448
1432 } // namespace blink 1449 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698