Bug 1344598 - Use nsIDocument::IsStyledByServo to check we are using servo or not. r?boris draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 06 Mar 2017 11:42:57 +0900
changeset 493791 4f87d187d67041b065ae8fe57712c72f74e0f403
parent 493561 8ab5e1742e7ae0c74a3a2581b4626b428754f63e
child 493822 280ae12dee97dfc6b1f20cd15618dff7f56173fa
push id47841
push userhikezoe@mozilla.com
push dateMon, 06 Mar 2017 02:43:36 +0000
reviewersboris
bugs1344598
milestone54.0a1
Bug 1344598 - Use nsIDocument::IsStyledByServo to check we are using servo or not. r?boris MozReview-Commit-ID: 1yQUAwHy51
dom/animation/KeyframeEffectReadOnly.cpp
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -532,18 +532,17 @@ KeyframeEffectReadOnly::ComposeStyle(
   mCurrentIterationOnLastCompose = computedTiming.mCurrentIteration;
 
   // If the progress is null, we don't have fill data for the current
   // time so we shouldn't animate.
   if (computedTiming.mProgress.IsNull()) {
     return;
   }
 
-  nsPresContext* presContext = GetPresContext();
-  bool isServoBackend = presContext && presContext->StyleSet()->IsServo();
+  bool isServoBackend = mDocument->IsStyledByServo();
 
   for (size_t propIdx = 0, propEnd = mProperties.Length();
        propIdx != propEnd; ++propIdx)
   {
     const AnimationProperty& prop = mProperties[propIdx];
 
     MOZ_ASSERT(prop.mSegments[0].mFromKey == 0.0, "incorrect first from key");
     MOZ_ASSERT(prop.mSegments[prop.mSegments.Length() - 1].mToKey == 1.0,
@@ -1613,17 +1612,17 @@ CreateStyleContextForAnimationValue(nsCS
 
   return styleContext.forget();
 }
 
 void
 KeyframeEffectReadOnly::CalculateCumulativeChangeHint(
   nsStyleContext *aStyleContext)
 {
-  if (aStyleContext->PresContext()->StyleSet()->IsServo()) {
+  if (mDocument->IsStyledByServo()) {
     // FIXME (bug 1303235): Do this for Servo too
     return;
   }
   mCumulativeChangeHint = nsChangeHint(0);
 
   for (const AnimationProperty& property : mProperties) {
     for (const AnimationPropertySegment& segment : property.mSegments) {
       // In case composite operation is not 'replace', we can't throttle
@@ -1687,18 +1686,17 @@ bool
 KeyframeEffectReadOnly::CanIgnoreIfNotVisible() const
 {
   if (!AnimationUtils::IsOffscreenThrottlingEnabled()) {
     return false;
   }
 
   // FIXME (bug 1303235): We don't calculate mCumulativeChangeHint for
   // the Servo backend yet
-  nsPresContext* presContext = GetPresContext();
-  if (!presContext || presContext->StyleSet()->IsServo()) {
+  if (mDocument->IsStyledByServo()) {
     return false;
   }
 
   // FIXME: For further sophisticated optimization we need to check
   // change hint on the segment corresponding to computedTiming.progress.
   return NS_IsHintSubset(
     mCumulativeChangeHint, nsChangeHint_Hints_CanIgnoreIfNotVisible);
 }