Bug 1462229 - Part 3: Guard that not touching null object during creating graph after animation inspector destroyed. r=gl

MozReview-Commit-ID: 2UWt3aq1e4x

--HG--
extra : rebase_source : ef6f2047efccde2fbc80b0cbfb4b82a181ecf1dd
This commit is contained in:
Daisuke Akatsuka 2018-05-28 09:27:55 +09:00
parent eae57fa593
commit 7703af13b4
5 changed files with 39 additions and 1 deletions

View File

@ -532,6 +532,11 @@ class AnimationInspector {
* https://drafts.csswg.org/web-animations/#the-animation-interface
*/
simulateAnimation(keyframes, effectTiming, isElementNeeded) {
// Don't simulate animation if the animation inspector is already destroyed.
if (!this.win) {
return null;
}
let targetEl = null;
if (isElementNeeded) {
@ -642,6 +647,11 @@ class AnimationInspector {
}
updateState(animations) {
// Animation inspector already destroyed
if (!this.inspector) {
return;
}
this.stopAnimationsCurrentTimeTimer();
this.inspector.store.dispatch(updateAnimations(animations));

View File

@ -50,7 +50,13 @@ class ComputedTimingPath extends TimingPath {
easing: keyframe.easing
};
});
const simulatedAnimation = simulateAnimation(frames, effectTiming, true);
if (!simulatedAnimation) {
return null;
}
const simulatedElement = simulatedAnimation.effect.target;
const win = simulatedElement.ownerGlobal;
const endTime = simulatedAnimation.effect.getComputedTiming().endTime;

View File

@ -36,6 +36,11 @@ class EffectTimingPath extends TimingPath {
});
const simulatedAnimation = simulateAnimation(null, effectTiming, false);
if (!simulatedAnimation) {
return null;
}
const endTime = simulatedAnimation.effect.getComputedTiming().endTime;
const getValueFunc = time => {

View File

@ -52,6 +52,11 @@ class NegativePath extends PureComponent {
});
const simulatedAnimation = simulateAnimation(frames, effectTiming, true);
if (!simulatedAnimation) {
return null;
}
const simulatedElement = simulatedAnimation.effect.target;
const win = simulatedElement.ownerGlobal;

View File

@ -83,7 +83,13 @@ class ComputedStylePath extends PureComponent {
duration,
fill: "forwards",
};
const simulatedAnimation = simulateAnimation(keyframes, effect, true);
if (!simulatedAnimation) {
return null;
}
const simulatedElement = simulatedAnimation.effect.target;
const win = simulatedElement.ownerGlobal;
const threshold = getPreferredProgressThresholdByKeyframes(keyframes);
@ -181,7 +187,13 @@ class ComputedStylePath extends PureComponent {
for (let i = 0; i < keyframes.length - 1; i++) {
const startKeyframe = keyframes[i];
const endKeyframe = keyframes[i + 1];
segments.push(...this.getPathSegments(startKeyframe, endKeyframe));
const keyframesSegments = this.getPathSegments(startKeyframe, endKeyframe);
if (!keyframesSegments) {
return null;
}
segments.push(...keyframesSegments);
}
return [