Bug 1365629: minor cleanup in ServoCSSParsingEnvironment code. r=canaltinova
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 21 May 2017 15:06:27 +0200
changeset 395033 f76dd202aa3844bab4a42b3b7a23f80b79e64136
parent 395032 dd3a293cf053608b7f8a6f5f72ae0a6eb5b66225
child 395034 07630be9df220071ba54238fbb765226ae7f5ea1
push idunknown
push userunknown
push dateunknown
reviewerscanaltinova
bugs1365629
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1365629: minor cleanup in ServoCSSParsingEnvironment code. r=canaltinova At first I thought that the problem was related to this bug, so I wrote this. I think it's worth landing. MozReview-Commit-ID: G6UKp5l5STm
layout/style/nsDOMCSSAttrDeclaration.cpp
layout/style/nsDOMCSSDeclaration.cpp
layout/style/nsDOMCSSDeclaration.h
--- a/layout/style/nsDOMCSSAttrDeclaration.cpp
+++ b/layout/style/nsDOMCSSAttrDeclaration.cpp
@@ -171,19 +171,20 @@ nsDOMCSSAttributeDeclaration::GetCSSPars
   aCSSParseEnv.mBaseURI = mElement->GetBaseURIForStyleAttr();
   aCSSParseEnv.mPrincipal = mElement->NodePrincipal();
   aCSSParseEnv.mCSSLoader = doc->CSSLoader();
 }
 
 nsDOMCSSDeclaration::ServoCSSParsingEnvironment
 nsDOMCSSAttributeDeclaration::GetServoCSSParsingEnvironment() const
 {
-  ServoCSSParsingEnvironment parsingEnv(mElement->GetURLDataForStyleAttr(),
-    mElement->OwnerDoc()->GetCompatibilityMode());
-  return parsingEnv;
+  return {
+    mElement->GetURLDataForStyleAttr(),
+    mElement->OwnerDoc()->GetCompatibilityMode(),
+  };
 }
 
 NS_IMETHODIMP
 nsDOMCSSAttributeDeclaration::GetParentRule(nsIDOMCSSRule **aParent)
 {
   NS_ENSURE_ARG_POINTER(aParent);
 
   *aParent = nullptr;
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -280,26 +280,30 @@ nsDOMCSSDeclaration::GetCSSParsingEnviro
   aCSSParseEnv.mCSSLoader = document ? document->CSSLoader() : nullptr;
 }
 
 /* static */ nsDOMCSSDeclaration::ServoCSSParsingEnvironment
 nsDOMCSSDeclaration::GetServoCSSParsingEnvironmentForRule(const css::Rule* aRule)
 {
   StyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr;
   if (!sheet) {
-    return ServoCSSParsingEnvironment(nullptr, eCompatibility_FullStandards);
+    return { nullptr, eCompatibility_FullStandards };
   }
 
   if (nsIDocument* document = aRule->GetDocument()) {
-    return ServoCSSParsingEnvironment(sheet->AsServo()->URLData(),
-      document->GetCompatibilityMode());
-  } else {
-    return ServoCSSParsingEnvironment(sheet->AsServo()->URLData(),
-                                      eCompatibility_FullStandards);
+    return {
+      sheet->AsServo()->URLData(),
+      document->GetCompatibilityMode(),
+    };
   }
+
+  return {
+    sheet->AsServo()->URLData(),
+    eCompatibility_FullStandards,
+  };
 }
 
 template<typename GeckoFunc, typename ServoFunc>
 nsresult
 nsDOMCSSDeclaration::ModifyDeclaration(GeckoFunc aGeckoFunc,
                                        ServoFunc aServoFunc)
 {
   DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify);
--- a/layout/style/nsDOMCSSDeclaration.h
+++ b/layout/style/nsDOMCSSDeclaration.h
@@ -144,22 +144,26 @@ protected:
                                  "reference; reference counting here has unacceptable "
                                  "performance overhead (see bug 649163)") mPrincipal;
     mozilla::css::Loader* MOZ_UNSAFE_REF("user of CSSParsingEnviroment must hold an owning "
                                          "reference; reference counting here has unacceptable "
                                          "performance overhead (see bug 649163)") mCSSLoader;
   };
 
   // Information neded to parse a declaration for Servo side.
-  struct MOZ_STACK_CLASS ServoCSSParsingEnvironment {
+  struct MOZ_STACK_CLASS ServoCSSParsingEnvironment
+  {
     mozilla::URLExtraData* mUrlExtraData;
     nsCompatibility mCompatMode;
 
-    ServoCSSParsingEnvironment(mozilla::URLExtraData* aUrlData, nsCompatibility aCompatMode)
-      : mUrlExtraData(aUrlData), mCompatMode(aCompatMode) {}
+    ServoCSSParsingEnvironment(mozilla::URLExtraData* aUrlData,
+                               nsCompatibility aCompatMode)
+      : mUrlExtraData(aUrlData)
+      , mCompatMode(aCompatMode)
+    {}
   };
 
   // On failure, mPrincipal should be set to null in aCSSParseEnv.
   // If mPrincipal is null, the other members may not be set to
   // anything meaningful.
   virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) = 0;
 
   // mUrlExtraData returns URL data for parsing url values in