Bug 569719 part 1: Rename nsCSSDeclaration to mozilla::css::Declaration. r=dbaron
authorZack Weinberg <zweinberg@mozilla.com>
Mon, 28 Jun 2010 15:49:35 -0700
changeset 47936 e428d87c3a25fcb8fc32bc98a9ff6d13d4f2e187
parent 47935 7a697c59e0e4bca71dab8a16b012f8f5e487d00f
child 47937 6f14e67fbfcd29f15a36b8648f52484463ea075d
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs569719
milestone2.0b2pre
Bug 569719 part 1: Rename nsCSSDeclaration to mozilla::css::Declaration. r=dbaron
content/base/src/nsAttrValue.cpp
content/base/src/nsGenericElement.cpp
content/html/document/src/nsHTMLFragmentContentSink.cpp
content/smil/nsSMILCSSProperty.cpp
content/smil/nsSMILCSSProperty.h
content/smil/nsSMILCSSValueType.cpp
content/svg/content/src/nsSVGElement.cpp
content/xul/content/src/nsXULElement.cpp
layout/style/nsCSSDataBlock.h
layout/style/nsCSSDeclaration.cpp
layout/style/nsCSSDeclaration.h
layout/style/nsCSSParser.cpp
layout/style/nsCSSParser.h
layout/style/nsCSSPropList.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSStruct.h
layout/style/nsCSSStyleRule.cpp
layout/style/nsCSSStyleSheet.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
layout/style/nsDOMCSSAttrDeclaration.cpp
layout/style/nsDOMCSSAttrDeclaration.h
layout/style/nsDOMCSSDeclaration.cpp
layout/style/nsDOMCSSDeclaration.h
layout/style/nsICSSStyleRule.h
layout/style/nsStyleAnimation.cpp
layout/style/nsStyleAnimation.h
--- a/content/base/src/nsAttrValue.cpp
+++ b/content/base/src/nsAttrValue.cpp
@@ -51,16 +51,18 @@
 #include "nsTPtrArray.h"
 #include "nsContentUtils.h"
 #include "nsReadableUtils.h"
 #include "prprf.h"
 #ifdef MOZ_SVG
 #include "nsISVGValue.h"
 #endif
 
+namespace css = mozilla::css;
+
 #define MISC_STR_PTR(_cont) \
   reinterpret_cast<void*>((_cont)->mStringBits & NS_ATTRVALUE_POINTERVALUE_MASK)
 
 nsTPtrArray<const nsAttrValue::EnumTable>* nsAttrValue::sEnumTableArray = nsnull;
 
 nsAttrValue::nsAttrValue()
     : mBits(0)
 {
@@ -420,17 +422,17 @@ nsAttrValue::ToString(nsAString& aResult
       aResult = intStr + NS_LITERAL_STRING("%");
 
       break;
     }
     case eCSSStyleRule:
     {
       aResult.Truncate();
       MiscContainer *container = GetMiscContainer();
-      nsCSSDeclaration* decl = container->mCSSStyleRule->GetDeclaration();
+      css::Declaration *decl = container->mCSSStyleRule->GetDeclaration();
       if (decl) {
         decl->ToString(aResult);
       }
 
       break;
     }
 #ifdef MOZ_SVG
     case eSVGValue:
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -67,18 +67,16 @@
 #include "nsString.h"
 #include "nsUnicharUtils.h"
 #include "nsIEventStateManager.h"
 #include "nsIDOMEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsDOMCID.h"
 #include "nsIServiceManager.h"
 #include "nsIDOMCSSStyleDeclaration.h"
-#include "nsCSSDeclaration.h"
-#include "nsDOMCSSDeclaration.h"
 #include "nsDOMCSSAttrDeclaration.h"
 #include "nsINameSpaceManager.h"
 #include "nsContentList.h"
 #include "nsDOMTokenList.h"
 #include "nsDOMError.h"
 #include "nsDOMString.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIDOMMutationEvent.h"
@@ -88,17 +86,16 @@
 #ifdef MOZ_XUL
 #include "nsXULElement.h"
 #endif /* MOZ_XUL */
 #include "nsFrameManager.h"
 #include "nsFrameSelection.h"
 
 #include "nsBindingManager.h"
 #include "nsXBLBinding.h"
-#include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIDOMViewCSS.h"
 #include "nsIXBLService.h"
 #include "nsPIDOMWindow.h"
 #include "nsIBoxObject.h"
 #include "nsPIBoxObject.h"
 #include "nsIDOMNSDocument.h"
 #include "nsIDOMNSElement.h"
 #include "nsClientRect.h"
--- a/content/html/document/src/nsHTMLFragmentContentSink.cpp
+++ b/content/html/document/src/nsHTMLFragmentContentSink.cpp
@@ -72,16 +72,18 @@
 #include "nsICSSStyleRule.h"
 #include "nsUnicharInputStream.h"
 #include "nsCSSStyleSheet.h"
 #include "nsICSSRuleList.h"
 #include "nsCSSDeclaration.h"
 #include "nsCSSProperty.h"
 #include "nsIDOMCSSRule.h"
 
+namespace css = mozilla::css;
+
 //
 // XXX THIS IS TEMPORARY CODE
 // There's a considerable amount of copied code from the
 // regular nsHTMLContentSink. All of it will be factored
 // at some pointe really soon!
 //
 
 class nsHTMLFragmentContentSink : public nsIFragmentContentSink,
@@ -1210,17 +1212,17 @@ nsHTMLParanoidFragmentSink::CloseContain
 
   return nsHTMLFragmentContentSink::CloseContainer(aTag);
 }
 
 void
 nsHTMLParanoidFragmentSink::SanitizeStyleRule(nsICSSStyleRule *aRule, nsAutoString &aRuleText)
 {
   aRuleText.Truncate();
-  nsCSSDeclaration *style = aRule->GetDeclaration();
+  css::Declaration *style = aRule->GetDeclaration();
   if (style) {
     nsresult rv = style->RemoveProperty(eCSSProperty_binding);
     if (NS_SUCCEEDED(rv)) {
       style->ToString(aRuleText);
     }
   }
 }
 
--- a/content/smil/nsSMILCSSProperty.cpp
+++ b/content/smil/nsSMILCSSProperty.cpp
@@ -35,17 +35,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* representation of a SMIL-animatable CSS property on an element */
 
 #include "nsSMILCSSProperty.h"
 #include "nsSMILCSSValueType.h"
 #include "nsSMILValue.h"
-#include "nsCSSDeclaration.h"
 #include "nsComputedDOMStyle.h"
 #include "nsStyleAnimation.h"
 #include "nsIContent.h"
 #include "nsIDOMElement.h"
 
 using namespace mozilla::dom;
 
 // Helper function
--- a/content/smil/nsSMILCSSProperty.h
+++ b/content/smil/nsSMILCSSProperty.h
@@ -41,17 +41,16 @@
 #define NS_SMILCSSPROPERTY_H_
 
 #include "nsISMILAttr.h"
 #include "nsIAtom.h"
 #include "nsCSSProperty.h"
 #include "nsCSSValue.h"
 
 class nsIContent;
-class nsCSSDeclaration;
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 /**
--- a/content/smil/nsSMILCSSValueType.cpp
+++ b/content/smil/nsSMILCSSValueType.cpp
@@ -38,17 +38,16 @@
 /* representation of a value for a SMIL-animated CSS property */
 
 #include "nsSMILCSSValueType.h"
 #include "nsString.h"
 #include "nsStyleAnimation.h"
 #include "nsSMILParserUtils.h"
 #include "nsSMILValue.h"
 #include "nsCSSValue.h"
-#include "nsCSSDeclaration.h"
 #include "nsColor.h"
 #include "nsPresContext.h"
 #include "nsIContent.h"
 #include "nsDebug.h"
 
 /*static*/ nsSMILCSSValueType nsSMILCSSValueType::sSingleton;
 
 struct ValueWrapper {
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -1089,48 +1089,51 @@ nsSVGElement::DidModifySVGObservable(nsI
   nsAttrValue newValue(aObservable);
   return SetAttrAndNotify(attrName->NamespaceID(), attrName->LocalName(),
                           attrName->GetPrefix(), EmptyString(), newValue,
                           data.modType, hasListeners, PR_TRUE, nsnull);
 }
 
 //------------------------------------------------------------------------
 // Helper class: MappedAttrParser, for parsing values of mapped attributes
+
+namespace {
+
 class MappedAttrParser {
 public:
-  MappedAttrParser(mozilla::css::Loader* aLoader,
+  MappedAttrParser(css::Loader* aLoader,
                    nsIURI* aDocURI,
                    already_AddRefed<nsIURI> aBaseURI,
                    nsIPrincipal* aNodePrincipal);
   ~MappedAttrParser();
 
   // Parses a mapped attribute value.
   void ParseMappedAttrValue(nsIAtom* aMappedAttrName,
                             nsAString& aMappedAttrValue);
 
   // If we've parsed any values for mapped attributes, this method returns
   // a new already_AddRefed nsICSSStyleRule that incorporates the parsed
-  // values. Otherwise, this method returns null. 
+  // values. Otherwise, this method returns null.
   already_AddRefed<nsICSSStyleRule> CreateStyleRule();
 
 private:
   // MEMBER DATA
   // -----------
   nsCSSParser       mParser;
 
   // Arguments for nsCSSParser::ParseProperty
   nsIURI*           mDocURI;
   nsCOMPtr<nsIURI>  mBaseURI;
   nsIPrincipal*     mNodePrincipal;
 
   // Declaration for storing parsed values (lazily initialized)
-  nsCSSDeclaration* mDecl;
+  css::Declaration* mDecl;
 };
 
-MappedAttrParser::MappedAttrParser(mozilla::css::Loader* aLoader,
+MappedAttrParser::MappedAttrParser(css::Loader* aLoader,
                                    nsIURI* aDocURI,
                                    already_AddRefed<nsIURI> aBaseURI,
                                    nsIPrincipal* aNodePrincipal)
   : mParser(aLoader), mDocURI(aDocURI), mBaseURI(aBaseURI),
     mNodePrincipal(aNodePrincipal), mDecl(nsnull)
 {
   // mParser should successfully construct, now that we have infallible malloc.
   NS_ABORT_IF_FALSE(mParser, "parser failed to initialize?");
@@ -1153,18 +1156,17 @@ MappedAttrParser::~MappedAttrParser()
                     "into a style rule (and had its pointer cleared)");
 }
 
 void
 MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName,
                                        nsAString& aMappedAttrValue)
 {
   if (!mDecl) {
-    // Need to do lazy initializion of declaration.
-    mDecl = new nsCSSDeclaration();
+    mDecl = new css::Declaration();
     mDecl->InitializeEmpty();
   }
 
   // Get the nsCSSProperty ID for our mapped attribute.
   nsCSSProperty propertyID =
     nsCSSProps::LookupProperty(nsAtomString(aMappedAttrName));
   PRBool changed; // outparam for ParseProperty. (ignored)
   mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI,
@@ -1182,16 +1184,18 @@ MappedAttrParser::CreateStyleRule()
   if (NS_FAILED(NS_NewCSSStyleRule(getter_AddRefs(rule), nsnull, mDecl))) {
     NS_WARNING("could not create style rule from mapped attributes");
     mDecl->RuleAbort(); // deletes declaration
   }
   mDecl = nsnull; // We no longer own the declaration -- drop our pointer to it
   return rule.forget();
 }
 
+} // anonymous namespace
+
 //----------------------------------------------------------------------
 // Implementation Helpers:
 
 PRBool
 nsSVGElement::IsEventName(nsIAtom* aName)
 {
   return PR_FALSE;
 }
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -117,26 +117,24 @@
 #include "nsXULControllers.h"
 #include "nsIBoxObject.h"
 #include "nsPIBoxObject.h"
 #include "nsXULDocument.h"
 #include "nsXULPopupListener.h"
 #include "nsRuleWalker.h"
 #include "nsIDOMViewCSS.h"
 #include "nsIDOMCSSStyleDeclaration.h"
-#include "nsCSSDeclaration.h"
 #include "nsCSSParser.h"
 #include "nsIListBoxObject.h"
 #include "nsContentUtils.h"
 #include "nsContentList.h"
 #include "nsMutationEvent.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsDOMAttributeMap.h"
-#include "nsDOMCSSDeclaration.h"
 #include "nsGkAtoms.h"
 #include "nsXULContentUtils.h"
 #include "nsNodeUtils.h"
 #include "nsFrameLoader.h"
 #include "prlog.h"
 #include "rdf.h"
 #include "nsIDOM3EventTarget.h"
 #include "nsIDOMEventGroup.h"
--- a/layout/style/nsCSSDataBlock.h
+++ b/layout/style/nsCSSDataBlock.h
@@ -43,35 +43,39 @@
 #define nsCSSDataBlock_h__
 
 #include "nsCSSStruct.h"
 #include "nsCSSProps.h"
 #include "nsCSSPropertySet.h"
 #include "nsAutoPtr.h"
 
 struct nsRuleData;
+class nsCSSExpandedDataBlock;
 
-class nsCSSExpandedDataBlock;
-class nsCSSDeclaration;
+namespace mozilla {
+namespace css {
+class Declaration;
+}
+}
 
 /**
  * An |nsCSSCompressedDataBlock| holds a usually-immutable chunk of
  * property-value data for a CSS declaration block (which we misname a
- * |nsCSSDeclaration|).  Mutation is accomplished through
+ * |css::Declaration|).  Mutation is accomplished through
  * |nsCSSExpandedDataBlock| or in some cases via direct slot access.
  *
  * Mutation is forbidden when the reference count is greater than one,
  * since once a style rule has used a compressed data block, mutation of
  * that block is forbidden, and any declarations that want to mutate it
  * need to clone it first.
  */
 class nsCSSCompressedDataBlock {
 public:
     friend class nsCSSExpandedDataBlock;
-    friend class nsCSSDeclaration;
+    friend class mozilla::css::Declaration;
 
     /**
      * Do what |nsIStyleRule::MapRuleInfoInto| needs to do for a style
      * rule using this block for storage.
      */
     void MapRuleInfoInto(nsRuleData *aRuleData) const;
 
     /**
--- a/layout/style/nsCSSDeclaration.cpp
+++ b/layout/style/nsCSSDeclaration.cpp
@@ -55,56 +55,57 @@
 #include "nsCSSProps.h"
 #include "nsFont.h"
 #include "nsReadableUtils.h"
 #include "nsStyleUtil.h"
 #include "nsStyleConsts.h"
 #include "nsCOMPtr.h"
 #include "CSSCalc.h"
 
-namespace css = mozilla::css;
+namespace mozilla {
+namespace css {
 
-nsCSSDeclaration::nsCSSDeclaration() 
+Declaration::Declaration()
 {
   // check that we can fit all the CSS properties into a PRUint8
   // for the mOrder array - if not, might need to use PRUint16!
   PR_STATIC_ASSERT(eCSSProperty_COUNT_no_shorthands - 1 <= PR_UINT8_MAX);
 
-  MOZ_COUNT_CTOR(nsCSSDeclaration);
+  MOZ_COUNT_CTOR(mozilla::css::Declaration);
 }
 
-nsCSSDeclaration::nsCSSDeclaration(const nsCSSDeclaration& aCopy)
+Declaration::Declaration(const Declaration& aCopy)
   : mOrder(aCopy.mOrder),
     mData(aCopy.mData ? aCopy.mData->Clone()
                       : already_AddRefed<nsCSSCompressedDataBlock>(nsnull)),
     mImportantData(aCopy.mImportantData
                       ? aCopy.mImportantData->Clone()
                       : already_AddRefed<nsCSSCompressedDataBlock>(nsnull))
 {
-  MOZ_COUNT_CTOR(nsCSSDeclaration);
+  MOZ_COUNT_CTOR(mozilla::css::Declaration);
 }
 
-nsCSSDeclaration::~nsCSSDeclaration(void)
+Declaration::~Declaration()
 {
-  MOZ_COUNT_DTOR(nsCSSDeclaration);
+  MOZ_COUNT_DTOR(mozilla::css::Declaration);
 }
 
 nsresult
-nsCSSDeclaration::ValueAppended(nsCSSProperty aProperty)
+Declaration::ValueAppended(nsCSSProperty aProperty)
 {
   NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(aProperty),
                     "shorthands forbidden");
   // order IS important for CSS, so remove and add to the end
   mOrder.RemoveElement(aProperty);
   mOrder.AppendElement(aProperty);
   return NS_OK;
 }
 
 nsresult
-nsCSSDeclaration::RemoveProperty(nsCSSProperty aProperty)
+Declaration::RemoveProperty(nsCSSProperty aProperty)
 {
   nsCSSExpandedDataBlock data;
   ExpandTo(&data);
   NS_ASSERTION(!mData && !mImportantData, "Expand didn't null things out");
 
   if (nsCSSProps::IsShorthand(aProperty)) {
     CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
       data.ClearProperty(*p);
@@ -114,28 +115,29 @@ nsCSSDeclaration::RemoveProperty(nsCSSPr
     data.ClearProperty(aProperty);
     mOrder.RemoveElement(aProperty);
   }
 
   CompressFrom(&data);
   return NS_OK;
 }
 
-PRBool nsCSSDeclaration::AppendValueToString(nsCSSProperty aProperty, nsAString& aResult) const
+PRBool Declaration::AppendValueToString(nsCSSProperty aProperty,
+                                        nsAString& aResult) const
 {
   nsCSSCompressedDataBlock *data = GetValueIsImportant(aProperty)
                                       ? mImportantData : mData;
   const void *storage = data->StorageFor(aProperty);
-  return nsCSSDeclaration::AppendStorageToString(aProperty, storage, aResult);
+  return Declaration::AppendStorageToString(aProperty, storage, aResult);
 }
 
 /* static */ PRBool
-nsCSSDeclaration::AppendStorageToString(nsCSSProperty aProperty,
-                                        const void* aStorage,
-                                        nsAString& aResult)
+Declaration::AppendStorageToString(nsCSSProperty aProperty,
+                                   const void* aStorage,
+                                   nsAString& aResult)
 {
   if (aStorage) {
     switch (nsCSSProps::kTypeTable[aProperty]) {
       case eCSSType_Value: {
         const nsCSSValue *val = static_cast<const nsCSSValue*>(aStorage);
         AppendCSSValueToString(aProperty, *val, aResult);
       } break;
       case eCSSType_Rect: {
@@ -245,34 +247,34 @@ struct CSSValueSerializeCalcOps {
   {
     mResult.AppendASCII(aString);
   }
 
   void AppendLeafValue(const input_type& aValue)
   {
     NS_ABORT_IF_FALSE(aValue.GetUnit() == eCSSUnit_Percent ||
                       aValue.IsLengthUnit(), "unexpected unit");
-    nsCSSDeclaration::AppendCSSValueToString(mProperty, aValue, mResult);
+    Declaration::AppendCSSValueToString(mProperty, aValue, mResult);
   }
 
   void AppendNumber(const input_type& aValue)
   {
     NS_ABORT_IF_FALSE(aValue.GetUnit() == eCSSUnit_Number, "unexpected unit");
-    nsCSSDeclaration::AppendCSSValueToString(mProperty, aValue, mResult);
+    Declaration::AppendCSSValueToString(mProperty, aValue, mResult);
   }
 
 private:
   nsCSSProperty mProperty;
   nsAString &mResult;
 };
 
 /* static */ PRBool
-nsCSSDeclaration::AppendCSSValueToString(nsCSSProperty aProperty,
-                                         const nsCSSValue& aValue,
-                                         nsAString& aResult)
+Declaration::AppendCSSValueToString(nsCSSProperty aProperty,
+                                    const nsCSSValue& aValue,
+                                    nsAString& aResult)
 {
   nsCSSUnit unit = aValue.GetUnit();
 
   if (eCSSUnit_Null == unit) {
     return PR_FALSE;
   }
 
   if (eCSSUnit_String <= unit && unit <= eCSSUnit_Attr) {
@@ -616,18 +618,17 @@ nsCSSDeclaration::AppendCSSValueToString
     case eCSSUnit_Seconds:      aResult.Append(PRUnichar('s'));    break;
     case eCSSUnit_Milliseconds: aResult.AppendLiteral("ms");   break;
   }
 
   return PR_TRUE;
 }
 
 nsresult
-nsCSSDeclaration::GetValue(nsCSSProperty aProperty,
-                           nsAString& aValue) const
+Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
 {
   aValue.Truncate(0);
 
   // simple properties are easy.
   if (!nsCSSProps::IsShorthand(aProperty)) {
     AppendValueToString(aProperty, aValue);
     return NS_OK;
   }
@@ -1172,24 +1173,24 @@ nsCSSDeclaration::GetValue(nsCSSProperty
     default:
       NS_NOTREACHED("no other shorthands");
       break;
   }
   return NS_OK;
 }
 
 PRBool
-nsCSSDeclaration::GetValueIsImportant(const nsAString& aProperty) const
+Declaration::GetValueIsImportant(const nsAString& aProperty) const
 {
   nsCSSProperty propID = nsCSSProps::LookupProperty(aProperty);
   return GetValueIsImportant(propID);
 }
 
 PRBool
-nsCSSDeclaration::GetValueIsImportant(nsCSSProperty aProperty) const
+Declaration::GetValueIsImportant(nsCSSProperty aProperty) const
 {
   if (!mImportantData)
     return PR_FALSE;
 
   // Calling StorageFor is inefficient, but we can assume '!important'
   // is rare.
 
   if (nsCSSProps::IsShorthand(aProperty)) {
@@ -1204,28 +1205,28 @@ nsCSSDeclaration::GetValueIsImportant(ns
     }
     return PR_TRUE;
   }
 
   return mImportantData->StorageFor(aProperty) != nsnull;
 }
 
 /* static */ void
-nsCSSDeclaration::AppendImportanceToString(PRBool aIsImportant,
-                                           nsAString& aString)
+Declaration::AppendImportanceToString(PRBool aIsImportant,
+                                      nsAString& aString)
 {
   if (aIsImportant) {
    aString.AppendLiteral(" ! important");
   }
 }
 
 void
-nsCSSDeclaration::AppendPropertyAndValueToString(nsCSSProperty aProperty,
-                                                 nsAutoString& aValue,
-                                                 nsAString& aResult) const
+Declaration::AppendPropertyAndValueToString(nsCSSProperty aProperty,
+                                            nsAutoString& aValue,
+                                            nsAString& aResult) const
 {
   NS_ASSERTION(0 <= aProperty && aProperty < eCSSProperty_COUNT,
                "property enum out of range");
   NS_ASSERTION((aProperty < eCSSProperty_COUNT_no_shorthands) ==
                  aValue.IsEmpty(),
                "aValue should be given for shorthands but not longhands");
   AppendASCIItoUTF16(nsCSSProps::GetStringValue(aProperty), aResult);
   aResult.AppendLiteral(": ");
@@ -1234,17 +1235,17 @@ nsCSSDeclaration::AppendPropertyAndValue
   else
     aResult.Append(aValue);
   PRBool  isImportant = GetValueIsImportant(aProperty);
   AppendImportanceToString(isImportant, aResult);
   aResult.AppendLiteral("; ");
 }
 
 nsresult
-nsCSSDeclaration::ToString(nsAString& aString) const
+Declaration::ToString(nsAString& aString) const
 {
   nsCSSCompressedDataBlock *systemFontData =
     GetValueIsImportant(eCSSProperty__x_system_font) ? mImportantData : mData;
   const nsCSSValue *systemFont = 
     systemFontData->ValueStorageFor(eCSSProperty__x_system_font);
   const PRBool haveSystemFont = systemFont &&
                                 systemFont->GetUnit() != eCSSUnit_None &&
                                 systemFont->GetUnit() != eCSSUnit_Null;
@@ -1331,58 +1332,58 @@ nsCSSDeclaration::ToString(nsAString& aS
   if (! aString.IsEmpty()) {
     // if the string is not empty, we have a trailing whitespace we should remove
     aString.Truncate(aString.Length() - 1);
   }
   return NS_OK;
 }
 
 #ifdef DEBUG
-void nsCSSDeclaration::List(FILE* out, PRInt32 aIndent) const
+void Declaration::List(FILE* out, PRInt32 aIndent) const
 {
   for (PRInt32 index = aIndent; --index >= 0; ) fputs("  ", out);
 
   fputs("{ ", out);
   nsAutoString s;
   ToString(s);
   fputs(NS_ConvertUTF16toUTF8(s).get(), out);
   fputs("}", out);
 }
 #endif
 
 nsresult
-nsCSSDeclaration::GetNthProperty(PRUint32 aIndex, nsAString& aReturn) const
+Declaration::GetNthProperty(PRUint32 aIndex, nsAString& aReturn) const
 {
   aReturn.Truncate();
   if (aIndex < mOrder.Length()) {
     nsCSSProperty property = OrderValueAt(aIndex);
     if (0 <= property) {
       AppendASCIItoUTF16(nsCSSProps::GetStringValue(property), aReturn);
     }
   }
-  
+
   return NS_OK;
 }
 
-nsCSSDeclaration*
-nsCSSDeclaration::Clone() const
+Declaration*
+Declaration::Clone() const
 {
-  return new nsCSSDeclaration(*this);
+  return new Declaration(*this);
 }
 
 PRBool
-nsCSSDeclaration::InitializeEmpty()
+Declaration::InitializeEmpty()
 {
   NS_ASSERTION(!mData && !mImportantData, "already initialized");
   mData = nsCSSCompressedDataBlock::CreateEmptyBlock();
   return mData != nsnull;
 }
 
 PRBool
-nsCSSDeclaration::EnsureMutable()
+Declaration::EnsureMutable()
 {
   if (!mData->IsMutable()) {
     nsRefPtr<nsCSSCompressedDataBlock> newBlock = mData->Clone();
     if (!newBlock) {
       return PR_FALSE;
     }
     newBlock.swap(mData);
   }
@@ -1390,8 +1391,11 @@ nsCSSDeclaration::EnsureMutable()
     nsRefPtr<nsCSSCompressedDataBlock> newBlock = mImportantData->Clone();
     if (!newBlock) {
       return PR_FALSE;
     }
     newBlock.swap(mImportantData);
   }
   return PR_TRUE;
 }
+
+} // namespace mozilla::css
+} // namespace mozilla
--- a/layout/style/nsCSSDeclaration.h
+++ b/layout/style/nsCSSDeclaration.h
@@ -50,26 +50,32 @@
 #include "nsString.h"
 #include "nsCoord.h"
 #include "nsCSSValue.h"
 #include "nsCSSProps.h"
 #include "nsTArray.h"
 #include "nsCSSDataBlock.h"
 #include "nsCSSStruct.h"
 
-class nsCSSDeclaration {
+// must be forward-declared in root namespace
+class CSSStyleRuleImpl;
+
+namespace mozilla {
+namespace css {
+
+class Declaration {
 public:
   /**
-   * Construct an |nsCSSDeclaration| that is in an invalid state (null
+   * Construct an |Declaration| that is in an invalid state (null
    * |mData|) and cannot be used until its |CompressFrom| method or
    * |InitializeEmpty| method is called.
    */
-  nsCSSDeclaration();
+  Declaration();
 
-  nsCSSDeclaration(const nsCSSDeclaration& aCopy);
+  Declaration(const Declaration& aCopy);
 
   /**
    * |ValueAppended| must be called to maintain this declaration's
    * |mOrder| whenever a property is parsed into an expanded data block
    * for this declaration.  aProperty must not be a shorthand.
    */
   nsresult ValueAppended(nsCSSProperty aProperty);
 
@@ -77,23 +83,23 @@ public:
 
   nsresult GetValue(nsCSSProperty aProperty, nsAString& aValue) const;
 
   PRBool HasImportantData() const { return mImportantData != nsnull; }
   PRBool GetValueIsImportant(nsCSSProperty aProperty) const;
   PRBool GetValueIsImportant(const nsAString& aProperty) const;
 
   PRUint32 Count() const {
-    return mOrder.Length(); 
+    return mOrder.Length();
   }
   nsresult GetNthProperty(PRUint32 aIndex, nsAString& aReturn) const;
 
   nsresult ToString(nsAString& aString) const;
 
-  nsCSSDeclaration* Clone() const;
+  Declaration* Clone() const;
 
   nsCSSCompressedDataBlock* GetNormalBlock() const { return mData; }
   nsCSSCompressedDataBlock* GetImportantBlock() const { return mImportantData; }
 
   /**
    * Initialize this declaration as holding no data.  Return false on
    * out-of-memory.
    */
@@ -169,51 +175,51 @@ public:
     mData = nsnull;
     mImportantData = nsnull;
     mOrder.Clear();
   }
 
 #ifdef DEBUG
   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
-  
+
   // return whether there was a value in |aValue| (i.e., it had a non-null unit)
   static PRBool AppendCSSValueToString(nsCSSProperty aProperty,
                                        const nsCSSValue& aValue,
                                        nsAString& aResult);
 
   // return whether there was a value in |aStorage| (i.e., it was non-null)
   static PRBool AppendStorageToString(nsCSSProperty aProperty,
                                       const void* aStorage,
                                       nsAString& aResult);
 
 private:
   // Not implemented, and not supported.
-  nsCSSDeclaration& operator=(const nsCSSDeclaration& aCopy);
-  PRBool operator==(const nsCSSDeclaration& aCopy) const;
+  Declaration& operator=(const Declaration& aCopy);
+  PRBool operator==(const Declaration& aCopy) const;
 
   static void AppendImportanceToString(PRBool aIsImportant, nsAString& aString);
   // return whether there was a value in |aValue| (i.e., it had a non-null unit)
   PRBool   AppendValueToString(nsCSSProperty aProperty, nsAString& aResult) const;
   // Helper for ToString with strange semantics regarding aValue.
   void     AppendPropertyAndValueToString(nsCSSProperty aProperty,
                                           nsAutoString& aValue,
                                           nsAString& aResult) const;
 
 private:
     //
     // Specialized ref counting.
     // We do not want everyone to ref count us, only the rules which hold
     //  onto us (our well defined lifetime is when the last rule releases
     //  us).
-    // It's worth a comment here that the main nsCSSDeclaration is refcounted,
-    //  but it's |mImportant| is not refcounted, but just owned by the
-    //  non-important declaration.
+    // It's worth a comment here that the main css::Declaration is
+    //  refcounted, but its |mImportant| is not refcounted, just owned
+    //  by the non-important declaration.
     //
-    friend class CSSStyleRuleImpl;
+    friend class ::CSSStyleRuleImpl;
     void AddRef(void) {
       if (mRefCnt == PR_UINT32_MAX) {
         NS_WARNING("refcount overflow, leaking object");
         return;
       }
       ++mRefCnt;
     }
     void Release(void) {
@@ -228,26 +234,29 @@ private:
     }
 public:
     void RuleAbort(void) {
       NS_ASSERTION(0 == mRefCnt, "bad RuleAbort");
       delete this;
     }
 private:
   // Block everyone, except us or a derivative, from deleting us.
-  ~nsCSSDeclaration(void);
-    
+  ~Declaration();
+
   nsCSSProperty OrderValueAt(PRUint32 aValue) const {
     return nsCSSProperty(mOrder.ElementAt(aValue));
   }
 
 private:
     nsAutoTArray<PRUint8, 8> mOrder;
     nsAutoRefCnt mRefCnt;
 
     // never null, except while expanded
     nsRefPtr<nsCSSCompressedDataBlock> mData;
 
     // may be null
     nsRefPtr<nsCSSCompressedDataBlock> mImportantData;
 };
 
+} // namespace mozilla::css
+} // namespace mozilla
+
 #endif /* nsCSSDeclaration_h___ */
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -85,16 +85,18 @@
 #include "nsContentUtils.h"
 #include "nsDOMError.h"
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "prlog.h"
 #include "CSSCalc.h"
 #include "nsMediaFeatures.h"
 
+namespace css = mozilla::css;
+
 // Flags for ParseVariant method
 #define VARIANT_KEYWORD         0x000001  // K
 #define VARIANT_LENGTH          0x000002  // L
 #define VARIANT_PERCENT         0x000004  // P
 #define VARIANT_COLOR           0x000008  // C eCSSUnit_Color, eCSSUnit_Ident (e.g.  "red")
 #define VARIANT_URL             0x000010  // U
 #define VARIANT_NUMBER          0x000020  // N
 #define VARIANT_INTEGER         0x000040  // I
@@ -199,33 +201,33 @@ public:
                                nsIURI*           aBaseURL,
                                nsIPrincipal*     aNodePrincipal,
                                nsICSSStyleRule** aResult);
 
   nsresult ParseAndAppendDeclaration(const nsAString&  aBuffer,
                                      nsIURI*           aSheetURL,
                                      nsIURI*           aBaseURL,
                                      nsIPrincipal*     aSheetPrincipal,
-                                     nsCSSDeclaration* aDeclaration,
+                                     css::Declaration* aDeclaration,
                                      PRBool            aParseOnlyOneDecl,
                                      PRBool*           aChanged,
                                      PRBool            aClearOldDecl);
 
   nsresult ParseRule(const nsAString&        aRule,
                      nsIURI*                 aSheetURL,
                      nsIURI*                 aBaseURL,
                      nsIPrincipal*           aSheetPrincipal,
                      nsCOMArray<nsICSSRule>& aResult);
 
   nsresult ParseProperty(const nsCSSProperty aPropID,
                          const nsAString& aPropValue,
                          nsIURI* aSheetURL,
                          nsIURI* aBaseURL,
                          nsIPrincipal* aSheetPrincipal,
-                         nsCSSDeclaration* aDeclaration,
+                         css::Declaration* aDeclaration,
                          PRBool* aChanged,
                          PRBool aIsImportant);
 
   nsresult ParseMediaList(const nsSubstring& aBuffer,
                           nsIURI* aURL, // for error reporting
                           PRUint32 aLineNumber, // for error reporting
                           nsMediaList* aMediaList,
                           PRBool aHTMLMode);
@@ -395,38 +397,38 @@ protected:
 
   // If aStopChar is non-zero, the selector list is done when we hit
   // aStopChar.  Otherwise, it's done when we hit EOF.
   PRBool ParseSelectorList(nsCSSSelectorList*& aListHead,
                            PRUnichar aStopChar);
   PRBool ParseSelectorGroup(nsCSSSelectorList*& aListHead);
   PRBool ParseSelector(nsCSSSelectorList* aList, PRUnichar aPrevCombinator);
 
-  nsCSSDeclaration* ParseDeclarationBlock(PRBool aCheckForBraces);
-  PRBool ParseDeclaration(nsCSSDeclaration* aDeclaration,
+  css::Declaration* ParseDeclarationBlock(PRBool aCheckForBraces);
+  PRBool ParseDeclaration(css::Declaration* aDeclaration,
                           PRBool aCheckForBraces,
                           PRBool aMustCallValueAppended,
                           PRBool* aChanged);
   // After a parse error parsing |aPropID|, clear the data in
   // |mTempData|.
   void ClearTempData(nsCSSProperty aPropID);
   // After a successful parse of |aPropID|, transfer data from
   // |mTempData| to |mData|.  Set |*aChanged| to true if something
   // changed, but leave it unmodified otherwise.  If aMustCallValueAppended
   // is false, will not call ValueAppended on aDeclaration if the property
   // is already set in it.  If aOverrideImportant is true, new data will
   // replace old settings of the same properties, even if the old settings
   // are !important and the new data aren't.
-  void TransferTempData(nsCSSDeclaration* aDeclaration,
+  void TransferTempData(css::Declaration* aDeclaration,
                         nsCSSProperty aPropID,
                         PRBool aIsImportant,
                         PRBool aOverrideImportant,
                         PRBool aMustCallValueAppended,
                         PRBool* aChanged);
-  void DoTransferTempData(nsCSSDeclaration* aDeclaration,
+  void DoTransferTempData(css::Declaration* aDeclaration,
                           nsCSSProperty aPropID,
                           PRBool aIsImportant,
                           PRBool aOverrideImportant,
                           PRBool aMustCallValueAppended,
                           PRBool* aChanged);
   // Used to do a fast copy of a property value from source location to
   // destination location.  It's the caller's responsibility to make sure that
   // the source and destination locations point to the right kind of objects
@@ -998,17 +1000,17 @@ CSSParserImpl::ParseStyleAttribute(const
     haveBraces = eCSSToken_Symbol == mToken.mType &&
                  '{' == mToken.mSymbol;
     UngetToken();
   }
   else {
     haveBraces = PR_FALSE;
   }
 
-  nsCSSDeclaration* declaration = ParseDeclarationBlock(haveBraces);
+  css::Declaration* declaration = ParseDeclarationBlock(haveBraces);
   if (declaration) {
     // Create a style rule for the declaration
     nsICSSStyleRule* rule = nsnull;
     nsresult rv = NS_NewCSSStyleRule(&rule, nsnull, declaration);
     if (NS_FAILED(rv)) {
       declaration->RuleAbort();
       ReleaseScanner();
       return rv;
@@ -1025,17 +1027,17 @@ CSSParserImpl::ParseStyleAttribute(const
   return NS_OK;
 }
 
 nsresult
 CSSParserImpl::ParseAndAppendDeclaration(const nsAString&  aBuffer,
                                          nsIURI*           aSheetURI,
                                          nsIURI*           aBaseURI,
                                          nsIPrincipal*     aSheetPrincipal,
-                                         nsCSSDeclaration* aDeclaration,
+                                         css::Declaration* aDeclaration,
                                          PRBool            aParseOnlyOneDecl,
                                          PRBool*           aChanged,
                                          PRBool            aClearOldDecl)
 {
   NS_PRECONDITION(aSheetPrincipal, "Must have principal here!");
   AssertInitialState();
 
   *aChanged = PR_FALSE;
@@ -1109,17 +1111,17 @@ CSSParserImpl::ParseRule(const nsAString
 }
 
 nsresult
 CSSParserImpl::ParseProperty(const nsCSSProperty aPropID,
                              const nsAString& aPropValue,
                              nsIURI* aSheetURI,
                              nsIURI* aBaseURI,
                              nsIPrincipal* aSheetPrincipal,
-                             nsCSSDeclaration* aDeclaration,
+                             css::Declaration* aDeclaration,
                              PRBool* aChanged,
                              PRBool aIsImportant)
 {
   NS_PRECONDITION(aSheetPrincipal, "Must have principal here!");
   AssertInitialState();
 
   NS_ASSERTION(nsnull != aBaseURI, "need base URI");
   NS_ASSERTION(nsnull != aDeclaration, "Need declaration to parse into!");
@@ -2421,17 +2423,17 @@ CSSParserImpl::ParseRuleSet(RuleAppendFu
     OUTPUT_ERROR();
     SkipRuleSet(aInsideBraces);
     return PR_FALSE;
   }
   NS_ASSERTION(nsnull != slist, "null selector list");
   CLEAR_ERROR();
 
   // Next parse the declaration block
-  nsCSSDeclaration* declaration = ParseDeclarationBlock(PR_TRUE);
+  css::Declaration* declaration = ParseDeclarationBlock(PR_TRUE);
   if (nsnull == declaration) {
     // XXX skip something here
     delete slist;
     return PR_FALSE;
   }
 
 #if 0
   slist->Dump();
@@ -3542,27 +3544,27 @@ CSSParserImpl::ParseSelector(nsCSSSelect
     selector->mLowercaseTag.swap(pseudoElement);
     selector->mPseudoClassList = pseudoElementArgs.forget();
     selector->SetPseudoType(pseudoElementType);
   }
 
   return PR_TRUE;
 }
 
-nsCSSDeclaration*
+css::Declaration*
 CSSParserImpl::ParseDeclarationBlock(PRBool aCheckForBraces)
 {
   if (aCheckForBraces) {
     if (!ExpectSymbol('{', PR_TRUE)) {
       REPORT_UNEXPECTED_TOKEN(PEBadDeclBlockStart);
       OUTPUT_ERROR();
       return nsnull;
     }
   }
-  nsCSSDeclaration* declaration = new nsCSSDeclaration();
+  css::Declaration* declaration = new css::Declaration();
   mData.AssertInitialState();
   if (declaration) {
     for (;;) {
       PRBool changed;
       if (!ParseDeclaration(declaration, aCheckForBraces,
                             PR_TRUE, &changed)) {
         if (!SkipDeclaration(aCheckForBraces)) {
           break;
@@ -3944,17 +3946,17 @@ CSSParserImpl::ParseTreePseudoElement(ns
   fakeSelector.mPseudoClassList = nsnull;
   return PR_TRUE;
 }
 #endif
 
 //----------------------------------------------------------------------
 
 PRBool
-CSSParserImpl::ParseDeclaration(nsCSSDeclaration* aDeclaration,
+CSSParserImpl::ParseDeclaration(css::Declaration* aDeclaration,
                                 PRBool aCheckForBraces,
                                 PRBool aMustCallValueAppended,
                                 PRBool* aChanged)
 {
   mTempData.AssertInitialState();
 
   // Get property name
   nsCSSToken* tk = &mToken;
@@ -4094,17 +4096,17 @@ CSSParserImpl::ClearTempData(nsCSSProper
     }
   } else {
     mTempData.ClearProperty(aPropID);
   }
   mTempData.AssertInitialState();
 }
 
 void
-CSSParserImpl::TransferTempData(nsCSSDeclaration* aDeclaration,
+CSSParserImpl::TransferTempData(css::Declaration* aDeclaration,
                                 nsCSSProperty aPropID,
                                 PRBool aIsImportant,
                                 PRBool aOverrideImportant,
                                 PRBool aMustCallValueAppended,
                                 PRBool* aChanged)
 {
   if (nsCSSProps::IsShorthand(aPropID)) {
     CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID) {
@@ -4117,17 +4119,17 @@ CSSParserImpl::TransferTempData(nsCSSDec
   }
   mTempData.AssertInitialState();
 }
 
 // Perhaps the transferring code should be in nsCSSExpandedDataBlock, in
 // case some other caller wants to use it in the future (although I
 // can't think of why).
 void
-CSSParserImpl::DoTransferTempData(nsCSSDeclaration* aDeclaration,
+CSSParserImpl::DoTransferTempData(css::Declaration* aDeclaration,
                                   nsCSSProperty aPropID,
                                   PRBool aIsImportant,
                                   PRBool aOverrideImportant,
                                   PRBool aMustCallValueAppended,
                                   PRBool* aChanged)
 {
   NS_ASSERTION(mTempData.HasPropertyBit(aPropID), "oops");
   if (aIsImportant) {
@@ -9652,17 +9654,17 @@ nsCSSParser::ParseStyleAttribute(const n
                         aNodePrincipal, aResult);
 }
 
 nsresult
 nsCSSParser::ParseAndAppendDeclaration(const nsAString&  aBuffer,
                                        nsIURI*           aSheetURI,
                                        nsIURI*           aBaseURI,
                                        nsIPrincipal*     aSheetPrincipal,
-                                       nsCSSDeclaration* aDeclaration,
+                                       css::Declaration* aDeclaration,
                                        PRBool            aParseOnlyOneDecl,
                                        PRBool*           aChanged,
                                        PRBool            aClearOldDecl)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseAndAppendDeclaration(aBuffer, aSheetURI, aBaseURI, aSheetPrincipal,
                               aDeclaration, aParseOnlyOneDecl, aChanged,
                               aClearOldDecl);
@@ -9680,17 +9682,17 @@ nsCSSParser::ParseRule(const nsAString& 
 }
 
 nsresult
 nsCSSParser::ParseProperty(const nsCSSProperty aPropID,
                            const nsAString&    aPropValue,
                            nsIURI*             aSheetURI,
                            nsIURI*             aBaseURI,
                            nsIPrincipal*       aSheetPrincipal,
-                           nsCSSDeclaration*   aDeclaration,
+                           css::Declaration*   aDeclaration,
                            PRBool*             aChanged,
                            PRBool              aIsImportant)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseProperty(aPropID, aPropValue, aSheetURI, aBaseURI,
                   aSheetPrincipal, aDeclaration, aChanged, aIsImportant);
 }
 
--- a/layout/style/nsCSSParser.h
+++ b/layout/style/nsCSSParser.h
@@ -46,23 +46,23 @@
 #include "nsCOMArray.h"
 
 class nsICSSRule;
 class nsICSSStyleRule;
 class nsCSSStyleSheet;
 class nsIPrincipal;
 class nsIURI;
 class nsIUnicharInputStream;
-class nsCSSDeclaration;
 struct nsCSSSelectorList;
 class nsMediaList;
 
 namespace mozilla {
 namespace css {
-  class Loader;
+class Declaration;
+class Loader;
 }
 }
 
 // Interface to the css parser.
 
 class NS_STACK_CLASS nsCSSParser {
 public:
   nsCSSParser(mozilla::css::Loader* aLoader = nsnull,
@@ -129,33 +129,33 @@ public:
                                nsIURI*           aBaseURL,
                                nsIPrincipal*     aNodePrincipal,
                                nsICSSStyleRule** aResult);
 
   nsresult ParseAndAppendDeclaration(const nsAString&  aBuffer,
                                      nsIURI*           aSheetURL,
                                      nsIURI*           aBaseURL,
                                      nsIPrincipal*     aSheetPrincipal,
-                                     nsCSSDeclaration* aDeclaration,
+                                     mozilla::css::Declaration* aDeclaration,
                                      PRBool            aParseOnlyOneDecl,
                                      PRBool*           aChanged,
                                      PRBool            aClearOldDecl);
 
   nsresult ParseRule(const nsAString&        aRule,
                      nsIURI*                 aSheetURL,
                      nsIURI*                 aBaseURL,
                      nsIPrincipal*           aSheetPrincipal,
                      nsCOMArray<nsICSSRule>& aResult);
 
   nsresult ParseProperty(const nsCSSProperty aPropID,
                          const nsAString&    aPropValue,
                          nsIURI*             aSheetURL,
                          nsIURI*             aBaseURL,
                          nsIPrincipal*       aSheetPrincipal,
-                         nsCSSDeclaration*   aDeclaration,
+                         mozilla::css::Declaration* aDeclaration,
                          PRBool*             aChanged,
                          PRBool              aIsImportant);
 
   /**
    * Parse aBuffer into a media list |aMediaList|, which must be
    * non-null, replacing its current contents.  If aHTMLMode is true,
    * parse according to HTML rules, with commas as the most important
    * delimiter.  Otherwise, parse according to CSS rules, with
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -69,17 +69,17 @@
   4. 'flags', a bitfield containing CSS_PROPERTY_* flags.
 
   5. 'datastruct' says which nsRuleData* struct this property goes in.
 
   6. 'member' gives the name of the member variable in the nsRuleData
   struct.
 
   7. 'type' gives the |nsCSSType| of the data in the nsRuleData struct
-  and in the nsCSSDeclaration backend.
+  and in the css::Declaration backend.
 
   8. 'kwtable', which is either nsnull or the name of the appropriate
   keyword table member of class nsCSSProps, for use in
   nsCSSProps::LookupPropertyValue.
 
   9. 'stylestruct_' [used only for CSS_PROP, not CSS_PROP_*] gives the
   name of the style struct.  Can be used to make nsStyle##stylestruct_
   and eStyleStruct_##stylestruct_
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -68,16 +68,18 @@
 
 #include "nsContentUtils.h"
 #include "nsStyleConsts.h"
 #include "nsDOMError.h"
 #include "nsStyleUtil.h"
 #include "nsCSSDeclaration.h"
 #include "nsPrintfCString.h"
 
+namespace css = mozilla::css;
+
 #define IMPL_STYLE_RULE_INHERIT(_class, super) \
 /* virtual */ already_AddRefed<nsIStyleSheet> _class::GetStyleSheet() const { return super::GetStyleSheet(); }  \
 /* virtual */ void _class::SetStyleSheet(nsCSSStyleSheet* aSheet) { super::SetStyleSheet(aSheet); }  \
 /* virtual */ void _class::SetParentRule(nsICSSGroupRule* aRule) { super::SetParentRule(aRule); }  \
 nsIDOMCSSRule* _class::GetDOMRuleWeak(nsresult *aResult) { *aResult = NS_OK; return this; }  \
 /* virtual */ void _class::MapRuleInfoInto(nsRuleData* aRuleData) { }
 
 #define IMPL_STYLE_RULE_INHERIT2(_class, super) \
@@ -1617,27 +1619,27 @@ nsCSSFontFaceStyleDecl::GetPropertyValue
       // we know we have eCSSUnit_String
       NS_ASSERTION(val.GetUnit() == eCSSUnit_String, "unexpected unit");
       nsDependentString family(val.GetStringBufferValue());
       nsStyleUtil::AppendEscapedCSSString(family, aResult);
       return NS_OK;
     }
 
   case eCSSFontDesc_Style:
-    nsCSSDeclaration::AppendCSSValueToString(eCSSProperty_font_style, val,
+    css::Declaration::AppendCSSValueToString(eCSSProperty_font_style, val,
                                              aResult);
     return NS_OK;
 
   case eCSSFontDesc_Weight:
-    nsCSSDeclaration::AppendCSSValueToString(eCSSProperty_font_weight, val,
+    css::Declaration::AppendCSSValueToString(eCSSProperty_font_weight, val,
                                              aResult);
     return NS_OK;
     
   case eCSSFontDesc_Stretch:
-    nsCSSDeclaration::AppendCSSValueToString(eCSSProperty_font_stretch, val,
+    css::Declaration::AppendCSSValueToString(eCSSProperty_font_stretch, val,
                                              aResult);
     return NS_OK;
 
   case eCSSFontDesc_Src:
     AppendSerializedFontSrc(val, aResult);
     return NS_OK;
 
   case eCSSFontDesc_UnicodeRange:
--- a/layout/style/nsCSSStruct.h
+++ b/layout/style/nsCSSStruct.h
@@ -255,17 +255,17 @@ private:
 };
 
 /****************************************************************************/
 
 struct nsCSSStruct {
   // EMPTY on purpose.  ABSTRACT with no virtuals (typedef void nsCSSStruct?)
 };
 
-// We use the nsCSS* structures for storing nsCSSDeclaration's
+// We use the nsCSS* structures for storing css::Declaration's
 // *temporary* data during parsing and modification.  (They are too big
 // for permanent storage.)  We also use them for nsRuleData, with some
 // additions of things that the style system must cascade, but that
 // aren't CSS properties.  Thus we use typedefs and inheritance
 // (forwards, when the rule data needs extra data) to make the rule data
 // structs from the declaration structs.
 // NOTE:  For compilation speed, this typedef also appears in nsRuleNode.h
 typedef nsCSSStruct nsRuleDataStruct;
--- a/layout/style/nsCSSStyleRule.cpp
+++ b/layout/style/nsCSSStyleRule.cpp
@@ -77,16 +77,18 @@
 #include "nsTArray.h"
 
 #include "nsContentUtils.h"
 #include "nsContentErrors.h"
 #include "mozAutoDocUpdate.h"
 
 #include "prlog.h"
 
+namespace css = mozilla::css;
+
 #define NS_IF_CLONE(member_)                                                  \
   PR_BEGIN_MACRO                                                              \
     if (member_) {                                                            \
       result->member_ = member_->Clone();                                     \
       if (!result->member_) {                                                 \
         delete result;                                                        \
         return nsnull;                                                        \
       }                                                                       \
@@ -952,17 +954,17 @@ class DOMCSSStyleRuleImpl;
 class DOMCSSDeclarationImpl : public nsDOMCSSDeclaration
 {
 public:
   DOMCSSDeclarationImpl(nsICSSStyleRule *aRule);
   virtual ~DOMCSSDeclarationImpl(void);
 
   NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent);
   void DropReference(void);
-  virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
+  virtual nsresult GetCSSDeclaration(css::Declaration **aDecl,
                                      PRBool aAllocate);
   virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
                                             nsIURI** aBaseURI,
                                             nsIPrincipal** aSheetPrincipal,
                                             mozilla::css::Loader** aCSSLoader);
   virtual nsresult DeclarationChanged();
   virtual nsIDocument* DocToUpdate();
 
@@ -1042,17 +1044,17 @@ NS_IMPL_RELEASE_USING_AGGREGATOR(DOMCSSD
 
 void
 DOMCSSDeclarationImpl::DropReference(void)
 {
   mRule = nsnull;
 }
 
 nsresult
-DOMCSSDeclarationImpl::GetCSSDeclaration(nsCSSDeclaration **aDecl,
+DOMCSSDeclarationImpl::GetCSSDeclaration(css::Declaration **aDecl,
                                          PRBool aAllocate)
 {
   if (mRule) {
     *aDecl = mRule->GetDeclaration();
   }
   else {
     *aDecl = nsnull;
   }
@@ -1270,33 +1272,33 @@ DOMCSSStyleRuleImpl::GetCSSStyleRule(nsI
 
 // -- nsCSSStyleRule -------------------------------
 
 class CSSStyleRuleImpl : public nsCSSRule,
                          public nsICSSStyleRule
 {
 public:
   CSSStyleRuleImpl(nsCSSSelectorList* aSelector,
-                   nsCSSDeclaration *aDeclaration);
+                   css::Declaration *aDeclaration);
 private:
   // for |Clone|
   CSSStyleRuleImpl(const CSSStyleRuleImpl& aCopy); 
   // for |DeclarationChanged|
   CSSStyleRuleImpl(CSSStyleRuleImpl& aCopy,
-                   nsCSSDeclaration *aDeclaration); 
+                   css::Declaration *aDeclaration); 
 public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual nsCSSSelectorList* Selector(void);
 
   virtual PRUint32 GetLineNumber(void) const;
   virtual void SetLineNumber(PRUint32 aLineNumber);
 
-  virtual nsCSSDeclaration* GetDeclaration(void) const;
+  virtual css::Declaration* GetDeclaration(void) const;
 
   virtual nsIStyleRule* GetImportantRule(void);
   virtual void RuleMatched();
 
   virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const;
   virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
   
   virtual void SetParentRule(nsICSSGroupRule* aRule);
@@ -1327,28 +1329,28 @@ private:
   // These are not supported and are not implemented! 
   CSSStyleRuleImpl& operator=(const CSSStyleRuleImpl& aCopy); 
 
 protected:
   virtual ~CSSStyleRuleImpl(void);
 
 protected:
   nsCSSSelectorList*      mSelector; // null for style attribute
-  nsCSSDeclaration*       mDeclaration;
+  css::Declaration*       mDeclaration;
   nsRefPtr<nsCSSCompressedDataBlock> mNormalBlock;
   CSSImportantRule*       mImportantRule;
-  DOMCSSStyleRuleImpl*    mDOMRule;                          
+  DOMCSSStyleRuleImpl*    mDOMRule;
   PRUint32                mLineNumber;
 };
 
 CSSStyleRuleImpl::CSSStyleRuleImpl(nsCSSSelectorList* aSelector,
-                                   nsCSSDeclaration* aDeclaration)
+                                   css::Declaration* aDeclaration)
   : nsCSSRule(),
     mSelector(aSelector),
-    mDeclaration(aDeclaration), 
+    mDeclaration(aDeclaration),
     mImportantRule(nsnull),
     mDOMRule(nsnull),
     mLineNumber(0)
 {
   mDeclaration->AddRef();
 }
 
 // for |Clone|
@@ -1362,17 +1364,17 @@ CSSStyleRuleImpl::CSSStyleRuleImpl(const
 {
   if (mDeclaration)
     mDeclaration->AddRef();
   // rest is constructed lazily on existing data
 }
 
 // for |DeclarationChanged|
 CSSStyleRuleImpl::CSSStyleRuleImpl(CSSStyleRuleImpl& aCopy,
-                                   nsCSSDeclaration* aDeclaration)
+                                   css::Declaration* aDeclaration)
   : nsCSSRule(aCopy),
     mSelector(aCopy.mSelector),
     mDeclaration(aDeclaration),
     mImportantRule(nsnull),
     mDOMRule(aCopy.mDOMRule),
     mLineNumber(aCopy.mLineNumber)
 {
   // The DOM rule is replacing |aCopy| with |this|, so transfer
@@ -1436,17 +1438,17 @@ PRUint32 CSSStyleRuleImpl::GetLineNumber
   return mLineNumber;
 }
 
 void CSSStyleRuleImpl::SetLineNumber(PRUint32 aLineNumber)
 {
   mLineNumber = aLineNumber;
 }
 
-nsCSSDeclaration* CSSStyleRuleImpl::GetDeclaration(void) const
+css::Declaration* CSSStyleRuleImpl::GetDeclaration(void) const
 {
   return mDeclaration;
 }
 
 nsIStyleRule* CSSStyleRuleImpl::GetImportantRule(void)
 {
   return mImportantRule;
 }
@@ -1639,17 +1641,17 @@ CSSStyleRuleImpl::SetSelectorText(const 
   // XXX then need to re-compute the cascade
   // XXX and dirty sheet
   return NS_OK;
 }
 
 nsresult
 NS_NewCSSStyleRule(nsICSSStyleRule** aInstancePtrResult,
                    nsCSSSelectorList* aSelector,
-                   nsCSSDeclaration* aDeclaration)
+                   css::Declaration* aDeclaration)
 {
   NS_PRECONDITION(aDeclaration, "must have a declaration");
   CSSStyleRuleImpl *it = new CSSStyleRuleImpl(aSelector, aDeclaration);
   if (!it) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   NS_ADDREF(*aInstancePtrResult = it);
--- a/layout/style/nsCSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -407,42 +407,42 @@ nsMediaQuery::AppendToString(nsAString& 
 
     if (expr.mValue.GetUnit() != eCSSUnit_Null) {
       aString.AppendLiteral(": ");
       switch (feature->mValueType) {
         case nsMediaFeature::eLength:
           NS_ASSERTION(expr.mValue.IsLengthUnit(), "bad unit");
           // Use 'width' as a property that takes length values
           // written in the normal way.
-          nsCSSDeclaration::AppendCSSValueToString(eCSSProperty_width,
+          css::Declaration::AppendCSSValueToString(eCSSProperty_width,
                                                    expr.mValue, aString);
           break;
         case nsMediaFeature::eInteger:
         case nsMediaFeature::eBoolInteger:
           NS_ASSERTION(expr.mValue.GetUnit() == eCSSUnit_Integer,
                        "bad unit");
           // Use 'z-index' as a property that takes integer values
           // written without anything extra.
-          nsCSSDeclaration::AppendCSSValueToString(eCSSProperty_z_index,
+          css::Declaration::AppendCSSValueToString(eCSSProperty_z_index,
                                                    expr.mValue, aString);
           break;
         case nsMediaFeature::eIntRatio:
           {
             NS_ASSERTION(expr.mValue.GetUnit() == eCSSUnit_Array,
                          "bad unit");
             nsCSSValue::Array *array = expr.mValue.GetArrayValue();
             NS_ASSERTION(array->Count() == 2, "unexpected length");
             NS_ASSERTION(array->Item(0).GetUnit() == eCSSUnit_Integer,
                          "bad unit");
             NS_ASSERTION(array->Item(1).GetUnit() == eCSSUnit_Integer,
                          "bad unit");
-            nsCSSDeclaration::AppendCSSValueToString(eCSSProperty_z_index,
+            css::Declaration::AppendCSSValueToString(eCSSProperty_z_index,
                                                      array->Item(0), aString);
             aString.AppendLiteral("/");
-            nsCSSDeclaration::AppendCSSValueToString(eCSSProperty_z_index,
+            css::Declaration::AppendCSSValueToString(eCSSProperty_z_index,
                                                      array->Item(1), aString);
           }
           break;
         case nsMediaFeature::eResolution:
           {
             nsAutoString buffer;
             buffer.AppendFloat(expr.mValue.GetFloatValue());
             aString.Append(buffer);
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -406,17 +406,17 @@ nsComputedDOMStyle::GetPresShellForConte
 
   return currentDoc->GetShell();
 }
 
 // nsDOMCSSDeclaration abstract methods which should never be called
 // on a nsComputedDOMStyle object, but must be defined to avoid
 // compile errors.
 nsresult
-nsComputedDOMStyle::GetCSSDeclaration(nsCSSDeclaration**, PRBool)
+nsComputedDOMStyle::GetCSSDeclaration(css::Declaration**, PRBool)
 {
   NS_RUNTIMEABORT("called nsComputedDOMStyle::GetCSSDeclaration");
   return NS_ERROR_FAILURE;
 }
 
 nsresult
 nsComputedDOMStyle::DeclarationChanged()
 {
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -99,17 +99,17 @@ public:
   void SetExposeVisitedStyle(PRBool aExpose) {
     NS_ASSERTION(aExpose != mExposeVisitedStyle, "should always be changing");
     mExposeVisitedStyle = aExpose;
   }
 
   // nsDOMCSSDeclaration abstract methods which should never be called
   // on a nsComputedDOMStyle object, but must be defined to avoid
   // compile errors.
-  virtual nsresult GetCSSDeclaration(nsCSSDeclaration**, PRBool);
+  virtual nsresult GetCSSDeclaration(mozilla::css::Declaration**, PRBool);
   virtual nsresult DeclarationChanged();
   virtual nsIDocument* DocToUpdate();
   virtual nsresult GetCSSParsingEnvironment(nsIURI**, nsIURI**, nsIPrincipal**,
                                             mozilla::css::Loader**);
 
 private:
   void AssertFlushedPendingReflows() {
     NS_ASSERTION(mFlushedPendingReflows,
--- a/layout/style/nsDOMCSSAttrDeclaration.cpp
+++ b/layout/style/nsDOMCSSAttrDeclaration.cpp
@@ -46,16 +46,18 @@
 #include "nsIURI.h"
 #include "nsINameSpaceManager.h"
 #include "nsStyleConsts.h"
 #include "nsContentUtils.h"
 #include "nsIContent.h"
 #include "nsIPrincipal.h"
 #include "nsNodeUtils.h"
 
+namespace css = mozilla::css;
+
 nsDOMCSSAttributeDeclaration::nsDOMCSSAttributeDeclaration(nsIContent *aContent
 #ifdef MOZ_SMIL
                                                            , PRBool aIsSMILOverride
 #endif // MOZ_SMIL
                                                            )
   : mContent(aContent)
 #ifdef MOZ_SMIL
   , mIsSMILOverride(aIsSMILOverride)
@@ -122,47 +124,47 @@ nsDOMCSSAttributeDeclaration::DocToUpdat
   }
   
   // We need GetOwnerDoc() rather than GetCurrentDoc() because it might
   // be the BeginUpdate call that inserts mContent into the document.
   return mContent->GetOwnerDoc();
 }
 
 nsresult
-nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsCSSDeclaration **aDecl,
+nsDOMCSSAttributeDeclaration::GetCSSDeclaration(css::Declaration **aDecl,
                                                 PRBool aAllocate)
 {
   nsresult result = NS_OK;
 
   *aDecl = nsnull;
   if (mContent) {
     nsICSSStyleRule* cssRule =
 #ifdef MOZ_SMIL
       mIsSMILOverride ? mContent->GetSMILOverrideStyleRule() :
 #endif // MOZ_SMIL
       mContent->GetInlineStyleRule();
     if (cssRule) {
       *aDecl = cssRule->GetDeclaration();
     }
     else if (aAllocate) {
-      nsCSSDeclaration *decl = new nsCSSDeclaration();
+      css::Declaration *decl = new css::Declaration();
       if (!decl)
         return NS_ERROR_OUT_OF_MEMORY;
       if (!decl->InitializeEmpty()) {
         decl->RuleAbort();
         return NS_ERROR_OUT_OF_MEMORY;
       }
-      
+
       nsCOMPtr<nsICSSStyleRule> newRule;
       result = NS_NewCSSStyleRule(getter_AddRefs(newRule), nsnull, decl);
       if (NS_FAILED(result)) {
         decl->RuleAbort();
         return result;
       }
-        
+
       result =
 #ifdef MOZ_SMIL
         mIsSMILOverride ?
           mContent->SetSMILOverrideStyleRule(newRule, PR_FALSE) :
 #endif // MOZ_SMIL
           mContent->SetInlineStyleRule(newRule, PR_FALSE);
       if (NS_SUCCEEDED(result)) {
         *aDecl = decl;
--- a/layout/style/nsDOMCSSAttrDeclaration.h
+++ b/layout/style/nsDOMCSSAttrDeclaration.h
@@ -64,17 +64,17 @@ public:
   ~nsDOMCSSAttributeDeclaration();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMCSSAttributeDeclaration,
                                            nsICSSDeclaration)
 
   // If GetCSSDeclaration returns non-null, then the decl it returns
   // is owned by our current style rule.
-  virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
+  virtual nsresult GetCSSDeclaration(mozilla::css::Declaration **aDecl,
                                      PRBool aAllocate);
   virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
                                             nsIURI** aBaseURI,
                                             nsIPrincipal** aSheetPrincipal,
                                             mozilla::css::Loader** aCSSLoader);
   NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent);
 
   virtual nsINode *GetParentObject()
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -73,18 +73,18 @@ NS_INTERFACE_TABLE_HEAD(nsDOMCSSDeclarat
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::GetPropertyValue(const nsCSSProperty aPropID,
                                       nsAString& aValue)
 {
   NS_PRECONDITION(aPropID != eCSSProperty_UNKNOWN,
                   "Should never pass eCSSProperty_UNKNOWN around");
-  
-  nsCSSDeclaration *decl;
+
+  css::Declaration* decl;
   nsresult result = GetCSSDeclaration(&decl, PR_FALSE);
 
   aValue.Truncate();
   if (decl) {
     result = decl->GetValue(aPropID, aValue);
   }
 
   return result;
@@ -102,17 +102,17 @@ nsDOMCSSDeclaration::SetPropertyValue(co
 
   return ParsePropertyValue(aPropID, aValue, PR_FALSE);
 }
 
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::GetCssText(nsAString& aCssText)
 {
-  nsCSSDeclaration* decl;
+  css::Declaration* decl;
   aCssText.Truncate();
   GetCSSDeclaration(&decl, PR_FALSE);
 
   if (decl) {
     decl->ToString(aCssText);
   }
 
   return NS_OK;
@@ -122,19 +122,19 @@ NS_IMETHODIMP
 nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
 {
   return ParseDeclaration(aCssText, PR_FALSE, PR_TRUE);
 }
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::GetLength(PRUint32* aLength)
 {
-  nsCSSDeclaration *decl;
+  css::Declaration* decl;
   nsresult result = GetCSSDeclaration(&decl, PR_FALSE);
- 
+
   if (decl) {
     *aLength = decl->Count();
   } else {
     *aLength = 0;
   }
 
   return result;
 }
@@ -149,17 +149,17 @@ nsDOMCSSDeclaration::GetPropertyCSSValue
   *aReturn = nsnull;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::Item(PRUint32 aIndex, nsAString& aReturn)
 {
-  nsCSSDeclaration *decl;
+  css::Declaration* decl;
   nsresult result = GetCSSDeclaration(&decl, PR_FALSE);
 
   aReturn.SetLength(0);
   if (decl) {
     result = decl->GetNthProperty(aIndex, aReturn);
   }
 
   return result;
@@ -177,17 +177,17 @@ nsDOMCSSDeclaration::GetPropertyValue(co
   
   return GetPropertyValue(propID, aReturn);
 }
 
 NS_IMETHODIMP    
 nsDOMCSSDeclaration::GetPropertyPriority(const nsAString& aPropertyName, 
                                          nsAString& aReturn)
 {
-  nsCSSDeclaration *decl;
+  css::Declaration* decl;
   nsresult result = GetCSSDeclaration(&decl, PR_FALSE);
 
   aReturn.Truncate();
   if (decl && decl->GetValueIsImportant(aPropertyName)) {
     aReturn.AssignLiteral("important");    
   }
 
   return result;
@@ -240,17 +240,17 @@ nsDOMCSSDeclaration::RemoveProperty(cons
   return rv;
 }
 
 nsresult
 nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
                                         const nsAString& aPropValue,
                                         PRBool aIsImportant)
 {
-  nsCSSDeclaration* decl;
+  css::Declaration* decl;
   nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
   if (!decl) {
     return result;
   }
 
   nsRefPtr<css::Loader> cssLoader;
   nsCOMPtr<nsIURI> baseURI, sheetURI;
   nsCOMPtr<nsIPrincipal> sheetPrincipal;
@@ -282,17 +282,17 @@ nsDOMCSSDeclaration::ParsePropertyValue(
   return result;
 }
 
 nsresult
 nsDOMCSSDeclaration::ParseDeclaration(const nsAString& aDecl,
                                       PRBool aParseOnlyOneDecl,
                                       PRBool aClearOldDecl)
 {
-  nsCSSDeclaration* decl;
+  css::Declaration* decl;
   nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
   if (!decl) {
     return result;
   }
 
   nsRefPtr<css::Loader> cssLoader;
   nsCOMPtr<nsIURI> baseURI, sheetURI;
   nsCOMPtr<nsIPrincipal> sheetPrincipal;
@@ -326,17 +326,17 @@ nsDOMCSSDeclaration::ParseDeclaration(co
   }
 
   return result;
 }
 
 nsresult
 nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
 {
-  nsCSSDeclaration* decl;
+  css::Declaration* decl;
   nsresult rv = GetCSSDeclaration(&decl, PR_FALSE);
   if (!decl) {
     return rv;
   }
 
   // For nsDOMCSSAttributeDeclaration, DeclarationChanged will lead to
   // Attribute setting code, which leads in turn to BeginUpdate.  We
   // need to start the update now so that the old rule doesn't get used
--- a/layout/style/nsDOMCSSDeclaration.h
+++ b/layout/style/nsDOMCSSDeclaration.h
@@ -39,24 +39,24 @@
 
 #ifndef nsDOMCSSDeclaration_h___
 #define nsDOMCSSDeclaration_h___
 
 #include "nsICSSDeclaration.h"
 #include "nsIDOMNSCSS2Properties.h"
 #include "nsCOMPtr.h"
 
-class nsCSSDeclaration;
 class nsCSSParser;
 class nsIURI;
 class nsIPrincipal;
 class nsIDocument;
 
 namespace mozilla {
 namespace css {
+class Declaration;
 class Loader;
 }
 }
 
 class nsDOMCSSDeclaration : public nsICSSDeclaration,
                             public nsIDOMNSCSS2Properties
 {
 public:
@@ -89,17 +89,17 @@ public:
   NS_DECL_NSIDOMCSS2PROPERTIES
   NS_DECL_NSIDOMSVGCSS2PROPERTIES
   NS_DECL_NSIDOMNSCSS2PROPERTIES
 
 protected:
   // Always fills in the out parameter, even on failure, and if the out
   // parameter is null the nsresult will be the correct thing to
   // propagate.
-  virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
+  virtual nsresult GetCSSDeclaration(mozilla::css::Declaration **aDecl,
                                      PRBool aAllocate) = 0;
   virtual nsresult DeclarationChanged() = 0;
   // Document that we must call BeginUpdate/EndUpdate on around the
   // calls to DeclarationChanged and the style rule mutation that leads
   // to it.
   virtual nsIDocument* DocToUpdate() = 0;
 
   // This will only fail if it can't get a parser or a principal.
--- a/layout/style/nsICSSStyleRule.h
+++ b/layout/style/nsICSSStyleRule.h
@@ -49,20 +49,25 @@
 #include "nsICSSRule.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsCSSValue.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCSSPseudoClasses.h"
 
 class nsIAtom;
-class nsCSSDeclaration;
 class nsCSSStyleSheet;
 struct nsCSSSelectorList;
 
+namespace mozilla {
+namespace css {
+class Declaration;
+}
+}
+
 struct nsAtomList {
 public:
   nsAtomList(nsIAtom* aAtom);
   nsAtomList(const nsString& aAtomValue);
   ~nsAtomList(void);
 
   /** Do a deep clone.  Should be used only on the first in the linked list. */
   nsAtomList* Clone() const { return Clone(PR_TRUE); }
@@ -298,23 +303,23 @@ public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_STYLE_RULE_IID)
 
   // null for style attribute
   virtual nsCSSSelectorList* Selector(void) = 0;
 
   virtual PRUint32 GetLineNumber(void) const = 0;
   virtual void SetLineNumber(PRUint32 aLineNumber) = 0;
 
-  virtual nsCSSDeclaration* GetDeclaration(void) const = 0;
+  virtual mozilla::css::Declaration* GetDeclaration(void) const = 0;
 
   /**
    * Return a new |nsIStyleRule| instance that replaces the current one,
-   * due to a change in the |nsCSSDeclaration|.  Due to the
-   * |nsIStyleRule| contract of immutability, this must be called if the
-   * declaration is modified.
+   * due to a change in the declaration.  Due to the |nsIStyleRule|
+   * contract of immutability, this must be called if the declaration
+   * is modified.
    *
    * |DeclarationChanged| handles replacing the object in the container
    * sheet or group rule if |aHandleContainer| is true.
    */
   virtual already_AddRefed<nsICSSStyleRule>
     DeclarationChanged(PRBool aHandleContainer) = 0;
 
   /**
@@ -332,11 +337,11 @@ public:
   virtual nsresult SetSelectorText(const nsAString& aSelectorText) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSStyleRule, NS_ICSS_STYLE_RULE_IID)
 
 nsresult
 NS_NewCSSStyleRule(nsICSSStyleRule** aInstancePtrResult,
                    nsCSSSelectorList* aSelector,
-                   nsCSSDeclaration* aDeclaration);
+                   mozilla::css::Declaration* aDeclaration);
 
 #endif /* nsICSSStyleRule_h___ */
--- a/layout/style/nsStyleAnimation.cpp
+++ b/layout/style/nsStyleAnimation.cpp
@@ -43,22 +43,23 @@
 #include "nsCOMArray.h"
 #include "nsIStyleRule.h"
 #include "nsICSSStyleRule.h"
 #include "nsString.h"
 #include "nsStyleContext.h"
 #include "nsStyleSet.h"
 #include "nsComputedDOMStyle.h"
 #include "nsCSSParser.h"
-#include "nsCSSDataBlock.h"
 #include "nsCSSDeclaration.h"
 #include "nsCSSStruct.h"
 #include "prlog.h"
 #include <math.h>
 
+namespace css = mozilla::css;
+
 // HELPER METHODS
 // --------------
 /*
  * Given two units, this method returns a common unit that they can both be
  * converted into, if possible.  This is intended to facilitate
  * interpolation, distance-computation, and addition between "similar" units.
  *
  * The ordering of the arguments should not affect the output of this method.
@@ -1603,21 +1604,17 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
 
 already_AddRefed<nsICSSStyleRule>
 BuildStyleRule(nsCSSProperty aProperty,
                nsIContent* aTargetElement,
                const nsAString& aSpecifiedValue,
                PRBool aUseSVGMode)
 {
   // Set up an empty CSS Declaration
-  nsCSSDeclaration* declaration = new nsCSSDeclaration();
-  if (!declaration) {
-    NS_WARNING("Failed to allocate nsCSSDeclaration");
-    return nsnull;
-  }
+  css::Declaration* declaration = new css::Declaration();
 
   PRBool changed; // ignored, but needed as outparam for ParseProperty
   nsIDocument* doc = aTargetElement->GetOwnerDoc();
   nsCOMPtr<nsIURI> baseURI = aTargetElement->GetBaseURI();
   nsCOMPtr<nsICSSStyleRule> styleRule;
   nsCSSParser parser(doc->CSSLoader());
 
   if (aUseSVGMode) {
@@ -1897,17 +1894,17 @@ nsStyleAnimation::UncomputeValue(nsCSSPr
       break;
   }
 
   nsCSSValue value;
   if (!nsStyleAnimation::UncomputeValue(aProperty, aPresContext,
                                         aComputedValue, storage)) {
     return PR_FALSE;
   }
-  return nsCSSDeclaration::AppendStorageToString(aProperty, storage,
+  return css::Declaration::AppendStorageToString(aProperty, storage,
                                                  aSpecifiedValue);
 }
 
 inline const void*
 StyleDataAtOffset(const void* aStyleStruct, ptrdiff_t aOffset)
 {
   return reinterpret_cast<const char*>(aStyleStruct) + aOffset;
 }
--- a/layout/style/nsStyleAnimation.h
+++ b/layout/style/nsStyleAnimation.h
@@ -45,17 +45,16 @@
 #include "prtypes.h"
 #include "nsAString.h"
 #include "nsCRTGlue.h"
 #include "nsStringBuffer.h"
 #include "nsCSSProperty.h"
 #include "nsCoord.h"
 #include "nsColor.h"
 
-class nsCSSDeclaration;
 class nsIContent;
 class nsPresContext;
 class nsStyleContext;
 struct nsCSSValueList;
 struct nsCSSValuePair;
 struct nsCSSValuePairList;
 struct nsCSSRect;