haikuwebkit/LayoutTests/css3/viewport-percentage-lengths/css3-viewport-percentage-le...

38 lines
2.0 KiB
HTML
Raw Permalink Normal View History

Implement 'vmax' from CSS3 values and units https://bugs.webkit.org/show_bug.cgi?id=91440 Patch by Uday Kiran <udaykiran@motorola.com> on 2013-02-06 Reviewed by Antti Koivisto. vmax is implemented as primitive length unit. New length type ViewportPercentageMax is added and included support for fetching the value of this viewport percentage unit based on current viewport size. The specification related to this implementation is http://dev.w3.org/csswg/css3-values/#viewport-relative-lengths. Source/WebCore: Tests: css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax-absolute.html css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax.html * css/CSSGrammar.y.in: Added vmax support. * css/CSSParser.cpp: Parsing of vmax unit. (WebCore::CSSParser::validUnit): Added vmax to valid units. (WebCore::CSSParser::createPrimitiveNumericValue): Added vmax to primitive untis. (WebCore::CSSParser::parseValidPrimitive): Creation of CSSPrimitive for vmax. (WebCore::CSSParser::detectNumberToken): Parsing of vmax token. * css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue): Added support for vmax. * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): Added support for vmax. (WebCore::unitCategory): Ditto. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Ditto. (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::customCssText): Added support for vmax. (WebCore::CSSPrimitiveValue::viewportPercentageLength): Function to create the Length structure for the viewport-percentage unit types. (WebCore::CSSPrimitiveValue::cloneForCSSOM): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isViewportPercentageLength): Checks whether the primitive value is ViewportPercentage Length. * css/CSSPrimitiveValue.idl: Added support for vmax. * css/LengthFunctions.cpp: Calcuation of length value based on the current viewport size. (WebCore::minimumValueForLength): (WebCore::valueForLength): (WebCore::floatValueForLength): * platform/Length.h: (WebCore::Length::isViewportPercentage): To check the Length is of type ViewportPercentage. * rendering/RenderBox.cpp: (WebCore::RenderBox::computeReplacedLogicalWidthUsing): (WebCore::RenderBox::computeReplacedLogicalHeightUsing): LayoutTests: * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle-expected.txt: * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle.html: * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax-absolute-expected.html: Added. * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax-absolute.html: Added. * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax-expected.html: Added. * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmax.html: Added. Canonical link: https://commits.webkit.org/127274@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142021 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-02-06 20:58:04 +00:00
<!DOCTYPE>
<html>
<style>
#element-container-vmax {
background:green;
}
</style>
<div id="element-container-vmax">TEST PASSED</div>
<script>
function applyStyle() {
var viewportMaxLength = Math.max(window.innerWidth, window.innerHeight);
var elementStyle = document.getElementById("element-container-vmax").style;
elementStyle.height = Math.floor(30 * viewportMaxLength / 100) + "px";
elementStyle.width = Math.floor(30 * viewportMaxLength / 100) + "px";
elementStyle.fontSize = Math.floor(3 * viewportMaxLength / 100) + "px";
elementStyle.lineHeight = Math.floor(4 * viewportMaxLength / 100) + "px";
elementStyle.textIndent = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.marginLeft = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.marginRight = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.marginTop = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.marginBottom = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.borderTopLeftRadius = Math.floor(1 * viewportMaxLength / 100) + "px";
elementStyle.borderTopRightRadius = Math.floor(1 * viewportMaxLength / 100) + "px";
elementStyle.borderBottomLeftRadius = Math.floor(1 * viewportMaxLength / 100) + "px";
elementStyle.borderBottomRightRadius = Math.floor(1 * viewportMaxLength / 100) + "px";
elementStyle.paddingLeft = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.paddingRight = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.paddingTop = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.paddingBottom = Math.floor(2 * viewportMaxLength / 100) + "px";
elementStyle.minHeight = Math.floor(10 * viewportMaxLength / 100) + "px";
elementStyle.minWidth = Math.floor(10 * viewportMaxLength / 100) + "px";
elementStyle.maxHeight = Math.floor(60 * viewportMaxLength / 100) + "px";
elementStyle.maxWidth = Math.floor(60 * viewportMaxLength / 100) + "px";
}
applyStyle();
</script>
</html>