RESOLVED FIXED 160076
[css-grid] Stretch alignment doesn't work for orthogonal flows
https://bugs.webkit.org/show_bug.cgi?id=160076
Summary [css-grid] Stretch alignment doesn't work for orthogonal flows
Javier Fernandez
Reported 2016-07-22 00:12:06 PDT
We are progressively adding support on grid for orthogonal flows, however, stretching is not possible yet in these cases.
Attachments
Patch (16.66 KB, patch)
2016-07-27 06:35 PDT, Javier Fernandez
no flags
Patch (18.45 KB, patch)
2016-08-22 12:12 PDT, Javier Fernandez
no flags
Javier Fernandez
Comment 1 2016-07-27 06:35:12 PDT
Darin Adler
Comment 2 2016-07-28 16:20:12 PDT
Comment on attachment 284691 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=284691&action=review > Source/WebCore/rendering/RenderGrid.cpp:2190 > + bool childHasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto() : childStyle.width().isAuto(); > + bool childHasAutoSizeInRowAxis = isHorizontalMode ? childStyle.width().isAuto() : childStyle.height().isAuto(); > + bool allowedToStretchChildAlongColumnAxis = childHasAutoSizeInColumnAxis && !hasAutoMarginsInColumnAxis(child); > + bool allowedToStretchChildAlongRowAxis = childHasAutoSizeInRowAxis && !hasAutoMarginsInRowAxis(child); > + bool stretchingAlongRowAxis = childStyle.resolvedJustifySelf(gridStyle, selfAlignmentNormalBehavior).position() == ItemPositionStretch; > + bool stretchingAlongColumnAxis = childStyle.resolvedAlignSelf(gridStyle, selfAlignmentNormalBehavior).position() == ItemPositionStretch; Inefficient to compute both axes and then only use the one that is needed below. Maybe these can be functions instead of booleans so we can call only the one that is needed. Also inefficient to compute stretchingAlongAxis when allowedToStretchChildAlongAxis is already false. Early return style would work for that. > Source/WebCore/rendering/RenderGrid.cpp:2203 > + if (allowedToStretchChildBlockSize) { > + LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBeforeStretching(overrideContainingBlockContentSizeForChild(child, childBlockDirection).value(), child); > + LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(stretchedLogicalHeight, LayoutUnit(-1)); > + child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.borderAndPaddingLogicalHeight()); > + if (desiredLogicalHeight != child.logicalHeight()) { > + // FIXME: Can avoid laying out here in some cases. See https://webkit.org/b/87905. > + child.setLogicalHeight(LayoutUnit()); > + child.setNeedsLayout(); > } > } Could be redone to use early exit instead of nesting the having he main function flow go into two nested if statements.
Javier Fernandez
Comment 3 2016-07-29 05:49:04 PDT
Comment on attachment 284691 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=284691&action=review >> Source/WebCore/rendering/RenderGrid.cpp:2190 >> + bool stretchingAlongColumnAxis = childStyle.resolvedAlignSelf(gridStyle, selfAlignmentNormalBehavior).position() == ItemPositionStretch; > > Inefficient to compute both axes and then only use the one that is needed below. Maybe these can be functions instead of booleans so we can call only the one that is needed. > > Also inefficient to compute stretchingAlongAxis when allowedToStretchChildAlongAxis is already false. Early return style would work for that. I understand, I was aiming for a clearer code but it's true we can improve in the points you made. Thanks for the review, I'll apply the suggested chances in the patch for landing. >> Source/WebCore/rendering/RenderGrid.cpp:2203 >> } > > Could be redone to use early exit instead of nesting the having he main function flow go into two nested if statements. Yeah, I'll do that.
Javier Fernandez
Comment 4 2016-08-22 12:12:05 PDT
WebKit Commit Bot
Comment 5 2016-08-22 13:13:02 PDT
Comment on attachment 286611 [details] Patch Clearing flags on attachment: 286611 Committed r204734: <http://trac.webkit.org/changeset/204734>
WebKit Commit Bot
Comment 6 2016-08-22 13:13:05 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.