Bug 1395452 - Call HasAnimationController() before GetAnimationController(); r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Thu, 31 Aug 2017 15:00:39 +0900
changeset 656401 a724b1b0b0df6e747b899784febdbd66d9e0666d
parent 656346 04b6be50a2526c7a26a63715f441c47e1aa1f9be
child 729130 205a4d0c273c4ca20cfdaadd99ac87f293d998d3
push id77202
push userbmo:bbirtles@mozilla.com
push dateThu, 31 Aug 2017 06:01:07 +0000
reviewershiro
bugs1395452
milestone57.0a1
Bug 1395452 - Call HasAnimationController() before GetAnimationController(); r?hiro nsDocument::GetAnimationController() will lazily create an animation controller which, in some call sites, is unnecessary. This patch first calls HasAnimationController() and only calls GetAnimationController() if it returns true. This avoids creating an animation controller in situations where one is not necessarily required. MozReview-Commit-ID: 4cdpLRvMVJU
gfx/thebes/gfxSVGGlyphs.cpp
layout/style/ServoStyleSet.cpp
--- a/gfx/thebes/gfxSVGGlyphs.cpp
+++ b/gfx/thebes/gfxSVGGlyphs.cpp
@@ -163,19 +163,19 @@ gfxSVGGlyphsDocument::SetupPresentation(
     if (!presShell->DidInitialize()) {
         nsRect rect = presContext->GetVisibleArea();
         rv = presShell->Initialize(rect.width, rect.height);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     mDocument->FlushPendingNotifications(FlushType::Layout);
 
-    nsSMILAnimationController* controller = mDocument->GetAnimationController();
-    if (controller) {
-      controller->Resume(nsSMILTimeContainer::PAUSE_IMAGE);
+    if (mDocument->HasAnimationController()) {
+      mDocument->GetAnimationController()
+               ->Resume(nsSMILTimeContainer::PAUSE_IMAGE);
     }
     mDocument->ImageTracker()->SetAnimatingState(true);
 
     mViewer = viewer;
     mPresShell = presShell;
     mPresShell->AddPostRefreshObserver(this);
 
     return NS_OK;
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -354,17 +354,20 @@ ServoStyleSet::PreTraverseSync()
 void
 ServoStyleSet::PreTraverse(ServoTraversalFlags aFlags, Element* aRoot)
 {
   PreTraverseSync();
 
   // Process animation stuff that we should avoid doing during the parallel
   // traversal.
   nsSMILAnimationController* smilController =
-    mPresContext->Document()->GetAnimationController();
+    mPresContext->Document()->HasAnimationController()
+    ? mPresContext->Document()->GetAnimationController()
+    : nullptr;
+
   if (aRoot) {
     mPresContext->EffectCompositor()
                 ->PreTraverseInSubtree(aFlags, aRoot);
     if (smilController) {
       smilController->PreTraverseInSubtree(aRoot);
     }
   } else {
     mPresContext->EffectCompositor()->PreTraverse(aFlags);