Skip to content

Commit

Permalink
[web-animations] WPT test css/CSS2/visufx/animation/visibility-interp…
Browse files Browse the repository at this point in the history
…olation.html is a unique failure

https://bugs.webkit.org/show_bug.cgi?id=270434

Reviewed by Antti Koivisto.

Interpolation of the "visibility" property is discrete when neither of the values for a given
animation interval is "visible", per https://drafts.csswg.org/web-animations-1/#animating-visibility.

This addresses the final failures in this test.

* LayoutTests/imported/w3c/web-platform-tests/css/CSS2/visufx/animation/visibility-interpolation-expected.txt:
* Source/WebCore/animation/CSSPropertyAnimation.cpp:
(WebCore::blendFunc):
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):

Canonical link: https://commits.webkit.org/275636@main
  • Loading branch information
graouts committed Mar 4, 2024
1 parent 64fda2f commit c8d2cfa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ PASS Web Animations: property <visibility> from [collapse] to [visible] at (0.1)
PASS Web Animations: property <visibility> from [collapse] to [visible] at (0.9) should be [visible]
PASS Web Animations: property <visibility> from [collapse] to [visible] at (1) should be [visible]
PASS Web Animations: property <visibility> from [collapse] to [visible] at (1.5) should be [visible]
FAIL CSS Transitions: property <visibility> from [collapse] to [hidden] at (-0.3) should be [hidden] assert_equals: expected "hidden " but got "collapse "
FAIL CSS Transitions: property <visibility> from [collapse] to [hidden] at (0) should be [hidden] assert_equals: expected "hidden " but got "collapse "
FAIL CSS Transitions: property <visibility> from [collapse] to [hidden] at (0.3) should be [hidden] assert_equals: expected "hidden " but got "collapse "
PASS CSS Transitions: property <visibility> from [collapse] to [hidden] at (-0.3) should be [hidden]
PASS CSS Transitions: property <visibility> from [collapse] to [hidden] at (0) should be [hidden]
PASS CSS Transitions: property <visibility> from [collapse] to [hidden] at (0.3) should be [hidden]
PASS CSS Transitions: property <visibility> from [collapse] to [hidden] at (0.5) should be [hidden]
PASS CSS Transitions: property <visibility> from [collapse] to [hidden] at (0.6) should be [hidden]
PASS CSS Transitions: property <visibility> from [collapse] to [hidden] at (1) should be [hidden]
PASS CSS Transitions: property <visibility> from [collapse] to [hidden] at (1.5) should be [hidden]
FAIL CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (-0.3) should be [hidden] assert_equals: expected "hidden " but got "collapse "
FAIL CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (0) should be [hidden] assert_equals: expected "hidden " but got "collapse "
FAIL CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (0.3) should be [hidden] assert_equals: expected "hidden " but got "collapse "
PASS CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (-0.3) should be [hidden]
PASS CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (0) should be [hidden]
PASS CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (0.3) should be [hidden]
PASS CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (0.5) should be [hidden]
PASS CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (0.6) should be [hidden]
PASS CSS Transitions with transition: all: property <visibility> from [collapse] to [hidden] at (1) should be [hidden]
Expand Down
27 changes: 24 additions & 3 deletions Source/WebCore/animation/CSSPropertyAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,10 @@ static inline ContentVisibility blendFunc(ContentVisibility from, ContentVisibil

static inline Visibility blendFunc(Visibility from, Visibility to, const CSSPropertyBlendingContext& context)
{
if (from != Visibility::Visible && to != Visibility::Visible)
return context.progress < 0.5 ? from : to;
if (context.isDiscrete) {
ASSERT(!context.progress || context.progress == 1.0);
return context.progress ? to : from;
}

// Any non-zero result means we consider the object to be visible. Only at 0 do we consider the object to be
// invisible. The invisible value we use (Visibility::Hidden vs. Visibility::Collapse) depends on the specified from/to values.
Expand Down Expand Up @@ -3469,6 +3471,25 @@ class QuotesWrapper final : public AnimationPropertyWrapperBase {
};
DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(QuotesWrapper);

DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(VisibilityWrapper);
class VisibilityWrapper final : public PropertyWrapper<Visibility> {
WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(VisibilityWrapper);
public:
VisibilityWrapper()
: PropertyWrapper(CSSPropertyVisibility, &RenderStyle::visibility, &RenderStyle::setVisibility)
{
}

private:
bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
{
// https://drafts.csswg.org/web-animations-1/#animating-visibility
// If neither value is visible, then discrete animation is used.
return value(from) == Visibility::Visible || value(to) == Visibility::Visible;
}
};
DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(VisibilityWrapper);

template <typename T>
class DiscreteSVGPropertyWrapper final : public AnimationPropertyWrapperBase {
WTF_MAKE_FAST_ALLOCATED;
Expand Down Expand Up @@ -3677,7 +3698,7 @@ CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap()
new LengthVariantPropertyWrapper<LengthSize>(CSSPropertyBorderTopRightRadius, &RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius),
new LengthVariantPropertyWrapper<LengthSize>(CSSPropertyBorderBottomLeftRadius, &RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius),
new LengthVariantPropertyWrapper<LengthSize>(CSSPropertyBorderBottomRightRadius, &RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius),
new PropertyWrapper<Visibility>(CSSPropertyVisibility, &RenderStyle::visibility, &RenderStyle::setVisibility),
new VisibilityWrapper,

new ClipWrapper,

Expand Down

0 comments on commit c8d2cfa

Please sign in to comment.