From 1b117f0519d719b394b6d4391cbde5e120713028 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 17 Aug 2017 09:04:56 -0700 Subject: [PATCH] Bug 1373343 - Skip the parallel traversal when the presshell isn't active. r=heycam I've verified with the profiler that we use the parallel traversal for loading a foreground tab, but not for a tab opened with ctrl-click. MozReview-Commit-ID: 2SiVDlLLyah --- layout/style/ServoStyleSet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index 0d20e44e07d9..a332843e905e 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -878,7 +878,9 @@ ServoStyleSet::StyleDocument(ServoTraversalFlags aBaseFlags) // Allow the parallel traversal, unless we're traversing traversing one of // the native anonymous document style roots, which are tiny and not worth // parallelizing over. - if (!root->IsInNativeAnonymousSubtree()) { + // + // We only allow the parallel traversal in active (foreground) tabs. + if (!root->IsInNativeAnonymousSubtree() && mPresContext->PresShell()->IsActive()) { flags |= ServoTraversalFlags::ParallelTraversal; } @@ -980,7 +982,8 @@ ServoStyleSet::StyleNewChildren(Element* aParent) // styling with this API. Not clear how common that is, but we allow parallel // traversals in this case to preserve the old behavior (where Servo would // use the parallel traversal i.f.f. the traversal root was the document root). - if (aParent == aParent->OwnerDoc()->GetRootElement()) { + if (aParent == aParent->OwnerDoc()->GetRootElement() && + mPresContext->PresShell()->IsActive()) { flags |= ServoTraversalFlags::ParallelTraversal; }