зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1710969 - Use an enum class for nsDOMCSSDeclaration::Operation. r=TYLin
No behavior change. Differential Revision: https://phabricator.services.mozilla.com/D115038
This commit is contained in:
Родитель
ce6918e771
Коммит
f06a044edd
|
@ -93,7 +93,7 @@ Document* nsDOMCSSAttributeDeclaration::DocToUpdate() {
|
|||
|
||||
DeclarationBlock* nsDOMCSSAttributeDeclaration::GetOrCreateCSSDeclaration(
|
||||
Operation aOperation, DeclarationBlock** aCreated) {
|
||||
MOZ_ASSERT(aOperation != eOperation_Modify || aCreated);
|
||||
MOZ_ASSERT(aOperation != Operation::Modify || aCreated);
|
||||
|
||||
if (!mElement) return nullptr;
|
||||
|
||||
|
@ -108,7 +108,7 @@ DeclarationBlock* nsDOMCSSAttributeDeclaration::GetOrCreateCSSDeclaration(
|
|||
return declaration;
|
||||
}
|
||||
|
||||
if (aOperation != eOperation_Modify) {
|
||||
if (aOperation != Operation::Modify) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ nsresult nsDOMCSSAttributeDeclaration::SetSMILValueHelper(SetterFunc aFunc) {
|
|||
// scripted animation.
|
||||
RefPtr<DeclarationBlock> created;
|
||||
DeclarationBlock* olddecl =
|
||||
GetOrCreateCSSDeclaration(eOperation_Modify, getter_AddRefs(created));
|
||||
GetOrCreateCSSDeclaration(Operation::Modify, getter_AddRefs(created));
|
||||
if (!olddecl) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ nsresult nsDOMCSSDeclaration::GetPropertyValue(const nsCSSPropertyID aPropID,
|
|||
MOZ_ASSERT(aValue.IsEmpty());
|
||||
|
||||
if (DeclarationBlock* decl =
|
||||
GetOrCreateCSSDeclaration(eOperation_Read, nullptr)) {
|
||||
GetOrCreateCSSDeclaration(Operation::Read, nullptr)) {
|
||||
decl->GetPropertyValueByID(aPropID, aValue);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -94,7 +94,7 @@ void nsDOMCSSDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID,
|
|||
void nsDOMCSSDeclaration::GetCssText(nsACString& aCssText) {
|
||||
MOZ_ASSERT(aCssText.IsEmpty());
|
||||
|
||||
if (auto* decl = GetOrCreateCSSDeclaration(eOperation_Read, nullptr)) {
|
||||
if (auto* decl = GetOrCreateCSSDeclaration(Operation::Read, nullptr)) {
|
||||
decl->ToString(aCssText);
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ void nsDOMCSSDeclaration::SetCssText(const nsACString& aCssText,
|
|||
// to ensure that it exists, or else SetCSSDeclaration may crash.
|
||||
RefPtr<DeclarationBlock> created;
|
||||
DeclarationBlock* olddecl =
|
||||
GetOrCreateCSSDeclaration(eOperation_Modify, getter_AddRefs(created));
|
||||
GetOrCreateCSSDeclaration(Operation::Modify, getter_AddRefs(created));
|
||||
if (!olddecl) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return;
|
||||
|
@ -147,7 +147,7 @@ void nsDOMCSSDeclaration::SetCssText(const nsACString& aCssText,
|
|||
}
|
||||
|
||||
uint32_t nsDOMCSSDeclaration::Length() {
|
||||
DeclarationBlock* decl = GetOrCreateCSSDeclaration(eOperation_Read, nullptr);
|
||||
DeclarationBlock* decl = GetOrCreateCSSDeclaration(Operation::Read, nullptr);
|
||||
|
||||
if (decl) {
|
||||
return decl->Count();
|
||||
|
@ -158,7 +158,7 @@ uint32_t nsDOMCSSDeclaration::Length() {
|
|||
|
||||
void nsDOMCSSDeclaration::IndexedGetter(uint32_t aIndex, bool& aFound,
|
||||
nsACString& aPropName) {
|
||||
DeclarationBlock* decl = GetOrCreateCSSDeclaration(eOperation_Read, nullptr);
|
||||
DeclarationBlock* decl = GetOrCreateCSSDeclaration(Operation::Read, nullptr);
|
||||
aFound = decl && decl->GetNthProperty(aIndex, aPropName);
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ NS_IMETHODIMP
|
|||
nsDOMCSSDeclaration::GetPropertyValue(const nsACString& aPropertyName,
|
||||
nsACString& aReturn) {
|
||||
MOZ_ASSERT(aReturn.IsEmpty());
|
||||
if (auto* decl = GetOrCreateCSSDeclaration(eOperation_Read, nullptr)) {
|
||||
if (auto* decl = GetOrCreateCSSDeclaration(Operation::Read, nullptr)) {
|
||||
decl->GetPropertyValue(aPropertyName, aReturn);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -175,7 +175,7 @@ nsDOMCSSDeclaration::GetPropertyValue(const nsACString& aPropertyName,
|
|||
void nsDOMCSSDeclaration::GetPropertyPriority(const nsACString& aPropertyName,
|
||||
nsACString& aPriority) {
|
||||
MOZ_ASSERT(aPriority.IsEmpty());
|
||||
DeclarationBlock* decl = GetOrCreateCSSDeclaration(eOperation_Read, nullptr);
|
||||
DeclarationBlock* decl = GetOrCreateCSSDeclaration(Operation::Read, nullptr);
|
||||
if (decl && decl->GetPropertyIsImportant(aPropertyName)) {
|
||||
aPriority.AssignLiteral("important");
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ nsresult nsDOMCSSDeclaration::ModifyDeclaration(
|
|||
Func aFunc) {
|
||||
RefPtr<DeclarationBlock> created;
|
||||
DeclarationBlock* olddecl =
|
||||
GetOrCreateCSSDeclaration(eOperation_Modify, getter_AddRefs(created));
|
||||
GetOrCreateCSSDeclaration(Operation::Modify, getter_AddRefs(created));
|
||||
if (!olddecl) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ nsresult nsDOMCSSDeclaration::ParseCustomPropertyValue(
|
|||
void nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID,
|
||||
ErrorResult& aRv) {
|
||||
DeclarationBlock* olddecl =
|
||||
GetOrCreateCSSDeclaration(eOperation_RemoveProperty, nullptr);
|
||||
GetOrCreateCSSDeclaration(Operation::RemoveProperty, nullptr);
|
||||
if (IsReadOnly()) {
|
||||
return;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ void nsDOMCSSDeclaration::RemovePropertyInternal(
|
|||
}
|
||||
|
||||
DeclarationBlock* olddecl =
|
||||
GetOrCreateCSSDeclaration(eOperation_RemoveProperty, nullptr);
|
||||
GetOrCreateCSSDeclaration(Operation::RemoveProperty, nullptr);
|
||||
if (!olddecl) {
|
||||
return; // no decl, so nothing to remove
|
||||
}
|
||||
|
|
|
@ -137,26 +137,26 @@ class nsDOMCSSDeclaration : public nsICSSDeclaration {
|
|||
|
||||
protected:
|
||||
// The reason for calling GetOrCreateCSSDeclaration.
|
||||
enum Operation {
|
||||
enum class Operation {
|
||||
// We are calling GetOrCreateCSSDeclaration so that we can read from it.
|
||||
// Does not allocate a new declaration if we don't have one yet; returns
|
||||
// nullptr in this case.
|
||||
eOperation_Read,
|
||||
Read,
|
||||
|
||||
// We are calling GetOrCreateCSSDeclaration so that we can set a property on
|
||||
// it or re-parse the whole declaration. Allocates a new declaration if we
|
||||
// don't have one yet. A nullptr return value indicates an error allocating
|
||||
// the declaration.
|
||||
eOperation_Modify,
|
||||
Modify,
|
||||
|
||||
// We are calling GetOrCreateCSSDeclaration so that we can remove a property
|
||||
// from it. Does not allocate a new declaration if we don't have one yet;
|
||||
// returns nullptr in this case.
|
||||
eOperation_RemoveProperty
|
||||
RemoveProperty,
|
||||
};
|
||||
|
||||
// If aOperation is eOperation_Modify, aCreated must be non-null and
|
||||
// the call may set it to point to the newly created object.
|
||||
// If aOperation is Modify, aCreated must be non-null and the call may set it
|
||||
// to point to the newly created object.
|
||||
virtual mozilla::DeclarationBlock* GetOrCreateCSSDeclaration(
|
||||
Operation aOperation, mozilla::DeclarationBlock** aCreated) = 0;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче