Bug 1333183 - Prime the root element cache before the servo traversal. r=emilio

This commit is contained in:
Bobby Holley 2017-02-02 14:03:46 -08:00
Родитель 0f1312abd1
Коммит 6fac28059f
2 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -4037,6 +4037,10 @@ nsIDocument::GetRootElement() const
Element*
nsDocument::GetRootElementInternal() const
{
// We invoke GetRootElement() immediately before the servo traversal, so we
// should always have a cache hit from Servo.
MOZ_ASSERT(NS_IsMainThread());
// Loop backwards because any non-elements, such as doctypes and PIs
// are likely to appear before the root element.
uint32_t i;

Просмотреть файл

@ -192,6 +192,11 @@ ServoStyleSet::PrepareAndTraverseSubtree(RawGeckoElementBorrowed aRoot,
mozilla::TraversalRootBehavior aRootBehavior) {
ResolveMappedAttrDeclarationBlocks();
// Get the Document's root element to ensure that the cache is valid before
// calling into the (potentially-parallel) Servo traversal, where a cache hit
// is necessary to avoid a data race when updating the cache.
mozilla::Unused << aRoot->OwnerDoc()->GetRootElement();
MOZ_ASSERT(!sInServoTraversal);
sInServoTraversal = true;
Servo_TraverseSubtree(aRoot, mRawSet.get(), aRootBehavior);