Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Dialog element only animates once
https://bugs.webkit.org/show_bug.cgi?id=236274 rdar://88635487 Reviewed by Tim Nguyen and Dean Jackson. LayoutTests/imported/w3c: Add two new tests that check that we correctly start, stop and resume animations on <dialog> and ::backdrop as a <dialog> element is open, closed and open again. * web-platform-tests/css/css-animations/dialog-animation-expected.txt: Added. * web-platform-tests/css/css-animations/dialog-animation.html: Added. * web-platform-tests/css/css-animations/dialog-backdrop-animation-expected.txt: Added. * web-platform-tests/css/css-animations/dialog-backdrop-animation.html: Added. * web-platform-tests/css/css-animations/support/testcommon.js: (addElement): (addDiv): Source/WebCore: Two issues related to CSS Animation surfaced in this bug which animates both <dialog> and its ::backdrop as the dialog is open and eventually re-opened. The first issue was that we didn't clear all CSS Animations state when a <dialog> was closed and its style was set to `display: none`. We now use the clearCSSAnimationsForStyleable() function (static so that it's not exposed on the Styleable struct) to correctly clear such state both when we identify a Styleable is newly getting `display: none` and when cancelDeclarativeAnimations() was called. This allows us to remove removeCSSAnimationCreatedByMarkup() a fair bit of work to clear CSS Animation state per-animation when we only ever used that function for _all_ animations. The second issue was that we never called cancelDeclarativeAnimations() for ::backdrop. We now do that inside of Element::removeFromTopLayer() at a point where the code in Styleable::fromRenderer() will still work as the element will still be contained in Document::topLayerElements(). Tests: imported/w3c/web-platform-tests/css/css-animations/dialog-animation.html imported/w3c/web-platform-tests/css/css-animations/dialog-backdrop-animation.html * dom/Element.cpp: (WebCore::Element::removeFromTopLayer): * style/Styleable.cpp: (WebCore::clearCSSAnimationsForStyleable): (WebCore::Styleable::cancelDeclarativeAnimations const): (WebCore::Styleable::updateCSSAnimations const): (WebCore::removeCSSAnimationCreatedByMarkup): Deleted. Canonical link: https://commits.webkit.org/247036@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
9 changed files
with
193 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS CSS Animations tied to <dialog open> are canceled and restarted as the dialog is hidden and shown | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>CSS Animations on a <dialog></title> | ||
<link rel="help" href="https://drafts.csswg.org/css-animations-1/"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support/testcommon.js"></script> | ||
<style> | ||
|
||
dialog[open] { | ||
animation: dialog-open-animation 1ms; | ||
} | ||
|
||
@keyframes dialog-open-animation { | ||
from { opacity: 0 } | ||
} | ||
|
||
</style> | ||
<div id="log"></div> | ||
<script> | ||
|
||
"use strict"; | ||
|
||
promise_test(async t => { | ||
const dialog = addElement(t, "dialog"); | ||
|
||
// Open the dialog a first time, this should trigger a CSS Animation. | ||
dialog.open = true; | ||
const animations = dialog.getAnimations(); | ||
assert_equals(animations.length, 1, "As the <dialog> is shown intially an animation is started"); | ||
|
||
await animations[0].finished; | ||
|
||
await waitForNextFrame(); | ||
|
||
dialog.open = false; | ||
assert_equals(dialog.getAnimations().length, 0, "As the <dialog> is closed the animation is removed"); | ||
|
||
await waitForNextFrame(); | ||
|
||
dialog.open = true; | ||
assert_equals(dialog.getAnimations().length, 1, "As the <dialog> is shown again an animation is started again"); | ||
}, "CSS Animations tied to <dialog open> are canceled and restarted as the dialog is hidden and shown"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS CSS Animations on a <dialog> ::backdrop are canceled and restarted as the dialog is hidden and shown | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>CSS Animations on a <dialog> ::backdrop</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-animations-1/"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support/testcommon.js"></script> | ||
<style> | ||
|
||
dialog[open]::backdrop { | ||
animation: dialog-backdrop-animation 1ms; | ||
} | ||
|
||
@keyframes dialog-backdrop-animation { | ||
from { opacity: 0 } | ||
} | ||
|
||
</style> | ||
<div id="log"></div> | ||
<script> | ||
|
||
"use strict"; | ||
|
||
promise_test(async t => { | ||
const dialog = addElement(t, "dialog"); | ||
|
||
// Open the dialog a first time, this should trigger a CSS Animation. | ||
dialog.showModal(); | ||
const animations = dialog.getAnimations({ subtree: true }); | ||
assert_equals(animations.length, 1, "As the <dialog> is shown intially an animation is started on its ::backdrop"); | ||
|
||
await animations[0].finished; | ||
|
||
await waitForNextFrame(); | ||
|
||
dialog.close(); | ||
assert_equals(dialog.getAnimations({ subtree: true }).length, 0, "As the <dialog> is closed the animation is removed from its ::backdrop"); | ||
|
||
await waitForNextFrame(); | ||
|
||
dialog.showModal(); | ||
assert_equals(dialog.getAnimations({ subtree: true }).length, 1, "As the <dialog> is shown again an animation is started again on its ::backdrop"); | ||
}, "CSS Animations on a <dialog> ::backdrop are canceled and restarted as the dialog is hidden and shown"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters