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
--- 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);