Bug 1302888 - Replace GetPresContext() with nsContentUtils::GetContextForContent() to obtain nsPresContext* in dom/animation
Edited all function calls in KeyFrameEffectReadOnly.cpp and one function call in EffectCompositor.cpp
MozReview-Commit-ID: BzSHLZna4xX
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -15,16 +15,17 @@
#include "mozilla/AnimationUtils.h"
#include "mozilla/EffectSet.h"
#include "mozilla/LayerAnimationInfo.h"
#include "mozilla/RestyleManager.h"
#include "mozilla/RestyleManagerInlines.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/StyleAnimationValue.h"
#include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetPresShellForContent
+#include "nsContentUtils.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSPropertyIDSet.h"
#include "nsCSSProps.h"
#include "nsIAtom.h"
#include "nsIPresShell.h"
#include "nsIPresShellInlines.h"
#include "nsLayoutUtils.h"
#include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation
@@ -891,17 +892,17 @@ EffectCompositor::UpdateCascadeResults(E
cascadeLevel == EffectCompositor::CascadeLevel::Transitions) {
hasCompositorPropertiesForTransition = true;
}
}
}
aEffectSet.MarkCascadeUpdated();
- nsPresContext* presContext = GetPresContext(aElement);
+ nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
if (!presContext) {
return;
}
// If properties for compositor are newly overridden by !important rules, or
// released from being overridden by !important rules, we need to update
// layers for animations level because it's a trigger to send animations to
// the compositor or pull animations back from the compositor.
@@ -920,27 +921,16 @@ EffectCompositor::UpdateCascadeResults(E
compositorPropertiesInSet(propertiesForAnimationsLevel)) {
presContext->EffectCompositor()->
RequestRestyle(aElement, aPseudoType,
EffectCompositor::RestyleType::Layer,
EffectCompositor::CascadeLevel::Transitions);
}
}
-/* static */ nsPresContext*
-EffectCompositor::GetPresContext(Element* aElement)
-{
- MOZ_ASSERT(aElement);
- nsIPresShell* shell = nsComputedDOMStyle::GetPresShellForContent(aElement);
- if (!shell) {
- return nullptr;
- }
- return shell->GetPresContext();
-}
-
/* static */ void
EffectCompositor::SetPerformanceWarning(
const nsIFrame *aFrame,
nsCSSPropertyID aProperty,
const AnimationPerformanceWarning& aWarning)
{
EffectSet* effects = EffectSet::GetEffectSet(aFrame);
if (!effects) {
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -990,18 +990,21 @@ KeyframeEffectReadOnly::UnregisterTarget
}
}
}
void
KeyframeEffectReadOnly::RequestRestyle(
EffectCompositor::RestyleType aRestyleType)
{
- nsPresContext* presContext = GetPresContext();
- if (presContext && mTarget && mAnimation) {
+ if (!mTarget) {
+ return;
+ }
+ nsPresContext* presContext = nsContentUtils::GetContextForContent(mTarget->mElement);
+ if (presContext && mAnimation) {
presContext->EffectCompositor()->
RequestRestyle(mTarget->mElement, mTarget->mPseudoType,
aRestyleType, mAnimation->CascadeLevel());
}
}
already_AddRefed<nsStyleContext>
KeyframeEffectReadOnly::GetTargetStyleContext()