Bug 1415352: Part 1c - Store the subject principal when setting Element.style properties. r?bz draft
authorKris Maglione <maglione.k@gmail.com>
Fri, 03 Nov 2017 21:44:03 -0700
changeset 694615 816463ddf590e757ad64c577e4e3681cb17b74f7
parent 694614 333aee0a2a8054cbf7ae7be2b4dd9d31658d21e1
child 694616 2fe3d215b53e76fbe1948629d6739827c08bce38
push id88175
push usermaglione.k@gmail.com
push dateTue, 07 Nov 2017 23:59:46 +0000
reviewersbz
bugs1415352
milestone58.0a1
Bug 1415352: Part 1c - Store the subject principal when setting Element.style properties. r?bz This causes the subject principal that was responsible for setting a CSS property, or the full cssText of an attribute, to be used as the triggering principal when loading URLs for that property. Note that this allows for different properties defined in the same style attribute to have different triggering principals, depending on the caller which originally set them, as long as the cssText of that attribute is not modified. Once it is, all properties revert to the principal of the caller that modified the CSS text. MozReview-Commit-ID: ISUyxbqAZMX
dom/bindings/GenerateCSS2PropertiesWebIDL.py
dom/interfaces/css/nsIDOMCSSStyleDeclaration.idl
dom/webidl/CSSStyleDeclaration.webidl
layout/style/nsCSSRules.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsDOMCSSAttrDeclaration.cpp
layout/style/nsDOMCSSAttrDeclaration.h
layout/style/nsDOMCSSDeclaration.cpp
layout/style/nsDOMCSSDeclaration.h
layout/style/nsICSSDeclaration.h
--- a/dom/bindings/GenerateCSS2PropertiesWebIDL.py
+++ b/dom/bindings/GenerateCSS2PropertiesWebIDL.py
@@ -23,17 +23,18 @@ def generate(output, idlFilename, prepro
 
     propList = eval(preprocessed)
     props = ""
     for [name, prop, id, flags, pref, proptype] in propList:
         if "CSS_PROPERTY_INTERNAL" in flags:
             continue
         # Unfortunately, even some of the getters here are fallible
         # (e.g. on nsComputedDOMStyle).
-        extendedAttrs = ["Throws", "TreatNullAs=EmptyString"]
+        extendedAttrs = ["Throws", "TreatNullAs=EmptyString",
+                         "NeedsSubjectPrincipal"]
         if pref is not "":
             extendedAttrs.append('Pref="%s"' % pref)
 
         # webkit properties get a capitalized "WebkitFoo" accessor (added here)
         # as well as a camelcase "webkitFoo" accessor (added next).
         if (prop.startswith("Webkit")):
             props += generateLine(prop, extendedAttrs)
 
--- a/dom/interfaces/css/nsIDOMCSSStyleDeclaration.idl
+++ b/dom/interfaces/css/nsIDOMCSSStyleDeclaration.idl
@@ -8,27 +8,34 @@
 /**
  * The nsIDOMCSSStyleDeclaration interface is a datatype for a CSS
  * style declaration in the Document Object Model.
  *
  * For more information on this interface please see
  * http://www.w3.org/TR/DOM-Level-2-Style
  */
 
+interface nsIPrincipal;
+
 [uuid(a6cf90be-15b3-11d2-932e-00805f8add32)]
 interface nsIDOMCSSStyleDeclaration : nsISupports
 {
-           attribute DOMString        cssText;
-                                        // raises(DOMException) on setting
+  %{C++
+  NS_IMETHOD GetCssText(nsAString& aCssText) = 0;
+  NS_IMETHOD SetCssText(const nsAString& aCssText,
+                        nsIPrincipal* aSubjectPrincipal = nullptr) = 0;
+  %}
 
   DOMString          getPropertyValue(in DOMString propertyName);
   nsIDOMCSSValue     getPropertyCSSValue(in DOMString propertyName);
   DOMString          removeProperty(in DOMString propertyName)
                                         raises(DOMException);
   DOMString          getPropertyPriority(in DOMString propertyName);
-  void               setProperty(in DOMString propertyName, 
-                                 in DOMString value, 
-                                 [optional] in DOMString priority)
-                                        raises(DOMException);
+  %{C++
+  NS_IMETHOD SetProperty(const nsAString& aPropertyName,
+                         const nsAString& aValue,
+                         const nsAString& aPriority,
+                         nsIPrincipal* aSubjectPrincipal = nullptr) = 0;
+  %}
   readonly attribute unsigned long    length;
   DOMString          item(in unsigned long index);
   readonly attribute nsIDOMCSSRule    parentRule;
 };
--- a/dom/webidl/CSSStyleDeclaration.webidl
+++ b/dom/webidl/CSSStyleDeclaration.webidl
@@ -3,27 +3,27 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * The origin of this IDL file is
  * http://dev.w3.org/csswg/cssom/
  */
 
 interface CSSStyleDeclaration {
-  [CEReactions, SetterThrows]
+  [CEReactions, NeedsSubjectPrincipal, SetterThrows]
   attribute DOMString cssText;
 
   readonly attribute unsigned long length;
   getter DOMString item(unsigned long index);
 
   [Throws]
   DOMString getPropertyValue(DOMString property);
   // Mozilla extension, sort of
   [Throws]
   CSSValue? getPropertyCSSValue(DOMString property);
   DOMString getPropertyPriority(DOMString property);
-  [CEReactions, Throws]
+  [CEReactions, NeedsSubjectPrincipal, Throws]
   void setProperty(DOMString property, [TreatNullAs=EmptyString] DOMString value, [TreatNullAs=EmptyString] optional DOMString priority = "");
   [CEReactions, Throws]
   DOMString removeProperty(DOMString property);
 
   readonly attribute CSSRule? parentRule;
 };
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -932,17 +932,18 @@ nsCSSFontFaceStyleDecl::GetCssTextImpl(n
       aCssText.AppendLiteral(": ");
       aCssText.Append(descStr);
       aCssText.AppendLiteral(";\n");
     }
   }
 }
 
 NS_IMETHODIMP
-nsCSSFontFaceStyleDecl::SetCssText(const nsAString & aCssText)
+nsCSSFontFaceStyleDecl::SetCssText(const nsAString& aCssText,
+                                   nsIPrincipal* aSubjectPrincipal)
 {
   return NS_ERROR_NOT_IMPLEMENTED; // bug 443978
 }
 
 NS_IMETHODIMP
 nsCSSFontFaceStyleDecl::GetPropertyValue(const nsAString & propertyName,
                                          nsAString & aResult)
 {
@@ -982,19 +983,20 @@ nsCSSFontFaceStyleDecl::GetPropertyPrior
                                             nsAString & aResult)
 {
   // font descriptors do not have priorities at present
   aResult.Truncate();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsCSSFontFaceStyleDecl::SetProperty(const nsAString & propertyName,
-                                    const nsAString & value,
-                                    const nsAString & priority)
+nsCSSFontFaceStyleDecl::SetProperty(const nsAString& propertyName,
+                                    const nsAString& value,
+                                    const nsAString& priority,
+                                    nsIPrincipal* aSubjectPrincipal)
 {
   // FIXME(heycam): If we are changing unicode-range, then a FontFace object
   // representing this rule must have its mUnicodeRange value invalidated.
 
   return NS_ERROR_NOT_IMPLEMENTED; // bug 443978
 }
 
 NS_IMETHODIMP
@@ -1054,20 +1056,21 @@ nsCSSFontFaceStyleDecl::GetPropertyValue
 {
   return
     GetPropertyValue(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aPropID)),
                      aValue);
 }
 
 NS_IMETHODIMP
 nsCSSFontFaceStyleDecl::SetPropertyValue(const nsCSSPropertyID aPropID,
-                                         const nsAString& aValue)
+                                         const nsAString& aValue,
+                                         nsIPrincipal* aSubjectPrincipal)
 {
   return SetProperty(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aPropID)),
-                     aValue, EmptyString());
+                     aValue, EmptyString(), aSubjectPrincipal);
 }
 
 nsINode*
 nsCSSFontFaceStyleDecl::GetParentObject()
 {
   return ContainingRule()->GetDocument();
 }
 
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -414,31 +414,33 @@ nsComputedDOMStyle::GetPropertyValue(con
   // this.
   return GetPropertyValue(
     NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(aPropID)),
     aValue);
 }
 
 NS_IMETHODIMP
 nsComputedDOMStyle::SetPropertyValue(const nsCSSPropertyID aPropID,
-                                     const nsAString& aValue)
+                                     const nsAString& aValue,
+                                     nsIPrincipal* aSubjectPrincipal)
 {
   return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
 }
 
 NS_IMETHODIMP
 nsComputedDOMStyle::GetCssText(nsAString& aCssText)
 {
   aCssText.Truncate();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComputedDOMStyle::SetCssText(const nsAString& aCssText)
+nsComputedDOMStyle::SetCssText(const nsAString& aCssText,
+                               nsIPrincipal* aSubjectPrincipal)
 {
   return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
 }
 
 NS_IMETHODIMP
 nsComputedDOMStyle::GetLength(uint32_t* aLength)
 {
   NS_PRECONDITION(aLength, "Null aLength!  Prepare to die!");
@@ -1191,17 +1193,18 @@ nsComputedDOMStyle::GetPropertyPriority(
   aReturn.Truncate();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsComputedDOMStyle::SetProperty(const nsAString& aPropertyName,
                                 const nsAString& aValue,
-                                const nsAString& aPriority)
+                                const nsAString& aPriority,
+                                nsIPrincipal* aSubjectPrincipal)
 {
   return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
 }
 
 NS_IMETHODIMP
 nsComputedDOMStyle::Item(uint32_t aIndex, nsAString& aReturn)
 {
   return nsDOMCSSDeclaration::Item(aIndex, aReturn);
--- a/layout/style/nsDOMCSSAttrDeclaration.cpp
+++ b/layout/style/nsDOMCSSAttrDeclaration.cpp
@@ -197,17 +197,18 @@ nsDOMCSSAttributeDeclaration::GetParentR
 /* virtual */ nsINode*
 nsDOMCSSAttributeDeclaration::GetParentObject()
 {
   return mElement;
 }
 
 NS_IMETHODIMP
 nsDOMCSSAttributeDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID,
-                                               const nsAString& aValue)
+                                               const nsAString& aValue,
+                                               nsIPrincipal* aSubjectPrincipal)
 {
   // Scripted modifications to style.opacity or style.transform
   // could immediately force us into the animated state if heuristics suggest
   // this is scripted animation.
   // FIXME: This is missing the margin shorthand and the logical versions of
   // the margin properties, see bug 1266287.
   if (aPropID == eCSSProperty_opacity || aPropID == eCSSProperty_transform ||
       aPropID == eCSSProperty_left || aPropID == eCSSProperty_top ||
@@ -215,10 +216,10 @@ nsDOMCSSAttributeDeclaration::SetPropert
       aPropID == eCSSProperty_background_position_x ||
       aPropID == eCSSProperty_background_position_y ||
       aPropID == eCSSProperty_background_position) {
     nsIFrame* frame = mElement->GetPrimaryFrame();
     if (frame) {
       ActiveLayerTracker::NotifyInlineStyleRuleModified(frame, aPropID, aValue, this);
     }
   }
-  return nsDOMCSSDeclaration::SetPropertyValue(aPropID, aValue);
+  return nsDOMCSSDeclaration::SetPropertyValue(aPropID, aValue, aSubjectPrincipal);
 }
--- a/layout/style/nsDOMCSSAttrDeclaration.h
+++ b/layout/style/nsDOMCSSAttrDeclaration.h
@@ -34,17 +34,18 @@ public:
   virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
   virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
   nsDOMCSSDeclaration::ServoCSSParsingEnvironment GetServoCSSParsingEnvironment() const final;
   NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
 
   virtual nsINode* GetParentObject() override;
 
   NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,
-                              const nsAString& aValue) override;
+                              const nsAString& aValue,
+                              nsIPrincipal* aSubjectPrincipal) override;
 
 protected:
   ~nsDOMCSSAttributeDeclaration();
 
   virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) override;
   virtual nsIDocument* DocToUpdate() override;
 
   RefPtr<Element> mElement;
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -49,17 +49,18 @@ nsDOMCSSDeclaration::GetPropertyValue(co
   if (DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read)) {
     decl->GetPropertyValueByID(aPropID, aValue);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID,
-                                      const nsAString& aValue)
+                                      const nsAString& aValue,
+                                      nsIPrincipal* aSubjectPrincipal)
 {
   switch (aPropID) {
     case eCSSProperty_background_position:
     case eCSSProperty_background_position_x:
     case eCSSProperty_background_position_y:
     case eCSSProperty_transform:
     case eCSSProperty_top:
     case eCSSProperty_left:
@@ -81,17 +82,17 @@ nsDOMCSSDeclaration::SetPropertyValue(co
   }
 
   if (aValue.IsEmpty()) {
     // If the new value of the property is an empty string we remove the
     // property.
     return RemovePropertyInternal(aPropID);
   }
 
-  return ParsePropertyValue(aPropID, aValue, false);
+  return ParsePropertyValue(aPropID, aValue, false, aSubjectPrincipal);
 }
 
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::GetCssText(nsAString& aCssText)
 {
   DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read);
   aCssText.Truncate();
@@ -99,17 +100,18 @@ nsDOMCSSDeclaration::GetCssText(nsAStrin
   if (decl) {
     decl->ToString(aCssText);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
+nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText,
+                                nsIPrincipal* aSubjectPrincipal)
 {
   // We don't need to *do* anything with the old declaration, but we need
   // to ensure that it exists, or else SetCSSDeclaration may crash.
   DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify);
   if (!olddecl) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
@@ -204,17 +206,18 @@ nsDOMCSSDeclaration::GetPropertyPriority
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::SetProperty(const nsAString& aPropertyName,
                                  const nsAString& aValue,
-                                 const nsAString& aPriority)
+                                 const nsAString& aPriority,
+                                 nsIPrincipal* aSubjectPrincipal)
 {
   if (aValue.IsEmpty()) {
     // If the new value of the property is an empty string we remove the
     // property.
     // XXX this ignores the priority string, should it?
     return RemovePropertyInternal(aPropertyName);
   }
 
@@ -231,19 +234,20 @@ nsDOMCSSDeclaration::SetProperty(const n
   } else if (aPriority.EqualsLiteral("important")) {
     important = true;
   } else {
     // XXX silent failure?
     return NS_OK;
   }
 
   if (propID == eCSSPropertyExtra_variable) {
-    return ParseCustomPropertyValue(aPropertyName, aValue, important);
+    return ParseCustomPropertyValue(aPropertyName, aValue, important,
+                                    aSubjectPrincipal);
   }
-  return ParsePropertyValue(propID, aValue, important);
+  return ParsePropertyValue(propID, aValue, important, aSubjectPrincipal);
 }
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName,
                                     nsAString& aReturn)
 {
   nsresult rv = GetPropertyValue(aPropertyName, aReturn);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -331,17 +335,18 @@ nsDOMCSSDeclaration::ModifyDeclaration(G
   }
 
   return SetCSSDeclaration(decl);
 }
 
 nsresult
 nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSPropertyID aPropID,
                                         const nsAString& aPropValue,
-                                        bool aIsImportant)
+                                        bool aIsImportant,
+                                        nsIPrincipal* aSubjectPrincipal)
 {
   return ModifyDeclaration(
     [&](css::Declaration* decl, CSSParsingEnvironment& env, bool* changed) {
       nsCSSParser cssParser(env.mCSSLoader);
       cssParser.ParseProperty(aPropID, aPropValue,
                               env.mSheetURI, env.mBaseURI, env.mPrincipal,
                               decl, changed, aIsImportant);
     },
@@ -351,17 +356,18 @@ nsDOMCSSDeclaration::ParsePropertyValue(
         decl->Raw(), aPropID, &value, aIsImportant, env.mUrlExtraData,
         ParsingMode::Default, env.mCompatMode, env.mLoader);
     });
 }
 
 nsresult
 nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
                                               const nsAString& aPropValue,
-                                              bool aIsImportant)
+                                              bool aIsImportant,
+                                              nsIPrincipal* aSubjectPrincipal)
 {
   MOZ_ASSERT(nsCSSProps::IsCustomPropertyName(aPropertyName));
   return ModifyDeclaration(
     [&](css::Declaration* decl, CSSParsingEnvironment& env, bool* changed) {
       nsCSSParser cssParser(env.mCSSLoader);
       auto propName = Substring(aPropertyName, CSS_CUSTOM_NAME_PREFIX_LENGTH);
       cssParser.ParseVariable(propName, aPropValue, env.mSheetURI,
                               env.mBaseURI, env.mPrincipal, decl,
--- a/layout/style/nsDOMCSSDeclaration.h
+++ b/layout/style/nsDOMCSSDeclaration.h
@@ -44,46 +44,51 @@ public:
   NS_IMETHOD_(MozExternalRefCountType) Release() override = 0;
 
   NS_DECL_NSICSSDECLARATION
   using nsICSSDeclaration::GetLength;
 
   // Require subclasses to implement |GetParentRule|.
   //NS_DECL_NSIDOMCSSSTYLEDECLARATION
   NS_IMETHOD GetCssText(nsAString & aCssText) override;
-  NS_IMETHOD SetCssText(const nsAString & aCssText) override;
+  NS_IMETHOD SetCssText(const nsAString & aCssText,
+                        nsIPrincipal* aSubjectPrincipal) override;
   NS_IMETHOD GetPropertyValue(const nsAString & propertyName,
                               nsAString & _retval) override;
   virtual already_AddRefed<mozilla::dom::CSSValue>
     GetPropertyCSSValue(const nsAString & propertyName,
                         mozilla::ErrorResult& aRv) override;
   using nsICSSDeclaration::GetPropertyCSSValue;
   NS_IMETHOD RemoveProperty(const nsAString & propertyName,
                             nsAString & _retval) override;
   NS_IMETHOD GetPropertyPriority(const nsAString & propertyName,
                                  nsAString & _retval) override;
-  NS_IMETHOD SetProperty(const nsAString & propertyName,
-                         const nsAString & value, const nsAString & priority) override;
+  NS_IMETHOD SetProperty(const nsAString& propertyName,
+                         const nsAString& value,
+                         const nsAString& priority,
+                         nsIPrincipal* aSubjectPrincipal) override;
   NS_IMETHOD GetLength(uint32_t *aLength) override;
   NS_IMETHOD GetParentRule(nsIDOMCSSRule * *aParentRule) override = 0;
 
   // WebIDL interface for CSS2Properties
 #define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_
 #define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_,          \
                  kwtable_, stylestruct_, stylestructoffset_, animtype_)      \
   void                                                                       \
-  Get##method_(nsAString& aValue, mozilla::ErrorResult& rv)                  \
+  Get##method_(nsAString& aValue, nsIPrincipal& aSubjectPrincipal,           \
+               mozilla::ErrorResult& rv)                                     \
   {                                                                          \
     rv = GetPropertyValue(eCSSProperty_##id_, aValue);                       \
   }                                                                          \
                                                                              \
   void                                                                       \
-  Set##method_(const nsAString& aValue, mozilla::ErrorResult& rv)            \
+  Set##method_(const nsAString& aValue, nsIPrincipal& aSubjectPrincipal,     \
+               mozilla::ErrorResult& rv)                                     \
   {                                                                          \
-    rv = SetPropertyValue(eCSSProperty_##id_, aValue);                       \
+    rv = SetPropertyValue(eCSSProperty_##id_, aValue, &aSubjectPrincipal);   \
   }
 
 #define CSS_PROP_LIST_EXCLUDE_INTERNAL
 #define CSS_PROP_LIST_INCLUDE_LOGICAL
 #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_)  \
   CSS_PROP(name_, id_, method_, flags_, pref_, X, X, X, X, X)
 #include "nsCSSPropList.h"
 
@@ -182,21 +187,23 @@ protected:
 
   // An implementation for GetServoCSSParsingEnvironment for callers wrapping
   // an css::Rule.
   static ServoCSSParsingEnvironment
     GetServoCSSParsingEnvironmentForRule(const mozilla::css::Rule* aRule);
 
   nsresult ParsePropertyValue(const nsCSSPropertyID aPropID,
                               const nsAString& aPropValue,
-                              bool aIsImportant);
+                              bool aIsImportant,
+                              nsIPrincipal* aSubjectPrincipal);
 
   nsresult ParseCustomPropertyValue(const nsAString& aPropertyName,
                                     const nsAString& aPropValue,
-                                    bool aIsImportant);
+                                    bool aIsImportant,
+                                    nsIPrincipal* aSubjectPrincipal);
 
   nsresult RemovePropertyInternal(nsCSSPropertyID aPropID);
   nsresult RemovePropertyInternal(const nsAString& aProperty);
 
 protected:
   virtual ~nsDOMCSSDeclaration();
 
 private:
--- a/layout/style/nsICSSDeclaration.h
+++ b/layout/style/nsICSSDeclaration.h
@@ -27,16 +27,17 @@
 #include "nsWrapperCache.h"
 #include "nsString.h"
 #include "nsIDOMCSSRule.h"
 #include "nsIDOMCSSValue.h"
 #include "mozilla/ErrorResult.h"
 #include "nsCOMPtr.h"
 
 class nsINode;
+class nsIPrincipal;
 
 // dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f
 #define NS_ICSSDECLARATION_IID \
 { 0xdbeabbfa, 0x6cb3, 0x4f5c, \
  { 0xae, 0xc2, 0xdd, 0x55, 0x8d, 0x9d, 0x68, 0x1f } }
 
 class nsICSSDeclaration : public nsIDOMCSSStyleDeclaration,
                           public nsWrapperCache
@@ -52,24 +53,26 @@ public:
                               nsAString& aValue) = 0;
 
   /**
    * Method analogous to nsIDOMCSSStyleDeclaration::SetProperty.  This
    * method does NOT allow setting a priority (the priority will
    * always be set to default priority).
    */
   NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,
-                              const nsAString& aValue) = 0;
+                              const nsAString& aValue,
+                              nsIPrincipal* aSubjectPrincipal = nullptr) = 0;
 
   virtual nsINode *GetParentObject() = 0;
 
   // Also have to declare all the nsIDOMCSSStyleDeclaration methods,
   // since we want to be able to call them from the WebIDL versions.
   NS_IMETHOD GetCssText(nsAString& aCssText) override = 0;
-  NS_IMETHOD SetCssText(const nsAString& aCssText) override = 0;
+  NS_IMETHOD SetCssText(const nsAString& aCssText,
+                        nsIPrincipal* aSubjectPrincipal = nullptr) override = 0;
   NS_IMETHOD GetPropertyValue(const nsAString& aPropName,
                               nsAString& aValue) override = 0;
   virtual already_AddRefed<mozilla::dom::CSSValue>
     GetPropertyCSSValue(const nsAString& aPropertyName,
                         mozilla::ErrorResult& aRv) = 0;
   NS_IMETHOD GetPropertyCSSValue(const nsAString& aProp, nsIDOMCSSValue** aVal) override
   {
     mozilla::ErrorResult error;
@@ -83,34 +86,36 @@ public:
     return NS_OK;
   }
   NS_IMETHOD RemoveProperty(const nsAString& aPropertyName,
                             nsAString& aReturn) override = 0;
   NS_IMETHOD GetPropertyPriority(const nsAString& aPropertyName,
                                  nsAString& aReturn) override = 0;
   NS_IMETHOD SetProperty(const nsAString& aPropertyName,
                          const nsAString& aValue,
-                         const nsAString& aPriority) override = 0;
+                         const nsAString& aPriority,
+                         nsIPrincipal* aSubjectPrincipal = nullptr) override = 0;
   NS_IMETHOD GetLength(uint32_t* aLength) override = 0;
   NS_IMETHOD Item(uint32_t aIndex, nsAString& aReturn) override
   {
     bool found;
     IndexedGetter(aIndex, found, aReturn);
     if (!found) {
       aReturn.Truncate();
     }
     return NS_OK;
   }
   NS_IMETHOD GetParentRule(nsIDOMCSSRule * *aParentRule) override = 0;
 
   // WebIDL interface for CSSStyleDeclaration
-  void SetCssText(const nsAString& aString, mozilla::ErrorResult& rv) {
-    rv = SetCssText(aString);
+  void SetCssText(const nsAString& aString, nsIPrincipal& aSubjectPrincipal,
+                  mozilla::ErrorResult& rv) {
+    rv = SetCssText(aString, &aSubjectPrincipal);
   }
-  void GetCssText(nsString& aString) {
+  void GetCssText(nsString& aString, nsIPrincipal& aSubjectPrincipal) {
     // Cast to nsAString& so we end up calling our virtual
     // |GetCssText(nsAString& aCssText)| overload, which does the real work.
     GetCssText(static_cast<nsAString&>(aString));
   }
   uint32_t Length() {
     uint32_t length;
     GetLength(&length);
     return length;
@@ -125,42 +130,48 @@ public:
   void GetPropertyValue(const nsAString& aPropName, nsString& aValue,
                         mozilla::ErrorResult& rv) {
     rv = GetPropertyValue(aPropName, aValue);
   }
   void GetPropertyPriority(const nsAString& aPropName, nsString& aPriority) {
     GetPropertyPriority(aPropName, static_cast<nsAString&>(aPriority));
   }
   void SetProperty(const nsAString& aPropName, const nsAString& aValue,
-                   const nsAString& aPriority, mozilla::ErrorResult& rv) {
-    rv = SetProperty(aPropName, aValue, aPriority);
+                   const nsAString& aPriority, nsIPrincipal& aSubjectPrincipal,
+                   mozilla::ErrorResult& rv) {
+    rv = SetProperty(aPropName, aValue, aPriority, &aSubjectPrincipal);
   }
   void RemoveProperty(const nsAString& aPropName, nsString& aRetval,
                       mozilla::ErrorResult& rv) {
     rv = RemoveProperty(aPropName, aRetval);
   }
   already_AddRefed<nsIDOMCSSRule> GetParentRule() {
     nsCOMPtr<nsIDOMCSSRule> rule;
     GetParentRule(getter_AddRefs(rule));
     return rule.forget();
   }
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration, NS_ICSSDECLARATION_IID)
 
 #define NS_DECL_NSICSSDECLARATION                                   \
-  NS_IMETHOD GetPropertyValue(const nsCSSPropertyID aPropID,          \
+  NS_IMETHOD GetPropertyValue(const nsCSSPropertyID aPropID,        \
                               nsAString& aValue) override;          \
-  NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,          \
-                              const nsAString& aValue) override;
+  NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,        \
+                              const nsAString& aValue,              \
+                              nsIPrincipal* aSubjectPrincipal = nullptr) override;
 
 #define NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER \
   NS_IMETHOD GetCssText(nsAString & aCssText) override; \
-  NS_IMETHOD SetCssText(const nsAString & aCssText) override; \
+  NS_IMETHOD SetCssText(const nsAString& aCssText,                 \
+                        nsIPrincipal* aSubjectPrincipal) override; \
   NS_IMETHOD GetPropertyValue(const nsAString & propertyName, nsAString & _retval) override; \
   NS_IMETHOD RemoveProperty(const nsAString & propertyName, nsAString & _retval) override; \
   NS_IMETHOD GetPropertyPriority(const nsAString & propertyName, nsAString & _retval) override; \
-  NS_IMETHOD SetProperty(const nsAString & propertyName, const nsAString & value, const nsAString & priority) override; \
+  NS_IMETHOD SetProperty(const nsAString& propertyName,                       \
+                         const nsAString& value,                              \
+                         const nsAString& priority,                           \
+                         nsIPrincipal* aSubjectPrincipal = nullptr) override; \
   NS_IMETHOD GetLength(uint32_t *aLength) override; \
   NS_IMETHOD Item(uint32_t index, nsAString & _retval) override; \
   NS_IMETHOD GetParentRule(nsIDOMCSSRule * *aParentRule) override;
 
 #endif // nsICSSDeclaration_h__