Changeset 142021 in webkit
- Timestamp:
- Feb 6, 2013 12:58:04 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r142020 r142021 1 2013-02-06 Uday Kiran <udaykiran@motorola.com> 2 3 Implement 'vmax' from CSS3 values and units 4 https://bugs.webkit.org/show_bug.cgi?id=91440 5 6 Reviewed by Antti Koivisto. 7 8 vmax is implemented as primitive length unit. 9 New length type ViewportPercentageMax is added and included support for fetching the value 10 of this viewport percentage unit based on current viewport size. 11 12 The specification related to this implementation is 13 http://dev.w3.org/csswg/css3-values/#viewport-relative-lengths. 14 15 * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle-expected.txt: 16 * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle.html: 17 * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax-absolute-expected.html: Added. 18 * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax-absolute.html: Added. 19 * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax-expected.html: Added. 20 * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax.html: Added. 21 1 22 2013-02-06 Zan Dobersek <zdobersek@igalia.com> 2 23 -
trunk/LayoutTests/css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle-expected.txt
r112749 r142021 1 Test for Bug: 27160 - Implement vw/vh/vm(viewport sizes) from CSS 3 Values and Units1 Test for Bug: 27160/91440 - Implement vw/vh/vmin/vmax (viewport sizes) from CSS 3 Values and Units 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 84 84 PASS style.getPropertyValue("padding-top") is '12px' 85 85 PASS style.getPropertyValue("padding-bottom") is '12px' 86 87 Test for vmax 88 PASS style.getPropertyValue("height") is '240px' 89 PASS style.getPropertyValue("width") is '240px' 90 PASS style.getPropertyValue("font-size") is '24px' 91 PASS style.getPropertyValue("line-height") is '32px' 92 PASS style.getPropertyValue("text-indent") is '2vmax' 93 PASS style.getPropertyValue("margin-left") is '16px' 94 PASS style.getPropertyValue("margin-right") is '16px' 95 PASS style.getPropertyValue("margin-top") is '16px' 96 PASS style.getPropertyValue("margin-bottom") is '16px' 97 PASS style.getPropertyValue("border-top-left-radius") is '8px' 98 PASS style.getPropertyValue("border-top-right-radius") is '8px' 99 PASS style.getPropertyValue("border-bottom-left-radius") is '8px' 100 PASS style.getPropertyValue("border-bottom-right-radius") is '8px' 101 PASS style.getPropertyValue("min-height") is '10vmax' 102 PASS style.getPropertyValue("min-width") is '10vmax' 103 PASS style.getPropertyValue("max-height") is '60vmax' 104 PASS style.getPropertyValue("max-width") is '60vmax' 105 PASS style.getPropertyValue("top") is '80px' 106 PASS style.getPropertyValue("bottom") is '80px' 107 PASS style.getPropertyValue("left") is '80px' 108 PASS style.getPropertyValue("right") is '80px' 109 PASS style.getPropertyValue("padding-left") is '16px' 110 PASS style.getPropertyValue("padding-right") is '16px' 111 PASS style.getPropertyValue("padding-top") is '16px' 112 PASS style.getPropertyValue("padding-bottom") is '16px' 86 113 PASS successfullyParsed is true 87 114 -
trunk/LayoutTests/css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle.html
r119990 r142021 103 103 padding-bottom:2vmin; 104 104 } 105 106 #element-container-vmax { 107 background:green; 108 height:30vmax; 109 width:30vmax; 110 font-size:3vmax; 111 line-height:4vmax; 112 text-indent:2vmax; 113 margin-left:2vmax; 114 margin-right:2vmax; 115 margin-top:2vmax; 116 margin-bottom:2vmax; 117 border-top-left-radius:1vmax; 118 border-top-right-radius:1vmax; 119 border-bottom-left-radius:1vmax; 120 border-bottom-right-radius:1vmax; 121 min-height:10vmax; 122 min-width:10vmax; 123 max-height:60vmax; 124 max-width:60vmax; 125 } 126 127 #element-container-absolute-vmax { 128 background:green; 129 position:absolute; 130 top:10vmax; 131 bottom:10vmax; 132 left:10vmax; 133 right:10vmax; 134 padding-left:2vmax; 135 padding-right:2vmax; 136 padding-top:2vmax; 137 padding-bottom:2vmax; 138 } 105 139 106 140 </style> … … 111 145 testRunner.dumpAsText(); 112 146 113 description("Test for Bug: 27160 - Implement vw/vh/vm(viewport sizes) from CSS 3 Values and Units");147 description("Test for Bug: 27160/91440 - Implement vw/vh/vmin/vmax (viewport sizes) from CSS 3 Values and Units"); 114 148 115 149 // These have to be global for the test helpers to see them. … … 209 243 shouldBe('style.getPropertyValue("padding-top")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'"); 210 244 shouldBe('style.getPropertyValue("padding-bottom")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'"); 245 246 debug("\nTest for vmax") 247 element.id = "element-container-vmax"; 248 style = window.getComputedStyle(element,null); 249 var viewportMaxLength = Math.max(window.innerWidth, window.innerHeight); 250 shouldBe('style.getPropertyValue("height")', "'" + Math.floor(30 * viewportMaxLength / 100) + "px'"); 251 shouldBe('style.getPropertyValue("width")', "'" + Math.floor(30 * viewportMaxLength / 100) + "px'"); 252 shouldBe('style.getPropertyValue("font-size")', "'" + Math.floor(3 * viewportMaxLength / 100) + "px'"); 253 shouldBe('style.getPropertyValue("line-height")', "'" + Math.floor(4 * viewportMaxLength / 100) + "px'"); 254 shouldBe('style.getPropertyValue("text-indent")', "'2vmax'"); 255 shouldBe('style.getPropertyValue("margin-left")', "'" + Math.floor(2 * viewportMaxLength / 100) + "px'"); 256 shouldBe('style.getPropertyValue("margin-right")', "'" + Math.floor(2 * viewportMaxLength / 100) + "px'"); 257 shouldBe('style.getPropertyValue("margin-top")', "'" + Math.floor(2 * viewportMaxLength / 100) + "px'"); 258 shouldBe('style.getPropertyValue("margin-bottom")', "'" + Math.floor(2 * viewportMaxLength / 100) + "px'"); 259 shouldBe('style.getPropertyValue("border-top-left-radius")', "'" + Math.floor(1 * viewportMaxLength / 100) + "px'"); 260 shouldBe('style.getPropertyValue("border-top-right-radius")', "'" + Math.floor(1 * viewportMaxLength / 100) + "px'"); 261 shouldBe('style.getPropertyValue("border-bottom-left-radius")', "'" + Math.floor(1 * viewportMaxLength / 100) + "px'"); 262 shouldBe('style.getPropertyValue("border-bottom-right-radius")', "'" + Math.floor(1 * viewportMaxLength / 100) + "px'"); 263 shouldBe('style.getPropertyValue("min-height")', "'10vmax'"); 264 shouldBe('style.getPropertyValue("min-width")', "'10vmax'"); 265 shouldBe('style.getPropertyValue("max-height")', "'60vmax'"); 266 shouldBe('style.getPropertyValue("max-width")', "'60vmax'"); 267 element.id = "element-container-absolute-vmax"; 268 shouldBe('style.getPropertyValue("top")', "'" + Math.floor(10 * viewportMaxLength / 100) + "px'"); 269 shouldBe('style.getPropertyValue("bottom")', "'" + Math.floor(10 * viewportMaxLength / 100) + "px'"); 270 shouldBe('style.getPropertyValue("left")', "'" + Math.floor(10 * viewportMaxLength / 100) + "px'"); 271 shouldBe('style.getPropertyValue("right")', "'" + Math.floor(10 * viewportMaxLength / 100) + "px'"); 272 shouldBe('style.getPropertyValue("padding-left")', "'" + Math.floor(2 * viewportMaxLength / 100) + "px'"); 273 shouldBe('style.getPropertyValue("padding-right")', "'" + Math.floor(2 * viewportMaxLength / 100) + "px'"); 274 shouldBe('style.getPropertyValue("padding-top")', "'" + Math.floor(2 * viewportMaxLength / 100) + "px'"); 275 shouldBe('style.getPropertyValue("padding-bottom")', "'" + Math.floor(2 * viewportMaxLength / 100) + "px'"); 211 276 } 212 277 getTheStyle(); -
trunk/Source/WebCore/ChangeLog
r142015 r142021 1 2013-02-06 Uday Kiran <udaykiran@motorola.com> 2 3 Implement 'vmax' from CSS3 values and units 4 https://bugs.webkit.org/show_bug.cgi?id=91440 5 6 Reviewed by Antti Koivisto. 7 8 vmax is implemented as primitive length unit. 9 New length type ViewportPercentageMax is added and included support for fetching the value 10 of this viewport percentage unit based on current viewport size. 11 12 The specification related to this implementation is 13 http://dev.w3.org/csswg/css3-values/#viewport-relative-lengths. 14 15 Tests: css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax-absolute.html 16 css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax.html 17 18 * css/CSSGrammar.y.in: Added vmax support. 19 * css/CSSParser.cpp: Parsing of vmax unit. 20 (WebCore::CSSParser::validUnit): Added vmax to valid units. 21 (WebCore::CSSParser::createPrimitiveNumericValue): Added vmax to primitive untis. 22 (WebCore::CSSParser::parseValidPrimitive): Creation of CSSPrimitive for vmax. 23 (WebCore::CSSParser::detectNumberToken): Parsing of vmax token. 24 * css/CSSParserValues.cpp: 25 (WebCore::CSSParserValue::createCSSValue): Added support for vmax. 26 * css/CSSPrimitiveValue.cpp: 27 (WebCore::isValidCSSUnitTypeForDoubleConversion): Added support for vmax. 28 (WebCore::unitCategory): Ditto. 29 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Ditto. 30 (WebCore::CSSPrimitiveValue::cleanup): 31 (WebCore::CSSPrimitiveValue::customCssText): Added support for vmax. 32 (WebCore::CSSPrimitiveValue::viewportPercentageLength): Function to create the Length structure for the viewport-percentage unit types. 33 (WebCore::CSSPrimitiveValue::cloneForCSSOM): 34 * css/CSSPrimitiveValue.h: 35 (WebCore::CSSPrimitiveValue::isViewportPercentageLength): Checks whether the primitive value is ViewportPercentage Length. 36 * css/CSSPrimitiveValue.idl: Added support for vmax. 37 * css/LengthFunctions.cpp: Calcuation of length value based on the current viewport size. 38 (WebCore::minimumValueForLength): 39 (WebCore::valueForLength): 40 (WebCore::floatValueForLength): 41 * platform/Length.h: 42 (WebCore::Length::isViewportPercentage): To check the Length is of type ViewportPercentage. 43 * rendering/RenderBox.cpp: 44 (WebCore::RenderBox::computeReplacedLogicalWidthUsing): 45 (WebCore::RenderBox::computeReplacedLogicalHeightUsing): 46 1 47 2013-02-06 Pravin D <pravind.2k4@gmail.com> 2 48 -
trunk/Source/WebCore/css/CSSGrammar.y.in
r140997 r142021 62 62 %} 63 63 64 %expect 6 564 %expect 66 65 65 66 66 %nonassoc LOWEST_PREC … … 170 170 %token <number> VH 171 171 %token <number> VMIN 172 %token <number> VMAX 172 173 %token <number> DPPX 173 174 %token <number> DPI … … 1712 1713 | VH maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VH; } 1713 1714 | VMIN maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMIN; } 1715 | VMAX maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMAX; } 1714 1716 | DPPX maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPPX; } 1715 1717 | DPI maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPI; } -
trunk/Source/WebCore/css/CSSParser.cpp
r141872 r142021 1599 1599 case CSSPrimitiveValue::CSS_VH: 1600 1600 case CSSPrimitiveValue::CSS_VMIN: 1601 case CSSPrimitiveValue::CSS_VMAX: 1601 1602 b = (unitflags & FLength); 1602 1603 break; … … 1643 1644 #if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY) 1644 1645 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) 1645 1646 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMIN)1647 1646 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS) 1647 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX) 1648 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiveValue::CSS_DPCM)); 1648 1649 #else 1649 1650 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) 1650 1651 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMIN));1651 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS) 1652 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX)); 1652 1653 #endif 1653 1654 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit)); … … 1707 1708 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS) 1708 1709 return createPrimitiveNumericValue(value); 1709 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VM IN)1710 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX) 1710 1711 return createPrimitiveNumericValue(value); 1711 1712 #if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY) … … 9980 9981 else if (isASCIIAlphaCaselessEqual(type[1], 'h')) 9981 9982 m_token = VH; 9982 } else if (length == 4 && isASCIIAlphaCaselessEqual(type[1], 'm') 9983 && isASCIIAlphaCaselessEqual(type[2], 'i') && isASCIIAlphaCaselessEqual(type[3], 'n')) 9984 m_token = VMIN; 9983 } else if (length == 4 && isASCIIAlphaCaselessEqual(type[1], 'm')) { 9984 if (isASCIIAlphaCaselessEqual(type[2], 'i') && isASCIIAlphaCaselessEqual(type[3], 'n')) 9985 m_token = VMIN; 9986 else if (isASCIIAlphaCaselessEqual(type[2], 'a') && isASCIIAlphaCaselessEqual(type[3], 'x')) 9987 m_token = VMAX; 9988 } 9985 9989 return; 9986 9990 -
trunk/Source/WebCore/css/CSSParserValues.cpp
r140371 r142021 112 112 case CSSPrimitiveValue::CSS_VH: 113 113 case CSSPrimitiveValue::CSS_VMIN: 114 case CSSPrimitiveValue::CSS_VMAX: 114 115 case CSSPrimitiveValue::CSS_TURN: 115 116 case CSSPrimitiveValue::CSS_REMS: -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r141570 r142021 94 94 case CSSPrimitiveValue::CSS_VH: 95 95 case CSSPrimitiveValue::CSS_VMIN: 96 case CSSPrimitiveValue::CSS_VMAX: 96 97 return true; 97 98 case CSSPrimitiveValue::CSS_ATTR: … … 160 161 case CSSPrimitiveValue::CSS_VH: 161 162 case CSSPrimitiveValue::CSS_VMIN: 163 case CSSPrimitiveValue::CSS_VMAX: 162 164 return CSSPrimitiveValue::UViewportPercentageLength; 163 165 #if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY) … … 306 308 case ViewportPercentageMin: 307 309 m_primitiveUnitType = CSS_VMIN; 310 m_value.num = length.viewportPercentageLength(); 311 break; 312 case ViewportPercentageMax: 313 m_primitiveUnitType = CSS_VMAX; 308 314 m_value.num = length.viewportPercentageLength(); 309 315 break; … … 437 443 case CSS_VH: 438 444 case CSS_VMIN: 445 case CSS_VMAX: 439 446 case CSS_DPPX: 440 447 case CSS_DPI: … … 1100 1107 text = formatNumber(m_value.num, "vmin"); 1101 1108 break; 1109 case CSS_VMAX: 1110 text = formatNumber(m_value.num, "vmax"); 1111 break; 1102 1112 #if ENABLE(CSS_VARIABLES) 1103 1113 case CSS_VARIABLE_NAME: … … 1166 1176 case CSS_VMIN: 1167 1177 viewportLength = Length(getDoubleValue(), ViewportPercentageMin); 1178 break; 1179 case CSS_VMAX: 1180 viewportLength = Length(getDoubleValue(), ViewportPercentageMax); 1168 1181 break; 1169 1182 default: … … 1234 1247 case CSS_VH: 1235 1248 case CSS_VMIN: 1249 case CSS_VMAX: 1236 1250 #if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY) 1237 1251 case CSS_DPPX: -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r132227 r142021 92 92 CSS_RECT = 24, 93 93 CSS_RGBCOLOR = 25, 94 // From CSS Values and Units. Viewport-percentage Lengths (vw/vh/vmin ).94 // From CSS Values and Units. Viewport-percentage Lengths (vw/vh/vmin/vmax). 95 95 CSS_VW = 26, 96 96 CSS_VH = 27, 97 97 CSS_VMIN = 28, 98 CSS_DPPX = 29, 99 CSS_DPI = 30, 100 CSS_DPCM = 31, 98 CSS_VMAX = 29, 99 CSS_DPPX = 30, 100 CSS_DPI = 31, 101 CSS_DPCM = 32, 101 102 CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.) 102 103 #if ENABLE(DASHBOARD_SUPPORT) … … 189 190 bool isVariableName() const { return primitiveType() == CSS_VARIABLE_NAME; } 190 191 #endif 191 bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VM IN; }192 bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VMAX; } 192 193 193 194 static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); } -
trunk/Source/WebCore/css/CSSPrimitiveValue.idl
r141034 r142021 52 52 const unsigned short CSS_VH = 27; 53 53 const unsigned short CSS_VMIN = 28; 54 const unsigned short CSS_VMAX = 29; 54 55 55 56 readonly attribute unsigned short primitiveType; -
trunk/Source/WebCore/css/LengthFunctions.cpp
r133779 r142021 67 67 } 68 68 return 0; 69 case ViewportPercentageMax: 70 if (renderView) { 71 IntSize viewportSize = renderView->viewportSize(); 72 return static_cast<LayoutUnit>(std::max(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f); 73 } 74 return 0; 69 75 case FillAvailable: 70 76 case Auto: … … 93 99 case ViewportPercentageHeight: 94 100 case ViewportPercentageMin: 101 case ViewportPercentageMax: 95 102 return minimumValueForLength(length, maximumValue, renderView, roundPercentages); 96 103 case FillAvailable: … … 138 145 } 139 146 return 0; 147 case ViewportPercentageMax: 148 if (renderView) { 149 IntSize viewportSize = renderView->viewportSize(); 150 return static_cast<int>(std::max(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f); 151 } 152 return 0; 140 153 case Relative: 141 154 case Intrinsic: … … 178 191 } 179 192 return 0; 193 case ViewportPercentageMax: 194 if (renderView) { 195 IntSize viewportSize = renderView->viewportSize(); 196 return static_cast<int>(std::max(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f); 197 } 198 return 0; 180 199 case Relative: 181 200 case Intrinsic: -
trunk/Source/WebCore/platform/Length.h
r140198 r142021 39 39 MinContent, MaxContent, FillAvailable, FitContent, 40 40 Calculated, 41 ViewportPercentageWidth, ViewportPercentageHeight, ViewportPercentageMin, 41 ViewportPercentageWidth, ViewportPercentageHeight, ViewportPercentageMin, ViewportPercentageMax, 42 42 Undefined 43 43 }; … … 266 266 { 267 267 LengthType lengthType = type(); 268 return lengthType >= ViewportPercentageWidth && lengthType <= ViewportPercentageM in;268 return lengthType >= ViewportPercentageWidth && lengthType <= ViewportPercentageMax; 269 269 } 270 270 float viewportPercentageLength() const -
trunk/Source/WebCore/rendering/RenderBox.cpp
r141963 r142021 2602 2602 case ViewportPercentageHeight: 2603 2603 case ViewportPercentageMin: 2604 case ViewportPercentageMax: 2604 2605 return adjustContentBoxLogicalWidthForBoxSizing(valueForLength(logicalWidth, 0, view())); 2605 2606 case Percent: … … 2691 2692 case ViewportPercentageHeight: 2692 2693 case ViewportPercentageMin: 2694 case ViewportPercentageMax: 2693 2695 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logicalHeight, 0, view())); 2694 2696 default:
Note: See TracChangeset
for help on using the changeset viewer.