Bug 1355348 - Fix hazard bustage by duplicating code in Gecko_GetStyleAttrDeclarationBlock and Gecko_GetSMILOverrideDeclarationBlock on a CLOSED TREE; r=me a=bustage-fix

This commit is contained in:
Brian Birtles (:birtles) 2017-04-27 11:54:26 +02:00
Родитель fcd72ab331
Коммит 9325ab468e
1 изменённых файлов: 20 добавлений и 19 удалений

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

@ -359,15 +359,10 @@ Gecko_DropElementSnapshot(ServoElementSnapshotOwned aSnapshot)
}
}
typedef DeclarationBlock*(*DeclarationBlockGetter)(RawGeckoElementBorrowed);
static RawServoDeclarationBlockStrongBorrowedOrNull
UnwrapDeclarationBlock(RawGeckoElementBorrowed aElement,
DeclarationBlockGetter aGetterFunc)
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
{
MOZ_ASSERT(aElement, "Invalid GeckoElement");
DeclarationBlock* decl = aGetterFunc(aElement);
DeclarationBlock* decl = aElement->GetInlineStyleDeclaration();
if (!decl) {
return nullptr;
}
@ -380,20 +375,26 @@ UnwrapDeclarationBlock(RawGeckoElementBorrowed aElement,
return decl->AsServo()->RefRawStrong();
}
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
{
return UnwrapDeclarationBlock(aElement, [](RawGeckoElementBorrowed elem) {
return elem->GetInlineStyleDeclaration();
});
}
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetSMILOverrideDeclarationBlock(RawGeckoElementBorrowed aElement)
{
return UnwrapDeclarationBlock(aElement, [](RawGeckoElementBorrowed elem) {
return const_cast<dom::Element*>(elem)->GetSMILOverrideStyleDeclaration();
});
// This function duplicates a lot of the code in
// Gecko_GetStyleAttrDeclarationBlock above because I haven't worked out a way
// to persuade hazard analysis that a pointer-to-lambda is ok yet.
MOZ_ASSERT(aElement, "Invalid GeckoElement");
DeclarationBlock* decl =
const_cast<dom::Element*>(aElement)->GetSMILOverrideStyleDeclaration();
if (!decl) {
return nullptr;
}
if (decl->IsGecko()) {
// XXX This can happen when nodes are adopted from a Gecko-style-backend
// document into a Servo-style-backend document. See bug 1330051.
NS_WARNING("stylo: requesting a Gecko declaration block?");
return nullptr;
}
return decl->AsServo()->RefRawStrong();
}
RawServoDeclarationBlockStrongBorrowedOrNull