From f06a044edd91baf1e536e32c206d5ca9e403d2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 13 May 2021 01:26:35 +0000 Subject: [PATCH] Bug 1710969 - Use an enum class for nsDOMCSSDeclaration::Operation. r=TYLin No behavior change. Differential Revision: https://phabricator.services.mozilla.com/D115038 --- layout/style/nsDOMCSSAttrDeclaration.cpp | 6 +++--- layout/style/nsDOMCSSDeclaration.cpp | 20 ++++++++++---------- layout/style/nsDOMCSSDeclaration.h | 12 ++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/layout/style/nsDOMCSSAttrDeclaration.cpp b/layout/style/nsDOMCSSAttrDeclaration.cpp index acb4296eee68..faf31dbc1f75 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -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 created; DeclarationBlock* olddecl = - GetOrCreateCSSDeclaration(eOperation_Modify, getter_AddRefs(created)); + GetOrCreateCSSDeclaration(Operation::Modify, getter_AddRefs(created)); if (!olddecl) { return NS_ERROR_NOT_AVAILABLE; } diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp index 975fd4457b14..b989ac932767 100644 --- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -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 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 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 } diff --git a/layout/style/nsDOMCSSDeclaration.h b/layout/style/nsDOMCSSDeclaration.h index eba85c0ddf9a..612b7e10b11e 100644 --- a/layout/style/nsDOMCSSDeclaration.h +++ b/layout/style/nsDOMCSSDeclaration.h @@ -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;