diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp
index 858044ead06..b06e020bcaf 100644
--- a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp
+++ b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp
@@ -42,6 +42,7 @@
#include "nsComputedDOMStyle.h"
#include "nsDOMError.h"
+#include "nsIDOMCSS2Properties.h"
#include "nsIDOMElement.h"
#include "nsIStyleContext.h"
#include "nsIScrollableFrame.h"
@@ -293,7 +294,7 @@ NS_NewComputedDOMStyle(nsIComputedDOMStyle** aComputedStyle)
}
nsComputedDOMStyle::nsComputedDOMStyle()
- : mPresShellWeak(nsnull), mT2P(0.0f)
+ : mInner(nsnull), mPresShellWeak(nsnull), mT2P(0.0f)
{
NS_INIT_ISUPPORTS();
}
@@ -315,15 +316,55 @@ nsComputedDOMStyle::Shutdown()
}
-// QueryInterface implementation for nsComputedDOMStyle
-NS_INTERFACE_MAP_BEGIN(nsComputedDOMStyle)
- NS_INTERFACE_MAP_ENTRY(nsIComputedDOMStyle)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSS2Properties)
- NS_INTERFACE_MAP_ENTRY(nsIDOMNSCSS2Properties)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIComputedDOMStyle)
- NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ComputedCSSStyleDeclaration)
-NS_INTERFACE_MAP_END
+NS_IMETHODIMP
+nsComputedDOMStyle::QueryInterface(REFNSIID aIID, void** aInstancePtr)
+{
+ if (!aInstancePtr) {
+ NS_ERROR("QueryInterface requires a non-NULL destination!");
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ nsISupports* inst;
+
+ if (aIID.Equals(NS_GET_IID(nsIComputedDOMStyle))) {
+ inst = NS_STATIC_CAST(nsIComputedDOMStyle*, this);
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMCSSStyleDeclaration))) {
+ inst = NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, this);
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMCSS2Properties))) {
+ if (!mInner) {
+ mInner = new CSS2PropertiesTearoff(this);
+ NS_ENSURE_TRUE(mInner, NS_ERROR_OUT_OF_MEMORY);
+ }
+ inst = NS_STATIC_CAST(nsIDOMCSS2Properties*,
+ NS_STATIC_CAST(nsISupports*, mInner));
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMNSCSS2Properties))) {
+ if (!mInner) {
+ mInner = new CSS2PropertiesTearoff(this);
+ NS_ENSURE_TRUE(mInner, NS_ERROR_OUT_OF_MEMORY);
+ }
+ inst = NS_STATIC_CAST(nsIDOMNSCSS2Properties*,
+ NS_STATIC_CAST(nsISupports*, mInner));
+ } else if (aIID.Equals(NS_GET_IID(nsISupports))) {
+ inst = NS_STATIC_CAST(nsISupports*,
+ NS_STATIC_CAST(nsIComputedDOMStyle*, this));
+ } else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
+ inst = nsContentUtils::GetClassInfoInstance(eDOMClassInfo_ComputedCSSStyleDeclaration_id);
+ NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
+ } else {
+ inst = nsnull;
+ }
+
+ nsresult rv;
+ if (!inst) {
+ rv = NS_NOINTERFACE;
+ } else {
+ NS_ADDREF(inst);
+ rv = NS_OK;
+ }
+
+ *aInstancePtr = inst;
+ return rv;
+}
static void doDestroyComputedDOMStyle(nsComputedDOMStyle *aComputedStyle)
@@ -3792,27 +3833,3 @@ nsComputedDOMStyle::GetBorderStyleFor(PRUint8 aSide, nsIFrame *aFrame,
return CallQueryInterface(val, aValue);
}
-
-// nsIDOMCSS2Properties
-
-#define CSS_PROP(name_, id_, method_, hint_) \
- NS_IMETHODIMP \
- nsComputedDOMStyle::Get##method_(nsAString& aValue) \
- { \
- return GetPropertyValue(NS_LITERAL_STRING(#name_), aValue); \
- } \
- \
- NS_IMETHODIMP \
- nsComputedDOMStyle::Set##method_(const nsAString& aValue) \
- { \
- return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; \
- }
-
-#define CSS_PROP_INTERNAL(name_, id_, method_, hint_) /* nothing */
-#define CSS_PROP_NOTIMPLEMENTED(name_, id_, method_, hint_) \
- CSS_PROP(name_, id_, method_, hint_)
-
-#include "nsCSSPropList.h"
-
-#undef CSS_PROP_INTERNAL
-#undef CSS_PROP
diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.h b/mozilla/content/html/style/src/nsComputedDOMStyle.h
index 2e607f2c0d3..d9f5b291fdf 100644
--- a/mozilla/content/html/style/src/nsComputedDOMStyle.h
+++ b/mozilla/content/html/style/src/nsComputedDOMStyle.h
@@ -41,9 +41,9 @@
#define nsComputedDOMStyle_h__
#include "nsIComputedDOMStyle.h"
-#include "nsIDOMCSS2Properties.h"
#include "nsROCSSPrimitiveValue.h"
+#include "nsDOMCSSDeclaration.h"
#include "nsDOMCSSRGBColor.h"
#include "nsDOMCSSValueList.h"
@@ -53,8 +53,7 @@
#include "nsCOMPtr.h"
#include "nsWeakReference.h"
-class nsComputedDOMStyle : public nsIComputedDOMStyle,
- public nsIDOMNSCSS2Properties
+class nsComputedDOMStyle : public nsIComputedDOMStyle
{
public:
NS_DECL_ISUPPORTS
@@ -63,9 +62,6 @@ public:
const nsAString& aPseudoElt,
nsIPresShell *aPresShell);
- NS_DECL_NSIDOMCSS2PROPERTIES
- NS_DECL_NSIDOMNSCSS2PROPERTIES
-
NS_DECL_NSIDOMCSSSTYLEDECLARATION
nsComputedDOMStyle();
@@ -280,6 +276,8 @@ private:
nsDOMCSSValueList* GetROCSSValueList(PRBool aCommaDelimited);
nsDOMCSSRGBColor* GetDOMCSSRGBColor(nscolor aColor);
+ nsCOMPtr mInner; // CSS2Properties
+
nsWeakPtr mPresShellWeak;
nsCOMPtr mContent;
diff --git a/mozilla/content/html/style/src/nsDOMCSSDeclaration.cpp b/mozilla/content/html/style/src/nsDOMCSSDeclaration.cpp
index 8efa0d5a4ed..4a388c18804 100644
--- a/mozilla/content/html/style/src/nsDOMCSSDeclaration.cpp
+++ b/mozilla/content/html/style/src/nsDOMCSSDeclaration.cpp
@@ -49,6 +49,7 @@
nsDOMCSSDeclaration::nsDOMCSSDeclaration()
+ : mInner(nsnull)
{
NS_INIT_ISUPPORTS();
}
@@ -58,14 +59,53 @@ nsDOMCSSDeclaration::~nsDOMCSSDeclaration()
}
-// QueryInterface implementation for CSSStyleSheetImpl
-NS_INTERFACE_MAP_BEGIN(nsDOMCSSDeclaration)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSS2Properties)
- NS_INTERFACE_MAP_ENTRY(nsIDOMNSCSS2Properties)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCSS2Properties)
- NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CSSStyleDeclaration)
-NS_INTERFACE_MAP_END
+NS_IMETHODIMP
+nsDOMCSSDeclaration::QueryInterface(REFNSIID aIID, void** aInstancePtr)
+{
+ if (!aInstancePtr) {
+ NS_ERROR("QueryInterface requires a non-NULL destination!");
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ nsISupports* inst;
+
+ if (aIID.Equals(NS_GET_IID(nsIDOMCSSStyleDeclaration))) {
+ inst = NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, this);
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMCSS2Properties))) {
+ if (!mInner) {
+ mInner = new CSS2PropertiesTearoff(this);
+ NS_ENSURE_TRUE(mInner, NS_ERROR_OUT_OF_MEMORY);
+ }
+ inst = NS_STATIC_CAST(nsIDOMCSS2Properties*,
+ NS_STATIC_CAST(nsISupports*, mInner));
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMNSCSS2Properties))) {
+ if (!mInner) {
+ mInner = new CSS2PropertiesTearoff(this);
+ NS_ENSURE_TRUE(mInner, NS_ERROR_OUT_OF_MEMORY);
+ }
+ inst = NS_STATIC_CAST(nsIDOMNSCSS2Properties*,
+ NS_STATIC_CAST(nsISupports*, mInner));
+ } else if (aIID.Equals(NS_GET_IID(nsISupports))) {
+ inst = NS_STATIC_CAST(nsISupports*,
+ NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, this));
+ } else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
+ inst = nsContentUtils::GetClassInfoInstance(eDOMClassInfo_CSSStyleDeclaration_id);
+ NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
+ } else {
+ inst = nsnull;
+ }
+
+ nsresult rv;
+ if (!inst) {
+ rv = NS_NOINTERFACE;
+ } else {
+ NS_ADDREF(inst);
+ rv = NS_OK;
+ }
+
+ *aInstancePtr = inst;
+ return rv;
+}
NS_IMPL_ADDREF(nsDOMCSSDeclaration);
@@ -200,59 +240,54 @@ nsDOMCSSDeclaration::SetProperty(const nsAString& aPropertyName,
return RemoveProperty(aPropertyName, tmp);
}
- nsresult res;
if (aPriority.IsEmpty()) {
- res = ParseDeclaration(aPropertyName + NS_LITERAL_STRING(":") +
- aValue,
- PR_TRUE, PR_FALSE);
+ return ParsePropertyValue(aPropertyName, aValue);
}
- else {
- res = ParseDeclaration(aPropertyName + NS_LITERAL_STRING(":") +
- aValue + NS_LITERAL_STRING("!") + aPriority,
- PR_TRUE, PR_FALSE);
- }
- return res;
+
+ return ParsePropertyValue(aPropertyName,
+ aValue + NS_LITERAL_STRING("!") + aPriority);
}
-/**
- * Helper function to reduce code size.
- */
-static nsresult
-CallSetProperty(nsDOMCSSDeclaration* aDecl,
- const nsAString& aPropName,
- const nsAString& aValue)
+//////////////////////////////////////////////////////////////////////////////
+
+CSS2PropertiesTearoff::CSS2PropertiesTearoff(nsISupports *aOuter)
{
- if (aValue.IsEmpty()) {
- // If the new value of the property is an empty string we remove the
- // property.
- nsAutoString tmp;
- return aDecl->RemoveProperty(aPropName, tmp);
- }
-
- return aDecl->ParsePropertyValue(aPropName, aValue);
+ NS_INIT_AGGREGATED(aOuter);
}
+CSS2PropertiesTearoff::~CSS2PropertiesTearoff()
+{
+}
+
+NS_IMPL_AGGREGATED(CSS2PropertiesTearoff);
+
+NS_INTERFACE_MAP_BEGIN_AGGREGATED(CSS2PropertiesTearoff)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMCSS2Properties)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMNSCSS2Properties)
+NS_INTERFACE_MAP_END_AGGREGATED(fOuter)
+
// nsIDOMCSS2Properties
+// nsIDOMNSCSS2Properties
-#define CSS_PROP(name_, id_, method_, hint_) \
- NS_IMETHODIMP \
- nsDOMCSSDeclaration::Get##method_(nsAString& aValue) \
- { \
- return GetPropertyValue(NS_LITERAL_STRING(#name_), aValue); \
- } \
- \
- NS_IMETHODIMP \
- nsDOMCSSDeclaration::Set##method_(const nsAString& aValue) \
- { \
- return CallSetProperty(this, NS_LITERAL_STRING(#name_), aValue); \
+#define CSS_PROP(name_, id_, method_, hint_) \
+ NS_IMETHODIMP \
+ CSS2PropertiesTearoff::Get##method_(nsAString& aValue) \
+ { \
+ return NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, fOuter)-> \
+ GetPropertyValue(NS_LITERAL_STRING(#name_), aValue); \
+ } \
+ \
+ NS_IMETHODIMP \
+ CSS2PropertiesTearoff::Set##method_(const nsAString& aValue) \
+ { \
+ return NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, fOuter)-> \
+ SetProperty(NS_LITERAL_STRING(#name_), aValue, nsAutoString()); \
}
-#define CSS_PROP_INTERNAL(name_, id_, method_, hint_) /* nothing */
-#define CSS_PROP_NOTIMPLEMENTED(name_, id_, method_, hint_) \
+#define CSS_PROP_INTERNAL(name_, id_, method_, hint_) /* nothing */
+#define CSS_PROP_NOTIMPLEMENTED(name_, id_, method_, hint_) \
CSS_PROP(name_, id_, method_, hint_)
-
#include "nsCSSPropList.h"
-
#undef CSS_PROP_INTERNAL
#undef CSS_PROP
diff --git a/mozilla/content/html/style/src/nsDOMCSSDeclaration.h b/mozilla/content/html/style/src/nsDOMCSSDeclaration.h
index c5adac39ba3..53023862ffe 100644
--- a/mozilla/content/html/style/src/nsDOMCSSDeclaration.h
+++ b/mozilla/content/html/style/src/nsDOMCSSDeclaration.h
@@ -42,12 +42,14 @@
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMCSS2Properties.h"
+#include "nsAgg.h"
+#include "nsCOMPtr.h"
+
class nsCSSDeclaration;
class nsICSSParser;
class nsIURI;
-class nsDOMCSSDeclaration : public nsIDOMCSSStyleDeclaration,
- public nsIDOMNSCSS2Properties
+class nsDOMCSSDeclaration : public nsIDOMCSSStyleDeclaration
{
public:
nsDOMCSSDeclaration();
@@ -73,9 +75,6 @@ public:
NS_IMETHOD Item(PRUint32 aIndex, nsAString& aReturn);
- NS_DECL_NSIDOMCSS2PROPERTIES
- NS_DECL_NSIDOMNSCSS2PROPERTIES
-
virtual void DropReference() = 0;
virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
PRBool aAllocate) = 0;
@@ -91,6 +90,23 @@ public:
protected:
virtual ~nsDOMCSSDeclaration();
+
+private:
+ nsCOMPtr mInner; // CSS2Properties
};
+
+class CSS2PropertiesTearoff : public nsIDOMNSCSS2Properties
+{
+public:
+ NS_DECL_AGGREGATED
+
+ NS_DECL_NSIDOMCSS2PROPERTIES
+ NS_DECL_NSIDOMNSCSS2PROPERTIES
+
+ CSS2PropertiesTearoff(nsISupports *aOuter);
+ virtual ~CSS2PropertiesTearoff();
+};
+
+
#endif // nsDOMCSSDeclaration_h___
diff --git a/mozilla/layout/style/nsComputedDOMStyle.cpp b/mozilla/layout/style/nsComputedDOMStyle.cpp
index 858044ead06..b06e020bcaf 100644
--- a/mozilla/layout/style/nsComputedDOMStyle.cpp
+++ b/mozilla/layout/style/nsComputedDOMStyle.cpp
@@ -42,6 +42,7 @@
#include "nsComputedDOMStyle.h"
#include "nsDOMError.h"
+#include "nsIDOMCSS2Properties.h"
#include "nsIDOMElement.h"
#include "nsIStyleContext.h"
#include "nsIScrollableFrame.h"
@@ -293,7 +294,7 @@ NS_NewComputedDOMStyle(nsIComputedDOMStyle** aComputedStyle)
}
nsComputedDOMStyle::nsComputedDOMStyle()
- : mPresShellWeak(nsnull), mT2P(0.0f)
+ : mInner(nsnull), mPresShellWeak(nsnull), mT2P(0.0f)
{
NS_INIT_ISUPPORTS();
}
@@ -315,15 +316,55 @@ nsComputedDOMStyle::Shutdown()
}
-// QueryInterface implementation for nsComputedDOMStyle
-NS_INTERFACE_MAP_BEGIN(nsComputedDOMStyle)
- NS_INTERFACE_MAP_ENTRY(nsIComputedDOMStyle)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSS2Properties)
- NS_INTERFACE_MAP_ENTRY(nsIDOMNSCSS2Properties)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIComputedDOMStyle)
- NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ComputedCSSStyleDeclaration)
-NS_INTERFACE_MAP_END
+NS_IMETHODIMP
+nsComputedDOMStyle::QueryInterface(REFNSIID aIID, void** aInstancePtr)
+{
+ if (!aInstancePtr) {
+ NS_ERROR("QueryInterface requires a non-NULL destination!");
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ nsISupports* inst;
+
+ if (aIID.Equals(NS_GET_IID(nsIComputedDOMStyle))) {
+ inst = NS_STATIC_CAST(nsIComputedDOMStyle*, this);
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMCSSStyleDeclaration))) {
+ inst = NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, this);
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMCSS2Properties))) {
+ if (!mInner) {
+ mInner = new CSS2PropertiesTearoff(this);
+ NS_ENSURE_TRUE(mInner, NS_ERROR_OUT_OF_MEMORY);
+ }
+ inst = NS_STATIC_CAST(nsIDOMCSS2Properties*,
+ NS_STATIC_CAST(nsISupports*, mInner));
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMNSCSS2Properties))) {
+ if (!mInner) {
+ mInner = new CSS2PropertiesTearoff(this);
+ NS_ENSURE_TRUE(mInner, NS_ERROR_OUT_OF_MEMORY);
+ }
+ inst = NS_STATIC_CAST(nsIDOMNSCSS2Properties*,
+ NS_STATIC_CAST(nsISupports*, mInner));
+ } else if (aIID.Equals(NS_GET_IID(nsISupports))) {
+ inst = NS_STATIC_CAST(nsISupports*,
+ NS_STATIC_CAST(nsIComputedDOMStyle*, this));
+ } else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
+ inst = nsContentUtils::GetClassInfoInstance(eDOMClassInfo_ComputedCSSStyleDeclaration_id);
+ NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
+ } else {
+ inst = nsnull;
+ }
+
+ nsresult rv;
+ if (!inst) {
+ rv = NS_NOINTERFACE;
+ } else {
+ NS_ADDREF(inst);
+ rv = NS_OK;
+ }
+
+ *aInstancePtr = inst;
+ return rv;
+}
static void doDestroyComputedDOMStyle(nsComputedDOMStyle *aComputedStyle)
@@ -3792,27 +3833,3 @@ nsComputedDOMStyle::GetBorderStyleFor(PRUint8 aSide, nsIFrame *aFrame,
return CallQueryInterface(val, aValue);
}
-
-// nsIDOMCSS2Properties
-
-#define CSS_PROP(name_, id_, method_, hint_) \
- NS_IMETHODIMP \
- nsComputedDOMStyle::Get##method_(nsAString& aValue) \
- { \
- return GetPropertyValue(NS_LITERAL_STRING(#name_), aValue); \
- } \
- \
- NS_IMETHODIMP \
- nsComputedDOMStyle::Set##method_(const nsAString& aValue) \
- { \
- return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; \
- }
-
-#define CSS_PROP_INTERNAL(name_, id_, method_, hint_) /* nothing */
-#define CSS_PROP_NOTIMPLEMENTED(name_, id_, method_, hint_) \
- CSS_PROP(name_, id_, method_, hint_)
-
-#include "nsCSSPropList.h"
-
-#undef CSS_PROP_INTERNAL
-#undef CSS_PROP
diff --git a/mozilla/layout/style/nsComputedDOMStyle.h b/mozilla/layout/style/nsComputedDOMStyle.h
index 2e607f2c0d3..d9f5b291fdf 100644
--- a/mozilla/layout/style/nsComputedDOMStyle.h
+++ b/mozilla/layout/style/nsComputedDOMStyle.h
@@ -41,9 +41,9 @@
#define nsComputedDOMStyle_h__
#include "nsIComputedDOMStyle.h"
-#include "nsIDOMCSS2Properties.h"
#include "nsROCSSPrimitiveValue.h"
+#include "nsDOMCSSDeclaration.h"
#include "nsDOMCSSRGBColor.h"
#include "nsDOMCSSValueList.h"
@@ -53,8 +53,7 @@
#include "nsCOMPtr.h"
#include "nsWeakReference.h"
-class nsComputedDOMStyle : public nsIComputedDOMStyle,
- public nsIDOMNSCSS2Properties
+class nsComputedDOMStyle : public nsIComputedDOMStyle
{
public:
NS_DECL_ISUPPORTS
@@ -63,9 +62,6 @@ public:
const nsAString& aPseudoElt,
nsIPresShell *aPresShell);
- NS_DECL_NSIDOMCSS2PROPERTIES
- NS_DECL_NSIDOMNSCSS2PROPERTIES
-
NS_DECL_NSIDOMCSSSTYLEDECLARATION
nsComputedDOMStyle();
@@ -280,6 +276,8 @@ private:
nsDOMCSSValueList* GetROCSSValueList(PRBool aCommaDelimited);
nsDOMCSSRGBColor* GetDOMCSSRGBColor(nscolor aColor);
+ nsCOMPtr mInner; // CSS2Properties
+
nsWeakPtr mPresShellWeak;
nsCOMPtr mContent;
diff --git a/mozilla/layout/style/nsDOMCSSDeclaration.cpp b/mozilla/layout/style/nsDOMCSSDeclaration.cpp
index 8efa0d5a4ed..4a388c18804 100644
--- a/mozilla/layout/style/nsDOMCSSDeclaration.cpp
+++ b/mozilla/layout/style/nsDOMCSSDeclaration.cpp
@@ -49,6 +49,7 @@
nsDOMCSSDeclaration::nsDOMCSSDeclaration()
+ : mInner(nsnull)
{
NS_INIT_ISUPPORTS();
}
@@ -58,14 +59,53 @@ nsDOMCSSDeclaration::~nsDOMCSSDeclaration()
}
-// QueryInterface implementation for CSSStyleSheetImpl
-NS_INTERFACE_MAP_BEGIN(nsDOMCSSDeclaration)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSS2Properties)
- NS_INTERFACE_MAP_ENTRY(nsIDOMNSCSS2Properties)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCSS2Properties)
- NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CSSStyleDeclaration)
-NS_INTERFACE_MAP_END
+NS_IMETHODIMP
+nsDOMCSSDeclaration::QueryInterface(REFNSIID aIID, void** aInstancePtr)
+{
+ if (!aInstancePtr) {
+ NS_ERROR("QueryInterface requires a non-NULL destination!");
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ nsISupports* inst;
+
+ if (aIID.Equals(NS_GET_IID(nsIDOMCSSStyleDeclaration))) {
+ inst = NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, this);
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMCSS2Properties))) {
+ if (!mInner) {
+ mInner = new CSS2PropertiesTearoff(this);
+ NS_ENSURE_TRUE(mInner, NS_ERROR_OUT_OF_MEMORY);
+ }
+ inst = NS_STATIC_CAST(nsIDOMCSS2Properties*,
+ NS_STATIC_CAST(nsISupports*, mInner));
+ } else if (aIID.Equals(NS_GET_IID(nsIDOMNSCSS2Properties))) {
+ if (!mInner) {
+ mInner = new CSS2PropertiesTearoff(this);
+ NS_ENSURE_TRUE(mInner, NS_ERROR_OUT_OF_MEMORY);
+ }
+ inst = NS_STATIC_CAST(nsIDOMNSCSS2Properties*,
+ NS_STATIC_CAST(nsISupports*, mInner));
+ } else if (aIID.Equals(NS_GET_IID(nsISupports))) {
+ inst = NS_STATIC_CAST(nsISupports*,
+ NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, this));
+ } else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
+ inst = nsContentUtils::GetClassInfoInstance(eDOMClassInfo_CSSStyleDeclaration_id);
+ NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
+ } else {
+ inst = nsnull;
+ }
+
+ nsresult rv;
+ if (!inst) {
+ rv = NS_NOINTERFACE;
+ } else {
+ NS_ADDREF(inst);
+ rv = NS_OK;
+ }
+
+ *aInstancePtr = inst;
+ return rv;
+}
NS_IMPL_ADDREF(nsDOMCSSDeclaration);
@@ -200,59 +240,54 @@ nsDOMCSSDeclaration::SetProperty(const nsAString& aPropertyName,
return RemoveProperty(aPropertyName, tmp);
}
- nsresult res;
if (aPriority.IsEmpty()) {
- res = ParseDeclaration(aPropertyName + NS_LITERAL_STRING(":") +
- aValue,
- PR_TRUE, PR_FALSE);
+ return ParsePropertyValue(aPropertyName, aValue);
}
- else {
- res = ParseDeclaration(aPropertyName + NS_LITERAL_STRING(":") +
- aValue + NS_LITERAL_STRING("!") + aPriority,
- PR_TRUE, PR_FALSE);
- }
- return res;
+
+ return ParsePropertyValue(aPropertyName,
+ aValue + NS_LITERAL_STRING("!") + aPriority);
}
-/**
- * Helper function to reduce code size.
- */
-static nsresult
-CallSetProperty(nsDOMCSSDeclaration* aDecl,
- const nsAString& aPropName,
- const nsAString& aValue)
+//////////////////////////////////////////////////////////////////////////////
+
+CSS2PropertiesTearoff::CSS2PropertiesTearoff(nsISupports *aOuter)
{
- if (aValue.IsEmpty()) {
- // If the new value of the property is an empty string we remove the
- // property.
- nsAutoString tmp;
- return aDecl->RemoveProperty(aPropName, tmp);
- }
-
- return aDecl->ParsePropertyValue(aPropName, aValue);
+ NS_INIT_AGGREGATED(aOuter);
}
+CSS2PropertiesTearoff::~CSS2PropertiesTearoff()
+{
+}
+
+NS_IMPL_AGGREGATED(CSS2PropertiesTearoff);
+
+NS_INTERFACE_MAP_BEGIN_AGGREGATED(CSS2PropertiesTearoff)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMCSS2Properties)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMNSCSS2Properties)
+NS_INTERFACE_MAP_END_AGGREGATED(fOuter)
+
// nsIDOMCSS2Properties
+// nsIDOMNSCSS2Properties
-#define CSS_PROP(name_, id_, method_, hint_) \
- NS_IMETHODIMP \
- nsDOMCSSDeclaration::Get##method_(nsAString& aValue) \
- { \
- return GetPropertyValue(NS_LITERAL_STRING(#name_), aValue); \
- } \
- \
- NS_IMETHODIMP \
- nsDOMCSSDeclaration::Set##method_(const nsAString& aValue) \
- { \
- return CallSetProperty(this, NS_LITERAL_STRING(#name_), aValue); \
+#define CSS_PROP(name_, id_, method_, hint_) \
+ NS_IMETHODIMP \
+ CSS2PropertiesTearoff::Get##method_(nsAString& aValue) \
+ { \
+ return NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, fOuter)-> \
+ GetPropertyValue(NS_LITERAL_STRING(#name_), aValue); \
+ } \
+ \
+ NS_IMETHODIMP \
+ CSS2PropertiesTearoff::Set##method_(const nsAString& aValue) \
+ { \
+ return NS_STATIC_CAST(nsIDOMCSSStyleDeclaration*, fOuter)-> \
+ SetProperty(NS_LITERAL_STRING(#name_), aValue, nsAutoString()); \
}
-#define CSS_PROP_INTERNAL(name_, id_, method_, hint_) /* nothing */
-#define CSS_PROP_NOTIMPLEMENTED(name_, id_, method_, hint_) \
+#define CSS_PROP_INTERNAL(name_, id_, method_, hint_) /* nothing */
+#define CSS_PROP_NOTIMPLEMENTED(name_, id_, method_, hint_) \
CSS_PROP(name_, id_, method_, hint_)
-
#include "nsCSSPropList.h"
-
#undef CSS_PROP_INTERNAL
#undef CSS_PROP
diff --git a/mozilla/layout/style/nsDOMCSSDeclaration.h b/mozilla/layout/style/nsDOMCSSDeclaration.h
index c5adac39ba3..53023862ffe 100644
--- a/mozilla/layout/style/nsDOMCSSDeclaration.h
+++ b/mozilla/layout/style/nsDOMCSSDeclaration.h
@@ -42,12 +42,14 @@
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMCSS2Properties.h"
+#include "nsAgg.h"
+#include "nsCOMPtr.h"
+
class nsCSSDeclaration;
class nsICSSParser;
class nsIURI;
-class nsDOMCSSDeclaration : public nsIDOMCSSStyleDeclaration,
- public nsIDOMNSCSS2Properties
+class nsDOMCSSDeclaration : public nsIDOMCSSStyleDeclaration
{
public:
nsDOMCSSDeclaration();
@@ -73,9 +75,6 @@ public:
NS_IMETHOD Item(PRUint32 aIndex, nsAString& aReturn);
- NS_DECL_NSIDOMCSS2PROPERTIES
- NS_DECL_NSIDOMNSCSS2PROPERTIES
-
virtual void DropReference() = 0;
virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
PRBool aAllocate) = 0;
@@ -91,6 +90,23 @@ public:
protected:
virtual ~nsDOMCSSDeclaration();
+
+private:
+ nsCOMPtr mInner; // CSS2Properties
};
+
+class CSS2PropertiesTearoff : public nsIDOMNSCSS2Properties
+{
+public:
+ NS_DECL_AGGREGATED
+
+ NS_DECL_NSIDOMCSS2PROPERTIES
+ NS_DECL_NSIDOMNSCSS2PROPERTIES
+
+ CSS2PropertiesTearoff(nsISupports *aOuter);
+ virtual ~CSS2PropertiesTearoff();
+};
+
+
#endif // nsDOMCSSDeclaration_h___
diff --git a/mozilla/xpcom/base/nsAgg.h b/mozilla/xpcom/base/nsAgg.h
index 5dd1a6eb74a..cd128821f4b 100644
--- a/mozilla/xpcom/base/nsAgg.h
+++ b/mozilla/xpcom/base/nsAgg.h
@@ -140,6 +140,9 @@ _class::Internal::Release(void) \
// for use with QI macros in nsISupportsUtils.h:
+#define NS_INTERFACE_MAP_BEGIN_AGGREGATED(_class) \
+ NS_IMPL_AGGREGATED_QUERY_HEAD(_class)
+
#define NS_IMPL_AGGREGATED_QUERY_HEAD(_class) \
NS_IMETHODIMP \
_class::AggregatedQueryInterface(REFNSIID aIID, void** aInstancePtr) \