Title: [260705] trunk
- Revision
- 260705
- Author
- [email protected]
- Date
- 2020-04-25 09:08:46 -0700 (Sat, 25 Apr 2020)
Log Message
[Web Animations] KeyframeEffect should ensure its target remains alive
https://bugs.webkit.org/show_bug.cgi?id=211019
Patch by Antoine Quint <[email protected]> on 2020-04-25
Reviewed by Daniel Bates.
Source/WebCore:
Test: webanimations/keyframe-effect-target-kept-alive.html
Make KeyframeEffect::m_target a RefPtr so that assigning an element to effect.target guarantees that element
is kept alive even if there are no other references to that element.
* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::KeyframeEffect):
(WebCore::KeyframeEffect::setTarget):
* animation/KeyframeEffect.h:
LayoutTests:
Add a test that creates a KeyframeEffect targeting an element with no other reference and trigger
garbage collection to check that the effect's target exists. This test would have failed prior to
this patch's code changes.
* webanimations/keyframe-effect-target-kept-alive-expected.txt: Added.
* webanimations/keyframe-effect-target-kept-alive.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (260704 => 260705)
--- trunk/LayoutTests/ChangeLog 2020-04-25 15:46:47 UTC (rev 260704)
+++ trunk/LayoutTests/ChangeLog 2020-04-25 16:08:46 UTC (rev 260705)
@@ -1,3 +1,17 @@
+2020-04-25 Antoine Quint <[email protected]>
+
+ [Web Animations] KeyframeEffect should ensure its target remains alive
+ https://bugs.webkit.org/show_bug.cgi?id=211019
+
+ Reviewed by Daniel Bates.
+
+ Add a test that creates a KeyframeEffect targeting an element with no other reference and trigger
+ garbage collection to check that the effect's target exists. This test would have failed prior to
+ this patch's code changes.
+
+ * webanimations/keyframe-effect-target-kept-alive-expected.txt: Added.
+ * webanimations/keyframe-effect-target-kept-alive.html: Added.
+
2020-04-25 Diego Pino Garcia <[email protected]>
[GTK] Gardening, emit baselines after r260690
Added: trunk/LayoutTests/webanimations/keyframe-effect-target-kept-alive-expected.txt (0 => 260705)
--- trunk/LayoutTests/webanimations/keyframe-effect-target-kept-alive-expected.txt (rev 0)
+++ trunk/LayoutTests/webanimations/keyframe-effect-target-kept-alive-expected.txt 2020-04-25 16:08:46 UTC (rev 260705)
@@ -0,0 +1,10 @@
+This test checks that a keyframe effect keeps its target alive even if that node has no other reference.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS effect.target.localName is "div"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/webanimations/keyframe-effect-target-kept-alive.html (0 => 260705)
--- trunk/LayoutTests/webanimations/keyframe-effect-target-kept-alive.html (rev 0)
+++ trunk/LayoutTests/webanimations/keyframe-effect-target-kept-alive.html 2020-04-25 16:08:46 UTC (rev 260705)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="target"></div>
+<script src=""
+<script>
+description("This test checks that a keyframe effect keeps its target alive even if that node has no other reference.");
+
+gc();
+const effect = new KeyframeEffect(document.createElement("div"), { });
+gc();
+shouldBeEqualToString("effect.target.localName", "div");
+
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (260704 => 260705)
--- trunk/Source/WebCore/ChangeLog 2020-04-25 15:46:47 UTC (rev 260704)
+++ trunk/Source/WebCore/ChangeLog 2020-04-25 16:08:46 UTC (rev 260705)
@@ -1,3 +1,20 @@
+2020-04-25 Antoine Quint <[email protected]>
+
+ [Web Animations] KeyframeEffect should ensure its target remains alive
+ https://bugs.webkit.org/show_bug.cgi?id=211019
+
+ Reviewed by Daniel Bates.
+
+ Test: webanimations/keyframe-effect-target-kept-alive.html
+
+ Make KeyframeEffect::m_target a RefPtr so that assigning an element to effect.target guarantees that element
+ is kept alive even if there are no other references to that element.
+
+ * animation/KeyframeEffect.cpp:
+ (WebCore::KeyframeEffect::KeyframeEffect):
+ (WebCore::KeyframeEffect::setTarget):
+ * animation/KeyframeEffect.h:
+
2020-04-25 Zalan Bujtas <[email protected]>
[LFC][TFC] Cleanup TableFormattingContext::layoutInFlowContent
Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (260704 => 260705)
--- trunk/Source/WebCore/animation/KeyframeEffect.cpp 2020-04-25 15:46:47 UTC (rev 260704)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp 2020-04-25 16:08:46 UTC (rev 260705)
@@ -528,7 +528,7 @@
}
KeyframeEffect::KeyframeEffect(Element* target, PseudoId pseudoId)
- : m_target(makeWeakPtr(target))
+ : m_target(target)
, m_pseudoId(pseudoId)
{
}
@@ -1121,11 +1121,11 @@
void KeyframeEffect::setTarget(RefPtr<Element>&& newTarget)
{
- if (m_target.get() == newTarget.get())
+ if (m_target == newTarget)
return;
auto* previousTargetElementOrPseudoElement = targetElementOrPseudoElement();
- m_target = makeWeakPtr(newTarget.get());
+ m_target = WTFMove(newTarget);
didChangeTargetElementOrPseudoElement(previousTargetElementOrPseudoElement);
}
Modified: trunk/Source/WebCore/animation/KeyframeEffect.h (260704 => 260705)
--- trunk/Source/WebCore/animation/KeyframeEffect.h 2020-04-25 15:46:47 UTC (rev 260704)
+++ trunk/Source/WebCore/animation/KeyframeEffect.h 2020-04-25 16:08:46 UTC (rev 260705)
@@ -202,7 +202,7 @@
KeyframeList m_blendingKeyframes { emptyString() };
Vector<ParsedKeyframe> m_parsedKeyframes;
Vector<AcceleratedAction> m_pendingAcceleratedActions;
- WeakPtr<Element> m_target;
+ RefPtr<Element> m_target;
PseudoId m_pseudoId { PseudoId::None };
std::unique_ptr<const RenderStyle> m_unanimatedStyle;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes