Changeset 195284 in webkit
- Timestamp:
- Jan 19, 2016 3:36:11 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r195281 r195284 1 2016-01-19 Javier Fernandez <jfernandez@igalia.com> 2 3 [css-grid][css-align] justify-self stretch is not applied for img elements 4 https://bugs.webkit.org/show_bug.cgi?id=153206 5 6 Reviewed by Darin Adler. 7 8 Test to verify Replaced Elements, like images, are stretched in the inline 9 axis, when fulfilling the Box Alignment restrictions on this regard. 10 11 * fast/css-grid-layout/grid-align-stretching-replaced-items-expected.txt: Added. 12 * fast/css-grid-layout/grid-align-stretching-replaced-items.html: Added. 13 1 14 2016-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r195281 r195284 1 2016-01-19 Javier Fernandez <jfernandez@igalia.com> 2 3 [css-grid][css-align] justify-self stretch is not applied for img elements 4 https://bugs.webkit.org/show_bug.cgi?id=153206 5 6 Reviewed by Darin Adler. 7 8 When computing the logical height, we check first if there is an override 9 height value set as a consequence of the stretching logic, so we use it 10 directly for any kind of element. However, in the case of the width 11 computation, we don't use such override value because it's the default 12 behavior of block-level boxes. 13 14 However, we consider some special cases which have to be treated as 15 replaced elements. Theses cases are evaluated first, so we don't let the 16 regular width computation logic to be executed, which is what we want 17 to implement the stretch behavior. 18 19 In order to let replaced elements, such images, to be stretched as a 20 consequence of the CSS alignment properties, we need to exclude grid 21 items from the cases to be treated as replaced elements during the width 22 computation. 23 24 Test: fast/css-grid-layout/grid-align-stretching-replaced-items.html 25 26 * rendering/RenderBox.cpp: 27 (WebCore::RenderBox::computeLogicalWidthInRegion): 28 (WebCore::RenderBox::hasStretchedLogicalWidth): 29 (WebCore::RenderBox::sizesLogicalWidthToFitContent): 30 * rendering/RenderBox.h: 31 1 32 2016-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 33 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r194710 r195284 2370 2370 bool inVerticalBox = parent()->isDeprecatedFlexibleBox() && (parent()->style().boxOrient() == VERTICAL); 2371 2371 bool stretching = (parent()->style().boxAlign() == BSTRETCH); 2372 // FIXME: Stretching is the only reason why we don't want the box to be treated as a replaced element, so we could perhaps 2373 // refactor all this logic, not only for flex and grid since alignment is intended to be applied to any block. 2372 2374 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inVerticalBox || !stretching); 2375 #if ENABLE(CSS_GRID_LAYOUT) 2376 treatAsReplaced = treatAsReplaced && (!isGridItem() || !hasStretchedLogicalWidth()); 2377 #endif 2373 2378 2374 2379 const RenderStyle& styleToUse = style(); … … 2518 2523 } 2519 2524 2525 // FIXME: Can/Should we move this inside specific layout classes (flex. grid)? Can we refactor columnFlexItemHasStretchAlignment logic? 2526 bool RenderBox::hasStretchedLogicalWidth() const 2527 { 2528 auto& style = this->style(); 2529 if (!style.logicalWidth().isAuto() || style.marginStart().isAuto() || style.marginEnd().isAuto()) 2530 return false; 2531 RenderBlock* containingBlock = this->containingBlock(); 2532 if (!containingBlock) { 2533 // We are evaluating align-self/justify-self, which default to 'normal' for the root element. 2534 // The 'normal' value behaves like 'start' except for Flexbox Items, which obviously should have a container. 2535 return false; 2536 } 2537 if (containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode()) 2538 return RenderStyle::resolveAlignment(containingBlock->style(), style, ItemPositionStretch) == ItemPositionStretch; 2539 return RenderStyle::resolveJustification(containingBlock->style(), style, ItemPositionStretch) == ItemPositionStretch; 2540 } 2541 2520 2542 bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const 2521 2543 { … … 2530 2552 2531 2553 #if ENABLE(CSS_GRID_LAYOUT) 2532 if (parent()->isRenderGrid()) { 2533 bool allowedToStretchChildAlongRowAxis = style().logicalWidth().isAuto() && !style().marginStartUsing(&parent()->style()).isAuto() && !style().marginEndUsing(&parent()->style()).isAuto(); 2534 return !allowedToStretchChildAlongRowAxis || RenderStyle::resolveJustification(parent()->style(), style(), ItemPositionStretch) != ItemPositionStretch; 2535 } 2554 if (isGridItem()) 2555 return !hasStretchedLogicalWidth(); 2536 2556 #endif 2537 2557 -
trunk/Source/WebCore/rendering/RenderBox.h
r194417 r195284 424 424 bool sizesLogicalWidthToFitContent(SizeType) const; 425 425 426 bool hasStretchedLogicalWidth() const; 427 426 428 LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion*) const; 427 429
Note: See TracChangeset
for help on using the changeset viewer.