haikuwebkit/LayoutTests/fast/css/prefixed-unprefixed-variant...

86 lines
3.9 KiB
HTML
Raw Permalink Normal View History

Correctly handle prefixed and unprefixed variants in CSSStyleDeclaration https://bugs.webkit.org/show_bug.cgi?id=157569 <rdar://problem/26223115> Patch by Antoine Quint <graouts@apple.com> on 2016-05-12 Reviewed by Dean Jackson. Source/WebCore: Tests: fast/css/prefixed-unprefixed-variant-style-declaration.html fast/css/shorthand-omitted-initial-value-overrides-shorthand.html We essentially revert the code added with https://bugs.webkit.org/show_bug.cgi?id=110011 which duplicated properties that had a prefixed or unprefixed variant. What we do now is to return the value of the prefixed or unprefixed variant through a CSSStyleDeclaration, but only return the properties specified by the author when reading from the `cssText` property. * css/CSSParser.cpp: (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseTransitionShorthand): (WebCore::CSSParser::addPropertyWithPrefixingVariant): Deleted. * css/CSSParser.h: Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. * css/CSSPropertyNames.in: Treat transition properties as we do animation properties. * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue): (WebCore::PropertySetCSSStyleDeclaration::getPropertyValue): Make these two methods call into the matching getXXXInternal() variant instead of going through the property set directly so that they would correctly pick up on the prefixed or unprefixed variant should there be one when the specified property is not specified directly. (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal): (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal): We used to simply return the value for the given property from the property set, which we still do but now also check if there is prefixed or unprefixed variant for the provided property in case it was absent. * css/StyleProperties.cpp: (WebCore::MutableStyleProperties::removeShorthandProperty): Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. (WebCore::StyleProperties::asText): Drive-by fix to also handle the animation-play-state and -webkit-animation-play-state properties when serializing to the shorthand. (WebCore::MutableStyleProperties::removeProperty): Deleted. (WebCore::MutableStyleProperties::removePrefixedOrUnprefixedProperty): Deleted. (WebCore::MutableStyleProperties::setProperty): Deleted. (WebCore::getIndexInShorthandVectorForPrefixingVariant): Deleted. (WebCore::MutableStyleProperties::appendPrefixingVariantProperty): Deleted. (WebCore::MutableStyleProperties::setPrefixingVariantProperty): Deleted. * css/StyleProperties.h: Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. LayoutTests: * animations/fill-mode-forwards-zero-duration.html: * animations/play-state-start-paused.html: These two tests incorrectly expected a shorthand property not to reset longhand properties that it covers to their initial values even if left out of the shorthand. * animations/unprefixed-properties-expected.txt: * animations/unprefixed-properties.html: This test incorrectly expected that setting an unprefixed property only would lead to reading the prefixed property through the CSSOM return the empty string, rather than the value set on the unprefixed property. * fast/css/prefixed-unprefixed-variant-style-declaration-expected.txt: Added. * fast/css/prefixed-unprefixed-variant-style-declaration.html: Added. New test checking that setting one of two of a property's unprefixed and prefixed variants correctly allows to read the style through the CSS OM for both variants, while only serializing the property that was set through cssText. * fast/css/shorthand-omitted-initial-value-overrides-shorthand-expected.txt: Added. * fast/css/shorthand-omitted-initial-value-overrides-shorthand.html: Added. New test checking that setting a longhand property and then the shorthand for that longhand correctly resets the initial values, even if they were omitted in the shorthand. Canonical link: https://commits.webkit.org/175753@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200769 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-12 12:47:21 +00:00
<script src="../../resources/js-test-pre.js"></script>
<body>
<script>
description("Test the prefixed or the unprefixed variant of a property allows reading from the CSS OM with both the prefixed and unprefixed variant.");
const PREFIX = "-webkit-";
function testPropertyVariants(property, value) {
function accessorForProperty(property) {
var firstIndexToTranspose = property.indexOf(PREFIX) === 0 ? 2 : 1;
return property.split("-").map(function(component, index) {
if (index < firstIndexToTranspose)
return component;
return component.charAt(0).toUpperCase() + component.substr(1);
}).join("");
}
var accessor = accessorForProperty(property);
var prefixedProperty = PREFIX + property;
var prefixedAccessor = accessorForProperty(prefixedProperty);
testProperty(property, property, prefixedProperty, accessor, prefixedAccessor, value);
testProperty(prefixedProperty, property, prefixedProperty, accessor, prefixedAccessor, value);
}
function testProperty(propertyToSet, unprefixedProperty, prefixedProperty, unprefixedAccessor, prefixedAccessor, value) {
function test(message, actual, expected) {
expected = expected || value;
if (actual === expected)
testPassed(message);
else
testFailed(`expected ${message} to be "${expected}" but got "${actual}"`);
}
var element = document.body.appendChild(document.createElement("div"));
element.style.setProperty(propertyToSet, value);
debug(`Setting "${propertyToSet}" to "${value}"`);
var style = element.style;
test(`element.style.${unprefixedAccessor}`, style[unprefixedAccessor]);
test(`element.style.${prefixedAccessor}`, style[prefixedAccessor]);
test(`element.style.getPropertyValue("${unprefixedProperty}")`, style.getPropertyValue(unprefixedProperty));
test(`element.style.getPropertyValue("${prefixedProperty}")`, style.getPropertyValue(prefixedProperty));
test(`element.style.getPropertyCSSValue("${unprefixedProperty}")`, style.getPropertyCSSValue(unprefixedProperty).cssText);
test(`element.style.getPropertyCSSValue("${prefixedProperty}")`, style.getPropertyCSSValue(prefixedProperty).cssText);
var computedStyle = window.getComputedStyle(element);
test(`getComputedStyle(element).${unprefixedAccessor}`, computedStyle[unprefixedAccessor]);
test(`getComputedStyle(element).${prefixedAccessor}`, computedStyle[prefixedAccessor]);
test(`getComputedStyle(element).getPropertyValue("${unprefixedProperty}")`, computedStyle.getPropertyValue(unprefixedProperty));
test(`getComputedStyle(element).getPropertyValue("${prefixedProperty}")`, computedStyle.getPropertyValue(prefixedProperty));
test(`getComputedStyle(element).getPropertyCSSValue("${unprefixedProperty}")`, computedStyle.getPropertyCSSValue(unprefixedProperty).cssText);
test(`getComputedStyle(element).getPropertyCSSValue("${prefixedProperty}")`, computedStyle.getPropertyCSSValue(prefixedProperty).cssText);
Make -webkit-transition-* and -webkit-animation-* properties be pure aliases of the unprefixed ones https://bugs.webkit.org/show_bug.cgi?id=160478 Reviewed by Dean Jackson. Source/WebCore: Remove the custom -webkit prefixed transition and animation properties, and just make them aliases of the unprefixed ones, as we do for transforms. -webkit-animation-trigger remains as the only prefixed-only animation property. This is mostly code deletion. Test: fast/css/longhand-overrides-shorthand-prefixing.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSProperty.h: (WebCore::prefixingVariantForPropertyId): Deleted. * css/CSSPropertyNames.in: * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::mapAnimationDelay): (WebCore::CSSToStyleMap::mapAnimationDirection): (WebCore::CSSToStyleMap::mapAnimationDuration): (WebCore::CSSToStyleMap::mapAnimationFillMode): (WebCore::CSSToStyleMap::mapAnimationIterationCount): (WebCore::CSSToStyleMap::mapAnimationName): (WebCore::CSSToStyleMap::mapAnimationPlayState): (WebCore::CSSToStyleMap::mapAnimationProperty): (WebCore::CSSToStyleMap::mapAnimationTimingFunction): * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal): (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal): * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::MutableStyleProperties::removeShorthandProperty): (WebCore::StyleProperties::asText): * css/StylePropertyShorthand.cpp: (WebCore::animationShorthandForParsing): * css/StylePropertyShorthand.h: * css/StyleResolver.cpp: (WebCore::StyleResolver::styleForKeyframe): * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseAnimationShorthand): (WebCore::CSSParser::parseTransitionShorthand): (WebCore::CSSParser::parseAnimationProperty): (WebCore::CSSParser::addPropertyWithPrefixingVariant): Deleted. * css/parser/CSSParser.h: * html/shadow/MediaControlElements.cpp: (WebCore::MediaControlPanelElement::makeOpaque): (WebCore::MediaControlPanelElement::makeTransparent): LayoutTests: Updated results, and a new test to ensure that longhand properties override shorthand ones, with various combinations of prefixing. * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/longhand-overrides-shorthand-prefixing-expected.txt: Added. * fast/css/longhand-overrides-shorthand-prefixing.html: Added. * fast/css/prefixed-unprefixed-variant-style-declaration-expected.txt: * fast/css/prefixed-unprefixed-variant-style-declaration.html: * transitions/svg-transitions-expected.txt: * transitions/transitions-parsing-expected.txt: * transitions/transitions-parsing.html: Canonical link: https://commits.webkit.org/180012@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-12 15:50:17 +00:00
test(`element.style.cssText`, element.style.cssText, `${unprefixedProperty}: ${value};`);
Correctly handle prefixed and unprefixed variants in CSSStyleDeclaration https://bugs.webkit.org/show_bug.cgi?id=157569 <rdar://problem/26223115> Patch by Antoine Quint <graouts@apple.com> on 2016-05-12 Reviewed by Dean Jackson. Source/WebCore: Tests: fast/css/prefixed-unprefixed-variant-style-declaration.html fast/css/shorthand-omitted-initial-value-overrides-shorthand.html We essentially revert the code added with https://bugs.webkit.org/show_bug.cgi?id=110011 which duplicated properties that had a prefixed or unprefixed variant. What we do now is to return the value of the prefixed or unprefixed variant through a CSSStyleDeclaration, but only return the properties specified by the author when reading from the `cssText` property. * css/CSSParser.cpp: (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseTransitionShorthand): (WebCore::CSSParser::addPropertyWithPrefixingVariant): Deleted. * css/CSSParser.h: Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. * css/CSSPropertyNames.in: Treat transition properties as we do animation properties. * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue): (WebCore::PropertySetCSSStyleDeclaration::getPropertyValue): Make these two methods call into the matching getXXXInternal() variant instead of going through the property set directly so that they would correctly pick up on the prefixed or unprefixed variant should there be one when the specified property is not specified directly. (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal): (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal): We used to simply return the value for the given property from the property set, which we still do but now also check if there is prefixed or unprefixed variant for the provided property in case it was absent. * css/StyleProperties.cpp: (WebCore::MutableStyleProperties::removeShorthandProperty): Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. (WebCore::StyleProperties::asText): Drive-by fix to also handle the animation-play-state and -webkit-animation-play-state properties when serializing to the shorthand. (WebCore::MutableStyleProperties::removeProperty): Deleted. (WebCore::MutableStyleProperties::removePrefixedOrUnprefixedProperty): Deleted. (WebCore::MutableStyleProperties::setProperty): Deleted. (WebCore::getIndexInShorthandVectorForPrefixingVariant): Deleted. (WebCore::MutableStyleProperties::appendPrefixingVariantProperty): Deleted. (WebCore::MutableStyleProperties::setPrefixingVariantProperty): Deleted. * css/StyleProperties.h: Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. LayoutTests: * animations/fill-mode-forwards-zero-duration.html: * animations/play-state-start-paused.html: These two tests incorrectly expected a shorthand property not to reset longhand properties that it covers to their initial values even if left out of the shorthand. * animations/unprefixed-properties-expected.txt: * animations/unprefixed-properties.html: This test incorrectly expected that setting an unprefixed property only would lead to reading the prefixed property through the CSSOM return the empty string, rather than the value set on the unprefixed property. * fast/css/prefixed-unprefixed-variant-style-declaration-expected.txt: Added. * fast/css/prefixed-unprefixed-variant-style-declaration.html: Added. New test checking that setting one of two of a property's unprefixed and prefixed variants correctly allows to read the style through the CSS OM for both variants, while only serializing the property that was set through cssText. * fast/css/shorthand-omitted-initial-value-overrides-shorthand-expected.txt: Added. * fast/css/shorthand-omitted-initial-value-overrides-shorthand.html: Added. New test checking that setting a longhand property and then the shorthand for that longhand correctly resets the initial values, even if they were omitted in the shorthand. Canonical link: https://commits.webkit.org/175753@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200769 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-12 12:47:21 +00:00
element.remove();
debug("");
}
testPropertyVariants("transition-property", "width");
testPropertyVariants("transition-duration", "1s");
testPropertyVariants("transition-timing-function", "linear");
testPropertyVariants("transition-delay", "0.5s");
testPropertyVariants("animation-name", "foo");
testPropertyVariants("animation-duration", "1s");
testPropertyVariants("animation-timing-function", "linear");
testPropertyVariants("animation-iteration-count", "5");
testPropertyVariants("animation-direction", "reverse");
testPropertyVariants("animation-play-state", "paused");
testPropertyVariants("animation-delay", "0.5s");
testPropertyVariants("animation-fill-mode", "forwards");
Make -webkit-transition-* and -webkit-animation-* properties be pure aliases of the unprefixed ones https://bugs.webkit.org/show_bug.cgi?id=160478 Reviewed by Dean Jackson. Source/WebCore: Remove the custom -webkit prefixed transition and animation properties, and just make them aliases of the unprefixed ones, as we do for transforms. -webkit-animation-trigger remains as the only prefixed-only animation property. This is mostly code deletion. Test: fast/css/longhand-overrides-shorthand-prefixing.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSProperty.h: (WebCore::prefixingVariantForPropertyId): Deleted. * css/CSSPropertyNames.in: * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::mapAnimationDelay): (WebCore::CSSToStyleMap::mapAnimationDirection): (WebCore::CSSToStyleMap::mapAnimationDuration): (WebCore::CSSToStyleMap::mapAnimationFillMode): (WebCore::CSSToStyleMap::mapAnimationIterationCount): (WebCore::CSSToStyleMap::mapAnimationName): (WebCore::CSSToStyleMap::mapAnimationPlayState): (WebCore::CSSToStyleMap::mapAnimationProperty): (WebCore::CSSToStyleMap::mapAnimationTimingFunction): * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal): (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal): * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::MutableStyleProperties::removeShorthandProperty): (WebCore::StyleProperties::asText): * css/StylePropertyShorthand.cpp: (WebCore::animationShorthandForParsing): * css/StylePropertyShorthand.h: * css/StyleResolver.cpp: (WebCore::StyleResolver::styleForKeyframe): * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseAnimationShorthand): (WebCore::CSSParser::parseTransitionShorthand): (WebCore::CSSParser::parseAnimationProperty): (WebCore::CSSParser::addPropertyWithPrefixingVariant): Deleted. * css/parser/CSSParser.h: * html/shadow/MediaControlElements.cpp: (WebCore::MediaControlPanelElement::makeOpaque): (WebCore::MediaControlPanelElement::makeTransparent): LayoutTests: Updated results, and a new test to ensure that longhand properties override shorthand ones, with various combinations of prefixing. * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/longhand-overrides-shorthand-prefixing-expected.txt: Added. * fast/css/longhand-overrides-shorthand-prefixing.html: Added. * fast/css/prefixed-unprefixed-variant-style-declaration-expected.txt: * fast/css/prefixed-unprefixed-variant-style-declaration.html: * transitions/svg-transitions-expected.txt: * transitions/transitions-parsing-expected.txt: * transitions/transitions-parsing.html: Canonical link: https://commits.webkit.org/180012@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-12 15:50:17 +00:00
testPropertyVariants("transform", "matrix(1, 0, 0, 1, 1, 1)");
Correctly handle prefixed and unprefixed variants in CSSStyleDeclaration https://bugs.webkit.org/show_bug.cgi?id=157569 <rdar://problem/26223115> Patch by Antoine Quint <graouts@apple.com> on 2016-05-12 Reviewed by Dean Jackson. Source/WebCore: Tests: fast/css/prefixed-unprefixed-variant-style-declaration.html fast/css/shorthand-omitted-initial-value-overrides-shorthand.html We essentially revert the code added with https://bugs.webkit.org/show_bug.cgi?id=110011 which duplicated properties that had a prefixed or unprefixed variant. What we do now is to return the value of the prefixed or unprefixed variant through a CSSStyleDeclaration, but only return the properties specified by the author when reading from the `cssText` property. * css/CSSParser.cpp: (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseTransitionShorthand): (WebCore::CSSParser::addPropertyWithPrefixingVariant): Deleted. * css/CSSParser.h: Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. * css/CSSPropertyNames.in: Treat transition properties as we do animation properties. * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue): (WebCore::PropertySetCSSStyleDeclaration::getPropertyValue): Make these two methods call into the matching getXXXInternal() variant instead of going through the property set directly so that they would correctly pick up on the prefixed or unprefixed variant should there be one when the specified property is not specified directly. (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal): (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal): We used to simply return the value for the given property from the property set, which we still do but now also check if there is prefixed or unprefixed variant for the provided property in case it was absent. * css/StyleProperties.cpp: (WebCore::MutableStyleProperties::removeShorthandProperty): Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. (WebCore::StyleProperties::asText): Drive-by fix to also handle the animation-play-state and -webkit-animation-play-state properties when serializing to the shorthand. (WebCore::MutableStyleProperties::removeProperty): Deleted. (WebCore::MutableStyleProperties::removePrefixedOrUnprefixedProperty): Deleted. (WebCore::MutableStyleProperties::setProperty): Deleted. (WebCore::getIndexInShorthandVectorForPrefixingVariant): Deleted. (WebCore::MutableStyleProperties::appendPrefixingVariantProperty): Deleted. (WebCore::MutableStyleProperties::setPrefixingVariantProperty): Deleted. * css/StyleProperties.h: Remove all code adding duplicated properties for the prefixed or unprefixed variant of properties that exist in both forms. LayoutTests: * animations/fill-mode-forwards-zero-duration.html: * animations/play-state-start-paused.html: These two tests incorrectly expected a shorthand property not to reset longhand properties that it covers to their initial values even if left out of the shorthand. * animations/unprefixed-properties-expected.txt: * animations/unprefixed-properties.html: This test incorrectly expected that setting an unprefixed property only would lead to reading the prefixed property through the CSSOM return the empty string, rather than the value set on the unprefixed property. * fast/css/prefixed-unprefixed-variant-style-declaration-expected.txt: Added. * fast/css/prefixed-unprefixed-variant-style-declaration.html: Added. New test checking that setting one of two of a property's unprefixed and prefixed variants correctly allows to read the style through the CSS OM for both variants, while only serializing the property that was set through cssText. * fast/css/shorthand-omitted-initial-value-overrides-shorthand-expected.txt: Added. * fast/css/shorthand-omitted-initial-value-overrides-shorthand.html: Added. New test checking that setting a longhand property and then the shorthand for that longhand correctly resets the initial values, even if they were omitted in the shorthand. Canonical link: https://commits.webkit.org/175753@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200769 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-12 12:47:21 +00:00
successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>