Bug 1395452 - Call HasAnimationController() before GetAnimationController(); r=hiro
authorBrian Birtles <birtles@gmail.com>
Thu, 31 Aug 2017 15:00:39 +0900
changeset 377902 c6950531b0437f605c04d50ea5354d35fe3323b5
parent 377901 c93c993bf569bb04000e4c2f6b8faa4069f7f3a5
child 377903 39432409ceddebce3161c1713fe51b4b4184ee41
push id32416
push userarchaeopteryx@coole-files.de
push dateThu, 31 Aug 2017 12:35:23 +0000
treeherdermozilla-central@c9079d347aaa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1395452
milestone57.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 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
@@ -368,17 +368,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);