Bug 1073336 part 9 - Add protected AnimationPlayer::GetPresContext(); r=dbaron
authorBrian Birtles <birtles@gmail.com>
Mon, 17 Nov 2014 13:45:58 +0900
changeset 240283 319ee0b01e09f297d12a7dbbad3e916a6844478f
parent 240282 720613a03d00928f64813a2970523125c02312e2
child 240284 9d2e86d4bab6a685aab9429dedad05f2f12b8f7b
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1073336
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1073336 part 9 - Add protected AnimationPlayer::GetPresContext(); r=dbaron This patch adds a further getter to find the pres context associated with an animation player's target element, if any.
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -2,16 +2,17 @@
 /* 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 "AnimationPlayer.h"
 #include "AnimationUtils.h"
 #include "mozilla/dom/AnimationPlayerBinding.h"
 #include "nsIDocument.h" // For nsIDocument
+#include "nsIPresShell.h" // For nsIPresShell
 #include "nsLayoutUtils.h" // For PostRestyleEvent (remove after bug 1073336)
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationPlayer, mTimeline, mSource)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AnimationPlayer, AddRef)
@@ -256,10 +257,24 @@ AnimationPlayer::GetRenderedDocument() c
   mSource->GetTarget(targetElement, pseudoType);
   if (!targetElement) {
     return nullptr;
   }
 
   return targetElement->GetComposedDoc();
 }
 
+nsPresContext*
+AnimationPlayer::GetPresContext() const
+{
+  nsIDocument* doc = GetRenderedDocument();
+  if (!doc) {
+    return nullptr;
+  }
+  nsIPresShell* shell = doc->GetShell();
+  if (!shell) {
+    return nullptr;
+  }
+  return shell->GetPresContext();
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -18,16 +18,17 @@
 // X11 has a #define for CurrentTime.
 #ifdef CurrentTime
 #undef CurrentTime
 #endif
 
 struct JSContext;
 class nsCSSPropertySet;
 class nsIDocument;
+class nsPresContext;
 
 namespace mozilla {
 namespace css {
 class AnimValuesStyleRule;
 } // namespace css
 
 class CSSAnimationPlayer;
 class CSSTransitionPlayer;
@@ -123,16 +124,17 @@ public:
   Nullable<TimeDuration> mStartTime; // Timeline timescale
 
 protected:
   void FlushStyle() const;
   void MaybePostRestyle() const;
   StickyTimeDuration SourceContentEnd() const;
 
   nsIDocument* GetRenderedDocument() const;
+  nsPresContext* GetPresContext() const;
 
   nsRefPtr<AnimationTimeline> mTimeline;
   nsRefPtr<Animation> mSource;
   Nullable<TimeDuration> mHoldTime;  // Player timescale
   bool mIsPaused;
   bool mIsRunningOnCompositor;
   // Indicates whether we were in the finished state during our
   // most recent unthrottled sample (our last ComposeStyle call).