Bug 1294299 part 3 - Make it possible to create empty ServoDeclarationBlock. r=heycam

MozReview-Commit-ID: FSdSXDFoxM

--HG--
extra : source : 47bdaffadab2dca8be8b6e49c7decf8ef02ea1e5
This commit is contained in:
Xidorn Quan 2016-11-03 14:41:02 +11:00
Родитель 60ba3c835d
Коммит 92119e2034
3 изменённых файлов: 12 добавлений и 2 удалений

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

@ -62,6 +62,8 @@ SERVO_BINDING_FUNC(Servo_RestyleWithAddedDeclaration,
// Style attribute
SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, RawServoDeclarationBlockStrong,
const nsACString* data)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_CreateEmpty,
RawServoDeclarationBlockStrong)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_AddRef, void,
RawServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_Release, void,

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

@ -14,6 +14,9 @@ namespace mozilla {
class ServoDeclarationBlock final : public DeclarationBlock
{
public:
ServoDeclarationBlock()
: ServoDeclarationBlock(Servo_DeclarationBlock_CreateEmpty().Consume()) {}
NS_INLINE_DECL_REFCOUNTING(ServoDeclarationBlock)
static already_AddRefed<ServoDeclarationBlock>

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

@ -128,8 +128,13 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation)
}
// cannot fail
RefPtr<css::Declaration> decl = new css::Declaration();
decl->InitializeEmpty();
RefPtr<DeclarationBlock> decl;
if (mElement->IsStyledByServo()) {
decl = new ServoDeclarationBlock();
} else {
decl = new css::Declaration();
decl->AsGecko()->InitializeEmpty();
}
// this *can* fail (inside SetAttrAndNotify, at least).
nsresult rv;