mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
Bug 1435139 - Don't call SetCSSDeclaration when removing non-existing property. r=bz
MozReview-Commit-ID: 8jt1D5RULEy --HG-- extra : rebase_source : 417b30d30aedfae0c843b292636317ac20da19c5
This commit is contained in:
parent
9f999d9c1d
commit
f990abd8f9
@ -197,12 +197,14 @@ Declaration::GetPropertyIsImportant(const nsAString& aProperty) const
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
Declaration::RemoveProperty(const nsAString& aProperty)
|
||||
{
|
||||
bool r = true;
|
||||
DispatchPropertyOperation(aProperty,
|
||||
[&](nsCSSPropertyID propID) { RemovePropertyByID(propID); },
|
||||
[&](const nsAString& name) { RemoveVariable(name); });
|
||||
[&](nsCSSPropertyID propID) { r = RemovePropertyByID(propID); },
|
||||
[&](const nsAString& name) { r = RemoveVariable(name); });
|
||||
return r;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1911,7 +1913,7 @@ Declaration::AddVariable(const nsAString& aName,
|
||||
mOrder.AppendElement(propertyIndex);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
Declaration::RemoveVariable(const nsAString& aName)
|
||||
{
|
||||
if (mVariables) {
|
||||
@ -1923,7 +1925,9 @@ Declaration::RemoveVariable(const nsAString& aName)
|
||||
nsTArray<nsString>::index_type index = mVariableOrder.IndexOf(aName);
|
||||
if (index != nsTArray<nsString>::NoIndex) {
|
||||
mOrder.RemoveElement(index + eCSSProperty_COUNT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -127,7 +127,9 @@ public:
|
||||
void GetPropertyValue(const nsAString& aProperty, nsAString& aValue) const;
|
||||
void GetPropertyValueByID(nsCSSPropertyID aPropID, nsAString& aValue) const;
|
||||
bool GetPropertyIsImportant(const nsAString& aProperty) const;
|
||||
void RemoveProperty(const nsAString& aProperty);
|
||||
// The two functions below returns whether there is any change to this
|
||||
// declaration block, i.e. whether any property is actually removed.
|
||||
bool RemoveProperty(const nsAString& aProperty);
|
||||
bool RemovePropertyByID(nsCSSPropertyID aProperty);
|
||||
|
||||
bool HasProperty(nsCSSPropertyID aProperty) const;
|
||||
@ -154,11 +156,12 @@ public:
|
||||
bool aOverrideImportant);
|
||||
|
||||
/**
|
||||
* Removes a custom property declaration from this object.
|
||||
* Removes a custom property declaration from this object, and
|
||||
* return whether the variable existed.
|
||||
*
|
||||
* @param aName The variable name (i.e., without the "--" prefix).
|
||||
*/
|
||||
void RemoveVariable(const nsAString& aName);
|
||||
bool RemoveVariable(const nsAString& aName);
|
||||
|
||||
/**
|
||||
* Gets the string value for a custom property declaration of a variable
|
||||
|
@ -132,7 +132,8 @@ public:
|
||||
inline void GetPropertyValueByID(nsCSSPropertyID aPropID,
|
||||
nsAString& aValue) const;
|
||||
inline bool GetPropertyIsImportant(const nsAString& aProperty) const;
|
||||
inline void RemoveProperty(const nsAString& aProperty);
|
||||
// Returns whether the property was removed.
|
||||
inline bool RemoveProperty(const nsAString& aProperty);
|
||||
// Returns whether the property was removed.
|
||||
inline bool RemovePropertyByID(nsCSSPropertyID aProperty);
|
||||
|
||||
|
@ -107,7 +107,7 @@ DeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const
|
||||
MOZ_STYLO_FORWARD(GetPropertyIsImportant, (aProperty))
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
DeclarationBlock::RemoveProperty(const nsAString& aProperty)
|
||||
{
|
||||
MOZ_STYLO_FORWARD(RemoveProperty, (aProperty))
|
||||
|
@ -467,7 +467,7 @@ SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPropertyById, bool,
|
||||
mozilla::ParsingMode parsing_mode,
|
||||
nsCompatibility quirks_mode,
|
||||
mozilla::css::Loader* loader)
|
||||
SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemoveProperty, void,
|
||||
SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemoveProperty, bool,
|
||||
RawServoDeclarationBlockBorrowed declarations,
|
||||
const nsACString* property)
|
||||
SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemovePropertyById, bool,
|
||||
|
@ -48,12 +48,12 @@ ServoDeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const
|
||||
return Servo_DeclarationBlock_GetPropertyIsImportant(mRaw, &property);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ServoDeclarationBlock::RemoveProperty(const nsAString& aProperty)
|
||||
{
|
||||
AssertMutable();
|
||||
NS_ConvertUTF16toUTF8 property(aProperty);
|
||||
Servo_DeclarationBlock_RemoveProperty(mRaw, &property);
|
||||
return Servo_DeclarationBlock_RemoveProperty(mRaw, &property);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -66,7 +66,8 @@ public:
|
||||
void GetPropertyValue(const nsAString& aProperty, nsAString& aValue) const;
|
||||
void GetPropertyValueByID(nsCSSPropertyID aPropID, nsAString& aValue) const;
|
||||
bool GetPropertyIsImportant(const nsAString& aProperty) const;
|
||||
void RemoveProperty(const nsAString& aProperty);
|
||||
// The two functions blow return whether any property was removed.
|
||||
bool RemoveProperty(const nsAString& aProperty);
|
||||
bool RemovePropertyByID(nsCSSPropertyID aPropID);
|
||||
|
||||
private:
|
||||
|
@ -421,7 +421,9 @@ nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID)
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
|
||||
|
||||
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
|
||||
decl->RemovePropertyByID(aPropID);
|
||||
if (!decl->RemovePropertyByID(aPropID)) {
|
||||
return NS_OK;
|
||||
}
|
||||
return SetCSSDeclaration(decl);
|
||||
}
|
||||
|
||||
@ -441,6 +443,8 @@ nsDOMCSSDeclaration::RemovePropertyInternal(const nsAString& aPropertyName)
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
|
||||
|
||||
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
|
||||
decl->RemoveProperty(aPropertyName);
|
||||
if (!decl->RemoveProperty(aPropertyName)) {
|
||||
return NS_OK;
|
||||
}
|
||||
return SetCSSDeclaration(decl);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user