haikuwebkit/LayoutTests/animations/unprefixed-shorthand.html

134 lines
4.5 KiB
HTML
Raw Permalink Normal View History

Support unprefixed animation property names https://bugs.webkit.org/show_bug.cgi?id=138678 <rdar://problem/18943059> Reviewed by Simon Fraser. Source/WebCore: Step 1 of 3 in unprefixing CSS animations: handling the property names and values. Unlike other unprefixing, where we use an alias that effectively removes the prefixed values from the code, for animations we need to keep the old values around so that existing content will not break (e.g. computed style). During testing I noticed that we didn't handle the (relatively) new animation-direction values of "reverse" and "alternate-reverse" when querying computed style. Tests: animations/unprefixed-properties.html animations/unprefixed-shorthand.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::propertyValue): Handle the unprefixed values, but also get animation direction to produce the correct results when "reverse" and "alternate-reverse" is specified. * css/CSSParser.cpp: Handle the new values. If necessary, pass a flag around indicating whether it is prefixed or unprefixed. (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseAnimationShorthand): Use the flag to decide which of the forms we're going to check. (WebCore::CSSParser::parseAnimationProperty): * css/CSSParser.h: * css/CSSProperty.h: (WebCore::prefixingVariantForPropertyId): Add prefixing/unprefixing variants for all the animation values, and clean up the code a bit. * css/CSSPropertyNames.in: Add new properties. * css/DeprecatedStyleBuilder.cpp: (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder): We need handlers for the unprefixed forms. This should move to the new StyleBuilder soon. * css/StyleProperties.cpp: Handle new values. (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): * css/StylePropertyShorthand.cpp: (WebCore::animationShorthand): (WebCore::animationShorthandForParsing): Decide which list of properties to use. (WebCore::shorthandForProperty): (WebCore::matchingShorthandsForLonghand): (WebCore::webkitAnimationShorthandForParsing): Deleted. * css/StylePropertyShorthand.h: * css/StyleResolver.cpp: Since the new properties come before "background" in alphabetical order, they are earlier in the CSSPropertyNames.in file, and thus we need to update the call sites that think CSSPropertyBackground is the first property. (WebCore::StyleResolver::styleForKeyframe): Replace CSSPropertyBackground with CSSPropertyAnimation. (WebCore::StyleResolver::styleForPage): (WebCore::StyleResolver::applyMatchedProperties): (WebCore::StyleResolver::applyProperty): LayoutTests: Tests for unprefixed parsing and calculation of animation properties. Fun fact, this is the first test we have for the computed style of all animation-direction values. * animations/unprefixed-properties-expected.txt: Added. * animations/unprefixed-properties.html: Added. * animations/unprefixed-shorthand-expected.txt: Added. * animations/unprefixed-shorthand.html: Added. Canonical link: https://commits.webkit.org/156530@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176050 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-11-13 01:23:15 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test the unprefixed animation shorthand.");
// These have to be global for the test helpers to see them.
var stylesheet, animationStyle;
var styleElement = document.createElement("style");
document.head.appendChild(styleElement);
stylesheet = styleElement.sheet;
function testAnimationShorthand(value, expectedName, expectedDuration, expectedDelay, expectedTimingFunction, expectedIterationCount, expectedDirection, expectedFillMode)
{
debug("");
debug("Setting animation: " + value);
stylesheet.insertRule("body { animation: " + value + "; }", 0);
debug("Check animation-name");
animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-name");
shouldBe("animationStyle.cssText", "'" + expectedName + "'");
debug("Check animation-duration");
animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-duration");
shouldBe("animationStyle.cssText", "'" + expectedDuration + "'");
debug("Check animation-delay");
animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-delay");
shouldBe("animationStyle.cssText", "'" + expectedDelay + "'");
debug("Check animation-timing-function");
animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-timing-function");
shouldBe("animationStyle.cssText", "'" + expectedTimingFunction + "'");
debug("Check animation-iteration-count");
animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-iteration-count");
shouldBe("animationStyle.cssText", "'" + expectedIterationCount + "'");
debug("Check animation-direction");
animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-direction");
shouldBe("animationStyle.cssText", "'" + expectedDirection + "'");
debug("Check animation-fill-mode");
animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-fill-mode");
shouldBe("animationStyle.cssText", "'" + expectedFillMode + "'");
stylesheet.deleteRule(0);
}
testAnimationShorthand("waldo",
"waldo",
"0s",
"0s",
"ease",
"1",
"normal",
"none");
testAnimationShorthand("waldo 2s",
"waldo",
"2s",
"0s",
"ease",
"1",
"normal",
"none");
testAnimationShorthand("3s banana 500ms",
"banana",
"3s",
"0.5s",
"ease",
"1",
"normal",
"none");
testAnimationShorthand("infinite alternate eggs 5s",
"eggs",
"5s",
"0s",
"ease",
"infinite",
"alternate",
"none");
testAnimationShorthand("forwards normal ease-in-out bacon 1s 2s",
"bacon",
"1s",
"2s",
"ease-in-out",
"1",
"normal",
"forwards");
testAnimationShorthand("pastrami 100ms cubic-bezier(0, 0, 1, 1) alternate-reverse",
"pastrami",
"0.1s",
"0s",
"cubic-bezier(0, 0, 1, 1)",
"1",
"alternate-reverse",
"none");
testAnimationShorthand("slightly-invalid 2s a",
"none",
"0s",
"0s",
"ease",
"1",
"normal",
"none");
testAnimationShorthand("completely invalid",
"none",
"0s",
"0s",
"ease",
"1",
"normal",
"none");
successfullyParsed = true;
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>