Bug 1344533 - Replace OwningElementRef::GetRenderedPresContext with nsContentUtils::GetContextForContext(). r?boris draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sun, 05 Mar 2017 17:28:49 +0900
changeset 493561 8ab5e1742e7ae0c74a3a2581b4626b428754f63e
parent 493524 80c06df83395314697d464f88f8daa98bf05465c
child 493791 4f87d187d67041b065ae8fe57712c72f74e0f403
push id47805
push userhikezoe@mozilla.com
push dateSun, 05 Mar 2017 08:29:48 +0000
reviewersboris
bugs1344533
milestone54.0a1
Bug 1344533 - Replace OwningElementRef::GetRenderedPresContext with nsContentUtils::GetContextForContext(). r?boris MozReview-Commit-ID: HaAvgNcORQb
layout/style/AnimationCommon.cpp
layout/style/AnimationCommon.h
layout/style/moz.build
layout/style/nsAnimationManager.cpp
layout/style/nsTransitionManager.cpp
deleted file mode 100644
--- a/layout/style/AnimationCommon.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "AnimationCommon.h"
-#include "nsTransitionManager.h"
-#include "nsAnimationManager.h"
-
-#include "ActiveLayerTracker.h"
-#include "gfxPlatform.h"
-#include "nsCSSPropertyIDSet.h"
-#include "nsCSSValue.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsStyleContext.h"
-#include "nsIFrame.h"
-#include "nsLayoutUtils.h"
-#include "FrameLayerBuilder.h"
-#include "nsDisplayList.h"
-#include "mozilla/AnimationUtils.h"
-#include "mozilla/EffectCompositor.h"
-#include "mozilla/EffectSet.h"
-#include "mozilla/MemoryReporting.h"
-#include "mozilla/dom/KeyframeEffectReadOnly.h"
-#include "nsRuleProcessorData.h"
-#include "nsStyleSet.h"
-#include "nsStyleChangeList.h"
-
-using mozilla::dom::Animation;
-using mozilla::dom::KeyframeEffectReadOnly;
-
-namespace mozilla {
-
-nsPresContext*
-OwningElementRef::GetRenderedPresContext() const
-{
-  if (!mElement) {
-    return nullptr;
-  }
-
-  nsIDocument* doc = mElement->GetComposedDoc();
-  if (!doc) {
-    return nullptr;
-  }
-
-  nsIPresShell* shell = doc->GetShell();
-  if (!shell) {
-    return nullptr;
-  }
-
-  return shell->GetPresContext();
-}
-
-} // namespace mozilla
--- a/layout/style/AnimationCommon.h
+++ b/layout/style/AnimationCommon.h
@@ -124,18 +124,16 @@ public:
   bool IsSet() const { return !!mElement; }
 
   void GetElement(dom::Element*& aElement,
                   CSSPseudoElementType& aPseudoType) const {
     aElement = mElement;
     aPseudoType = mPseudoType;
   }
 
-  nsPresContext* GetRenderedPresContext() const;
-
 private:
   dom::Element* MOZ_NON_OWNING_REF mElement;
   CSSPseudoElementType             mPseudoType;
 };
 
 template <class EventInfo>
 class DelayedEventDispatcher
 {
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -142,17 +142,16 @@ EXPORTS.mozilla.css += [
     'NameSpaceRule.h',
     'Rule.h',
     'SheetParsingMode.h',
     'StyleRule.h',
 ]
 
 UNIFIED_SOURCES += [
     'AnimationCollection.cpp',
-    'AnimationCommon.cpp',
     'BindingStyleRule.cpp',
     'CounterStyleManager.cpp',
     'CSS.cpp',
     'CSSLexer.cpp',
     'CSSRuleList.cpp',
     'CSSStyleSheet.cpp',
     'CSSVariableDeclarations.cpp',
     'CSSVariableResolver.cpp',
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -13,16 +13,17 @@
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/dom/DocumentTimeline.h"
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
 
 #include "nsPresContext.h"
 #include "nsStyleSet.h"
 #include "nsStyleChangeList.h"
+#include "nsContentUtils.h"
 #include "nsCSSRules.h"
 #include "mozilla/GeckoRestyleManager.h"
 #include "nsLayoutUtils.h"
 #include "nsIFrame.h"
 #include "nsIDocument.h"
 #include "nsDOMMutationObserver.h"
 #include "nsIPresShell.h"
 #include "nsIPresShellInlines.h"
@@ -186,17 +187,18 @@ CSSAnimation::QueueEvents(StickyTimeDura
   }
 
   dom::Element* owningElement;
   CSSPseudoElementType owningPseudoType;
   mOwningElement.GetElement(owningElement, owningPseudoType);
   MOZ_ASSERT(owningElement, "Owning element should be set");
 
   // Get the nsAnimationManager so we can queue events on it
-  nsPresContext* presContext = mOwningElement.GetRenderedPresContext();
+  nsPresContext* presContext =
+    nsContentUtils::GetContextForContent(owningElement);
   if (!presContext) {
     return;
   }
   nsAnimationManager* manager = presContext->AnimationManager();
 
   const StickyTimeDuration zeroDuration;
   uint64_t currentIteration = 0;
   ComputedTiming::AnimationPhase currentPhase;
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -6,16 +6,17 @@
 
 /* Code to start and animate CSS transitions. */
 
 #include "nsTransitionManager.h"
 #include "nsAnimationManager.h"
 #include "mozilla/dom/CSSTransitionBinding.h"
 
 #include "nsIContent.h"
+#include "nsContentUtils.h"
 #include "nsStyleContext.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TimeStamp.h"
 #include "nsRefreshDriver.h"
 #include "nsRuleProcessorData.h"
 #include "nsRuleWalker.h"
 #include "nsCSSPropertyIDSet.h"
 #include "mozilla/EffectCompositor.h"
@@ -184,17 +185,18 @@ CSSTransition::QueueEvents(StickyTimeDur
     return;
   }
 
   dom::Element* owningElement;
   CSSPseudoElementType owningPseudoType;
   mOwningElement.GetElement(owningElement, owningPseudoType);
   MOZ_ASSERT(owningElement, "Owning element should be set");
 
-  nsPresContext* presContext = mOwningElement.GetRenderedPresContext();
+  nsPresContext* presContext =
+    nsContentUtils::GetContextForContent(owningElement);
   if (!presContext) {
     return;
   }
 
   const StickyTimeDuration zeroDuration = StickyTimeDuration();
 
   TransitionPhase currentPhase;
   StickyTimeDuration intervalStartTime;