Bug 1182856 - Part 3: Cancel transitions for destroy frames. r=heycam
authorBoris Chiou <boris.chiou@gmail.com>
Sun, 10 Apr 2016 21:29:00 +0200
changeset 330667 c60ba2b201caf69c56d644c990a57446e70ad85b
parent 330666 8278f70e662c456896b46c67acc328d456957ed1
child 330668 4cf35697f25718c2462460edffbd67783a639f78
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1182856
milestone48.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 1182856 - Part 3: Cancel transitions for destroy frames. r=heycam Add HasCSSTransition() and cancel transitions for destroyed frames.
layout/generic/nsFrame.cpp
layout/generic/nsFrame.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -695,19 +695,19 @@ nsFrame::DestroyFrom(nsIFrame* aDestruct
       RestyleManager::ReframingStyleContexts* rsc =
         presContext->RestyleManager()->AsGecko()->GetReframingStyleContexts();
       if (rsc) {
         rsc->Put(mContent, mStyleContext);
       }
     }
   }
 
-  if (HasCSSAnimations()) {
+  if (HasCSSAnimations() || HasCSSTransitions()) {
     // If no new frame for this element is created by the end of the
-    // restyling process, stop animations for this frame
+    // restyling process, stop animations and transitions for this frame
     if (presContext->RestyleManager()->IsGecko()) {
       RestyleManager::AnimationsWithDestroyedFrame* adf =
         presContext->RestyleManager()->AsGecko()->GetAnimationsWithDestroyedFrame();
       // AnimationsWithDestroyedFrame only lives during the restyling process.
       if (adf) {
         adf->Put(mContent, mStyleContext);
       }
     } else {
@@ -9347,16 +9347,24 @@ nsIFrame::CaretPosition::~CaretPosition(
 bool
 nsFrame::HasCSSAnimations()
 {
   auto collection =
     AnimationCollection<CSSAnimation>::GetAnimationCollection(this);
   return collection && collection->mAnimations.Length() > 0;
 }
 
+bool
+nsFrame::HasCSSTransitions()
+{
+  auto collection =
+    AnimationCollection<CSSTransition>::GetAnimationCollection(this);
+  return collection && collection->mAnimations.Length() > 0;
+}
+
 // Box layout debugging
 #ifdef DEBUG_REFLOW
 int32_t gIndent2 = 0;
 
 void
 nsAdaptorAddIndents()
 {
     for(int32_t i=0; i < gIndent2; i++)
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -673,16 +673,19 @@ private:
                  nscoord aHeight,
                  bool aMoveFrame = true);
 
   NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState);
 
   // Returns true if this frame has any kind of CSS animations.
   bool HasCSSAnimations();
 
+  // Returns true if this frame has any kind of CSS transitions.
+  bool HasCSSTransitions();
+
 #ifdef DEBUG_FRAME_DUMP
 public:
   /**
    * Get a printable from of the name of the frame type.
    * XXX This should be eliminated and we use GetType() instead...
    */
   virtual nsresult  GetFrameName(nsAString& aResult) const override;
   nsresult MakeFrameName(const nsAString& aKind, nsAString& aResult) const;