Bug 978833 patch 10 - Raise consistent exceptions so that the exception doesn't depend on rule destruction timing. r=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Thu, 05 Nov 2015 16:44:09 +0800
changeset 271348 da3bf914effe192549fc81b44363fa9ef36a0e69
parent 271347 3a1bf2c602114a72dfd99a6aeb737f3cb116076b
child 271349 e69922893211b78e5593fbd1c795e66248a357a1
push id29638
push userkwierso@gmail.com
push dateFri, 06 Nov 2015 02:44:30 +0000
treeherdermozilla-central@cc48981c026c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs978833, 727834
milestone45.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 978833 patch 10 - Raise consistent exceptions so that the exception doesn't depend on rule destruction timing. r=bzbarsky Prior to patch 12, rule destruction for rules that were matched doesn't happen until rule tree GC. This means that GetCSSDeclaration is less likely to return null, but then GetCSSParsingEnvironment might fail. With StyleRule no longer participating in the rule tree, they're more likely to be destroyed quickly, leading to the !olddecl failure case instead of the !env.mPrincipal failure case. This is needed to avoid patch 12 causing: TEST-UNEXPECTED-FAIL | layout/inspector/tests/chrome/test_bug727834.xul | original rule is not available for modification anymore - got "NS_ERROR_FAILURE", expected "NS_ERROR_NOT_AVAILABLE"
layout/style/nsDOMCSSDeclaration.cpp
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -102,17 +102,17 @@ nsDOMCSSDeclaration::GetCssText(nsAStrin
 
 NS_IMETHODIMP
 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.
   css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
   if (!olddecl) {
-    return NS_ERROR_FAILURE;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   CSSParsingEnvironment env;
   GetCSSParsingEnvironment(env);
   if (!env.mPrincipal) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
@@ -308,17 +308,17 @@ nsDOMCSSDeclaration::GetCSSParsingEnviro
 
 nsresult
 nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
                                         const nsAString& aPropValue,
                                         bool aIsImportant)
 {
   css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
   if (!olddecl) {
-    return NS_ERROR_FAILURE;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   CSSParsingEnvironment env;
   GetCSSParsingEnvironment(env);
   if (!env.mPrincipal) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
@@ -346,17 +346,17 @@ nsresult
 nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
                                               const nsAString& aPropValue,
                                               bool aIsImportant)
 {
   MOZ_ASSERT(nsCSSProps::IsCustomPropertyName(aPropertyName));
 
   css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
   if (!olddecl) {
-    return NS_ERROR_FAILURE;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   CSSParsingEnvironment env;
   GetCSSParsingEnvironment(env);
   if (!env.mPrincipal) {
     return NS_ERROR_NOT_AVAILABLE;
   }