mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-19 19:03:07 +09:00
Issue #2488 - Part 2: Remove the DeclarationBlock class and use Declaration directly
This commit is contained in:
parent
63076e4211
commit
4d7bdedade
27 changed files with 210 additions and 356 deletions
|
|
@ -8,10 +8,9 @@
|
|||
#include "nsDOMCSSDeclaration.h"
|
||||
|
||||
#include "nsCSSParser.h"
|
||||
#include "mozilla/DeclarationBlockInlines.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/css/Rule.h"
|
||||
#include "mozilla/DeclarationBlockInlines.h"
|
||||
#include "mozilla/css/Declaration.h"
|
||||
#include "mozilla/dom/CSS2PropertiesBinding.h"
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
|
@ -49,7 +48,7 @@ nsDOMCSSDeclaration::GetPropertyValue(const nsCSSPropertyID aPropID,
|
|||
"Should never pass eCSSProperty_UNKNOWN around");
|
||||
|
||||
aValue.Truncate();
|
||||
if (DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read)) {
|
||||
if (css::Declaration* decl = GetCSSDeclaration(eOperation_Read)) {
|
||||
decl->GetPropertyValueByID(aPropID, aValue);
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
@ -97,7 +96,7 @@ nsDOMCSSDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID,
|
|||
NS_IMETHODIMP
|
||||
nsDOMCSSDeclaration::GetCssText(nsAString& aCssText)
|
||||
{
|
||||
DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
aCssText.Truncate();
|
||||
|
||||
if (decl) {
|
||||
|
|
@ -112,7 +111,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
|
|||
{
|
||||
// We don't need to *do* anything with the old declaration, but we need
|
||||
// to ensure that it exists, or else SetCSSDeclaration may crash.
|
||||
DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
if (!olddecl) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
@ -130,7 +129,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
|
|||
// rule (see stack in bug 209575).
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
|
||||
|
||||
RefPtr<DeclarationBlock> newdecl;
|
||||
RefPtr<css::Declaration> newdecl;
|
||||
RefPtr<css::Declaration> decl(new css::Declaration());
|
||||
decl->InitializeEmpty();
|
||||
nsCSSParser cssParser(env.mCSSLoader);
|
||||
|
|
@ -149,7 +148,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
|
|||
NS_IMETHODIMP
|
||||
nsDOMCSSDeclaration::GetLength(uint32_t* aLength)
|
||||
{
|
||||
DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
|
||||
if (decl) {
|
||||
*aLength = decl->Count();
|
||||
|
|
@ -171,7 +170,7 @@ nsDOMCSSDeclaration::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorRe
|
|||
void
|
||||
nsDOMCSSDeclaration::IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName)
|
||||
{
|
||||
DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
aFound = decl && decl->GetNthProperty(aIndex, aPropName);
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +179,7 @@ nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName,
|
|||
nsAString& aReturn)
|
||||
{
|
||||
aReturn.Truncate();
|
||||
if (DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read)) {
|
||||
if (css::Declaration* decl = GetCSSDeclaration(eOperation_Read)) {
|
||||
decl->GetPropertyValue(aPropertyName, aReturn);
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
@ -190,7 +189,7 @@ NS_IMETHODIMP
|
|||
nsDOMCSSDeclaration::GetAuthoredPropertyValue(const nsAString& aPropertyName,
|
||||
nsAString& aReturn)
|
||||
{
|
||||
if (DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read)) {
|
||||
if (css::Declaration* decl = GetCSSDeclaration(eOperation_Read)) {
|
||||
decl->GetAuthoredPropertyValue(aPropertyName, aReturn);
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
@ -200,7 +199,7 @@ NS_IMETHODIMP
|
|||
nsDOMCSSDeclaration::GetPropertyPriority(const nsAString& aPropertyName,
|
||||
nsAString& aReturn)
|
||||
{
|
||||
DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
|
||||
aReturn.Truncate();
|
||||
if (decl && decl->GetPropertyIsImportant(aPropertyName)) {
|
||||
|
|
@ -276,7 +275,7 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSPropertyID aPropID,
|
|||
const nsAString& aPropValue,
|
||||
bool aIsImportant)
|
||||
{
|
||||
DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
if (!olddecl) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
@ -293,13 +292,13 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSPropertyID aPropID,
|
|||
// between when we mutate the declaration and when we set the new
|
||||
// rule (see stack in bug 209575).
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
|
||||
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
|
||||
RefPtr<css::Declaration> decl = olddecl->EnsureMutable();
|
||||
|
||||
bool changed;
|
||||
nsCSSParser cssParser(env.mCSSLoader);
|
||||
cssParser.ParseProperty(aPropID, aPropValue,
|
||||
env.mSheetURI, env.mBaseURI, env.mPrincipal,
|
||||
decl->AsGecko(), &changed, aIsImportant);
|
||||
decl, &changed, aIsImportant);
|
||||
if (!changed) {
|
||||
// Parsing failed -- but we don't throw an exception for that.
|
||||
return NS_OK;
|
||||
|
|
@ -315,7 +314,7 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
|
|||
{
|
||||
MOZ_ASSERT(nsCSSProps::IsCustomPropertyName(aPropertyName));
|
||||
|
||||
DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
if (!olddecl) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
@ -332,13 +331,13 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
|
|||
// between when we mutate the declaration and when we set the new
|
||||
// rule (see stack in bug 209575).
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
|
||||
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
|
||||
RefPtr<css::Declaration> decl = olddecl->EnsureMutable();
|
||||
|
||||
bool changed;
|
||||
auto propName = Substring(aPropertyName, CSS_CUSTOM_NAME_PREFIX_LENGTH);
|
||||
nsCSSParser cssParser(env.mCSSLoader);
|
||||
cssParser.ParseVariable(propName, aPropValue, env.mSheetURI,
|
||||
env.mBaseURI, env.mPrincipal, decl->AsGecko(),
|
||||
env.mBaseURI, env.mPrincipal, decl,
|
||||
&changed, aIsImportant);
|
||||
if (!changed) {
|
||||
// Parsing failed -- but we don't throw an exception for that.
|
||||
|
|
@ -351,7 +350,7 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
|
|||
nsresult
|
||||
nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID)
|
||||
{
|
||||
DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_RemoveProperty);
|
||||
css::Declaration* olddecl = GetCSSDeclaration(eOperation_RemoveProperty);
|
||||
if (!olddecl) {
|
||||
return NS_OK; // no decl, so nothing to remove
|
||||
}
|
||||
|
|
@ -363,7 +362,7 @@ nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID)
|
|||
// rule (see stack in bug 209575).
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
|
||||
|
||||
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
|
||||
RefPtr<css::Declaration> decl = olddecl->EnsureMutable();
|
||||
decl->RemovePropertyByID(aPropID);
|
||||
return SetCSSDeclaration(decl);
|
||||
}
|
||||
|
|
@ -371,7 +370,7 @@ nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID)
|
|||
nsresult
|
||||
nsDOMCSSDeclaration::RemovePropertyInternal(const nsAString& aPropertyName)
|
||||
{
|
||||
DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_RemoveProperty);
|
||||
css::Declaration* olddecl = GetCSSDeclaration(eOperation_RemoveProperty);
|
||||
if (!olddecl) {
|
||||
return NS_OK; // no decl, so nothing to remove
|
||||
}
|
||||
|
|
@ -383,7 +382,7 @@ nsDOMCSSDeclaration::RemovePropertyInternal(const nsAString& aPropertyName)
|
|||
// rule (see stack in bug 209575).
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
|
||||
|
||||
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
|
||||
RefPtr<css::Declaration> decl = olddecl->EnsureMutable();
|
||||
decl->RemoveProperty(aPropertyName);
|
||||
return SetCSSDeclaration(decl);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue