Changeset 143476 in webkit
- Timestamp:
- Feb 20, 2013, 10:37:06 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r143475 r143476 1 2013-02-20 Ojan Vafai <ojan@chromium.org> 2 3 Make intrinsic width values work for positioned elements 4 https://bugs.webkit.org/show_bug.cgi?id=110264 5 6 Reviewed by Tony Chang. 7 8 * fast/css-intrinsic-dimensions/intrinsic-sized-absolutes-expected.txt: Added. 9 * fast/css-intrinsic-dimensions/intrinsic-sized-absolutes.html: Added. 10 * fast/css-intrinsic-dimensions/width-shrinks-avoid-floats-expected.txt: Added. 11 * fast/css-intrinsic-dimensions/width-shrinks-avoid-floats.html: Added. 12 1 13 2013-02-20 Robert Hogan <robert@webkit.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r143475 r143476 1 2013-02-20 Ojan Vafai <ojan@chromium.org> 2 3 Make intrinsic width values work for positioned elements 4 https://bugs.webkit.org/show_bug.cgi?id=110264 5 6 Reviewed by Tony Chang. 7 8 Tests: fast/css-intrinsic-dimensions/intrinsic-sized-absolutes.html 9 fast/css-intrinsic-dimensions/width-shrinks-avoid-floats.html 10 11 * rendering/RenderBox.cpp: 12 (WebCore::RenderBox::computeIntrinsicLogicalWidthUsing): 13 (WebCore::RenderBox::computeLogicalWidthInRegionUsing): 14 Move the computation of intrinsic widths out into a helper function so that 15 computePositionedLogicalWidthUsing can use it. As per the current spec, 16 fill-available measures shrink to avoid floats. http://dev.w3.org/csswg/css3-sizing/ 17 18 (WebCore::RenderBox::computePositionedLogicalWidth): 19 Compute intrinsic min-widths in addition to non-zero ones. Intrinsic widths 20 return true for isZero. width and max-width don't need modifying since they already 21 call computePositionedLogicalWidthUsing for intrinsic widths. 22 23 (WebCore::RenderBox::computePositionedLogicalWidthUsing): 24 Compute intrinsic widths and use a Fixed length for the rest of the positioned width 25 computation. Doesn't include bordersPlusPadding because the caller, expected the content 26 width and adds in the bordersPlusPadding later. 27 28 * rendering/RenderBox.h: 29 1 30 2013-02-20 Robert Hogan <robert@webkit.org> 2 31 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r143313 r143476 2039 2039 } 2040 2040 2041 LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const 2042 { 2043 if (logicalWidthLength.type() == MinContent) 2044 return minIntrinsicLogicalWidth(); 2045 if (logicalWidthLength.type() == MaxContent) 2046 return maxIntrinsicLogicalWidth(); 2047 2048 RenderView* renderView = view(); 2049 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), availableLogicalWidth, renderView); 2050 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidth, renderView); 2051 LayoutUnit fillAvailableMeasure = availableLogicalWidth - marginStart - marginEnd; 2052 2053 if (logicalWidthLength.type() == FillAvailable) 2054 return fillAvailableMeasure; 2055 if (logicalWidthLength.type() == FitContent) { 2056 LayoutUnit minLogicalWidth = 0; 2057 LayoutUnit maxLogicalWidth = 0; 2058 computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth); 2059 minLogicalWidth += borderAndPaddingLogicalWidth(); 2060 maxLogicalWidth += borderAndPaddingLogicalWidth(); 2061 return max(minLogicalWidth, min(maxLogicalWidth, fillAvailableMeasure)); 2062 } 2063 ASSERT_NOT_REACHED(); 2064 return 0; 2065 } 2066 2041 2067 LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, LayoutUnit availableLogicalWidth, 2042 2068 const RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const … … 2061 2087 } 2062 2088 2063 if (logicalWidth.type() == MinContent) 2064 return minIntrinsicLogicalWidth(); 2065 if (logicalWidth.type() == MaxContent) 2066 return maxIntrinsicLogicalWidth(); 2089 if (logicalWidth.isIntrinsic()) 2090 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth); 2067 2091 2068 2092 RenderView* renderView = view(); … … 2071 2095 LayoutUnit logicalWidthResult = availableLogicalWidth - marginStart - marginEnd; 2072 2096 2073 // shrinkToAvoidFloats() is only true for width: auto so the below code works correctly for2074 // width: fill-available since no case matches and it returns the logicalWidthResult from above.2075 2097 if (shrinkToAvoidFloats() && cb->containsFloats()) 2076 2098 logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFloats(marginStart, marginEnd, cb, region, offsetFromLogicalTopOfFirstPage)); 2077 2078 if (logicalWidth.type() == FitContent) {2079 LayoutUnit minLogicalWidth = 0;2080 LayoutUnit maxLogicalWidth = 0;2081 computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);2082 minLogicalWidth += borderAndPaddingLogicalWidth();2083 maxLogicalWidth += borderAndPaddingLogicalWidth();2084 return max(minLogicalWidth, min(maxLogicalWidth, logicalWidthResult));2085 }2086 2087 if (logicalWidth.type() == FillAvailable)2088 return logicalWidthResult;2089 2099 2090 2100 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(widthType)) … … 3001 3011 3002 3012 // Calculate constraint equation values for 'min-width' case. 3003 if (!style()->logicalMinWidth().isZero() ) {3013 if (!style()->logicalMinWidth().isZero() || style()->logicalMinWidth().isIntrinsic()) { 3004 3014 LogicalExtentComputedValues minValues; 3005 3015 … … 3063 3073 if (widthSizeType == MinSize && logicalWidth.isAuto()) 3064 3074 logicalWidth = Length(0, Fixed); 3075 else if (logicalWidth.isIntrinsic()) 3076 logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, containerLogicalWidth) - bordersPlusPadding, Fixed); 3065 3077 3066 3078 // 'left' and 'right' cannot both be 'auto' because one would of been -
trunk/Source/WebCore/rendering/RenderBox.h
r142816 r143476 659 659 void computePositionedLogicalWidthReplaced(LogicalExtentComputedValues&) const; 660 660 661 LayoutUnit computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const; 662 661 663 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const; 662 664
Note:
See TracChangeset
for help on using the changeset viewer.