haikuwebkit/LayoutTests/webanimations/css-transition-element-with...

42 lines
1.2 KiB
HTML
Raw Permalink Normal View History

CSS custom properties on pseudo elements background gradients causes infinite layout and high CPU load https://bugs.webkit.org/show_bug.cgi?id=194332 <rdar://problem/47873895> Reviewed by Simon Fraser. Source/WebCore: When a background-image uses a CSS custom property the resulting StyleGeneratedImage may not be the same object as during prior style updates. This caused transitions to be triggered for all style updates for such background-image values. To fix this, we modify the == operator for StyleGeneratedImage to use arePointingToEqualData() with the CSSImageGeneratorValue member and added an == operator for the CSSImageGeneratorValue class to call into the existing equals() methods. These equals() methods are now overrides of the virtual CSSImageGeneratorValue method. This change in behavior required a change in RenderElement::updateFillImages() to not only check whether the images were identical, but to also check whether the renderer was registered as a client on the new images. To do this, we add a new virtual hasClient() method on StyleImage. Test: webanimations/css-transition-element-with-gradient-background-image-and-css-custom-property.html * css/CSSImageGeneratorValue.cpp: (WebCore::CSSImageGeneratorValue::operator== const): * css/CSSImageGeneratorValue.h: * rendering/RenderElement.cpp: (WebCore::RenderElement::updateFillImages): * rendering/style/FillLayer.cpp: (WebCore::FillLayer::imagesIdentical): Deleted. * rendering/style/FillLayer.h: * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::hasClient const): * rendering/style/StyleCachedImage.h: * rendering/style/StyleGeneratedImage.cpp: (WebCore::StyleGeneratedImage::operator== const): (WebCore::StyleGeneratedImage::hasClient const): * rendering/style/StyleGeneratedImage.h: * rendering/style/StyleImage.h: * rendering/style/StyleMultiImage.cpp: (WebCore::StyleMultiImage::hasClient const): * rendering/style/StyleMultiImage.h: LayoutTests: Add a test where an element with a background-image set to a CSS gradient using a custom property as a color stop changes another property targeted by a transition to check that there is no background-image transition generated. * webanimations/css-transition-element-with-gradient-background-image-and-css-custom-property-expected.txt: Added. * webanimations/css-transition-element-with-gradient-background-image-and-css-custom-property.html: Added. Canonical link: https://commits.webkit.org/237410@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277112 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-06 20:11:19 +00:00
<!DOCTYPE html>
<meta charset="utf-8">
<style>
:root {
--custom-color: blue;
}
.target {
width: 100px;
height: 100px;
background: linear-gradient(var(--custom-color), green);
transition-duration: 1s;
}
.target.transition {
margin-left: 100px;
}
</style>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
'use strict';
promise_test(async test => {
const target = document.body.appendChild(document.createElement("div"));
target.classList.add("target");
await new Promise(requestAnimationFrame);
target.classList.add("transition");
const animations = target.getAnimations();
assert_equals(animations.length, 1, "There is only one animation applied to the target.");
assert_true(animations[0] instanceof CSSTransition, "The single animation applied to the target is a CSS transition.");
assert_equals(animations[0].transitionProperty, "margin-left", "The single CSS transition applied to the target is for the margin-left property.");
}, `An element with a background-image set to a CSS gradient with a stop color set by a custom property does not yield a background-image transition when another CSS property changes.`);
</script>
</body>