Changeset 182780 in webkit
- Timestamp:
- Apr 13, 2015 9:59:09 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r182768 r182780 1 2015-04-13 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [CSS Grid Layout] Columns set in percentages collapse to auto width 4 https://bugs.webkit.org/show_bug.cgi?id=141435 5 6 Reviewed by David Hyatt. 7 8 Added new tests to check that percentage track breadths are properly 9 calculated under different sizing conditions. 10 Modified one test to include relative sizes too. 11 12 * fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution-expected.txt: 13 * fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution.html: 14 * fast/css-grid-layout/percent-intrinsic-track-breadth-expected.txt: Added. 15 * fast/css-grid-layout/percent-intrinsic-track-breadth.html: Added. 16 * fast/css-grid-layout/percent-track-breadths-regarding-container-size-expected.txt: Added. 17 * fast/css-grid-layout/percent-track-breadths-regarding-container-size.html: Added. 18 1 19 2015-04-10 Brent Fulgham <bfulgham@apple.com> 2 20 -
trunk/LayoutTests/fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution-expected.txt
r164609 r182780 21 21 XXXXX XXXXX XXXXX XXXXXX 22 22 PASS 23 XXXXX XXXXXX 24 XXXXX XXXXXX 25 XXXXX XXXXXX 26 XXXXX XXXXXX 27 PASS 28 XXXXX XXXXXX 29 XXXXX XXXXXX 30 XXXXX XXXXXX 31 XXXXX XXXXXX 32 PASS 33 XXXXX XXXXXX 34 XXXXX XXXXXX 35 XXXXX XXXXXX 36 XXXXX XXXXXX 37 PASS 38 XXXXX XXXXXX 39 XXXXX XXXXX XXXXXX 40 XXXXX XXXXXX 41 XXXXX XXXXX XXXXX XXXXXX 42 PASS -
trunk/LayoutTests/fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution.html
r168416 r182780 11 11 -webkit-grid-template-columns: 50px 100px; 12 12 -webkit-grid-template-rows: auto auto; 13 } 14 15 .sizedToGridAreaMinSizes { 16 font: 10px/1 Ahem; 17 min-width: 100%; 18 min-height: 100%; 13 19 } 14 20 </style> … … 54 60 </div> 55 61 62 <div class="unconstrainedContainer" style="position: relative"> 63 <div class="grid gridMinMaxMinMax"> 64 <div class="sizedToGridAreaMinSizes firstRowFirstColumn" data-expected-width="50" data-expected-height="20">XXXXX XXXXXX</div> 65 <div class="sizedToGridAreaMinSizes firstRowSecondColumn" data-expected-width="100" data-expected-height="20">XXXXX XXXXXX</div> 66 <div class="sizedToGridAreaMinSizes secondRowFirstColumn" data-expected-width="50" data-expected-height="100">XXXXX XXXXXX</div> 67 <div class="sizedToGridAreaMinSizes secondRowSecondColumn" data-expected-width="100" data-expected-height="100">XXXXX XXXXXX</div> 68 </div> 69 </div> 70 71 <div style="position: relative; height: 100px;"> 72 <div class="grid gridMinMaxMinMax"> 73 <div class="sizedToGridAreaMinSizes firstRowFirstColumn" data-expected-width="50" data-expected-height="20">XXXXX XXXXXX</div> 74 <div class="sizedToGridAreaMinSizes firstRowSecondColumn" data-expected-width="100" data-expected-height="20">XXXXX XXXXXX</div> 75 <div class="sizedToGridAreaMinSizes secondRowFirstColumn" data-expected-width="50" data-expected-height="100">XXXXX XXXXXX</div> 76 <div class="sizedToGridAreaMinSizes secondRowSecondColumn" data-expected-width="100" data-expected-height="100">XXXXX XXXXXX</div> 77 </div> 78 </div> 79 80 <div style="position: relative;"> 81 <div class="grid gridMinMaxMinMax" style="height: 100px;"> 82 <div class="sizedToGridAreaMinSizes firstRowFirstColumn" data-expected-width="50" data-expected-height="20">XXXXX XXXXXX</div> 83 <div class="sizedToGridAreaMinSizes firstRowSecondColumn" data-expected-width="100" data-expected-height="20">XXXXX XXXXXX</div> 84 <div class="sizedToGridAreaMinSizes secondRowFirstColumn" data-expected-width="50" data-expected-height="80">XXXXX XXXXXX</div> 85 <div class="sizedToGridAreaMinSizes secondRowSecondColumn" data-expected-width="100" data-expected-height="80">XXXXX XXXXXX</div> 86 </div> 87 </div> 88 89 <div class="unconstrainedContainer" style="position: relative"> 90 <div class="grid gridAutoAuto"> 91 <div class="sizedToGridAreaMinSizes firstRowFirstColumn" data-expected-width="50" data-expected-height="30">XXXXX XXXXXX</div> 92 <div class="sizedToGridAreaMinSizes firstRowSecondColumn" data-expected-width="100" data-expected-height="30">XXXXX XXXXX XXXXXX</div> 93 <div class="sizedToGridAreaMinSizes secondRowFirstColumn" data-expected-width="50" data-expected-height="40">XXXXX XXXXXX</div> 94 <div class="sizedToGridAreaMinSizes secondRowSecondColumn" data-expected-width="100" data-expected-height="40">XXXXX XXXXX XXXXX XXXXXX</div> 95 </div> 96 </div> 97 56 98 </body> 57 99 </html> -
trunk/Source/WebCore/ChangeLog
r182773 r182780 1 2015-04-13 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [CSS Grid Layout] Columns set in percentages collapse to auto width 4 https://bugs.webkit.org/show_bug.cgi?id=141435 5 6 Reviewed by David Hyatt. 7 8 Based on a patch by Sergio Villar Senin <svillar@igalia.com>. 9 10 This patch adds 2 new new methods in RenderBox to determine if the grid 11 has a definite size or not. 12 13 RenderGrid::gridTrackSize() was not checking properly if the grid has or 14 not an indefinite size. 15 The condition was including auto which is not indefinite per se. For 16 example, auto is definite if the containing block is definite. 17 As the new method is more expensive, we just call it when it's really 18 needed to avoid performance regressions. 19 20 Finally we were setting the override logical width/height to -1 (no 21 possible resolution) for all the items regardless if they've a relative 22 width/height or a fixed one. 23 Added the condition, including not only items with percentage logical 24 width/height but also relative, to avoid overriding the value for items 25 with fixed width/height as it's not needed. 26 27 Tests: fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution.html 28 fast/css-grid-layout/percent-intrinsic-track-breadth.html 29 fast/css-grid-layout/percent-track-breadths-regarding-container-size.html 30 31 * rendering/RenderBox.cpp: 32 (WebCore::logicalWidthIsResolvable): 33 (WebCore::RenderBox::hasDefiniteLogicalWidth): 34 (WebCore::RenderBox::percentageLogicalHeightIsResolvableFromBlock): 35 (WebCore::RenderBox::hasRelativeLogicalWidth): 36 * rendering/RenderBox.h: 37 * rendering/RenderGrid.cpp: 38 (WebCore::RenderGrid::hasDefiniteLogicalSize): 39 (WebCore::RenderGrid::gridTrackSize): 40 (WebCore::RenderGrid::logicalContentHeightForChild): 41 (WebCore::RenderGrid::minContentForChild): 42 (WebCore::RenderGrid::maxContentForChild): 43 * rendering/RenderGrid.h: 44 1 45 2015-04-13 Chris Dumez <cdumez@apple.com> 2 46 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r182674 r182780 4453 4453 } 4454 4454 4455 static bool logicalWidthIsResolvable(const RenderBox& renderBox) 4456 { 4457 const RenderBox* box = &renderBox; 4458 while (!box->isRenderView() && !box->isOutOfFlowPositioned() 4459 #if ENABLE(CSS_GRID_LAYOUT) 4460 && !box->hasOverrideContainingBlockLogicalWidth() 4461 #endif 4462 && (box->style().logicalWidth().isAuto() || box->isAnonymousBlock())) 4463 box = box->containingBlock(); 4464 4465 if (box->style().logicalWidth().isFixed()) 4466 return true; 4467 if (box->isRenderView()) 4468 return true; 4469 // The size of the containing block of an absolutely positioned element is always definite with respect to that 4470 // element (http://dev.w3.org/csswg/css-sizing-3/#definite). 4471 if (box->isOutOfFlowPositioned()) 4472 return true; 4473 #if ENABLE(CSS_GRID_LAYOUT) 4474 if (box->hasOverrideContainingBlockLogicalWidth()) 4475 return box->overrideContainingBlockContentLogicalWidth() != -1; 4476 #endif 4477 if (box->style().logicalWidth().isPercent()) 4478 return logicalWidthIsResolvable(*box->containingBlock()); 4479 4480 return false; 4481 } 4482 4483 bool RenderBox::hasDefiniteLogicalWidth() const 4484 { 4485 return logicalWidthIsResolvable(*this); 4486 } 4487 4455 4488 inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box) 4456 4489 { … … 4470 4503 if (!inQuirksMode && !cb->isAnonymousBlock()) 4471 4504 break; 4505 #if ENABLE(CSS_GRID_LAYOUT) 4506 if (cb->hasOverrideContainingBlockLogicalHeight()) 4507 return cb->overrideContainingBlockContentLogicalHeight() != -1; 4508 #endif 4509 4472 4510 cb = cb->containingBlock(); 4473 4511 } … … 4500 4538 4501 4539 return false; 4540 } 4541 4542 bool RenderBox::hasDefiniteLogicalHeight() const 4543 { 4544 const Length& logicalHeight = style().logicalHeight(); 4545 if (logicalHeight.isIntrinsicOrAuto()) 4546 return false; 4547 if (logicalHeight.isFixed()) 4548 return true; 4549 // The size of the containing block of an absolutely positioned element is always definite with respect to that 4550 // element (http://dev.w3.org/csswg/css-sizing-3/#definite). 4551 if (isOutOfFlowPositioned()) 4552 return true; 4553 #if ENABLE(CSS_GRID_LAYOUT) 4554 if (hasOverrideContainingBlockLogicalHeight()) 4555 return overrideContainingBlockContentLogicalHeight() != -1; 4556 #endif 4557 4558 return percentageLogicalHeightIsResolvable(this); 4502 4559 } 4503 4560 … … 4782 4839 } 4783 4840 4841 bool RenderBox::hasRelativeLogicalWidth() const 4842 { 4843 return style().logicalWidth().isPercent() 4844 || style().logicalMinWidth().isPercent() 4845 || style().logicalMaxWidth().isPercent(); 4846 } 4847 4784 4848 static void markBoxForRelayoutAfterSplit(RenderBox& box) 4785 4849 { -
trunk/Source/WebCore/rendering/RenderBox.h
r182127 r182780 443 443 virtual LayoutUnit computeReplacedLogicalHeight() const; 444 444 445 bool hasDefiniteLogicalWidth() const; 445 446 static bool percentageLogicalHeightIsResolvableFromBlock(const RenderBlock* containingBlock, bool outOfFlowPositioned); 447 bool hasDefiniteLogicalHeight() const; 446 448 LayoutUnit computePercentageLogicalHeight(const Length& height) const; 447 449 … … 570 572 virtual bool hasRelativeDimensions() const; 571 573 virtual bool hasRelativeLogicalHeight() const; 574 virtual bool hasRelativeLogicalWidth() const; 572 575 573 576 bool hasHorizontalLayoutOverflow() const -
trunk/Source/WebCore/rendering/RenderGrid.cpp
r182726 r182780 519 519 } 520 520 521 bool RenderGrid::hasDefiniteLogicalSize(GridTrackSizingDirection direction) const 522 { 523 return (direction == ForRows) ? hasDefiniteLogicalHeight() : hasDefiniteLogicalWidth(); 524 } 525 521 526 GridTrackSize RenderGrid::gridTrackSize(GridTrackSizingDirection direction, unsigned i) const 522 527 { … … 525 530 auto& trackSize = (i >= trackStyles.size()) ? (isForColumns ? style().gridAutoColumns() : style().gridAutoRows()) : trackStyles[i]; 526 531 527 // If the logical width/height of the grid container is indefinite, percentage values are treated as <auto> (or in 528 // the case of minmax() as min-content for the first position and max-content for the second). 529 Length logicalSize = isForColumns ? style().logicalWidth() : style().logicalHeight(); 530 if (logicalSize.isIntrinsicOrAuto()) { 531 const GridLength& oldMinTrackBreadth = trackSize.minTrackBreadth(); 532 const GridLength& oldMaxTrackBreadth = trackSize.maxTrackBreadth(); 533 return GridTrackSize(oldMinTrackBreadth.isPercentage() ? Length(MinContent) : oldMinTrackBreadth, oldMaxTrackBreadth.isPercentage() ? Length(MaxContent) : oldMaxTrackBreadth); 534 } 535 536 return trackSize; 532 GridLength minTrackBreadth = trackSize.minTrackBreadth(); 533 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); 534 535 if (minTrackBreadth.isPercentage() || maxTrackBreadth.isPercentage()) { 536 if (!hasDefiniteLogicalSize(direction)) { 537 if (minTrackBreadth.isPercentage()) 538 minTrackBreadth = Length(MinContent); 539 if (maxTrackBreadth.isPercentage()) 540 maxTrackBreadth = Length(MaxContent); 541 } 542 } 543 544 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 537 545 } 538 546 … … 541 549 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth() : LayoutUnit(); 542 550 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, columnTracks); 543 if (child. style().logicalHeight().isPercent() || oldOverrideContainingBlockContentLogicalWidth != overrideContainingBlockContentLogicalWidth)551 if (child.hasRelativeLogicalHeight() || oldOverrideContainingBlockContentLogicalWidth != overrideContainingBlockContentLogicalWidth) 544 552 child.setNeedsLayout(MarkOnlyThis); 545 553 546 554 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth); 547 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is555 // If |child| has a relative logical height, we shouldn't let it override its intrinsic height, which is 548 556 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). 549 child.setOverrideContainingBlockContentLogicalHeight(-1); 557 if (child.hasRelativeLogicalHeight()) 558 child.setOverrideContainingBlockContentLogicalHeight(-1); 550 559 child.layoutIfNeeded(); 551 560 return child.logicalHeight() + child.marginLogicalHeight(); … … 560 569 561 570 if (direction == ForColumns) { 571 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is 572 // what we are interested in here. Thus we need to set the override logical width to -1 (no possible resolution). 573 if (child.hasRelativeLogicalWidth()) 574 child.setOverrideContainingBlockContentLogicalWidth(-1); 575 562 576 // FIXME: It's unclear if we should return the intrinsic width or the preferred width. 563 577 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html … … 576 590 577 591 if (direction == ForColumns) { 592 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is 593 // what we are interested in here. Thus we need to set the override logical width to -1 (no possible resolution). 594 if (child.hasRelativeLogicalWidth()) 595 child.setOverrideContainingBlockContentLogicalWidth(-1); 596 578 597 // FIXME: It's unclear if we should return the intrinsic width or the preferred width. 579 598 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html -
trunk/Source/WebCore/rendering/RenderGrid.h
r182704 r182780 144 144 } 145 145 146 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const; 147 146 148 Vector<Vector<Vector<RenderBox*, 1>>> m_grid; 147 149 Vector<LayoutUnit> m_columnPositions;
Note: See TracChangeset
for help on using the changeset viewer.