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

Side by Side Diff: Source/core/layout/LayoutGrid.cpp

Issue 1335213004: [CSS Grid Layout] Content sized tracks must clear the override height (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 611 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
612 } 612 }
613 613
614 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack> & columnTracks) 614 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack> & columnTracks)
615 { 615 {
616 SubtreeLayoutScope layoutScope(child); 616 SubtreeLayoutScope layoutScope(child);
617 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth () : LayoutUnit(); 617 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth () : LayoutUnit();
618 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh ild(child, ForColumns, columnTracks); 618 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh ild(child, ForColumns, columnTracks);
619 if (child.hasRelativeLogicalHeight() || oldOverrideContainingBlockContentLog icalWidth != overrideContainingBlockContentLogicalWidth) { 619 if (child.hasRelativeLogicalHeight() || oldOverrideContainingBlockContentLog icalWidth != overrideContainingBlockContentLogicalWidth) {
620 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); 620 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged );
621 // We need to clear the stretched height to properly compute logical hei ght during layout. 621 }
622
623 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight();
624 // We need to clear the stretched height to properly compute logical height during layout.
625 if (hasOverrideHeight && child.needsLayout())
622 child.clearOverrideLogicalContentHeight(); 626 child.clearOverrideLogicalContentHeight();
623 }
624 627
625 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth); 628 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth);
626 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is 629 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is
627 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). 630 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution).
628 if (child.hasRelativeLogicalHeight()) 631 if (child.hasRelativeLogicalHeight())
629 child.setOverrideContainingBlockContentLogicalHeight(-1); 632 child.setOverrideContainingBlockContentLogicalHeight(-1);
630 child.layoutIfNeeded(); 633 child.layoutIfNeeded();
631 // If the child was stretched we should use its intrinsic height. 634 // If the child was stretched we should use its intrinsic height.
632 return (child.hasOverrideLogicalContentHeight() ? childIntrinsicHeight(child ) : child.logicalHeight()) + child.marginLogicalHeight(); 635 return (hasOverrideHeight ? childIntrinsicHeight(child) : child.logicalHeigh t()) + child.marginLogicalHeight();
633 } 636 }
634 637
635 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, Vector<GridTrack>& columnTracks) 638 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, Vector<GridTrack>& columnTracks)
636 { 639 {
637 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 640 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
638 // TODO(svillar): Properly support orthogonal writing mode. 641 // TODO(svillar): Properly support orthogonal writing mode.
639 if (hasOrthogonalWritingMode) 642 if (hasOrthogonalWritingMode)
640 return LayoutUnit(); 643 return LayoutUnit();
641 644
642 const Length& childMinSize = direction == ForColumns ? child.style()->logica lMinWidth() : child.style()->logicalMinHeight(); 645 const Length& childMinSize = direction == ForColumns ? child.style()->logica lMinWidth() : child.style()->logicalMinHeight();
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 1926
1924 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); 1927 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child));
1925 } 1928 }
1926 1929
1927 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 1930 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
1928 { 1931 {
1929 GridPainter(*this).paintChildren(paintInfo, paintOffset); 1932 GridPainter(*this).paintChildren(paintInfo, paintOffset);
1930 } 1933 }
1931 1934
1932 } // namespace blink 1935 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698