Issue #2488 - Part 2: Remove the DeclarationBlock class and use Declaration directly

This commit is contained in:
FranklinDM 2024-03-28 19:04:36 +08:00 committed by roytam1
commit 4d7bdedade
27 changed files with 210 additions and 356 deletions

View file

@ -59,9 +59,14 @@ ImportantStyleData::List(FILE* out, int32_t aIndent) const
}
#endif
Declaration::Declaration()
: mImmutable(false)
{
mContainer.mRaw = 0;
}
Declaration::Declaration(const Declaration& aCopy)
: DeclarationBlock(aCopy),
mOrder(aCopy.mOrder),
: mOrder(aCopy.mOrder),
mVariableOrder(aCopy.mVariableOrder),
mData(aCopy.mData ? aCopy.mData->Clone() : nullptr),
mImportantData(aCopy.mImportantData ?
@ -71,7 +76,8 @@ Declaration::Declaration(const Declaration& aCopy)
nullptr),
mImportantVariables(aCopy.mImportantVariables ?
new CSSVariableDeclarations(*aCopy.mImportantVariables) :
nullptr)
nullptr),
mImmutable(false)
{
}
@ -1827,6 +1833,24 @@ Declaration::InitializeEmpty()
mData = nsCSSCompressedDataBlock::CreateEmptyBlock();
}
already_AddRefed<Declaration>
Declaration::Clone() const
{
RefPtr<Declaration> result;
result = new Declaration(*this);
return result.forget();
}
already_AddRefed<Declaration>
Declaration::EnsureMutable()
{
AssertNotExpanded();
if (!IsMutable()) {
return Clone();
}
return do_AddRef(this);
}
size_t
Declaration::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{