diff --git a/mozilla/content/html/content/public/nsIHTMLContent.h b/mozilla/content/html/content/public/nsIHTMLContent.h
index 794569b51cb..11893e69f62 100644
--- a/mozilla/content/html/content/public/nsIHTMLContent.h
+++ b/mozilla/content/html/content/public/nsIHTMLContent.h
@@ -27,12 +27,17 @@ class nsIStyleRule;
class nsIStyleContext;
class nsIPresContext;
class nsXIFConverter;
+class nsIHTMLAttributes;
// IID for the nsIHTMLContent class
#define NS_IHTMLCONTENT_IID \
{ 0xb9e110b0, 0x94d6, 0x11d1, \
{0x89, 0x5c, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
+typedef void (*nsMapAttributesFunc)(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
+
// Abstract interface for all html content
class nsIHTMLContent : public nsIContent {
public:
@@ -61,6 +66,7 @@ public:
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCountResult) const = 0;
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const = 0;
NS_IMETHOD SetID(nsIAtom* aID) = 0;
NS_IMETHOD GetID(nsIAtom*& aResult) const = 0;
@@ -71,9 +77,6 @@ public:
NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult) = 0;
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext) = 0;
-
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const = 0;
diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
index 8e9cb12ef1c..2dd1b1c7889 100644
--- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
@@ -584,15 +584,20 @@ DOMAttributeMap::GetLength(PRUint32 *aLength)
//----------------------------------------------------------------------
-static nsresult EnsureWritableAttributes(nsIHTMLAttributes*& aAttributes, PRBool aCreate)
+static nsresult EnsureWritableAttributes(nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes, PRBool aCreate)
{
nsresult result = NS_OK;
if (nsnull == aAttributes) {
if (PR_TRUE == aCreate) {
- result = NS_NewHTMLAttributes(&aAttributes);
+ nsMapAttributesFunc mapFunc;
+ result = aContent->GetAttributeMappingFunction(mapFunc);
if (NS_OK == result) {
- aAttributes->AddContentRef();
+ result = NS_NewHTMLAttributes(&aAttributes, mapFunc);
+ if (NS_OK == result) {
+ aAttributes->AddContentRef();
+ }
}
}
}
@@ -1032,7 +1037,7 @@ nsGenericHTMLElement::SetDocument(nsIDocument* aDocument)
AddScriptEventListener(nsHTMLAtoms::onblur, val, kIDOMFocusListenerIID);
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- sheet->SetAttributesFor(mTag, mAttributes); // sync attributes with sheet
+ sheet->SetAttributesFor(mContent, mAttributes); // sync attributes with sheet
}
return NS_OK;
@@ -1198,11 +1203,26 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
nsHTMLValue val;
if (NS_CONTENT_ATTR_NOT_THERE !=
mContent->StringToAttribute(aAttribute, aValue, val)) {
+ // string value was mapped to nsHTMLValue, set it that way
+ result = SetAttribute(aAttribute, val, aNotify);
}
else {
- val.SetStringValue(aValue);
+ // set as string value to avoid another string copy
+ if (nsnull != mDocument) { // set attr via style sheet
+ nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
+ result = sheet->SetAttributeFor(aAttribute, aValue, mContent, mAttributes);
+ }
+ else { // manage this ourselves and re-sync when we connect to doc
+ result = EnsureWritableAttributes(mContent, mAttributes, PR_TRUE);
+ if (nsnull != mAttributes) {
+ PRInt32 count;
+ result = mAttributes->SetAttribute(aAttribute, aValue, count);
+ if (0 == count) {
+ ReleaseAttributes(mAttributes);
+ }
+ }
+ }
}
- result = SetAttribute(aAttribute, val, aNotify);
}
return result;
}
@@ -1215,10 +1235,10 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetAttributeFor(aAttribute, aValue, mTag, mAttributes);
+ result = sheet->SetAttributeFor(aAttribute, aValue, mContent, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- result = EnsureWritableAttributes(mAttributes, PR_TRUE);
+ result = EnsureWritableAttributes(mContent, mAttributes, PR_TRUE);
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetAttribute(aAttribute, aValue, count);
@@ -1233,20 +1253,20 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
/**
* Handle attributes common to all html elements
*/
-nsresult
-nsGenericHTMLElement::MapAttributesInto(nsIStyleContext* aStyleContext,
- nsIPresContext* aPresContext)
+void
+nsGenericHTMLElement::MapCommonAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aStyleContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::dir, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::dir, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleDisplay* display = (nsStyleDisplay*)
aStyleContext->GetMutableStyleData(eStyleStruct_Display);
display->mDirection = value.GetIntValue();
}
}
- return NS_OK;
}
nsresult
@@ -1273,10 +1293,10 @@ nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->UnsetAttributeFor(aAttribute, mTag, mAttributes);
+ result = sheet->UnsetAttributeFor(aAttribute, mContent, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- result = EnsureWritableAttributes(mAttributes, PR_FALSE);
+ result = EnsureWritableAttributes(mContent, mAttributes, PR_FALSE);
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->UnsetAttribute(aAttribute, count);
@@ -1399,10 +1419,10 @@ nsGenericHTMLElement::SetID(nsIAtom* aID)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetIDFor(aID, mTag, mAttributes);
+ result = sheet->SetIDFor(aID, mContent, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- EnsureWritableAttributes(mAttributes, PRBool(nsnull != aID));
+ EnsureWritableAttributes(mContent, mAttributes, PRBool(nsnull != aID));
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetID(aID, count);
@@ -1430,10 +1450,10 @@ nsGenericHTMLElement::SetClass(nsIAtom* aClass)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetClassFor(aClass, mTag, mAttributes);
+ result = sheet->SetClassFor(aClass, mContent, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- EnsureWritableAttributes(mAttributes, PRBool(nsnull != aClass));
+ EnsureWritableAttributes(mContent, mAttributes, PRBool(nsnull != aClass));
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetClass(aClass, count);
@@ -2162,10 +2182,11 @@ nsGenericHTMLElement::ImageAttributeToString(nsIAtom* aAttribute,
}
void
-nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
float p2t = aPresContext->GetPixelsToTwips();
@@ -2175,7 +2196,7 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
aContext->GetMutableStyleData(eStyleStruct_Spacing);
// width: value
- GetAttribute(nsHTMLAtoms::width, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
pos->mWidth.SetCoordValue(twips);
@@ -2185,7 +2206,7 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
}
// height: value
- GetAttribute(nsHTMLAtoms::height, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
pos->mHeight.SetCoordValue(twips);
@@ -2195,7 +2216,7 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
}
// hspace: value
- GetAttribute(nsHTMLAtoms::hspace, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
spacing->mMargin.SetRight(nsStyleCoord(twips));
@@ -2206,7 +2227,7 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
}
// vspace: value
- GetAttribute(nsHTMLAtoms::vspace, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
spacing->mMargin.SetBottom(nsStyleCoord(twips));
@@ -2219,12 +2240,13 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
}
void
-nsGenericHTMLElement::MapImageAlignAttributeInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageAlignAttributeInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
PRUint8 align = value.GetIntValue();
nsStyleDisplay* display = (nsStyleDisplay*)
@@ -2255,15 +2277,16 @@ nsGenericHTMLElement::MapImageAlignAttributeInto(nsIStyleContext* aContext,
}
void
-nsGenericHTMLElement::MapImageBorderAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageBorderAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext,
nscolor aBorderColors[4])
{
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
// border: pixels
- GetAttribute(nsHTMLAtoms::border, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::border, value);
if (value.GetUnit() != eHTMLUnit_Pixel) {
if (nsnull == aBorderColors) {
return;
@@ -2313,14 +2336,15 @@ nsGenericHTMLElement::MapImageBorderAttributesInto(nsIStyleContext* aContext,
}
void
-nsGenericHTMLElement::MapBackgroundAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapBackgroundAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
nsHTMLValue value;
// background
if (NS_CONTENT_ATTR_HAS_VALUE ==
- GetAttribute(nsHTMLAtoms::background, value)) {
+ aAttributes->GetAttribute(nsHTMLAtoms::background, value)) {
if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString absURLSpec;
nsAutoString spec;
@@ -2328,15 +2352,11 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(nsIStyleContext* aContext,
if (spec.Length() > 0) {
// Resolve url to an absolute url
nsIURL* docURL = nsnull;
- nsIDocument* doc = mDocument;
- if (nsnull != doc) {
- docURL = doc->GetDocumentURL();
- }
+ aPresContext->GetBaseURL(docURL);
nsresult rv = NS_MakeAbsoluteURL(docURL, "", spec, absURLSpec);
- if (nsnull != docURL) {
- NS_RELEASE(docURL);
- }
+ NS_IF_RELEASE(docURL);
+
nsStyleColor* color = (nsStyleColor*)
aContext->GetMutableStyleData(eStyleStruct_Color);
color->mBackgroundImage = absURLSpec;
@@ -2347,7 +2367,7 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(nsIStyleContext* aContext,
}
// bgcolor
- if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::bgcolor, value)) {
+ if (NS_CONTENT_ATTR_HAS_VALUE == aAttributes->GetAttribute(nsHTMLAtoms::bgcolor, value)) {
if (eHTMLUnit_Color == value.GetUnit()) {
nsStyleColor* color = (nsStyleColor*)
aContext->GetMutableStyleData(eStyleStruct_Color);
diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h
index 78e0faf9858..814930c0224 100644
--- a/mozilla/content/html/content/src/nsGenericHTMLElement.h
+++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h
@@ -140,8 +140,6 @@ public:
nsresult SetClass(nsIAtom* aClass);
nsresult GetClass(nsIAtom*& aResult) const;
nsresult GetStyleRule(nsIStyleRule*& aResult);
- nsresult MapAttributesInto(nsIStyleContext* aStyleContext,
- nsIPresContext* aPresContext);
nsresult ToHTMLString(nsString& aResult) const;
nsresult ToHTML(FILE* out) const;
nsresult CreateFrame(nsIPresContext* aPresContext,
@@ -231,18 +229,26 @@ public:
const nsHTMLValue& aValue,
nsString& aResult);
- void MapImageAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ static void MapCommonAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aStyleContext,
+ nsIPresContext* aPresContext);
- void MapImageAlignAttributeInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ static void MapImageAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
- void MapImageBorderAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext,
- nscolor aBorderColors[4]);
+ static void MapImageAlignAttributeInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
- void MapBackgroundAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ static void MapImageBorderAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext,
+ nscolor aBorderColors[4]);
+
+ static void MapBackgroundAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
static nsresult GetScriptObjectFactory(nsIDOMScriptObjectFactory **aFactory);
@@ -699,8 +705,7 @@ public:
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
nsHTMLValue& aValue, \
nsString& aResult) const; \
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
#define NS_IMPL_IHTMLCONTENT_USING_GENERIC2(_g) \
NS_IMETHOD Compact() { \
@@ -764,8 +769,7 @@ public:
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
nsHTMLValue& aValue, \
nsString& aResult) const; \
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
/**
* This macro implements the portion of query interface that is
diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
index e703b396929..37d1530d36d 100644
--- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -214,13 +214,22 @@ nsHTMLAnchorElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLAnchorElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLAnchorElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
// XXX support suppress in here
NS_IMETHODIMP
nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
diff --git a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp
index daea436a92b..f0d7a78b653 100644
--- a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp
@@ -189,16 +189,26 @@ nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLAppletElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- mInner.MapImageAlignAttributeInto(aContext, aPresContext);
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLAppletElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLAppletElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp
index 59db5608d4e..931afd9c5e3 100644
--- a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp
@@ -161,13 +161,22 @@ nsHTMLAreaElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLAreaElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLAreaElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLAreaElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLBRElement.cpp b/mozilla/content/html/content/src/nsHTMLBRElement.cpp
index 43ca4b5b07c..67418da1704 100644
--- a/mozilla/content/html/content/src/nsHTMLBRElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLBRElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLBRElementIID, NS_IDOMHTMLBRELEMENT_IID);
@@ -159,22 +160,31 @@ nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLBRElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsStyleDisplay* display = (nsStyleDisplay*)
aContext->GetMutableStyleData(eStyleStruct_Display);
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::clear, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::clear, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
display->mBreakType = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLBRElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLBRElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLBaseElement.cpp b/mozilla/content/html/content/src/nsHTMLBaseElement.cpp
index cb9264388d6..ba685f841ed 100644
--- a/mozilla/content/html/content/src/nsHTMLBaseElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLBaseElement.cpp
@@ -143,13 +143,22 @@ nsHTMLBaseElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLBaseElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLBaseElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLBaseElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp b/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp
index b86eaab74b0..04c4bed9586 100644
--- a/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp
@@ -148,14 +148,24 @@ nsHTMLBaseFontElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLBaseFontElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- // XXX write me?
- return mInner.MapAttributesInto(aContext, aPresContext);
+ // XXX write me
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLBaseFontElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLBaseFontElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp
index 7ded91b806e..5951b161226 100644
--- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp
@@ -26,12 +26,14 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIPresShell.h"
#include "nsStyleUtil.h"
#include "nsIDocument.h"
#include "nsIHTMLDocument.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIStyleRule.h"
#include "nsIWebShell.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
@@ -90,6 +92,8 @@ public:
protected:
nsGenericHTMLContainerElement mInner;
BodyRule* mStyleRule;
+
+friend BodyRule;
};
class BodyRule: public nsIStyleRule {
@@ -103,8 +107,7 @@ public:
NS_IMETHOD HashValue(PRUint32& aValue) const;
NS_IMETHOD MapStyleInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext,
- nsIContent* aContent);
+ nsIPresContext* aPresContext);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
@@ -140,10 +143,8 @@ BodyRule::HashValue(PRUint32& aValue) const
}
NS_IMETHODIMP
-BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
{
- NS_ASSERTION(aContent == mPart, "bad content mapping");
if (nsnull != mPart) {
nsStyleSpacing* styleSpacing = (nsStyleSpacing*)(aContext->GetMutableStyleData(eStyleStruct_Spacing));
@@ -173,7 +174,9 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
}
if (count < attrCount) { // more to go...
- mPart->MapAttributesInto(aContext, aPresContext);
+ nsMapAttributesFunc func;
+ mPart->GetAttributeMappingFunction(func);
+ (*func)(mPart->mInner.mAttributes, aContext, aPresContext);
}
}
@@ -312,14 +315,16 @@ nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- mInner.MapBackgroundAttributesInto(aContext, aPresContext);
- GetAttribute(nsHTMLAtoms::text, value);
+ nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aContext, aPresContext);
+
+ aAttributes->GetAttribute(nsHTMLAtoms::text, value);
if (eHTMLUnit_Color == value.GetUnit()) {
nsStyleColor* color = (nsStyleColor*)
aContext->GetMutableStyleData(eStyleStruct_Color);
@@ -327,27 +332,36 @@ nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext,
aPresContext->SetDefaultColor(color->mColor);
}
- nsIHTMLDocument* htmlDoc;
- if (NS_OK == mInner.mDocument->QueryInterface(kIHTMLDocumentIID,
- (void**)&htmlDoc)) {
- nsIHTMLStyleSheet* styleSheet;
- if (NS_OK == htmlDoc->GetAttributeStyleSheet(&styleSheet)) {
- GetAttribute(nsHTMLAtoms::link, value);
- if (eHTMLUnit_Color == value.GetUnit()) {
- styleSheet->SetLinkColor(value.GetColorValue());
- }
+ nsIPresShell* presShell = aPresContext->GetShell();
+ if (nsnull != presShell) {
+ nsIDocument* doc = presShell->GetDocument();
+ if (nsnull != doc) {
+ nsIHTMLDocument* htmlDoc;
+ if (NS_OK == doc->QueryInterface(kIHTMLDocumentIID,
+ (void**)&htmlDoc)) {
+ nsIHTMLStyleSheet* styleSheet;
+ if (NS_OK == htmlDoc->GetAttributeStyleSheet(&styleSheet)) {
+ aAttributes->GetAttribute(nsHTMLAtoms::link, value);
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ styleSheet->SetLinkColor(value.GetColorValue());
+ }
- GetAttribute(nsHTMLAtoms::alink, value);
- if (eHTMLUnit_Color == value.GetUnit()) {
- styleSheet->SetActiveLinkColor(value.GetColorValue());
- }
+ aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ styleSheet->SetActiveLinkColor(value.GetColorValue());
+ }
- GetAttribute(nsHTMLAtoms::vlink, value);
- if (eHTMLUnit_Color == value.GetUnit()) {
- styleSheet->SetVisitedLinkColor(value.GetColorValue());
+ aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ styleSheet->SetVisitedLinkColor(value.GetColorValue());
+ }
+ NS_RELEASE(styleSheet);
+ }
+ NS_RELEASE(htmlDoc);
}
+ NS_RELEASE(doc);
}
- NS_RELEASE(htmlDoc);
+ NS_RELEASE(presShell);
}
// marginwidth/height get set by a special style rule
@@ -361,9 +375,17 @@ nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext,
font->mFont.size = nsStyleUtil::CalcFontPointSize(3, (PRInt32)defaultFont.size, scaleFactor);
font->mFixedFont.size = nsStyleUtil::CalcFontPointSize(3, (PRInt32)defaultFixedFont.size, scaleFactor);
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLBodyElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLBodyElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp
index e4a2ca9a27d..0fcfa436357 100644
--- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp
@@ -177,11 +177,19 @@ nsHTMLButtonElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLButtonElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLButtonElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLDListElement.cpp b/mozilla/content/html/content/src/nsHTMLDListElement.cpp
index 41f99ccad0e..f92025a20c3 100644
--- a/mozilla/content/html/content/src/nsHTMLDListElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLDListElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLDListElementIID, NS_IDOMHTMLDLISTELEMENT_IID);
@@ -144,24 +145,33 @@ nsHTMLDListElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLDListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLDListElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLDListElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLDelElement.cpp b/mozilla/content/html/content/src/nsHTMLDelElement.cpp
index f36ab407a4c..e220083bdff 100644
--- a/mozilla/content/html/content/src/nsHTMLDelElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLDelElement.cpp
@@ -145,14 +145,23 @@ nsHTMLDelElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLDelElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLDelElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLDelElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp b/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp
index 5102ab4843d..96b9bb94731 100644
--- a/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX nav4 has type= start= (same as OL/UL)
@@ -163,30 +164,40 @@ nsHTMLDirectoryElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLDirectoryElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLDirectoryElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLDirectoryElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLDivElement.cpp b/mozilla/content/html/content/src/nsHTMLDivElement.cpp
index dc2a4d964ee..8c5f3c2114d 100644
--- a/mozilla/content/html/content/src/nsHTMLDivElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLDivElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX support missing nav attributes? gutter, cols, width
@@ -166,22 +167,31 @@ nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLDivElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
text->mTextAlign = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLDivElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLDivElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp b/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp
index d13ee91e26e..8c7d2fbbe0f 100644
--- a/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp
@@ -159,16 +159,25 @@ nsHTMLEmbedElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLEmbedElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- mInner.MapImageAlignAttributeInto(aContext, aPresContext);
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLEmbedElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLEmbedElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLFontElement.cpp b/mozilla/content/html/content/src/nsHTMLFontElement.cpp
index 4d4c67cef18..9f26b633e83 100644
--- a/mozilla/content/html/content/src/nsHTMLFontElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFontElement.cpp
@@ -28,6 +28,7 @@
#include "nsStyleConsts.h"
#include "nsStyleUtil.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLFontElementIID, NS_IDOMHTMLFONTELEMENT_IID);
@@ -181,11 +182,12 @@ nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleFont* font = (nsStyleFont*)
aContext->GetMutableStyleData(eStyleStruct_Font);
@@ -199,7 +201,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFont();
// face: string list
- GetAttribute(nsHTMLAtoms::face, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::face, value);
if (value.GetUnit() == eHTMLUnit_String) {
nsIDeviceContext* dc = aPresContext->GetDeviceContext();
@@ -228,7 +230,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
}
// pointSize: int, enum
- GetAttribute(nsHTMLAtoms::pointSize, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::pointSize, value);
if (value.GetUnit() == eHTMLUnit_Integer) {
// XXX should probably sanitize value
font->mFont.size = parentFont->mFont.size +
@@ -246,7 +248,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
// size: int, enum , NOTE: this does not count as an explicit size
// also this has no effect if font is already explicit
if (0 == (font->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT)) {
- GetAttribute(nsHTMLAtoms::size, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::size, value);
if ((value.GetUnit() == eHTMLUnit_Integer) ||
(value.GetUnit() == eHTMLUnit_Enumerated)) {
PRInt32 size = value.GetIntValue();
@@ -269,7 +271,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
}
// fontWeight: int, enum
- GetAttribute(nsHTMLAtoms::fontWeight, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::fontWeight, value);
if (value.GetUnit() == eHTMLUnit_Integer) { // +/-
PRInt32 weight = parentFont->mFont.weight + value.GetIntValue();
font->mFont.weight =
@@ -285,7 +287,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
}
// color: color
- GetAttribute(nsHTMLAtoms::color, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::color, value);
if (value.GetUnit() == eHTMLUnit_Color) {
nsStyleColor* color = (nsStyleColor*)
aContext->GetMutableStyleData(eStyleStruct_Color);
@@ -304,7 +306,14 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
NS_IF_RELEASE(parentContext);
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLFontElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp
index 3db62773f3b..f869db3a2e3 100644
--- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp
@@ -186,14 +186,24 @@ nsHTMLFormElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLFormElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLFormElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLFormElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp
index 6c293dcc41f..28812db1166 100644
--- a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp
@@ -163,12 +163,20 @@ nsHTMLFrameElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLFrameElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLFrameElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp
index e0378c59d7b..5403916e2d0 100644
--- a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp
@@ -145,12 +145,20 @@ nsHTMLFrameSetElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLFrameSetElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLFrameSetElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLHRElement.cpp b/mozilla/content/html/content/src/nsHTMLHRElement.cpp
index b0911864657..cf1eedc49c6 100644
--- a/mozilla/content/html/content/src/nsHTMLHRElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLHRElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLHRElementIID, NS_IDOMHTMLHRELEMENT_IID);
@@ -180,14 +181,15 @@ nsHTMLHRElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
// align: enum
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
@@ -198,7 +200,7 @@ nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext,
float p2t = aPresContext->GetPixelsToTwips();
nsStylePosition* pos = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
- GetAttribute(nsHTMLAtoms::width, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
pos->mWidth.SetCoordValue(twips);
@@ -207,9 +209,17 @@ nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext,
pos->mWidth.SetPercentValue(value.GetPercentValue());
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLHRElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLHRElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLHeadElement.cpp b/mozilla/content/html/content/src/nsHTMLHeadElement.cpp
index 562a3230486..7737e484890 100644
--- a/mozilla/content/html/content/src/nsHTMLHeadElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLHeadElement.cpp
@@ -140,13 +140,22 @@ nsHTMLHeadElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLHeadElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLHeadElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLHeadElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp
index 4dbf8375056..5b8ba7c43c0 100644
--- a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLHeadingElementIID, NS_IDOMHTMLHEADINGELEMENT_IID);
@@ -151,22 +152,31 @@ nsHTMLHeadingElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLHeadingElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
text->mTextAlign = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLHeadingElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLHeadingElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp b/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp
index d2f97cebe74..42d87ba7599 100644
--- a/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp
@@ -140,13 +140,22 @@ nsHTMLHtmlElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLHtmlElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLHtmlElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLHtmlElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp
index 3e2e5806fe7..43c7ca16b06 100644
--- a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp
@@ -169,14 +169,23 @@ nsHTMLIFrameElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLIFrameElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLIFrameElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLIFrameElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp
index 1a6befe33a5..fe639a91b71 100644
--- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX nav attrs: suppress
@@ -209,13 +210,14 @@ nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
PRUint8 align = value.GetIntValue();
nsStyleDisplay* display = (nsStyleDisplay*)
@@ -243,11 +245,19 @@ nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext,
}
}
}
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLImageElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLImageElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp
index a8a17278eaf..01e9c970252 100644
--- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX align=left, hspace, vspace, border? other nav4 attrs
@@ -237,14 +238,23 @@ nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLInputElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX align
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLInputElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLInputElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLInsElement.cpp b/mozilla/content/html/content/src/nsHTMLInsElement.cpp
index 7ceff2510b5..d5146328430 100644
--- a/mozilla/content/html/content/src/nsHTMLInsElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLInsElement.cpp
@@ -145,14 +145,23 @@ nsHTMLInsElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLInsElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLInsElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLInsElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp b/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp
index 84bfe6fb19d..60f60e2934a 100644
--- a/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp
@@ -157,14 +157,23 @@ nsHTMLIsIndexElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLIsIndexElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLIsIndexElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLIsIndexElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLLIElement.cpp b/mozilla/content/html/content/src/nsHTMLLIElement.cpp
index 8be6117f6af..dbb9cc98f50 100644
--- a/mozilla/content/html/content/src/nsHTMLLIElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLLIElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLLIElementIID, NS_IDOMHTMLLIELEMENT_IID);
@@ -169,22 +170,30 @@ nsHTMLLIElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLIElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLLIElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLLabelElement.cpp b/mozilla/content/html/content/src/nsHTMLLabelElement.cpp
index bc159662ff9..bee260dd58d 100644
--- a/mozilla/content/html/content/src/nsHTMLLabelElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLLabelElement.cpp
@@ -160,12 +160,20 @@ nsHTMLLabelElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLabelElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLLabelElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp
index 4389532d22d..b5fd9ad9e40 100644
--- a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp
@@ -160,14 +160,23 @@ nsHTMLLegendElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLegendElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLLegendElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLLegendElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp
index 89bf51d93ab..4d55dbc87aa 100644
--- a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp
@@ -164,13 +164,22 @@ nsHTMLLinkElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLinkElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLLinkElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLLinkElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLMapElement.cpp b/mozilla/content/html/content/src/nsHTMLMapElement.cpp
index f4ec4c062be..8368a571dba 100644
--- a/mozilla/content/html/content/src/nsHTMLMapElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLMapElement.cpp
@@ -158,14 +158,23 @@ nsHTMLMapElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLMapElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLMapElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLMapElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLMenuElement.cpp b/mozilla/content/html/content/src/nsHTMLMenuElement.cpp
index 62add355dce..176296ea26e 100644
--- a/mozilla/content/html/content/src/nsHTMLMenuElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLMenuElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX nav4 has type= start= (same as OL/UL)
@@ -163,30 +164,39 @@ nsHTMLMenuElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLMenuElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLMenuElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLMenuElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLMetaElement.cpp b/mozilla/content/html/content/src/nsHTMLMetaElement.cpp
index b81f8396c8a..dd26f1a0c4c 100644
--- a/mozilla/content/html/content/src/nsHTMLMetaElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLMetaElement.cpp
@@ -149,13 +149,22 @@ nsHTMLMetaElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLMetaElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLMetaElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLMetaElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLModElement.cpp b/mozilla/content/html/content/src/nsHTMLModElement.cpp
index 9115745b06f..f044ae1bf7b 100644
--- a/mozilla/content/html/content/src/nsHTMLModElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLModElement.cpp
@@ -145,14 +145,23 @@ nsHTMLModElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLModElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLModElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLModElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLOListElement.cpp b/mozilla/content/html/content/src/nsHTMLOListElement.cpp
index c483ab5b2d4..bcadc736e29 100644
--- a/mozilla/content/html/content/src/nsHTMLOListElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLOListElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLOListElementIID, NS_IDOMHTMLOLISTELEMENT_IID);
@@ -183,30 +184,39 @@ nsHTMLOListElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLOListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLOListElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLOListElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp
index 6e12754af5c..813345d747b 100644
--- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp
@@ -222,16 +222,25 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- mInner.MapImageAlignAttributeInto(aContext, aPresContext);
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLObjectElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLObjectElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp
index 17f5799f1b2..bd59dd73eaa 100644
--- a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp
@@ -145,14 +145,23 @@ nsHTMLOptGroupElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLOptGroupElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLOptGroupElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp
index 26c87b3c42b..5437204034e 100644
--- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp
@@ -169,14 +169,23 @@ nsHTMLOptionElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLOptionElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLOptionElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLOptionElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp
index 1af3c821244..412c5ad5b55 100644
--- a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX missing nav attributes
@@ -153,22 +154,32 @@ nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLParagraphElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
text->mTextAlign = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLParagraphElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLParagraphElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLParamElement.cpp b/mozilla/content/html/content/src/nsHTMLParamElement.cpp
index b0b3888e855..43f8749bac5 100644
--- a/mozilla/content/html/content/src/nsHTMLParamElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLParamElement.cpp
@@ -151,14 +151,23 @@ nsHTMLParamElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLParamElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLParamElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLParamElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLPreElement.cpp b/mozilla/content/html/content/src/nsHTMLPreElement.cpp
index 967506382ed..7a3e590469c 100644
--- a/mozilla/content/html/content/src/nsHTMLPreElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLPreElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX wrap, variable, cols, tabstop
@@ -167,21 +168,22 @@ nsHTMLPreElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLPreElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
// wrap: empty
- GetAttribute(nsHTMLAtoms::wrap, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::wrap, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
// variable: empty
- GetAttribute(nsHTMLAtoms::variable, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::variable, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
nsStyleFont* font = (nsStyleFont*)
aContext->GetMutableStyleData(eStyleStruct_Font);
@@ -189,19 +191,28 @@ nsHTMLPreElement::MapAttributesInto(nsIStyleContext* aContext,
}
// cols: int
- GetAttribute(nsHTMLAtoms::cols, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
if (value.GetUnit() == eHTMLUnit_Integer) {
// XXX set
}
// tabstop: int
+ aAttributes->GetAttribute(nsHTMLAtoms::tabstop, value);
if (value.GetUnit() == eHTMLUnit_Integer) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLPreElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLPreElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp b/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp
index 91130983f78..265f77b28cb 100644
--- a/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp
@@ -142,14 +142,23 @@ nsHTMLQuoteElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLQuoteElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLQuoteElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLQuoteElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp
index 745e5fd3747..700d706eaef 100644
--- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp
@@ -204,13 +204,22 @@ nsHTMLScriptElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLScriptElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLScriptElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLScriptElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp
index 4291d57a267..3bd339914ef 100644
--- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp
@@ -214,14 +214,23 @@ nsHTMLSelectElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLSelectElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLSelectElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLSelectElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp
index 6e12754af5c..813345d747b 100644
--- a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp
@@ -222,16 +222,25 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- mInner.MapImageAlignAttributeInto(aContext, aPresContext);
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLObjectElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLObjectElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLSpacerElement.cpp b/mozilla/content/html/content/src/nsHTMLSpacerElement.cpp
index a92684d0965..a4cd287b9a3 100644
--- a/mozilla/content/html/content/src/nsHTMLSpacerElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLSpacerElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX add nsIDOMHTMLSpacer?
@@ -158,15 +159,16 @@ nsHTMLSpacerElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLSpacerElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleDisplay* display = (nsStyleDisplay*)
aContext->GetMutableStyleData(eStyleStruct_Display);
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (eHTMLUnit_Enumerated == value.GetUnit()) {
switch (value.GetIntValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
@@ -180,7 +182,7 @@ nsHTMLSpacerElement::MapAttributesInto(nsIStyleContext* aContext,
}
}
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString tmp;
value.GetStringValue(tmp);
@@ -195,9 +197,17 @@ nsHTMLSpacerElement::MapAttributesInto(nsIStyleContext* aContext,
}
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLSpacerElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLSpacerElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLSpanElement.cpp b/mozilla/content/html/content/src/nsHTMLSpanElement.cpp
index 04d4236eac2..0ecbf3e5922 100644
--- a/mozilla/content/html/content/src/nsHTMLSpanElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLSpanElement.cpp
@@ -128,14 +128,23 @@ nsHTMLSpanElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLSpanElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLSpanElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLSpanElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp
index f64f6a5a46d..8efdaf51030 100644
--- a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp
@@ -148,13 +148,22 @@ nsHTMLStyleElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLStyleElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLStyleElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLStyleElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp
index e3a2081b48e..e5503b7254a 100644
--- a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp
@@ -142,14 +142,23 @@ nsHTMLTableCaptionElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableCaptionElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableCaptionElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableCaptionElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp
index 29c4f471aee..4ed7853d237 100644
--- a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp
@@ -197,14 +197,23 @@ nsHTMLTableCellElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableCellElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableCellElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableCellElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp
index a630d307144..1169edb826b 100644
--- a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp
@@ -157,14 +157,23 @@ nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableColElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableColElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableColElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp
index 4daf4bdf8e9..c3e141a738b 100644
--- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp
@@ -301,14 +301,23 @@ nsHTMLTableElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp
index 1902ec8b710..794cb3985db 100644
--- a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp
@@ -222,14 +222,23 @@ nsHTMLTableRowElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableRowElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableRowElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableRowElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp
index a2fb451d713..cfa8d1ce995 100644
--- a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp
@@ -179,14 +179,23 @@ nsHTMLTableSectionElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableSectionElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableSectionElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableSectionElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp
index 8a9c2be8642..47e0b2052aa 100644
--- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -202,14 +202,23 @@ nsHTMLTextAreaElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTextAreaElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTextAreaElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLTitleElement.cpp b/mozilla/content/html/content/src/nsHTMLTitleElement.cpp
index 59833e452a5..98b68ddaaf9 100644
--- a/mozilla/content/html/content/src/nsHTMLTitleElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTitleElement.cpp
@@ -141,13 +141,23 @@ nsHTMLTitleElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTitleElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTitleElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLTitleElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLUListElement.cpp b/mozilla/content/html/content/src/nsHTMLUListElement.cpp
index e461d9a36ca..0df490cedb1 100644
--- a/mozilla/content/html/content/src/nsHTMLUListElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLUListElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
extern nsGenericHTMLElement::EnumTable kListTypeTable[];
@@ -164,30 +165,39 @@ nsHTMLUListElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLUListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLUListElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLUListElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLWBRElement.cpp b/mozilla/content/html/content/src/nsHTMLWBRElement.cpp
index 1e9a89cb065..01884378f92 100644
--- a/mozilla/content/html/content/src/nsHTMLWBRElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLWBRElement.cpp
@@ -138,13 +138,23 @@ nsHTMLWBRElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLWBRElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLWBRElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLWBRElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/style/src/nsCSSStyleRule.cpp b/mozilla/content/html/style/src/nsCSSStyleRule.cpp
index 9016a41cc22..3bd6a337810 100644
--- a/mozilla/content/html/style/src/nsCSSStyleRule.cpp
+++ b/mozilla/content/html/style/src/nsCSSStyleRule.cpp
@@ -168,8 +168,7 @@ public:
PRInt32 aMask, const nsStyleFont* aFont,
nsIPresContext* aPresContext);
- NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent);
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
@@ -515,8 +514,7 @@ PRBool CSSStyleRuleImpl::SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord
}
NS_IMETHODIMP
-CSSStyleRuleImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+CSSStyleRuleImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
{
if (nsnull != mDeclaration) {
nsStyleFont* font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font);
diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
index fabeaca8404..945525537bf 100644
--- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
+++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
@@ -31,6 +31,7 @@
#include "nsIFrame.h"
#include "nsString.h"
#include "nsIPtr.h"
+#include "nsHTMLIIDs.h"
//#define DEBUG_REFS
//#define DEBUG_RULES
@@ -38,7 +39,6 @@
static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
NS_DEF_PTR(nsIHTMLContent);
NS_DEF_PTR(nsIContent);
diff --git a/mozilla/content/html/style/src/nsHTMLAttributes.cpp b/mozilla/content/html/style/src/nsHTMLAttributes.cpp
index 6a45e6dce68..24d8c2c51ab 100644
--- a/mozilla/content/html/style/src/nsHTMLAttributes.cpp
+++ b/mozilla/content/html/style/src/nsHTMLAttributes.cpp
@@ -164,14 +164,13 @@ HTMLAttribute::SizeOf(nsISizeOfHandler* aHandler) const
// ----------------
-
class HTMLAttributesImpl: public nsIHTMLAttributes, public nsIStyleRule {
public:
void* operator new(size_t size);
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
- HTMLAttributesImpl(void);
+ HTMLAttributesImpl(nsMapAttributesFunc aMapFunc);
HTMLAttributesImpl(const HTMLAttributesImpl& aCopy);
~HTMLAttributesImpl(void);
@@ -208,11 +207,11 @@ public:
NS_IMETHOD Clone(nsIHTMLAttributes** aInstancePtrResult);
NS_IMETHOD Reset(void);
+ NS_IMETHOD SetMappingFunction(nsMapAttributesFunc aMapFunc);
// nsIStyleRule
NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aResult) const;
- NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent);
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
/**
* Add this object's size information to the sizeof handler.
@@ -229,11 +228,12 @@ protected:
PRUint32 mInHeap : 1;
PRUint32 mRefCnt : 31;
+ PRInt32 mContentRefCount;
PRInt32 mCount;
HTMLAttribute mFirst;
nsIAtom* mID;
nsIAtom* mClass;
- PRInt32 mContentRefCount;
+ nsMapAttributesFunc mMapper;
};
void* HTMLAttributesImpl::operator new(size_t size)
@@ -271,12 +271,13 @@ void HTMLAttributesImpl::operator delete(void* ptr)
}
-HTMLAttributesImpl::HTMLAttributesImpl(void)
+HTMLAttributesImpl::HTMLAttributesImpl(nsMapAttributesFunc aMapFunc)
: mFirst(),
mCount(0),
mID(nsnull),
mClass(nsnull),
- mContentRefCount(0)
+ mContentRefCount(0),
+ mMapper(aMapFunc)
{
NS_INIT_REFCNT();
}
@@ -286,7 +287,8 @@ HTMLAttributesImpl::HTMLAttributesImpl(const HTMLAttributesImpl& aCopy)
mCount(aCopy.mCount),
mID(aCopy.mID),
mClass(aCopy.mClass),
- mContentRefCount(0)
+ mContentRefCount(0),
+ mMapper(aCopy.mMapper)
{
NS_INIT_REFCNT();
@@ -424,7 +426,7 @@ HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
HTMLAttribute* last = nsnull;
HTMLAttribute* attr = &mFirst;
- if (0 < mCount) {
+ if (nsnull != mFirst.mAttribute) {
while (nsnull != attr) {
if (attr->mAttribute == aAttribute) {
attr->mValue.SetStringValue(aValue);
@@ -477,7 +479,7 @@ HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute,
HTMLAttribute* last = nsnull;
HTMLAttribute* attr = &mFirst;
- if (0 < mCount) {
+ if (nsnull != mFirst.mAttribute) {
while (nsnull != attr) {
if (attr->mAttribute == aAttribute) {
attr->mValue = aValue;
@@ -728,15 +730,23 @@ HTMLAttributesImpl::Reset(void)
mFirst.mNext = nsnull;
NS_IF_RELEASE(mID);
NS_IF_RELEASE(mClass);
+ mMapper = nsnull;
return NS_OK;
}
NS_IMETHODIMP
-HTMLAttributesImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+HTMLAttributesImpl::SetMappingFunction(nsMapAttributesFunc aMapFunc)
{
- if (nsnull != aContent) {
- ((nsIHTMLContent*)aContent)->MapAttributesInto(aContext, aPresContext);
+ mMapper = aMapFunc;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLAttributesImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
+{
+ NS_ASSERTION(nsnull != mMapper, "no mapping function");
+ if (nsnull != mMapper) {
+ (*mMapper)(this, aContext, aPresContext);
}
return NS_OK;
}
@@ -770,13 +780,13 @@ HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const
}
extern NS_HTML nsresult
- NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult)
+ NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult, nsMapAttributesFunc aMapFunc)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
- HTMLAttributesImpl *it = new HTMLAttributesImpl();
+ HTMLAttributesImpl *it = new HTMLAttributesImpl(aMapFunc);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
diff --git a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp
index ec655f2b333..edba400dbed 100644
--- a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp
+++ b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp
@@ -25,10 +25,10 @@
#include "nsIHTMLContent.h"
#include "nsIStyleRule.h"
#include "nsIFrame.h"
+#include "nsHTMLIIDs.h"
static NS_DEFINE_IID(kIHTMLCSSStyleSheetIID, NS_IHTML_CSS_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
class HTMLCSSStyleSheetImpl : public nsIHTMLCSSStyleSheet {
diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
index c8a2e659f90..d214750b638 100644
--- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
+++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
@@ -34,11 +34,11 @@
#include "nsTableCell.h"
#include "nsTableColFrame.h"
#include "nsTableFrame.h"
+#include "nsHTMLIIDs.h"
static NS_DEFINE_IID(kIHTMLStyleSheetIID, NS_IHTML_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
class HTMLAnchorRule : public nsIStyleRule {
@@ -51,8 +51,7 @@ public:
NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aValue) const;
NS_IMETHOD HashValue(PRUint32& aValue) const;
- NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent);
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
@@ -85,8 +84,7 @@ HTMLAnchorRule::HashValue(PRUint32& aValue) const
}
NS_IMETHODIMP
-HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
{
nsStyleColor* styleColor = (nsStyleColor*)(aContext->GetMutableStyleData(eStyleStruct_Color));
@@ -107,7 +105,7 @@ HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const
class AttributeKey: public nsHashKey
{
public:
- AttributeKey(nsIAtom* aTag, nsIHTMLAttributes* aAttributes);
+ AttributeKey(nsMapAttributesFunc aMapFunc, nsIHTMLAttributes* aAttributes);
virtual ~AttributeKey(void);
PRBool Equals(const nsHashKey* aOther) const;
@@ -120,31 +118,29 @@ private:
AttributeKey& operator=(const AttributeKey& aCopy);
public:
- nsIAtom* mTag;
+ nsMapAttributesFunc mMapFunc;
nsIHTMLAttributes* mAttributes;
PRUint32 mHashSet: 1;
PRUint32 mHashCode: 31;
};
-AttributeKey::AttributeKey(nsIAtom* aTag, nsIHTMLAttributes* aAttributes)
- : mTag(aTag),
+AttributeKey::AttributeKey(nsMapAttributesFunc aMapFunc, nsIHTMLAttributes* aAttributes)
+ : mMapFunc(aMapFunc),
mAttributes(aAttributes)
{
- NS_ADDREF(mTag);
NS_ADDREF(mAttributes);
mHashSet = 0;
}
AttributeKey::~AttributeKey(void)
{
- NS_RELEASE(mTag);
NS_RELEASE(mAttributes);
}
PRBool AttributeKey::Equals(const nsHashKey* aOther) const
{
const AttributeKey* other = (const AttributeKey*)aOther;
- if (mTag == other->mTag) {
+ if (mMapFunc == other->mMapFunc) {
PRBool equals;
mAttributes->Equals(other->mAttributes, equals);
return equals;
@@ -159,7 +155,7 @@ PRUint32 AttributeKey::HashValue(void) const
PRUint32 hash;
mAttributes->HashValue(hash);
self->mHashCode = (0x7FFFFFFF & hash);
- self->mHashCode |= (0x7FFFFFFF & PRUint32(mTag));
+ self->mHashCode |= (0x7FFFFFFF & PRUint32(mMapFunc));
self->mHashSet = 1;
}
return mHashCode;
@@ -167,7 +163,7 @@ PRUint32 AttributeKey::HashValue(void) const
nsHashKey* AttributeKey::Clone(void) const
{
- AttributeKey* clown = new AttributeKey(mTag, mAttributes);
+ AttributeKey* clown = new AttributeKey(mMapFunc, mAttributes);
if (nsnull != clown) {
clown->mHashSet = mHashSet;
clown->mHashCode = mHashCode;
@@ -206,14 +202,19 @@ public:
NS_IMETHOD SetVisitedLinkColor(nscolor aColor);
// Attribute management methods, aAttributes is an in/out param
- NS_IMETHOD SetAttributesFor(nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetIDFor(nsIAtom* aID, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue, nsIAtom* aTag,
+ NS_IMETHOD SetAttributesFor(nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue, nsIAtom* aTag,
+ NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIAtom* aTag,
+ NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
@@ -230,11 +231,11 @@ protected:
virtual ~HTMLStyleSheetImpl();
NS_IMETHOD EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRBool aCreate,
nsIHTMLAttributes*& aSingleAttrs);
NS_IMETHOD UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRInt32 aAttrCount,
nsIHTMLAttributes*& aAttributes);
@@ -379,6 +380,7 @@ PRInt32 AppendRulesFrom(nsIFrame* aFrame, nsIPresContext* aPresContext, PRInt32&
AppendData data(backstopCount, aInsertPoint, aResults);
rules->EnumerateForwards(AppendFunc, &data);
aInsertPoint = data.mInsert;
+ NS_RELEASE(rules);
}
NS_RELEASE(context);
}
@@ -563,12 +565,14 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor)
return NS_OK;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsIHTMLAttributes* attrs = aAttributes;
if (nsnull != attrs) {
- AttributeKey key(aTag, attrs);
+ nsMapAttributesFunc mapFunc;
+ aContent->GetAttributeMappingFunction(mapFunc);
+ AttributeKey key(mapFunc, attrs);
nsIHTMLAttributes* sharedAttrs = (nsIHTMLAttributes*)mAttrTable.Get(&key);
if (nsnull == sharedAttrs) { // we have a new unique set
mAttrTable.Put(&key, attrs);
@@ -588,37 +592,43 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIAtom* aTag, nsIHTMLAttribu
return NS_OK;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetIDFor(nsIAtom* aID, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(nsnull != aID);
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetID(aID, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(nsnull != aClass);
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetClass(aClass, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
@@ -627,19 +637,22 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIAtom* aTag, ns
NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
const nsString& aValue,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, PR_TRUE, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, PR_TRUE, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetAttribute(aAttribute, aValue, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
@@ -647,7 +660,7 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
NS_IMETHODIMP
HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRBool aCreate,
nsIHTMLAttributes*& aSingleAttrs)
{
@@ -659,9 +672,10 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
if (nsnull != mRecycledAttrs) {
aSingleAttrs = mRecycledAttrs;
mRecycledAttrs = nsnull;
+ aSingleAttrs->SetMappingFunction(aMapFunc);
}
else {
- result = NS_NewHTMLAttributes(&aSingleAttrs);
+ result = NS_NewHTMLAttributes(&aSingleAttrs, aMapFunc);
}
}
else {
@@ -688,7 +702,7 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
}
else { // one content ref, ok to use, remove from table because hash may change
if (1 == contentRefCount) {
- AttributeKey key(aTag, aSingleAttrs);
+ AttributeKey key(aMapFunc, aSingleAttrs);
mAttrTable.Remove(&key);
NS_ADDREF(aSingleAttrs); // add a local ref so we match up
}
@@ -703,14 +717,14 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
NS_IMETHODIMP
HTMLStyleSheetImpl::UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRInt32 aAttrCount,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
if (0 < aAttrCount) {
- AttributeKey key(aTag, aSingleAttrs);
+ AttributeKey key(aMapFunc, aSingleAttrs);
nsIHTMLAttributes* sharedAttrs = (nsIHTMLAttributes*)mAttrTable.Get(&key);
if (nsnull == sharedAttrs) { // we have a new unique set
mAttrTable.Put(&key, aSingleAttrs);
@@ -757,39 +771,45 @@ HTMLStyleSheetImpl::UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(eHTMLUnit_Null != aValue.GetUnit());
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetAttribute(aAttribute, aValue, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
}
NS_IMETHODIMP HTMLStyleSheetImpl::UnsetAttributeFor(nsIAtom* aAttribute,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, PR_FALSE, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, PR_FALSE, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->UnsetAttribute(aAttribute, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
diff --git a/mozilla/content/html/style/src/nsIHTMLAttributes.h b/mozilla/content/html/style/src/nsIHTMLAttributes.h
index 0c1740fb473..0e259169dd3 100644
--- a/mozilla/content/html/style/src/nsIHTMLAttributes.h
+++ b/mozilla/content/html/style/src/nsIHTMLAttributes.h
@@ -21,11 +21,10 @@
#include "nslayout.h"
#include "nsISupports.h"
#include "nsHTMLValue.h"
-#include "nsIContent.h"
+#include "nsIHTMLContent.h"
class nsIAtom;
class nsISizeOfHandler;
class nsISupportsArray;
-class nsIHTMLContent;
// IID for the nsIHTMLAttributes interface {a18f85f0-c058-11d1-8031-006008159b5a}
@@ -33,6 +32,7 @@ class nsIHTMLContent;
{0xa18f85f0, 0xc058, 0x11d1, \
{0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
+
class nsIHTMLAttributes : public nsISupports {
public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
@@ -65,6 +65,7 @@ public:
NS_IMETHOD Clone(nsIHTMLAttributes** aInstancePtrResult) = 0;
NS_IMETHOD Reset(void) = 0;
+ NS_IMETHOD SetMappingFunction(nsMapAttributesFunc aMapFunc) = 0;
/**
* Add this object's size information to the sizeof handler.
@@ -75,7 +76,7 @@ public:
};
extern NS_HTML nsresult
- NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult);
+ NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult, nsMapAttributesFunc aMapFunc);
#endif /* nsIHTMLAttributes_h___ */
diff --git a/mozilla/layout/html/base/src/nsHTMLBullet.cpp b/mozilla/layout/html/base/src/nsHTMLBullet.cpp
index 1f3545bcf58..5352e6d0709 100644
--- a/mozilla/layout/html/base/src/nsHTMLBullet.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLBullet.cpp
@@ -55,8 +55,7 @@ public:
NS_IMETHOD IsSynthetic(PRBool& aResult);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
@@ -119,14 +118,20 @@ Bullet::Bullet()
{
}
-NS_IMETHODIMP
-Bullet::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- // Force display to be inline (bullet's are not block level)
nsStyleDisplay* display = (nsStyleDisplay*)
aContext->GetMutableStyleData(eStyleStruct_Display);
display->mDisplay = NS_STYLE_DISPLAY_INLINE;
+}
+
+NS_IMETHODIMP
+Bullet::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.cpp b/mozilla/layout/html/base/src/nsHTMLContainer.cpp
index 71f35c5f15a..172c0c0817b 100644
--- a/mozilla/layout/html/base/src/nsHTMLContainer.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLContainer.cpp
@@ -296,9 +296,9 @@ nsHTMLContainer::AttributeToString(nsIAtom* aAttribute,
}
NS_IMETHODIMP
-nsHTMLContainer::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+nsHTMLContainer::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
{
+ NS_ERROR("you must override this method");
return NS_OK;
}
diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.h b/mozilla/layout/html/base/src/nsHTMLContainer.h
index b50f0a51c82..4dcbb8459a1 100644
--- a/mozilla/layout/html/base/src/nsHTMLContainer.h
+++ b/mozilla/layout/html/base/src/nsHTMLContainer.h
@@ -52,8 +52,7 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
diff --git a/mozilla/layout/html/base/src/nsHTMLContent.cpp b/mozilla/layout/html/base/src/nsHTMLContent.cpp
index d477b32c931..1e6a279d197 100644
--- a/mozilla/layout/html/base/src/nsHTMLContent.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLContent.cpp
@@ -364,6 +364,13 @@ nsHTMLContent::GetAttributeCount(PRInt32& aCount) const
return NS_OK;
}
+NS_IMETHODIMP
+nsHTMLContent::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = nsnull;
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsHTMLContent::SetID(nsIAtom* aID)
{
@@ -397,14 +404,6 @@ nsHTMLContent::GetStyleRule(nsIStyleRule*& aResult)
return NS_OK;
}
-NS_IMETHODIMP
-nsHTMLContent::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
-{
- return NS_OK;
-}
-
-
void nsHTMLContent::ListAttributes(FILE* out) const
{
nsISupportsArray* attrs;
diff --git a/mozilla/layout/html/base/src/nsHTMLContent.h b/mozilla/layout/html/base/src/nsHTMLContent.h
index 5f37b6e3e60..11e881f0c5b 100644
--- a/mozilla/layout/html/base/src/nsHTMLContent.h
+++ b/mozilla/layout/html/base/src/nsHTMLContent.h
@@ -112,6 +112,7 @@ public:
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCountResult) const;
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const;
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
NS_IMETHOD SetID(nsIAtom* aID);
NS_IMETHOD GetID(nsIAtom*& aResult) const;
@@ -122,9 +123,6 @@ public:
NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
-
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const = 0;
diff --git a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp
index 5072a526f7c..73fb6d9271d 100644
--- a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp
@@ -147,15 +147,20 @@ nsHTMLTagContent::ConvertContentToXIF(nsXIFConverter& aConverter) const
-static nsresult EnsureWritableAttributes(nsIHTMLAttributes*& aAttributes, PRBool aCreate)
+static nsresult EnsureWritableAttributes(nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes, PRBool aCreate)
{
nsresult result = NS_OK;
if (nsnull == aAttributes) {
if (PR_TRUE == aCreate) {
- result = NS_NewHTMLAttributes(&aAttributes);
+ nsMapAttributesFunc mapFunc;
+ result = aContent->GetAttributeMappingFunction(mapFunc);
if (NS_OK == result) {
- aAttributes->AddContentRef();
+ result = NS_NewHTMLAttributes(&aAttributes, mapFunc);
+ if (NS_OK == result) {
+ aAttributes->AddContentRef();
+ }
}
}
}
@@ -331,7 +336,7 @@ nsHTMLTagContent::SetDocument(nsIDocument* aDocument)
if (nsnull != mAttributes) {
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- sheet->SetAttributesFor(mTag, mAttributes); // sync attributes with sheet
+ sheet->SetAttributesFor(this, mAttributes); // sync attributes with sheet
}
return rv;
}
@@ -555,10 +560,10 @@ nsHTMLTagContent::SetAttribute(nsIAtom* aAttribute,
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetAttributeFor(aAttribute, aValue, mTag, mAttributes);
+ result = sheet->SetAttributeFor(aAttribute, aValue, this, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- result = EnsureWritableAttributes(mAttributes, PR_TRUE);
+ result = EnsureWritableAttributes(this, mAttributes, PR_TRUE);
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetAttribute(aAttribute, aValue, count);
@@ -579,10 +584,10 @@ nsHTMLTagContent::SetAttribute(nsIAtom* aAttribute,
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetAttributeFor(aAttribute, aValue, mTag, mAttributes);
+ result = sheet->SetAttributeFor(aAttribute, aValue, this, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- result = EnsureWritableAttributes(mAttributes, PR_TRUE);
+ result = EnsureWritableAttributes(this, mAttributes, PR_TRUE);
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetAttribute(aAttribute, aValue, count);
@@ -600,10 +605,10 @@ nsHTMLTagContent::UnsetAttribute(nsIAtom* aAttribute)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->UnsetAttributeFor(aAttribute, mTag, mAttributes);
+ result = sheet->UnsetAttributeFor(aAttribute, this, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- result = EnsureWritableAttributes(mAttributes, PR_FALSE);
+ result = EnsureWritableAttributes(this, mAttributes, PR_FALSE);
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->UnsetAttribute(aAttribute, count);
@@ -653,10 +658,10 @@ nsHTMLTagContent::SetID(nsIAtom* aID)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetIDFor(aID, mTag, mAttributes);
+ result = sheet->SetIDFor(aID, this, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- EnsureWritableAttributes(mAttributes, PRBool(nsnull != aID));
+ EnsureWritableAttributes(this, mAttributes, PRBool(nsnull != aID));
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetID(aID, count);
@@ -684,10 +689,10 @@ nsHTMLTagContent::SetClass(nsIAtom* aClass)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetClassFor(aClass, mTag, mAttributes);
+ result = sheet->SetClassFor(aClass, this, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- EnsureWritableAttributes(mAttributes, PRBool(nsnull != aClass));
+ EnsureWritableAttributes(this, mAttributes, PRBool(nsnull != aClass));
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetClass(aClass, count);
diff --git a/mozilla/layout/html/base/src/nsIHTMLContent.h b/mozilla/layout/html/base/src/nsIHTMLContent.h
index 794569b51cb..11893e69f62 100644
--- a/mozilla/layout/html/base/src/nsIHTMLContent.h
+++ b/mozilla/layout/html/base/src/nsIHTMLContent.h
@@ -27,12 +27,17 @@ class nsIStyleRule;
class nsIStyleContext;
class nsIPresContext;
class nsXIFConverter;
+class nsIHTMLAttributes;
// IID for the nsIHTMLContent class
#define NS_IHTMLCONTENT_IID \
{ 0xb9e110b0, 0x94d6, 0x11d1, \
{0x89, 0x5c, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
+typedef void (*nsMapAttributesFunc)(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
+
// Abstract interface for all html content
class nsIHTMLContent : public nsIContent {
public:
@@ -61,6 +66,7 @@ public:
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCountResult) const = 0;
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const = 0;
NS_IMETHOD SetID(nsIAtom* aID) = 0;
NS_IMETHOD GetID(nsIAtom*& aResult) const = 0;
@@ -71,9 +77,6 @@ public:
NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult) = 0;
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext) = 0;
-
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const = 0;
diff --git a/mozilla/layout/html/content/src/nsCommentNode.cpp b/mozilla/layout/html/content/src/nsCommentNode.cpp
index e3e36c285a3..79995681ed4 100644
--- a/mozilla/layout/html/content/src/nsCommentNode.cpp
+++ b/mozilla/layout/html/content/src/nsCommentNode.cpp
@@ -19,6 +19,7 @@
#include "nsHTMLContainer.h"
#include "nsFrame.h"
#include "nsHTMLIIDs.h"
+#include "nsGenericHTMLElement.h"
// XXX rework this
@@ -33,6 +34,8 @@ public:
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
+
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
protected:
@@ -91,6 +94,22 @@ nsCommentNode::List(FILE* out, PRInt32 aIndent) const
return NS_OK;
}
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
+{
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsCommentNode::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
nsresult
NS_NewCommentNode(nsIHTMLContent** aInstancePtrResult,
nsIAtom* aTag, const nsString& aComment)
diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
index 8e9cb12ef1c..2dd1b1c7889 100644
--- a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
@@ -584,15 +584,20 @@ DOMAttributeMap::GetLength(PRUint32 *aLength)
//----------------------------------------------------------------------
-static nsresult EnsureWritableAttributes(nsIHTMLAttributes*& aAttributes, PRBool aCreate)
+static nsresult EnsureWritableAttributes(nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes, PRBool aCreate)
{
nsresult result = NS_OK;
if (nsnull == aAttributes) {
if (PR_TRUE == aCreate) {
- result = NS_NewHTMLAttributes(&aAttributes);
+ nsMapAttributesFunc mapFunc;
+ result = aContent->GetAttributeMappingFunction(mapFunc);
if (NS_OK == result) {
- aAttributes->AddContentRef();
+ result = NS_NewHTMLAttributes(&aAttributes, mapFunc);
+ if (NS_OK == result) {
+ aAttributes->AddContentRef();
+ }
}
}
}
@@ -1032,7 +1037,7 @@ nsGenericHTMLElement::SetDocument(nsIDocument* aDocument)
AddScriptEventListener(nsHTMLAtoms::onblur, val, kIDOMFocusListenerIID);
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- sheet->SetAttributesFor(mTag, mAttributes); // sync attributes with sheet
+ sheet->SetAttributesFor(mContent, mAttributes); // sync attributes with sheet
}
return NS_OK;
@@ -1198,11 +1203,26 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
nsHTMLValue val;
if (NS_CONTENT_ATTR_NOT_THERE !=
mContent->StringToAttribute(aAttribute, aValue, val)) {
+ // string value was mapped to nsHTMLValue, set it that way
+ result = SetAttribute(aAttribute, val, aNotify);
}
else {
- val.SetStringValue(aValue);
+ // set as string value to avoid another string copy
+ if (nsnull != mDocument) { // set attr via style sheet
+ nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
+ result = sheet->SetAttributeFor(aAttribute, aValue, mContent, mAttributes);
+ }
+ else { // manage this ourselves and re-sync when we connect to doc
+ result = EnsureWritableAttributes(mContent, mAttributes, PR_TRUE);
+ if (nsnull != mAttributes) {
+ PRInt32 count;
+ result = mAttributes->SetAttribute(aAttribute, aValue, count);
+ if (0 == count) {
+ ReleaseAttributes(mAttributes);
+ }
+ }
+ }
}
- result = SetAttribute(aAttribute, val, aNotify);
}
return result;
}
@@ -1215,10 +1235,10 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetAttributeFor(aAttribute, aValue, mTag, mAttributes);
+ result = sheet->SetAttributeFor(aAttribute, aValue, mContent, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- result = EnsureWritableAttributes(mAttributes, PR_TRUE);
+ result = EnsureWritableAttributes(mContent, mAttributes, PR_TRUE);
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetAttribute(aAttribute, aValue, count);
@@ -1233,20 +1253,20 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
/**
* Handle attributes common to all html elements
*/
-nsresult
-nsGenericHTMLElement::MapAttributesInto(nsIStyleContext* aStyleContext,
- nsIPresContext* aPresContext)
+void
+nsGenericHTMLElement::MapCommonAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aStyleContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::dir, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::dir, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleDisplay* display = (nsStyleDisplay*)
aStyleContext->GetMutableStyleData(eStyleStruct_Display);
display->mDirection = value.GetIntValue();
}
}
- return NS_OK;
}
nsresult
@@ -1273,10 +1293,10 @@ nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->UnsetAttributeFor(aAttribute, mTag, mAttributes);
+ result = sheet->UnsetAttributeFor(aAttribute, mContent, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- result = EnsureWritableAttributes(mAttributes, PR_FALSE);
+ result = EnsureWritableAttributes(mContent, mAttributes, PR_FALSE);
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->UnsetAttribute(aAttribute, count);
@@ -1399,10 +1419,10 @@ nsGenericHTMLElement::SetID(nsIAtom* aID)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetIDFor(aID, mTag, mAttributes);
+ result = sheet->SetIDFor(aID, mContent, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- EnsureWritableAttributes(mAttributes, PRBool(nsnull != aID));
+ EnsureWritableAttributes(mContent, mAttributes, PRBool(nsnull != aID));
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetID(aID, count);
@@ -1430,10 +1450,10 @@ nsGenericHTMLElement::SetClass(nsIAtom* aClass)
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
- result = sheet->SetClassFor(aClass, mTag, mAttributes);
+ result = sheet->SetClassFor(aClass, mContent, mAttributes);
}
else { // manage this ourselves and re-sync when we connect to doc
- EnsureWritableAttributes(mAttributes, PRBool(nsnull != aClass));
+ EnsureWritableAttributes(mContent, mAttributes, PRBool(nsnull != aClass));
if (nsnull != mAttributes) {
PRInt32 count;
result = mAttributes->SetClass(aClass, count);
@@ -2162,10 +2182,11 @@ nsGenericHTMLElement::ImageAttributeToString(nsIAtom* aAttribute,
}
void
-nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
float p2t = aPresContext->GetPixelsToTwips();
@@ -2175,7 +2196,7 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
aContext->GetMutableStyleData(eStyleStruct_Spacing);
// width: value
- GetAttribute(nsHTMLAtoms::width, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
pos->mWidth.SetCoordValue(twips);
@@ -2185,7 +2206,7 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
}
// height: value
- GetAttribute(nsHTMLAtoms::height, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
pos->mHeight.SetCoordValue(twips);
@@ -2195,7 +2216,7 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
}
// hspace: value
- GetAttribute(nsHTMLAtoms::hspace, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
spacing->mMargin.SetRight(nsStyleCoord(twips));
@@ -2206,7 +2227,7 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
}
// vspace: value
- GetAttribute(nsHTMLAtoms::vspace, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
spacing->mMargin.SetBottom(nsStyleCoord(twips));
@@ -2219,12 +2240,13 @@ nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
}
void
-nsGenericHTMLElement::MapImageAlignAttributeInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageAlignAttributeInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
PRUint8 align = value.GetIntValue();
nsStyleDisplay* display = (nsStyleDisplay*)
@@ -2255,15 +2277,16 @@ nsGenericHTMLElement::MapImageAlignAttributeInto(nsIStyleContext* aContext,
}
void
-nsGenericHTMLElement::MapImageBorderAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageBorderAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext,
nscolor aBorderColors[4])
{
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
// border: pixels
- GetAttribute(nsHTMLAtoms::border, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::border, value);
if (value.GetUnit() != eHTMLUnit_Pixel) {
if (nsnull == aBorderColors) {
return;
@@ -2313,14 +2336,15 @@ nsGenericHTMLElement::MapImageBorderAttributesInto(nsIStyleContext* aContext,
}
void
-nsGenericHTMLElement::MapBackgroundAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapBackgroundAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
nsHTMLValue value;
// background
if (NS_CONTENT_ATTR_HAS_VALUE ==
- GetAttribute(nsHTMLAtoms::background, value)) {
+ aAttributes->GetAttribute(nsHTMLAtoms::background, value)) {
if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString absURLSpec;
nsAutoString spec;
@@ -2328,15 +2352,11 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(nsIStyleContext* aContext,
if (spec.Length() > 0) {
// Resolve url to an absolute url
nsIURL* docURL = nsnull;
- nsIDocument* doc = mDocument;
- if (nsnull != doc) {
- docURL = doc->GetDocumentURL();
- }
+ aPresContext->GetBaseURL(docURL);
nsresult rv = NS_MakeAbsoluteURL(docURL, "", spec, absURLSpec);
- if (nsnull != docURL) {
- NS_RELEASE(docURL);
- }
+ NS_IF_RELEASE(docURL);
+
nsStyleColor* color = (nsStyleColor*)
aContext->GetMutableStyleData(eStyleStruct_Color);
color->mBackgroundImage = absURLSpec;
@@ -2347,7 +2367,7 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(nsIStyleContext* aContext,
}
// bgcolor
- if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::bgcolor, value)) {
+ if (NS_CONTENT_ATTR_HAS_VALUE == aAttributes->GetAttribute(nsHTMLAtoms::bgcolor, value)) {
if (eHTMLUnit_Color == value.GetUnit()) {
nsStyleColor* color = (nsStyleColor*)
aContext->GetMutableStyleData(eStyleStruct_Color);
diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.h b/mozilla/layout/html/content/src/nsGenericHTMLElement.h
index 78e0faf9858..814930c0224 100644
--- a/mozilla/layout/html/content/src/nsGenericHTMLElement.h
+++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.h
@@ -140,8 +140,6 @@ public:
nsresult SetClass(nsIAtom* aClass);
nsresult GetClass(nsIAtom*& aResult) const;
nsresult GetStyleRule(nsIStyleRule*& aResult);
- nsresult MapAttributesInto(nsIStyleContext* aStyleContext,
- nsIPresContext* aPresContext);
nsresult ToHTMLString(nsString& aResult) const;
nsresult ToHTML(FILE* out) const;
nsresult CreateFrame(nsIPresContext* aPresContext,
@@ -231,18 +229,26 @@ public:
const nsHTMLValue& aValue,
nsString& aResult);
- void MapImageAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ static void MapCommonAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aStyleContext,
+ nsIPresContext* aPresContext);
- void MapImageAlignAttributeInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ static void MapImageAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
- void MapImageBorderAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext,
- nscolor aBorderColors[4]);
+ static void MapImageAlignAttributeInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
- void MapBackgroundAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ static void MapImageBorderAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext,
+ nscolor aBorderColors[4]);
+
+ static void MapBackgroundAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
static nsresult GetScriptObjectFactory(nsIDOMScriptObjectFactory **aFactory);
@@ -699,8 +705,7 @@ public:
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
nsHTMLValue& aValue, \
nsString& aResult) const; \
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
#define NS_IMPL_IHTMLCONTENT_USING_GENERIC2(_g) \
NS_IMETHOD Compact() { \
@@ -764,8 +769,7 @@ public:
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
nsHTMLValue& aValue, \
nsString& aResult) const; \
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
/**
* This macro implements the portion of query interface that is
diff --git a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp
index e703b396929..37d1530d36d 100644
--- a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp
@@ -214,13 +214,22 @@ nsHTMLAnchorElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLAnchorElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLAnchorElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
// XXX support suppress in here
NS_IMETHODIMP
nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
diff --git a/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp b/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp
index daea436a92b..f0d7a78b653 100644
--- a/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp
@@ -189,16 +189,26 @@ nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLAppletElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- mInner.MapImageAlignAttributeInto(aContext, aPresContext);
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLAppletElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLAppletElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp b/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp
index 59db5608d4e..931afd9c5e3 100644
--- a/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp
@@ -161,13 +161,22 @@ nsHTMLAreaElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLAreaElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLAreaElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLAreaElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLBRElement.cpp b/mozilla/layout/html/content/src/nsHTMLBRElement.cpp
index 43ca4b5b07c..67418da1704 100644
--- a/mozilla/layout/html/content/src/nsHTMLBRElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLBRElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLBRElementIID, NS_IDOMHTMLBRELEMENT_IID);
@@ -159,22 +160,31 @@ nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLBRElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsStyleDisplay* display = (nsStyleDisplay*)
aContext->GetMutableStyleData(eStyleStruct_Display);
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::clear, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::clear, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
display->mBreakType = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLBRElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLBRElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp b/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp
index cb9264388d6..ba685f841ed 100644
--- a/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp
@@ -143,13 +143,22 @@ nsHTMLBaseElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLBaseElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLBaseElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLBaseElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp b/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp
index b86eaab74b0..04c4bed9586 100644
--- a/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp
@@ -148,14 +148,24 @@ nsHTMLBaseFontElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLBaseFontElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- // XXX write me?
- return mInner.MapAttributesInto(aContext, aPresContext);
+ // XXX write me
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLBaseFontElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLBaseFontElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp b/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp
index 7ded91b806e..5951b161226 100644
--- a/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp
@@ -26,12 +26,14 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIPresShell.h"
#include "nsStyleUtil.h"
#include "nsIDocument.h"
#include "nsIHTMLDocument.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIStyleRule.h"
#include "nsIWebShell.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
@@ -90,6 +92,8 @@ public:
protected:
nsGenericHTMLContainerElement mInner;
BodyRule* mStyleRule;
+
+friend BodyRule;
};
class BodyRule: public nsIStyleRule {
@@ -103,8 +107,7 @@ public:
NS_IMETHOD HashValue(PRUint32& aValue) const;
NS_IMETHOD MapStyleInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext,
- nsIContent* aContent);
+ nsIPresContext* aPresContext);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
@@ -140,10 +143,8 @@ BodyRule::HashValue(PRUint32& aValue) const
}
NS_IMETHODIMP
-BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
{
- NS_ASSERTION(aContent == mPart, "bad content mapping");
if (nsnull != mPart) {
nsStyleSpacing* styleSpacing = (nsStyleSpacing*)(aContext->GetMutableStyleData(eStyleStruct_Spacing));
@@ -173,7 +174,9 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
}
if (count < attrCount) { // more to go...
- mPart->MapAttributesInto(aContext, aPresContext);
+ nsMapAttributesFunc func;
+ mPart->GetAttributeMappingFunction(func);
+ (*func)(mPart->mInner.mAttributes, aContext, aPresContext);
}
}
@@ -312,14 +315,16 @@ nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- mInner.MapBackgroundAttributesInto(aContext, aPresContext);
- GetAttribute(nsHTMLAtoms::text, value);
+ nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aContext, aPresContext);
+
+ aAttributes->GetAttribute(nsHTMLAtoms::text, value);
if (eHTMLUnit_Color == value.GetUnit()) {
nsStyleColor* color = (nsStyleColor*)
aContext->GetMutableStyleData(eStyleStruct_Color);
@@ -327,27 +332,36 @@ nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext,
aPresContext->SetDefaultColor(color->mColor);
}
- nsIHTMLDocument* htmlDoc;
- if (NS_OK == mInner.mDocument->QueryInterface(kIHTMLDocumentIID,
- (void**)&htmlDoc)) {
- nsIHTMLStyleSheet* styleSheet;
- if (NS_OK == htmlDoc->GetAttributeStyleSheet(&styleSheet)) {
- GetAttribute(nsHTMLAtoms::link, value);
- if (eHTMLUnit_Color == value.GetUnit()) {
- styleSheet->SetLinkColor(value.GetColorValue());
- }
+ nsIPresShell* presShell = aPresContext->GetShell();
+ if (nsnull != presShell) {
+ nsIDocument* doc = presShell->GetDocument();
+ if (nsnull != doc) {
+ nsIHTMLDocument* htmlDoc;
+ if (NS_OK == doc->QueryInterface(kIHTMLDocumentIID,
+ (void**)&htmlDoc)) {
+ nsIHTMLStyleSheet* styleSheet;
+ if (NS_OK == htmlDoc->GetAttributeStyleSheet(&styleSheet)) {
+ aAttributes->GetAttribute(nsHTMLAtoms::link, value);
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ styleSheet->SetLinkColor(value.GetColorValue());
+ }
- GetAttribute(nsHTMLAtoms::alink, value);
- if (eHTMLUnit_Color == value.GetUnit()) {
- styleSheet->SetActiveLinkColor(value.GetColorValue());
- }
+ aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ styleSheet->SetActiveLinkColor(value.GetColorValue());
+ }
- GetAttribute(nsHTMLAtoms::vlink, value);
- if (eHTMLUnit_Color == value.GetUnit()) {
- styleSheet->SetVisitedLinkColor(value.GetColorValue());
+ aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ styleSheet->SetVisitedLinkColor(value.GetColorValue());
+ }
+ NS_RELEASE(styleSheet);
+ }
+ NS_RELEASE(htmlDoc);
}
+ NS_RELEASE(doc);
}
- NS_RELEASE(htmlDoc);
+ NS_RELEASE(presShell);
}
// marginwidth/height get set by a special style rule
@@ -361,9 +375,17 @@ nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext,
font->mFont.size = nsStyleUtil::CalcFontPointSize(3, (PRInt32)defaultFont.size, scaleFactor);
font->mFixedFont.size = nsStyleUtil::CalcFontPointSize(3, (PRInt32)defaultFixedFont.size, scaleFactor);
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLBodyElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLBodyElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp
index e4a2ca9a27d..0fcfa436357 100644
--- a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp
@@ -177,11 +177,19 @@ nsHTMLButtonElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLButtonElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLButtonElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLDListElement.cpp b/mozilla/layout/html/content/src/nsHTMLDListElement.cpp
index 41f99ccad0e..f92025a20c3 100644
--- a/mozilla/layout/html/content/src/nsHTMLDListElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLDListElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLDListElementIID, NS_IDOMHTMLDLISTELEMENT_IID);
@@ -144,24 +145,33 @@ nsHTMLDListElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLDListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLDListElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLDListElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLDelElement.cpp b/mozilla/layout/html/content/src/nsHTMLDelElement.cpp
index f36ab407a4c..e220083bdff 100644
--- a/mozilla/layout/html/content/src/nsHTMLDelElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLDelElement.cpp
@@ -145,14 +145,23 @@ nsHTMLDelElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLDelElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLDelElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLDelElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp b/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp
index 5102ab4843d..96b9bb94731 100644
--- a/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX nav4 has type= start= (same as OL/UL)
@@ -163,30 +164,40 @@ nsHTMLDirectoryElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLDirectoryElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLDirectoryElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLDirectoryElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLDivElement.cpp b/mozilla/layout/html/content/src/nsHTMLDivElement.cpp
index dc2a4d964ee..8c5f3c2114d 100644
--- a/mozilla/layout/html/content/src/nsHTMLDivElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLDivElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX support missing nav attributes? gutter, cols, width
@@ -166,22 +167,31 @@ nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLDivElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
text->mTextAlign = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLDivElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLDivElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp b/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp
index d13ee91e26e..8c7d2fbbe0f 100644
--- a/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp
@@ -159,16 +159,25 @@ nsHTMLEmbedElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLEmbedElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- mInner.MapImageAlignAttributeInto(aContext, aPresContext);
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLEmbedElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLEmbedElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLFontElement.cpp b/mozilla/layout/html/content/src/nsHTMLFontElement.cpp
index 4d4c67cef18..9f26b633e83 100644
--- a/mozilla/layout/html/content/src/nsHTMLFontElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLFontElement.cpp
@@ -28,6 +28,7 @@
#include "nsStyleConsts.h"
#include "nsStyleUtil.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLFontElementIID, NS_IDOMHTMLFONTELEMENT_IID);
@@ -181,11 +182,12 @@ nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleFont* font = (nsStyleFont*)
aContext->GetMutableStyleData(eStyleStruct_Font);
@@ -199,7 +201,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFont();
// face: string list
- GetAttribute(nsHTMLAtoms::face, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::face, value);
if (value.GetUnit() == eHTMLUnit_String) {
nsIDeviceContext* dc = aPresContext->GetDeviceContext();
@@ -228,7 +230,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
}
// pointSize: int, enum
- GetAttribute(nsHTMLAtoms::pointSize, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::pointSize, value);
if (value.GetUnit() == eHTMLUnit_Integer) {
// XXX should probably sanitize value
font->mFont.size = parentFont->mFont.size +
@@ -246,7 +248,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
// size: int, enum , NOTE: this does not count as an explicit size
// also this has no effect if font is already explicit
if (0 == (font->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT)) {
- GetAttribute(nsHTMLAtoms::size, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::size, value);
if ((value.GetUnit() == eHTMLUnit_Integer) ||
(value.GetUnit() == eHTMLUnit_Enumerated)) {
PRInt32 size = value.GetIntValue();
@@ -269,7 +271,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
}
// fontWeight: int, enum
- GetAttribute(nsHTMLAtoms::fontWeight, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::fontWeight, value);
if (value.GetUnit() == eHTMLUnit_Integer) { // +/-
PRInt32 weight = parentFont->mFont.weight + value.GetIntValue();
font->mFont.weight =
@@ -285,7 +287,7 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
}
// color: color
- GetAttribute(nsHTMLAtoms::color, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::color, value);
if (value.GetUnit() == eHTMLUnit_Color) {
nsStyleColor* color = (nsStyleColor*)
aContext->GetMutableStyleData(eStyleStruct_Color);
@@ -304,7 +306,14 @@ nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
NS_IF_RELEASE(parentContext);
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLFontElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLFormElement.cpp b/mozilla/layout/html/content/src/nsHTMLFormElement.cpp
index 3db62773f3b..f869db3a2e3 100644
--- a/mozilla/layout/html/content/src/nsHTMLFormElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLFormElement.cpp
@@ -186,14 +186,24 @@ nsHTMLFormElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLFormElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLFormElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLFormElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp b/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp
index 6c293dcc41f..28812db1166 100644
--- a/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp
@@ -163,12 +163,20 @@ nsHTMLFrameElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLFrameElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLFrameElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp b/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp
index e0378c59d7b..5403916e2d0 100644
--- a/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp
@@ -145,12 +145,20 @@ nsHTMLFrameSetElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLFrameSetElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLFrameSetElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLHRElement.cpp b/mozilla/layout/html/content/src/nsHTMLHRElement.cpp
index b0911864657..cf1eedc49c6 100644
--- a/mozilla/layout/html/content/src/nsHTMLHRElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLHRElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLHRElementIID, NS_IDOMHTMLHRELEMENT_IID);
@@ -180,14 +181,15 @@ nsHTMLHRElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
// align: enum
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
@@ -198,7 +200,7 @@ nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext,
float p2t = aPresContext->GetPixelsToTwips();
nsStylePosition* pos = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
- GetAttribute(nsHTMLAtoms::width, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
pos->mWidth.SetCoordValue(twips);
@@ -207,9 +209,17 @@ nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext,
pos->mWidth.SetPercentValue(value.GetPercentValue());
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLHRElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLHRElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp b/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp
index 562a3230486..7737e484890 100644
--- a/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp
@@ -140,13 +140,22 @@ nsHTMLHeadElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLHeadElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLHeadElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLHeadElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp b/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp
index 4dbf8375056..5b8ba7c43c0 100644
--- a/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLHeadingElementIID, NS_IDOMHTMLHEADINGELEMENT_IID);
@@ -151,22 +152,31 @@ nsHTMLHeadingElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLHeadingElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
text->mTextAlign = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLHeadingElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLHeadingElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp b/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp
index d2f97cebe74..42d87ba7599 100644
--- a/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp
@@ -140,13 +140,22 @@ nsHTMLHtmlElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLHtmlElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLHtmlElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLHtmlElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp
index 3e2e5806fe7..43c7ca16b06 100644
--- a/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp
@@ -169,14 +169,23 @@ nsHTMLIFrameElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLIFrameElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLIFrameElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLIFrameElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLImageElement.cpp b/mozilla/layout/html/content/src/nsHTMLImageElement.cpp
index 1a6befe33a5..fe639a91b71 100644
--- a/mozilla/layout/html/content/src/nsHTMLImageElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLImageElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX nav attrs: suppress
@@ -209,13 +210,14 @@ nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
PRUint8 align = value.GetIntValue();
nsStyleDisplay* display = (nsStyleDisplay*)
@@ -243,11 +245,19 @@ nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext,
}
}
}
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLImageElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLImageElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
index a8a17278eaf..01e9c970252 100644
--- a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX align=left, hspace, vspace, border? other nav4 attrs
@@ -237,14 +238,23 @@ nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLInputElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX align
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLInputElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLInputElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLInsElement.cpp b/mozilla/layout/html/content/src/nsHTMLInsElement.cpp
index 7ceff2510b5..d5146328430 100644
--- a/mozilla/layout/html/content/src/nsHTMLInsElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLInsElement.cpp
@@ -145,14 +145,23 @@ nsHTMLInsElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLInsElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLInsElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLInsElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp b/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp
index 84bfe6fb19d..60f60e2934a 100644
--- a/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp
@@ -157,14 +157,23 @@ nsHTMLIsIndexElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLIsIndexElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLIsIndexElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLIsIndexElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLLIElement.cpp b/mozilla/layout/html/content/src/nsHTMLLIElement.cpp
index 8be6117f6af..dbb9cc98f50 100644
--- a/mozilla/layout/html/content/src/nsHTMLLIElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLIElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLLIElementIID, NS_IDOMHTMLLIELEMENT_IID);
@@ -169,22 +170,30 @@ nsHTMLLIElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLIElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLLIElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp b/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp
index bc159662ff9..bee260dd58d 100644
--- a/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp
@@ -160,12 +160,20 @@ nsHTMLLabelElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLabelElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLLabelElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp b/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp
index 48e2ab28970..9db107a28db 100644
--- a/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLLayerElementIID, NS_IDOMHTMLELEMENT_IID);
@@ -202,33 +203,34 @@ nsHTMLLayerElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLayerElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// Note: ua.css specifies that the 'position' is absolute
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
float p2t = aPresContext->GetPixelsToTwips();
nsStylePosition* position = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
// Left
- GetAttribute(nsHTMLAtoms::left, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::left, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
position->mLeftOffset.SetCoordValue(twips);
}
// Top
- GetAttribute(nsHTMLAtoms::top, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::top, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
position->mTopOffset.SetCoordValue(twips);
}
// Width
- GetAttribute(nsHTMLAtoms::width, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
position->mWidth.SetCoordValue(twips);
@@ -238,7 +240,7 @@ nsHTMLLayerElement::MapAttributesInto(nsIStyleContext* aContext,
}
// Height
- GetAttribute(nsHTMLAtoms::height, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
position->mHeight.SetCoordValue(twips);
@@ -248,13 +250,13 @@ nsHTMLLayerElement::MapAttributesInto(nsIStyleContext* aContext,
}
// Z-index
- GetAttribute(nsHTMLAtoms::zindex, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::zindex, value);
if (value.GetUnit() == eHTMLUnit_Integer) {
position->mZIndex.SetIntValue(value.GetIntValue(), eStyleUnit_Integer);
}
// Visibility
- GetAttribute(nsHTMLAtoms::visibility, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::visibility, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleDisplay* display = (nsStyleDisplay*)
aContext->GetMutableStyleData(eStyleStruct_Display);
@@ -263,11 +265,19 @@ nsHTMLLayerElement::MapAttributesInto(nsIStyleContext* aContext,
}
// Background and bgcolor
- mInner.MapBackgroundAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aContext, aPresContext);
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLLayerElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLLayerElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp b/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp
index 4389532d22d..b5fd9ad9e40 100644
--- a/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp
@@ -160,14 +160,23 @@ nsHTMLLegendElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLegendElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLLegendElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLLegendElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp b/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp
index 89bf51d93ab..4d55dbc87aa 100644
--- a/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp
@@ -164,13 +164,22 @@ nsHTMLLinkElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLLinkElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLLinkElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLLinkElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLMapElement.cpp b/mozilla/layout/html/content/src/nsHTMLMapElement.cpp
index f4ec4c062be..8368a571dba 100644
--- a/mozilla/layout/html/content/src/nsHTMLMapElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLMapElement.cpp
@@ -158,14 +158,23 @@ nsHTMLMapElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLMapElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLMapElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLMapElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp b/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp
index 62add355dce..176296ea26e 100644
--- a/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX nav4 has type= start= (same as OL/UL)
@@ -163,30 +164,39 @@ nsHTMLMenuElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLMenuElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLMenuElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLMenuElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp b/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp
index b81f8396c8a..dd26f1a0c4c 100644
--- a/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp
@@ -149,13 +149,22 @@ nsHTMLMetaElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLMetaElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLMetaElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLMetaElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLModElement.cpp b/mozilla/layout/html/content/src/nsHTMLModElement.cpp
index 9115745b06f..f044ae1bf7b 100644
--- a/mozilla/layout/html/content/src/nsHTMLModElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLModElement.cpp
@@ -145,14 +145,23 @@ nsHTMLModElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLModElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLModElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLModElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLOListElement.cpp b/mozilla/layout/html/content/src/nsHTMLOListElement.cpp
index c483ab5b2d4..bcadc736e29 100644
--- a/mozilla/layout/html/content/src/nsHTMLOListElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLOListElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
static NS_DEFINE_IID(kIDOMHTMLOListElementIID, NS_IDOMHTMLOLISTELEMENT_IID);
@@ -183,30 +184,39 @@ nsHTMLOListElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLOListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLOListElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLOListElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp b/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp
index 6e12754af5c..813345d747b 100644
--- a/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp
@@ -222,16 +222,25 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- mInner.MapImageAlignAttributeInto(aContext, aPresContext);
- mInner.MapImageAttributesInto(aContext, aPresContext);
- mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLObjectElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLObjectElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp
index 17f5799f1b2..bd59dd73eaa 100644
--- a/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp
@@ -145,14 +145,23 @@ nsHTMLOptGroupElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLOptGroupElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLOptGroupElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp b/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp
index 26c87b3c42b..5437204034e 100644
--- a/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp
@@ -169,14 +169,23 @@ nsHTMLOptionElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLOptionElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLOptionElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLOptionElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp b/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp
index 1af3c821244..412c5ad5b55 100644
--- a/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX missing nav attributes
@@ -153,22 +154,32 @@ nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLParagraphElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
text->mTextAlign = value.GetIntValue();
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLParagraphElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLParagraphElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLParamElement.cpp b/mozilla/layout/html/content/src/nsHTMLParamElement.cpp
index b0b3888e855..43f8749bac5 100644
--- a/mozilla/layout/html/content/src/nsHTMLParamElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLParamElement.cpp
@@ -151,14 +151,23 @@ nsHTMLParamElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLParamElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLParamElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLParamElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLPreElement.cpp b/mozilla/layout/html/content/src/nsHTMLPreElement.cpp
index 967506382ed..7a3e590469c 100644
--- a/mozilla/layout/html/content/src/nsHTMLPreElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLPreElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX wrap, variable, cols, tabstop
@@ -167,21 +168,22 @@ nsHTMLPreElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLPreElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
// wrap: empty
- GetAttribute(nsHTMLAtoms::wrap, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::wrap, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
// variable: empty
- GetAttribute(nsHTMLAtoms::variable, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::variable, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
nsStyleFont* font = (nsStyleFont*)
aContext->GetMutableStyleData(eStyleStruct_Font);
@@ -189,19 +191,28 @@ nsHTMLPreElement::MapAttributesInto(nsIStyleContext* aContext,
}
// cols: int
- GetAttribute(nsHTMLAtoms::cols, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
if (value.GetUnit() == eHTMLUnit_Integer) {
// XXX set
}
// tabstop: int
+ aAttributes->GetAttribute(nsHTMLAtoms::tabstop, value);
if (value.GetUnit() == eHTMLUnit_Integer) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLPreElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLPreElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp b/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp
index 91130983f78..265f77b28cb 100644
--- a/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp
@@ -142,14 +142,23 @@ nsHTMLQuoteElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLQuoteElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLQuoteElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLQuoteElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp b/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp
index 745e5fd3747..700d706eaef 100644
--- a/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp
@@ -204,13 +204,22 @@ nsHTMLScriptElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLScriptElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLScriptElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLScriptElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp
index 4291d57a267..3bd339914ef 100644
--- a/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp
@@ -214,14 +214,23 @@ nsHTMLSelectElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLSelectElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLSelectElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLSelectElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLSpacerElement.cpp b/mozilla/layout/html/content/src/nsHTMLSpacerElement.cpp
index a92684d0965..a4cd287b9a3 100644
--- a/mozilla/layout/html/content/src/nsHTMLSpacerElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLSpacerElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
// XXX add nsIDOMHTMLSpacer?
@@ -158,15 +159,16 @@ nsHTMLSpacerElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLSpacerElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleDisplay* display = (nsStyleDisplay*)
aContext->GetMutableStyleData(eStyleStruct_Display);
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (eHTMLUnit_Enumerated == value.GetUnit()) {
switch (value.GetIntValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
@@ -180,7 +182,7 @@ nsHTMLSpacerElement::MapAttributesInto(nsIStyleContext* aContext,
}
}
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString tmp;
value.GetStringValue(tmp);
@@ -195,9 +197,17 @@ nsHTMLSpacerElement::MapAttributesInto(nsIStyleContext* aContext,
}
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLSpacerElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLSpacerElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLSpanElement.cpp b/mozilla/layout/html/content/src/nsHTMLSpanElement.cpp
index 04d4236eac2..0ecbf3e5922 100644
--- a/mozilla/layout/html/content/src/nsHTMLSpanElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLSpanElement.cpp
@@ -128,14 +128,23 @@ nsHTMLSpanElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLSpanElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLSpanElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLSpanElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp b/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp
index f64f6a5a46d..8efdaf51030 100644
--- a/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp
@@ -148,13 +148,22 @@ nsHTMLStyleElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLStyleElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLStyleElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLStyleElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp
index e3a2081b48e..e5503b7254a 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp
@@ -142,14 +142,23 @@ nsHTMLTableCaptionElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableCaptionElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableCaptionElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableCaptionElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp
index 29c4f471aee..4ed7853d237 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp
@@ -197,14 +197,23 @@ nsHTMLTableCellElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableCellElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableCellElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableCellElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp
index a630d307144..1169edb826b 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp
@@ -157,14 +157,23 @@ nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableColElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableColElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableColElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLTableElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableElement.cpp
index 4daf4bdf8e9..c3e141a738b 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableElement.cpp
@@ -301,14 +301,23 @@ nsHTMLTableElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp
index 1902ec8b710..794cb3985db 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp
@@ -222,14 +222,23 @@ nsHTMLTableRowElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableRowElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableRowElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableRowElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp
index a2fb451d713..cfa8d1ce995 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp
@@ -179,14 +179,23 @@ nsHTMLTableSectionElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTableSectionElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTableSectionElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTableSectionElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp
index 8a9c2be8642..47e0b2052aa 100644
--- a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp
@@ -202,14 +202,23 @@ nsHTMLTextAreaElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTextAreaElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
// XXX write me
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTextAreaElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp b/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp
index 59833e452a5..98b68ddaaf9 100644
--- a/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp
@@ -141,13 +141,23 @@ nsHTMLTitleElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLTitleElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLTitleElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLTitleElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLUListElement.cpp b/mozilla/layout/html/content/src/nsHTMLUListElement.cpp
index e461d9a36ca..0df490cedb1 100644
--- a/mozilla/layout/html/content/src/nsHTMLUListElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLUListElement.cpp
@@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIHTMLAttributes.h"
extern nsGenericHTMLElement::EnumTable kListTypeTable[];
@@ -164,30 +165,39 @@ nsHTMLUListElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLUListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if (nsnull != mInner.mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleList* list = (nsStyleList*)
aContext->GetMutableStyleData(eStyleStruct_List);
// type: enum
- GetAttribute(nsHTMLAtoms::type, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
list->mListStyleType = value.GetIntValue();
}
// compact: empty
- GetAttribute(nsHTMLAtoms::compact, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
if (value.GetUnit() == eHTMLUnit_Empty) {
// XXX set
}
}
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLUListElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
NS_IMETHODIMP
nsHTMLUListElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLWBRElement.cpp b/mozilla/layout/html/content/src/nsHTMLWBRElement.cpp
index 1e9a89cb065..01884378f92 100644
--- a/mozilla/layout/html/content/src/nsHTMLWBRElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLWBRElement.cpp
@@ -138,13 +138,23 @@ nsHTMLWBRElement::AttributeToString(nsIAtom* aAttribute,
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
-NS_IMETHODIMP
-nsHTMLWBRElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- return mInner.MapAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
}
+NS_IMETHODIMP
+nsHTMLWBRElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
+
NS_IMETHODIMP
nsHTMLWBRElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/document/src/nsHTMLFrame.cpp b/mozilla/layout/html/document/src/nsHTMLFrame.cpp
index 112e1c276d4..547613c6afa 100644
--- a/mozilla/layout/html/document/src/nsHTMLFrame.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLFrame.cpp
@@ -40,11 +40,11 @@
#include "nsIPref.h"
//#include "nsIDocumentWidget.h"
#include "nsHTMLFrameset.h"
+#include "nsGenericHTMLElement.h"
class nsHTMLFrame;
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
-static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
@@ -183,8 +183,7 @@ public:
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
@@ -693,14 +692,23 @@ nsHTMLFrame::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
}
-NS_IMETHODIMP
-nsHTMLFrame::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- MapImagePropertiesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLFrame::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
+
PRInt32 nsHTMLFrame::GetMargin(nsIAtom* aType, nsIPresContext* aPresContext)
{
float p2t = aPresContext->GetPixelsToTwips();
diff --git a/mozilla/layout/html/document/src/nsHTMLFrameset.cpp b/mozilla/layout/html/document/src/nsHTMLFrameset.cpp
index 4ea28ddfafa..62930f1c003 100644
--- a/mozilla/layout/html/document/src/nsHTMLFrameset.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLFrameset.cpp
@@ -39,6 +39,7 @@
#include "nsCSSLayout.h"
#include "nsHTMLBase.h"
#include "nsIDocumentLoader.h"
+#include "nsGenericHTMLElement.h"
// masks for mEdgeVisibility
#define LEFT_VIS 0x0001
@@ -1378,12 +1379,20 @@ nsHTMLFrameset::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
return nsHTMLContainer::SetAttribute(aAttribute, aValue, aNotify);
}
-NS_IMETHODIMP
-nsHTMLFrameset::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- MapImagePropertiesInto(aContext, aPresContext);
- MapImageBorderInto(aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, nsnull);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsHTMLFrameset::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
diff --git a/mozilla/layout/html/document/src/nsHTMLFrameset.h b/mozilla/layout/html/document/src/nsHTMLFrameset.h
index be08cb19396..45614293f6f 100644
--- a/mozilla/layout/html/document/src/nsHTMLFrameset.h
+++ b/mozilla/layout/html/document/src/nsHTMLFrameset.h
@@ -208,8 +208,7 @@ public:
nsIFrame*& aResult);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
diff --git a/mozilla/layout/html/forms/src/nsForm.cpp b/mozilla/layout/html/forms/src/nsForm.cpp
index 39ee3b70837..11da9655fc1 100644
--- a/mozilla/layout/html/forms/src/nsForm.cpp
+++ b/mozilla/layout/html/forms/src/nsForm.cpp
@@ -866,7 +866,7 @@ nsForm::SetAttribute(const nsString& aName, const nsString& aValue,
else {
// Use default storage for unknown attributes
if (nsnull == mAttributes) {
- NS_NewHTMLAttributes(&mAttributes);
+ NS_NewHTMLAttributes(&mAttributes, nsnull);
}
if (nsnull != mAttributes) {
PRInt32 na;
diff --git a/mozilla/layout/html/forms/src/nsInput.cpp b/mozilla/layout/html/forms/src/nsInput.cpp
index f145fc5a6c5..61e2b2e497a 100644
--- a/mozilla/layout/html/forms/src/nsInput.cpp
+++ b/mozilla/layout/html/forms/src/nsInput.cpp
@@ -37,6 +37,8 @@
#include "nsStyleConsts.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsITextWidget.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
#define ALIGN_UNSET PRUint8(-1)
@@ -101,16 +103,20 @@ void nsInput::SetContent(const nsString& aValue)
}
}
-NS_IMETHODIMP
-nsInput::MapAttributesInto(nsIStyleContext* aContext,
+void
+nsInput::MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- if (ALIGN_UNSET != mAlign) {
+ nsHTMLValue value;
+
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
+ if (eHTMLUnit_Enumerated == value.GetUnit()) {
nsStyleDisplay* display = (nsStyleDisplay*)
aContext->GetMutableStyleData(eStyleStruct_Display);
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
- switch (mAlign) {
+ switch (value.GetIntValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
display->mFloats = NS_STYLE_FLOAT_LEFT;
break;
@@ -118,11 +124,18 @@ nsInput::MapAttributesInto(nsIStyleContext* aContext,
display->mFloats = NS_STYLE_FLOAT_RIGHT;
break;
default:
- text->mVerticalAlign.SetIntValue(mAlign, eStyleUnit_Enumerated);
+ text->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
break;
}
}
- MapImagePropertiesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsInput::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &nsInput::MapAttributesInto;
return NS_OK;
}
@@ -331,7 +344,7 @@ nsInput::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
if (ParseAlignParam(aValue, val)) {
mAlign = val.GetIntValue();
// Reflect the attribute into the syle system
- return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); // is this needed?
+ return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify); // is this needed? YES
} else {
mAlign = ALIGN_UNSET;
}
diff --git a/mozilla/layout/html/forms/src/nsInput.h b/mozilla/layout/html/forms/src/nsInput.h
index f29b97ea2d1..829442dd375 100644
--- a/mozilla/layout/html/forms/src/nsInput.h
+++ b/mozilla/layout/html/forms/src/nsInput.h
@@ -52,8 +52,10 @@ public:
nsIStyleContext* aStyleContext,
nsIFrame*& aResult) = 0;
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
+ static void MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
/**
* @see nsISupports QueryInterface
diff --git a/mozilla/layout/html/forms/src/nsInputButton.cpp b/mozilla/layout/html/forms/src/nsInputButton.cpp
index 13ad6c90546..9c026b52edb 100644
--- a/mozilla/layout/html/forms/src/nsInputButton.cpp
+++ b/mozilla/layout/html/forms/src/nsInputButton.cpp
@@ -46,6 +46,8 @@
#include "nsStyleUtil.h"
#include "nsDOMEvent.h"
#include "nsStyleConsts.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
enum nsButtonTagType {
kButtonTag_Button,
@@ -63,9 +65,9 @@ enum nsButtonType {
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
-class nsInputButton : public nsInput {
+typedef nsInput nsInputButtonSuper;
+class nsInputButton : public nsInputButtonSuper {
public:
- typedef nsInput nsInputButtonSuper;
nsInputButton (nsIAtom* aTag, nsIFormManager* aManager,
nsButtonType aType);
@@ -76,8 +78,7 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
nsButtonType GetButtonType() { return mType; }
nsButtonTagType GetButtonTagType() { return mTagType; }
@@ -315,22 +316,35 @@ nsInputButton::SetAttribute(nsIAtom* aAttribute, const nsString& aString,
return nsInputButtonSuper::SetAttribute(aAttribute, aString, aNotify);
}
-NS_IMETHODIMP
-nsInputButton::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- if ((kButton_Image == mType) && (kButtonTag_Input == mTagType)) {
+ nsHTMLValue value;
+ aAttributes->GetAttribute(nsHTMLAtoms::type, value);
+ if (eHTMLUnit_String == value.GetUnit()) { // XXX thiws should be parses in AttributeToString
+ nsAutoString val;
+ value.GetStringValue(val);
+ if (val.EqualsIgnoreCase("image")) {
// Apply the image border as well. For form elements the color is
// always forced to blue.
- static nscolor blue[4] = {
- NS_RGB(0, 0, 255),
- NS_RGB(0, 0, 255),
- NS_RGB(0, 0, 255),
- NS_RGB(0, 0, 255)
- };
- MapImageBorderInto(aContext, aPresContext, blue);
+ static nscolor blue[4] = {
+ NS_RGB(0, 0, 255),
+ NS_RGB(0, 0, 255),
+ NS_RGB(0, 0, 255),
+ NS_RGB(0, 0, 255)
+ };
+ nsGenericHTMLElement::MapImageBorderAttributesInto(aAttributes, aContext, aPresContext, blue);
+ }
}
- nsInputButtonSuper::MapAttributesInto(aContext, aPresContext);
+ nsInputButtonSuper::MapAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsInputButton::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
diff --git a/mozilla/layout/html/forms/src/nsInputCheckbox.cpp b/mozilla/layout/html/forms/src/nsInputCheckbox.cpp
index 9ba78f0c642..731d11c812a 100644
--- a/mozilla/layout/html/forms/src/nsInputCheckbox.cpp
+++ b/mozilla/layout/html/forms/src/nsInputCheckbox.cpp
@@ -153,9 +153,10 @@ nsInputCheckbox::~nsInputCheckbox()
}
-NS_IMETHODIMP
-nsInputCheckbox::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
float p2t = aPresContext->GetPixelsToTwips();
nscoord pad = NSIntPixelsToTwips(3, p2t);
@@ -172,16 +173,22 @@ nsInputCheckbox::MapAttributesInto(nsIStyleContext* aContext,
}
// add bottom padding if backward mode
// XXX why isn't this working?
- nsIFormManager* formMan = GetFormManager();
- if (formMan && (kBackwardMode == formMan->GetMode())) {
+
+ nsCompatibility mode;
+ aPresContext->GetCompatibilityMode(mode);
+ if (eCompatibility_NavQuirks == mode) {
if (eStyleUnit_Null == spacing->mMargin.GetBottomUnit()) {
nsStyleCoord bottom(pad);
spacing->mMargin.SetBottom(bottom);
}
- nsInput::MapAttributesInto(aContext, aPresContext);
}
- NS_IF_RELEASE(formMan);
+ nsInput::MapAttributesInto(aAttributes, aContext, aPresContext);
+}
+NS_IMETHODIMP
+nsInputCheckbox::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
diff --git a/mozilla/layout/html/forms/src/nsInputCheckbox.h b/mozilla/layout/html/forms/src/nsInputCheckbox.h
index e6f58381f29..d6dc155965b 100644
--- a/mozilla/layout/html/forms/src/nsInputCheckbox.h
+++ b/mozilla/layout/html/forms/src/nsInputCheckbox.h
@@ -44,8 +44,8 @@ public:
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
+
virtual void Reset();
protected:
diff --git a/mozilla/layout/html/forms/src/nsInputRadio.cpp b/mozilla/layout/html/forms/src/nsInputRadio.cpp
index 51857e47ecc..d12b0a19974 100644
--- a/mozilla/layout/html/forms/src/nsInputRadio.cpp
+++ b/mozilla/layout/html/forms/src/nsInputRadio.cpp
@@ -135,9 +135,10 @@ nsInputRadio::~nsInputRadio()
{
}
-NS_IMETHODIMP
-nsInputRadio::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
float p2t = aPresContext->GetPixelsToTwips();
nscoord pad = NSIntPixelsToTwips(3, p2t);
@@ -154,19 +155,25 @@ nsInputRadio::MapAttributesInto(nsIStyleContext* aContext,
}
// add bottom padding if backward mode
// XXX why isn't this working?
- nsIFormManager* formMan = GetFormManager();
- if (formMan && (kBackwardMode == formMan->GetMode())) {
+ nsCompatibility mode;
+ aPresContext->GetCompatibilityMode(mode);
+ if (eCompatibility_NavQuirks == mode) {
if (eStyleUnit_Null == spacing->mMargin.GetBottomUnit()) {
nsStyleCoord bottom(pad);
spacing->mMargin.SetBottom(bottom);
}
- nsInput::MapAttributesInto(aContext, aPresContext);
}
- NS_IF_RELEASE(formMan);
+ nsInput::MapAttributesInto(aAttributes, aContext, aPresContext);
+}
+NS_IMETHODIMP
+nsInputRadio::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
+
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
void
diff --git a/mozilla/layout/html/forms/src/nsInputRadio.h b/mozilla/layout/html/forms/src/nsInputRadio.h
index 73c7d07e407..7c692223453 100644
--- a/mozilla/layout/html/forms/src/nsInputRadio.h
+++ b/mozilla/layout/html/forms/src/nsInputRadio.h
@@ -53,8 +53,8 @@ public:
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
+
virtual void Reset();
protected:
diff --git a/mozilla/layout/html/style/src/nsCSSStyleRule.cpp b/mozilla/layout/html/style/src/nsCSSStyleRule.cpp
index 9016a41cc22..3bd6a337810 100644
--- a/mozilla/layout/html/style/src/nsCSSStyleRule.cpp
+++ b/mozilla/layout/html/style/src/nsCSSStyleRule.cpp
@@ -168,8 +168,7 @@ public:
PRInt32 aMask, const nsStyleFont* aFont,
nsIPresContext* aPresContext);
- NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent);
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
@@ -515,8 +514,7 @@ PRBool CSSStyleRuleImpl::SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord
}
NS_IMETHODIMP
-CSSStyleRuleImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+CSSStyleRuleImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
{
if (nsnull != mDeclaration) {
nsStyleFont* font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font);
diff --git a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp
index fabeaca8404..945525537bf 100644
--- a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp
+++ b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp
@@ -31,6 +31,7 @@
#include "nsIFrame.h"
#include "nsString.h"
#include "nsIPtr.h"
+#include "nsHTMLIIDs.h"
//#define DEBUG_REFS
//#define DEBUG_RULES
@@ -38,7 +39,6 @@
static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
NS_DEF_PTR(nsIHTMLContent);
NS_DEF_PTR(nsIContent);
diff --git a/mozilla/layout/html/style/src/nsHTMLAttributes.cpp b/mozilla/layout/html/style/src/nsHTMLAttributes.cpp
index 6a45e6dce68..24d8c2c51ab 100644
--- a/mozilla/layout/html/style/src/nsHTMLAttributes.cpp
+++ b/mozilla/layout/html/style/src/nsHTMLAttributes.cpp
@@ -164,14 +164,13 @@ HTMLAttribute::SizeOf(nsISizeOfHandler* aHandler) const
// ----------------
-
class HTMLAttributesImpl: public nsIHTMLAttributes, public nsIStyleRule {
public:
void* operator new(size_t size);
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
- HTMLAttributesImpl(void);
+ HTMLAttributesImpl(nsMapAttributesFunc aMapFunc);
HTMLAttributesImpl(const HTMLAttributesImpl& aCopy);
~HTMLAttributesImpl(void);
@@ -208,11 +207,11 @@ public:
NS_IMETHOD Clone(nsIHTMLAttributes** aInstancePtrResult);
NS_IMETHOD Reset(void);
+ NS_IMETHOD SetMappingFunction(nsMapAttributesFunc aMapFunc);
// nsIStyleRule
NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aResult) const;
- NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent);
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
/**
* Add this object's size information to the sizeof handler.
@@ -229,11 +228,12 @@ protected:
PRUint32 mInHeap : 1;
PRUint32 mRefCnt : 31;
+ PRInt32 mContentRefCount;
PRInt32 mCount;
HTMLAttribute mFirst;
nsIAtom* mID;
nsIAtom* mClass;
- PRInt32 mContentRefCount;
+ nsMapAttributesFunc mMapper;
};
void* HTMLAttributesImpl::operator new(size_t size)
@@ -271,12 +271,13 @@ void HTMLAttributesImpl::operator delete(void* ptr)
}
-HTMLAttributesImpl::HTMLAttributesImpl(void)
+HTMLAttributesImpl::HTMLAttributesImpl(nsMapAttributesFunc aMapFunc)
: mFirst(),
mCount(0),
mID(nsnull),
mClass(nsnull),
- mContentRefCount(0)
+ mContentRefCount(0),
+ mMapper(aMapFunc)
{
NS_INIT_REFCNT();
}
@@ -286,7 +287,8 @@ HTMLAttributesImpl::HTMLAttributesImpl(const HTMLAttributesImpl& aCopy)
mCount(aCopy.mCount),
mID(aCopy.mID),
mClass(aCopy.mClass),
- mContentRefCount(0)
+ mContentRefCount(0),
+ mMapper(aCopy.mMapper)
{
NS_INIT_REFCNT();
@@ -424,7 +426,7 @@ HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
HTMLAttribute* last = nsnull;
HTMLAttribute* attr = &mFirst;
- if (0 < mCount) {
+ if (nsnull != mFirst.mAttribute) {
while (nsnull != attr) {
if (attr->mAttribute == aAttribute) {
attr->mValue.SetStringValue(aValue);
@@ -477,7 +479,7 @@ HTMLAttributesImpl::SetAttribute(nsIAtom* aAttribute,
HTMLAttribute* last = nsnull;
HTMLAttribute* attr = &mFirst;
- if (0 < mCount) {
+ if (nsnull != mFirst.mAttribute) {
while (nsnull != attr) {
if (attr->mAttribute == aAttribute) {
attr->mValue = aValue;
@@ -728,15 +730,23 @@ HTMLAttributesImpl::Reset(void)
mFirst.mNext = nsnull;
NS_IF_RELEASE(mID);
NS_IF_RELEASE(mClass);
+ mMapper = nsnull;
return NS_OK;
}
NS_IMETHODIMP
-HTMLAttributesImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+HTMLAttributesImpl::SetMappingFunction(nsMapAttributesFunc aMapFunc)
{
- if (nsnull != aContent) {
- ((nsIHTMLContent*)aContent)->MapAttributesInto(aContext, aPresContext);
+ mMapper = aMapFunc;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLAttributesImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
+{
+ NS_ASSERTION(nsnull != mMapper, "no mapping function");
+ if (nsnull != mMapper) {
+ (*mMapper)(this, aContext, aPresContext);
}
return NS_OK;
}
@@ -770,13 +780,13 @@ HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const
}
extern NS_HTML nsresult
- NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult)
+ NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult, nsMapAttributesFunc aMapFunc)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
- HTMLAttributesImpl *it = new HTMLAttributesImpl();
+ HTMLAttributesImpl *it = new HTMLAttributesImpl(aMapFunc);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
diff --git a/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp
index ec655f2b333..edba400dbed 100644
--- a/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp
+++ b/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp
@@ -25,10 +25,10 @@
#include "nsIHTMLContent.h"
#include "nsIStyleRule.h"
#include "nsIFrame.h"
+#include "nsHTMLIIDs.h"
static NS_DEFINE_IID(kIHTMLCSSStyleSheetIID, NS_IHTML_CSS_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
class HTMLCSSStyleSheetImpl : public nsIHTMLCSSStyleSheet {
diff --git a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp
index c8a2e659f90..d214750b638 100644
--- a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp
+++ b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp
@@ -34,11 +34,11 @@
#include "nsTableCell.h"
#include "nsTableColFrame.h"
#include "nsTableFrame.h"
+#include "nsHTMLIIDs.h"
static NS_DEFINE_IID(kIHTMLStyleSheetIID, NS_IHTML_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
class HTMLAnchorRule : public nsIStyleRule {
@@ -51,8 +51,7 @@ public:
NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aValue) const;
NS_IMETHOD HashValue(PRUint32& aValue) const;
- NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent);
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
@@ -85,8 +84,7 @@ HTMLAnchorRule::HashValue(PRUint32& aValue) const
}
NS_IMETHODIMP
-HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
{
nsStyleColor* styleColor = (nsStyleColor*)(aContext->GetMutableStyleData(eStyleStruct_Color));
@@ -107,7 +105,7 @@ HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const
class AttributeKey: public nsHashKey
{
public:
- AttributeKey(nsIAtom* aTag, nsIHTMLAttributes* aAttributes);
+ AttributeKey(nsMapAttributesFunc aMapFunc, nsIHTMLAttributes* aAttributes);
virtual ~AttributeKey(void);
PRBool Equals(const nsHashKey* aOther) const;
@@ -120,31 +118,29 @@ private:
AttributeKey& operator=(const AttributeKey& aCopy);
public:
- nsIAtom* mTag;
+ nsMapAttributesFunc mMapFunc;
nsIHTMLAttributes* mAttributes;
PRUint32 mHashSet: 1;
PRUint32 mHashCode: 31;
};
-AttributeKey::AttributeKey(nsIAtom* aTag, nsIHTMLAttributes* aAttributes)
- : mTag(aTag),
+AttributeKey::AttributeKey(nsMapAttributesFunc aMapFunc, nsIHTMLAttributes* aAttributes)
+ : mMapFunc(aMapFunc),
mAttributes(aAttributes)
{
- NS_ADDREF(mTag);
NS_ADDREF(mAttributes);
mHashSet = 0;
}
AttributeKey::~AttributeKey(void)
{
- NS_RELEASE(mTag);
NS_RELEASE(mAttributes);
}
PRBool AttributeKey::Equals(const nsHashKey* aOther) const
{
const AttributeKey* other = (const AttributeKey*)aOther;
- if (mTag == other->mTag) {
+ if (mMapFunc == other->mMapFunc) {
PRBool equals;
mAttributes->Equals(other->mAttributes, equals);
return equals;
@@ -159,7 +155,7 @@ PRUint32 AttributeKey::HashValue(void) const
PRUint32 hash;
mAttributes->HashValue(hash);
self->mHashCode = (0x7FFFFFFF & hash);
- self->mHashCode |= (0x7FFFFFFF & PRUint32(mTag));
+ self->mHashCode |= (0x7FFFFFFF & PRUint32(mMapFunc));
self->mHashSet = 1;
}
return mHashCode;
@@ -167,7 +163,7 @@ PRUint32 AttributeKey::HashValue(void) const
nsHashKey* AttributeKey::Clone(void) const
{
- AttributeKey* clown = new AttributeKey(mTag, mAttributes);
+ AttributeKey* clown = new AttributeKey(mMapFunc, mAttributes);
if (nsnull != clown) {
clown->mHashSet = mHashSet;
clown->mHashCode = mHashCode;
@@ -206,14 +202,19 @@ public:
NS_IMETHOD SetVisitedLinkColor(nscolor aColor);
// Attribute management methods, aAttributes is an in/out param
- NS_IMETHOD SetAttributesFor(nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetIDFor(nsIAtom* aID, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue, nsIAtom* aTag,
+ NS_IMETHOD SetAttributesFor(nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue, nsIAtom* aTag,
+ NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIAtom* aTag,
+ NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
@@ -230,11 +231,11 @@ protected:
virtual ~HTMLStyleSheetImpl();
NS_IMETHOD EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRBool aCreate,
nsIHTMLAttributes*& aSingleAttrs);
NS_IMETHOD UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRInt32 aAttrCount,
nsIHTMLAttributes*& aAttributes);
@@ -379,6 +380,7 @@ PRInt32 AppendRulesFrom(nsIFrame* aFrame, nsIPresContext* aPresContext, PRInt32&
AppendData data(backstopCount, aInsertPoint, aResults);
rules->EnumerateForwards(AppendFunc, &data);
aInsertPoint = data.mInsert;
+ NS_RELEASE(rules);
}
NS_RELEASE(context);
}
@@ -563,12 +565,14 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor)
return NS_OK;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsIHTMLAttributes* attrs = aAttributes;
if (nsnull != attrs) {
- AttributeKey key(aTag, attrs);
+ nsMapAttributesFunc mapFunc;
+ aContent->GetAttributeMappingFunction(mapFunc);
+ AttributeKey key(mapFunc, attrs);
nsIHTMLAttributes* sharedAttrs = (nsIHTMLAttributes*)mAttrTable.Get(&key);
if (nsnull == sharedAttrs) { // we have a new unique set
mAttrTable.Put(&key, attrs);
@@ -588,37 +592,43 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIAtom* aTag, nsIHTMLAttribu
return NS_OK;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetIDFor(nsIAtom* aID, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(nsnull != aID);
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetID(aID, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(nsnull != aClass);
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetClass(aClass, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
@@ -627,19 +637,22 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIAtom* aTag, ns
NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
const nsString& aValue,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, PR_TRUE, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, PR_TRUE, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetAttribute(aAttribute, aValue, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
@@ -647,7 +660,7 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
NS_IMETHODIMP
HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRBool aCreate,
nsIHTMLAttributes*& aSingleAttrs)
{
@@ -659,9 +672,10 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
if (nsnull != mRecycledAttrs) {
aSingleAttrs = mRecycledAttrs;
mRecycledAttrs = nsnull;
+ aSingleAttrs->SetMappingFunction(aMapFunc);
}
else {
- result = NS_NewHTMLAttributes(&aSingleAttrs);
+ result = NS_NewHTMLAttributes(&aSingleAttrs, aMapFunc);
}
}
else {
@@ -688,7 +702,7 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
}
else { // one content ref, ok to use, remove from table because hash may change
if (1 == contentRefCount) {
- AttributeKey key(aTag, aSingleAttrs);
+ AttributeKey key(aMapFunc, aSingleAttrs);
mAttrTable.Remove(&key);
NS_ADDREF(aSingleAttrs); // add a local ref so we match up
}
@@ -703,14 +717,14 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
NS_IMETHODIMP
HTMLStyleSheetImpl::UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRInt32 aAttrCount,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
if (0 < aAttrCount) {
- AttributeKey key(aTag, aSingleAttrs);
+ AttributeKey key(aMapFunc, aSingleAttrs);
nsIHTMLAttributes* sharedAttrs = (nsIHTMLAttributes*)mAttrTable.Get(&key);
if (nsnull == sharedAttrs) { // we have a new unique set
mAttrTable.Put(&key, aSingleAttrs);
@@ -757,39 +771,45 @@ HTMLStyleSheetImpl::UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(eHTMLUnit_Null != aValue.GetUnit());
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetAttribute(aAttribute, aValue, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
}
NS_IMETHODIMP HTMLStyleSheetImpl::UnsetAttributeFor(nsIAtom* aAttribute,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, PR_FALSE, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, PR_FALSE, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->UnsetAttribute(aAttribute, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
diff --git a/mozilla/layout/html/style/src/nsIHTMLAttributes.h b/mozilla/layout/html/style/src/nsIHTMLAttributes.h
index 0c1740fb473..0e259169dd3 100644
--- a/mozilla/layout/html/style/src/nsIHTMLAttributes.h
+++ b/mozilla/layout/html/style/src/nsIHTMLAttributes.h
@@ -21,11 +21,10 @@
#include "nslayout.h"
#include "nsISupports.h"
#include "nsHTMLValue.h"
-#include "nsIContent.h"
+#include "nsIHTMLContent.h"
class nsIAtom;
class nsISizeOfHandler;
class nsISupportsArray;
-class nsIHTMLContent;
// IID for the nsIHTMLAttributes interface {a18f85f0-c058-11d1-8031-006008159b5a}
@@ -33,6 +32,7 @@ class nsIHTMLContent;
{0xa18f85f0, 0xc058, 0x11d1, \
{0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
+
class nsIHTMLAttributes : public nsISupports {
public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
@@ -65,6 +65,7 @@ public:
NS_IMETHOD Clone(nsIHTMLAttributes** aInstancePtrResult) = 0;
NS_IMETHOD Reset(void) = 0;
+ NS_IMETHOD SetMappingFunction(nsMapAttributesFunc aMapFunc) = 0;
/**
* Add this object's size information to the sizeof handler.
@@ -75,7 +76,7 @@ public:
};
extern NS_HTML nsresult
- NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult);
+ NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult, nsMapAttributesFunc aMapFunc);
#endif /* nsIHTMLAttributes_h___ */
diff --git a/mozilla/layout/html/style/src/nsIHTMLStyleSheet.h b/mozilla/layout/html/style/src/nsIHTMLStyleSheet.h
index 0ad667aaf3e..d888afc2d45 100644
--- a/mozilla/layout/html/style/src/nsIHTMLStyleSheet.h
+++ b/mozilla/layout/html/style/src/nsIHTMLStyleSheet.h
@@ -26,6 +26,7 @@ class nsIAtom;
class nsString;
class nsHTMLValue;
class nsIHTMLAttributes;
+class nsIHTMLContent;
// IID for the nsIHTMLStyleSheet interface {bddbd1b0-c5cc-11d1-8031-006008159b5a}
#define NS_IHTML_STYLE_SHEET_IID \
@@ -38,14 +39,19 @@ public:
NS_IMETHOD SetVisitedLinkColor(nscolor aColor) = 0;
// Attribute management methods
- NS_IMETHOD SetAttributesFor(nsIAtom* aTag, nsIHTMLAttributes*& aAttributes) = 0;
- NS_IMETHOD SetIDFor(nsIAtom* aID, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes) = 0;
- NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes) = 0;
- NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue, nsIAtom* aTag,
+ NS_IMETHOD SetAttributesFor(nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes) = 0;
+ NS_IMETHOD SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes) = 0;
+ NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes) = 0;
+ NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes) = 0;
- NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue, nsIAtom* aTag,
+ NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes) = 0;
- NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIAtom* aTag,
+ NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes) = 0;
};
diff --git a/mozilla/layout/html/table/src/nsTableCaption.cpp b/mozilla/layout/html/table/src/nsTableCaption.cpp
index 61499af76d8..6e0a65670e6 100644
--- a/mozilla/layout/html/table/src/nsTableCaption.cpp
+++ b/mozilla/layout/html/table/src/nsTableCaption.cpp
@@ -27,6 +27,8 @@
#include "nsIPresContext.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
#ifdef NS_DEBUG
@@ -90,9 +92,10 @@ nsTableCaption::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
return nsTableContent::SetAttribute(aAttribute, aValue, aNotify);
}
-NS_IMETHODIMP
-nsTableCaption::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
@@ -100,7 +103,7 @@ nsTableCaption::MapAttributesInto(nsIStyleContext* aContext,
nsHTMLValue value;
// align
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() != eHTMLUnit_Null) {
NS_ASSERTION(value.GetUnit() == eHTMLUnit_Enumerated, "unexpected unit");
@@ -123,10 +126,18 @@ nsTableCaption::MapAttributesInto(nsIStyleContext* aContext,
textStyle->mTextAlign = alignValue;
}
}
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsTableCaption::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
+
NS_IMETHODIMP
nsTableCaption::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
diff --git a/mozilla/layout/html/table/src/nsTableCaption.h b/mozilla/layout/html/table/src/nsTableCaption.h
index 248ebe5b02a..14e8fb7b9b4 100644
--- a/mozilla/layout/html/table/src/nsTableCaption.h
+++ b/mozilla/layout/html/table/src/nsTableCaption.h
@@ -62,8 +62,7 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
/** @see nsIHTMLContent::CreateFrame */
NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
diff --git a/mozilla/layout/html/table/src/nsTableCell.cpp b/mozilla/layout/html/table/src/nsTableCell.cpp
index 5fdaa340f5d..3c9901c1e0c 100644
--- a/mozilla/layout/html/table/src/nsTableCell.cpp
+++ b/mozilla/layout/html/table/src/nsTableCell.cpp
@@ -26,6 +26,8 @@
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
#include "nsIPtr.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
// hack, remove when hack in nsTableCol constructor is removed
static PRInt32 HACKcounter=0;
@@ -36,8 +38,6 @@ static nsIAtom *HACKattribute=nsnull;
NS_DEF_PTR(nsIStyleContext);
-static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
-
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
static PRBool gsNoisyRefs = PR_FALSE;
@@ -232,9 +232,10 @@ nsTableCell::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
-NS_IMETHODIMP
-nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
@@ -244,7 +245,7 @@ nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
nsStyleText* textStyle = nsnull;
// align: enum
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
@@ -252,7 +253,7 @@ nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
}
// valign: enum
- GetAttribute(nsHTMLAtoms::valign, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
@@ -260,13 +261,11 @@ nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
- MapBackgroundAttributesInto(aContext, aPresContext);
-
// width: pixel
float p2t = aPresContext->GetPixelsToTwips();
nsStylePosition* pos = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
- GetAttribute(nsHTMLAtoms::width, widthValue);
+ aAttributes->GetAttribute(nsHTMLAtoms::width, widthValue);
if (widthValue.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(widthValue.GetPixelValue(), p2t);
pos->mWidth.SetCoordValue(twips);
@@ -276,7 +275,7 @@ nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
}
// height: pixel
- GetAttribute(nsHTMLAtoms::height, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
pos->mHeight.SetCoordValue(twips);
@@ -284,7 +283,7 @@ nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
// nowrap
// nowrap depends on the width attribute, so be sure to handle it after width is mapped!
- GetAttribute(nsHTMLAtoms::nowrap, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::nowrap, value);
if (value.GetUnit() == eHTMLUnit_Empty)
{
if (widthValue.GetUnit() != eHTMLUnit_Pixel)
@@ -295,68 +294,18 @@ nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
}
}
+ nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsTableCell::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
-void
-nsTableCell::MapBackgroundAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
-{
- nsHTMLValue value;
- nsStyleColor* color=nsnull;
- // background
- if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::background, value)) {
- if (eHTMLUnit_String == value.GetUnit()) {
- color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
- SetBackgroundFromAttribute(color, &value);
- }
- }
-
- // bgcolor
- if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::bgcolor, value)) {
- if (eHTMLUnit_Color == value.GetUnit()) {
- if (nsnull==color)
- color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
- color->mBackgroundColor = value.GetColorValue();
- color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
- }
- else if (eHTMLUnit_String == value.GetUnit()) {
- nsAutoString buffer;
- value.GetStringValue(buffer);
- char cbuf[40];
- buffer.ToCString(cbuf, sizeof(cbuf));
-
- if (nsnull==color)
- color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
- NS_ColorNameToRGB(cbuf, &(color->mBackgroundColor));
- color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
- }
- }
-}
-
-void nsTableCell::SetBackgroundFromAttribute(nsStyleColor *aColor, nsHTMLValue *aValue)
-{
- NS_ASSERTION(nsnull!=aColor && nsnull!=aValue, "bad args");
-
- // Resolve url to an absolute url
- nsIURL* docURL = nsnull;
- nsIDocument* doc = mDocument;
- if (nsnull != doc) {
- docURL = doc->GetDocumentURL();
- }
-
- nsAutoString absURLSpec;
- nsAutoString spec;
- aValue->GetStringValue(spec);
- nsresult rv = NS_MakeAbsoluteURL(docURL, "", spec, absURLSpec);
- if (nsnull != docURL) {
- NS_RELEASE(docURL);
- }
- aColor->mBackgroundImage = absURLSpec;
- aColor->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE;
- aColor->mBackgroundRepeat = NS_STYLE_BG_REPEAT_XY;
-}
NS_IMETHODIMP
nsTableCell::AttributeToString(nsIAtom* aAttribute,
diff --git a/mozilla/layout/html/table/src/nsTableCell.h b/mozilla/layout/html/table/src/nsTableCell.h
index 35633e061f0..a0a877ff5e7 100644
--- a/mozilla/layout/html/table/src/nsTableCell.h
+++ b/mozilla/layout/html/table/src/nsTableCell.h
@@ -95,19 +95,12 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const;
- virtual void MapBackgroundAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
-
- void SetBackgroundFromAttribute(nsStyleColor *aColor, nsHTMLValue *aValue);
-
-
/** @return the number of rows spanned by this cell. Always >= 1 */
virtual int GetRowSpan ();
diff --git a/mozilla/layout/html/table/src/nsTableCol.cpp b/mozilla/layout/html/table/src/nsTableCol.cpp
index 0c9c7e8f90a..59288403724 100644
--- a/mozilla/layout/html/table/src/nsTableCol.cpp
+++ b/mozilla/layout/html/table/src/nsTableCol.cpp
@@ -26,6 +26,8 @@
#include "nsIPresContext.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@@ -123,20 +125,21 @@ nsTableCol::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
return nsTableContent::SetAttribute(aAttribute, aValue, aNotify);
}
-NS_IMETHODIMP
-nsTableCol::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
float p2t;
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// width
- GetAttribute(nsHTMLAtoms::width, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() != eHTMLUnit_Null) {
nsStylePosition* position = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
@@ -153,7 +156,7 @@ nsTableCol::MapAttributesInto(nsIStyleContext* aContext,
}
// align: enum
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
@@ -161,7 +164,7 @@ nsTableCol::MapAttributesInto(nsIStyleContext* aContext,
}
// valign: enum
- GetAttribute(nsHTMLAtoms::valign, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
@@ -169,6 +172,13 @@ nsTableCol::MapAttributesInto(nsIStyleContext* aContext,
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
}
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsTableCol::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
diff --git a/mozilla/layout/html/table/src/nsTableCol.h b/mozilla/layout/html/table/src/nsTableCol.h
index f260561ac18..387f1b74b6a 100644
--- a/mozilla/layout/html/table/src/nsTableCol.h
+++ b/mozilla/layout/html/table/src/nsTableCol.h
@@ -78,8 +78,7 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
/** @see nsIHTMLContent::CreateFrame */
NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
diff --git a/mozilla/layout/html/table/src/nsTableColGroup.cpp b/mozilla/layout/html/table/src/nsTableColGroup.cpp
index 8c3c1348608..e3d6189d7a7 100644
--- a/mozilla/layout/html/table/src/nsTableColGroup.cpp
+++ b/mozilla/layout/html/table/src/nsTableColGroup.cpp
@@ -26,6 +26,8 @@
#include "nsIPresContext.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@@ -320,20 +322,21 @@ nsTableColGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
return nsTableContent::SetAttribute(aAttribute, aValue, aNotify);
}
-NS_IMETHODIMP
-nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
float p2t;
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// width
- GetAttribute(nsHTMLAtoms::width, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() != eHTMLUnit_Null) {
nsStylePosition* position = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
@@ -350,7 +353,7 @@ nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext,
}
// align: enum
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
@@ -358,7 +361,7 @@ nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext,
}
// valign: enum
- GetAttribute(nsHTMLAtoms::valign, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
@@ -366,9 +369,18 @@ nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext,
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
}
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsTableColGroup::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
+
+
NS_IMETHODIMP
nsTableColGroup::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
diff --git a/mozilla/layout/html/table/src/nsTableColGroup.h b/mozilla/layout/html/table/src/nsTableColGroup.h
index bb209e4f91a..43939d3239b 100644
--- a/mozilla/layout/html/table/src/nsTableColGroup.h
+++ b/mozilla/layout/html/table/src/nsTableColGroup.h
@@ -79,8 +79,7 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
/** @see nsIHTMLContent::CreateFrame */
NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
diff --git a/mozilla/layout/html/table/src/nsTablePart.cpp b/mozilla/layout/html/table/src/nsTablePart.cpp
index 1d4e764f97c..d0677b7b345 100644
--- a/mozilla/layout/html/table/src/nsTablePart.cpp
+++ b/mozilla/layout/html/table/src/nsTablePart.cpp
@@ -34,8 +34,9 @@
#include "nsHTMLAtoms.h"
#include "nsStyleConsts.h"
#include "nsUnitConversion.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
-static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITableContentIID, NS_ITABLECONTENT_IID);
#ifdef NS_DEBUG
@@ -718,99 +719,17 @@ nsTablePart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
return nsHTMLTagContent::SetAttribute(aAttribute, aValue, aNotify);
}
-NS_IMETHODIMP
-nsTablePart::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapTableBorderInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
- float p2t = aPresContext->GetPixelsToTwips();
- nsHTMLValue value;
-
- // width
- GetAttribute(nsHTMLAtoms::width, value);
- if (value.GetUnit() != eHTMLUnit_Null) {
- nsStylePosition* position = (nsStylePosition*)
- aContext->GetMutableStyleData(eStyleStruct_Position);
- switch (value.GetUnit()) {
- case eHTMLUnit_Percent:
- position->mWidth.SetPercentValue(value.GetPercentValue());
- break;
-
- case eHTMLUnit_Pixel:
- position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
- break;
- }
- }
- // border
- GetTableBorder(this, aContext, aPresContext);
-
- // align
- GetAttribute(nsHTMLAtoms::align, value);
- if (value.GetUnit() == eHTMLUnit_Enumerated) { // it may be another type if illegal
- nsStyleDisplay* display = (nsStyleDisplay*)aContext->GetMutableStyleData(eStyleStruct_Display);
- switch (value.GetIntValue()) {
- case NS_STYLE_TEXT_ALIGN_LEFT:
- display->mFloats = NS_STYLE_FLOAT_LEFT;
- break;
-
- case NS_STYLE_TEXT_ALIGN_RIGHT:
- display->mFloats = NS_STYLE_FLOAT_RIGHT;
- break;
- }
- }
-
- // cellpadding
- nsStyleTable* tableStyle=nsnull;
- GetAttribute(nsHTMLAtoms::cellpadding, value);
- if (value.GetUnit() == eHTMLUnit_Pixel) {
- tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
- tableStyle->mCellPadding.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
- }
-
- // cellspacing (reuses tableStyle if already resolved)
- GetAttribute(nsHTMLAtoms::cellspacing, value);
- if (value.GetUnit() == eHTMLUnit_Pixel) {
- if (nsnull==tableStyle)
- tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
- tableStyle->mCellSpacing.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
- }
- else
- { // XXX: remove me as soon as we get this from the style sheet
- if (nsnull==tableStyle)
- tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
- tableStyle->mCellSpacing.SetCoordValue(NSIntPixelsToTwips(2, p2t));
- }
-
- // cols
- GetAttribute(nsHTMLAtoms::cols, value);
- if (value.GetUnit() != eHTMLUnit_Null) {
- if (nsnull==tableStyle)
- tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
- if (value.GetUnit() == eHTMLUnit_Integer)
- tableStyle->mCols = value.GetIntValue();
- else // COLS had no value, so it refers to all columns
- tableStyle->mCols = NS_STYLE_TABLE_COLS_ALL;
- }
-
- //background: color
- MapBackgroundAttributesInto(aContext, aPresContext);
-
- return NS_OK;
-}
-
-void nsTablePart::GetTableBorder(nsIHTMLContent* aContent,
- nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
-{
- NS_PRECONDITION(nsnull!=aContent, "bad content arg");
- NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
- NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
-
nsHTMLValue value;
- aContent->GetAttribute(nsHTMLAtoms::border, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::border, value);
if ((value.GetUnit() == eHTMLUnit_Pixel) ||
(value.GetUnit() == eHTMLUnit_Empty)) {
nsStyleSpacing* spacing = (nsStyleSpacing*)
@@ -853,6 +772,96 @@ void nsTablePart::GetTableBorder(nsIHTMLContent* aContent,
}
}
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
+{
+ NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
+ NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
+
+ float p2t = aPresContext->GetPixelsToTwips();
+ nsHTMLValue value;
+
+ // width
+ aAttributes->GetAttribute(nsHTMLAtoms::width, value);
+ if (value.GetUnit() != eHTMLUnit_Null) {
+ nsStylePosition* position = (nsStylePosition*)
+ aContext->GetMutableStyleData(eStyleStruct_Position);
+ switch (value.GetUnit()) {
+ case eHTMLUnit_Percent:
+ position->mWidth.SetPercentValue(value.GetPercentValue());
+ break;
+
+ case eHTMLUnit_Pixel:
+ position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
+ break;
+ }
+ }
+ // border
+ MapTableBorderInto(aAttributes, aContext, aPresContext);
+
+ // align
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) { // it may be another type if illegal
+ nsStyleDisplay* display = (nsStyleDisplay*)aContext->GetMutableStyleData(eStyleStruct_Display);
+ switch (value.GetIntValue()) {
+ case NS_STYLE_TEXT_ALIGN_LEFT:
+ display->mFloats = NS_STYLE_FLOAT_LEFT;
+ break;
+
+ case NS_STYLE_TEXT_ALIGN_RIGHT:
+ display->mFloats = NS_STYLE_FLOAT_RIGHT;
+ break;
+ }
+ }
+
+ // cellpadding
+ nsStyleTable* tableStyle=nsnull;
+ aAttributes->GetAttribute(nsHTMLAtoms::cellpadding, value);
+ if (value.GetUnit() == eHTMLUnit_Pixel) {
+ tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
+ tableStyle->mCellPadding.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
+ }
+
+ // cellspacing (reuses tableStyle if already resolved)
+ aAttributes->GetAttribute(nsHTMLAtoms::cellspacing, value);
+ if (value.GetUnit() == eHTMLUnit_Pixel) {
+ if (nsnull==tableStyle)
+ tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
+ tableStyle->mCellSpacing.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
+ }
+ else
+ { // XXX: remove me as soon as we get this from the style sheet
+ if (nsnull==tableStyle)
+ tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
+ tableStyle->mCellSpacing.SetCoordValue(NSIntPixelsToTwips(2, p2t));
+ }
+
+ // cols
+ aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
+ if (value.GetUnit() != eHTMLUnit_Null) {
+ if (nsnull==tableStyle)
+ tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
+ if (value.GetUnit() == eHTMLUnit_Integer)
+ tableStyle->mCols = value.GetIntValue();
+ else // COLS had no value, so it refers to all columns
+ tableStyle->mCols = NS_STYLE_TABLE_COLS_ALL;
+ }
+
+ //background: color
+ nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aContext, aPresContext);
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsTablePart::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
+ return NS_OK;
+}
+
+
/* ---------- Global Functions ---------- */
/**
diff --git a/mozilla/layout/html/table/src/nsTablePart.h b/mozilla/layout/html/table/src/nsTablePart.h
index a7e3a3121bd..c82a5c451e9 100644
--- a/mozilla/layout/html/table/src/nsTablePart.h
+++ b/mozilla/layout/html/table/src/nsTablePart.h
@@ -72,8 +72,7 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
/* overrides from nsHTMLContainer */
diff --git a/mozilla/layout/html/table/src/nsTableRow.cpp b/mozilla/layout/html/table/src/nsTableRow.cpp
index 201722f6e09..c1afd2f5b14 100644
--- a/mozilla/layout/html/table/src/nsTableRow.cpp
+++ b/mozilla/layout/html/table/src/nsTableRow.cpp
@@ -29,6 +29,8 @@
#include "nsIContentDelegate.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
static NS_DEFINE_IID(kITableContentIID, NS_ITABLECONTENT_IID);
@@ -253,18 +255,19 @@ nsTableRow::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
return nsTableContent::SetAttribute(aAttribute, aValue, aNotify);
}
-NS_IMETHODIMP
-nsTableRow::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// align: enum
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
@@ -272,7 +275,7 @@ nsTableRow::MapAttributesInto(nsIStyleContext* aContext,
}
// valign: enum
- GetAttribute(nsHTMLAtoms::valign, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
@@ -281,11 +284,20 @@ nsTableRow::MapAttributesInto(nsIStyleContext* aContext,
}
//background: color
- MapBackgroundAttributesInto(aContext, aPresContext);
+ nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aContext, aPresContext);
}
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsTableRow::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
+
+
NS_IMETHODIMP
nsTableRow::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
diff --git a/mozilla/layout/html/table/src/nsTableRow.h b/mozilla/layout/html/table/src/nsTableRow.h
index 5acd5538418..4021d6c2aa6 100644
--- a/mozilla/layout/html/table/src/nsTableRow.h
+++ b/mozilla/layout/html/table/src/nsTableRow.h
@@ -72,8 +72,7 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
/** @see nsIHTMLContent::CreateFrame */
NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
diff --git a/mozilla/layout/html/table/src/nsTableRowGroup.cpp b/mozilla/layout/html/table/src/nsTableRowGroup.cpp
index 65b324632d2..90246bc1aa1 100644
--- a/mozilla/layout/html/table/src/nsTableRowGroup.cpp
+++ b/mozilla/layout/html/table/src/nsTableRowGroup.cpp
@@ -31,6 +31,8 @@
#include "nsIDocument.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
+#include "nsIHTMLAttributes.h"
+#include "nsGenericHTMLElement.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@@ -96,18 +98,19 @@ nsTableRowGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
return nsTableContent::SetAttribute(aAttribute, aValue, aNotify);
}
-NS_IMETHODIMP
-nsTableRowGroup::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+static void
+MapAttributesInto(nsIHTMLAttributes* aAttributes,
+ nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
- if (nsnull != mAttributes) {
+ if (nsnull != aAttributes) {
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// align: enum
- GetAttribute(nsHTMLAtoms::align, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
@@ -115,7 +118,7 @@ nsTableRowGroup::MapAttributesInto(nsIStyleContext* aContext,
}
// valign: enum
- GetAttribute(nsHTMLAtoms::valign, value);
+ aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
@@ -123,9 +126,17 @@ nsTableRowGroup::MapAttributesInto(nsIStyleContext* aContext,
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
}
+ nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
+}
+
+NS_IMETHODIMP
+nsTableRowGroup::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const
+{
+ aMapFunc = &MapAttributesInto;
return NS_OK;
}
+
nsresult
nsTableRowGroup::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
diff --git a/mozilla/layout/html/table/src/nsTableRowGroup.h b/mozilla/layout/html/table/src/nsTableRowGroup.h
index bdce3f1d866..07e786ee91b 100644
--- a/mozilla/layout/html/table/src/nsTableRowGroup.h
+++ b/mozilla/layout/html/table/src/nsTableRowGroup.h
@@ -63,8 +63,7 @@ public:
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
+ NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
/** @see nsIHTMLContent::CreateFrame */
NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
diff --git a/mozilla/layout/style/nsCSSStyleRule.cpp b/mozilla/layout/style/nsCSSStyleRule.cpp
index 9016a41cc22..3bd6a337810 100644
--- a/mozilla/layout/style/nsCSSStyleRule.cpp
+++ b/mozilla/layout/style/nsCSSStyleRule.cpp
@@ -168,8 +168,7 @@ public:
PRInt32 aMask, const nsStyleFont* aFont,
nsIPresContext* aPresContext);
- NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent);
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
@@ -515,8 +514,7 @@ PRBool CSSStyleRuleImpl::SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord
}
NS_IMETHODIMP
-CSSStyleRuleImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+CSSStyleRuleImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
{
if (nsnull != mDeclaration) {
nsStyleFont* font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font);
diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp
index fabeaca8404..945525537bf 100644
--- a/mozilla/layout/style/nsCSSStyleSheet.cpp
+++ b/mozilla/layout/style/nsCSSStyleSheet.cpp
@@ -31,6 +31,7 @@
#include "nsIFrame.h"
#include "nsString.h"
#include "nsIPtr.h"
+#include "nsHTMLIIDs.h"
//#define DEBUG_REFS
//#define DEBUG_RULES
@@ -38,7 +39,6 @@
static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
NS_DEF_PTR(nsIHTMLContent);
NS_DEF_PTR(nsIContent);
diff --git a/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp b/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp
index ec655f2b333..edba400dbed 100644
--- a/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp
+++ b/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp
@@ -25,10 +25,10 @@
#include "nsIHTMLContent.h"
#include "nsIStyleRule.h"
#include "nsIFrame.h"
+#include "nsHTMLIIDs.h"
static NS_DEFINE_IID(kIHTMLCSSStyleSheetIID, NS_IHTML_CSS_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
class HTMLCSSStyleSheetImpl : public nsIHTMLCSSStyleSheet {
diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp
index c8a2e659f90..d214750b638 100644
--- a/mozilla/layout/style/nsHTMLStyleSheet.cpp
+++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp
@@ -34,11 +34,11 @@
#include "nsTableCell.h"
#include "nsTableColFrame.h"
#include "nsTableFrame.h"
+#include "nsHTMLIIDs.h"
static NS_DEFINE_IID(kIHTMLStyleSheetIID, NS_IHTML_STYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
-static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
class HTMLAnchorRule : public nsIStyleRule {
@@ -51,8 +51,7 @@ public:
NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aValue) const;
NS_IMETHOD HashValue(PRUint32& aValue) const;
- NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent);
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
@@ -85,8 +84,7 @@ HTMLAnchorRule::HashValue(PRUint32& aValue) const
}
NS_IMETHODIMP
-HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
- nsIContent* aContent)
+HTMLAnchorRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext)
{
nsStyleColor* styleColor = (nsStyleColor*)(aContext->GetMutableStyleData(eStyleStruct_Color));
@@ -107,7 +105,7 @@ HTMLAnchorRule::List(FILE* out, PRInt32 aIndent) const
class AttributeKey: public nsHashKey
{
public:
- AttributeKey(nsIAtom* aTag, nsIHTMLAttributes* aAttributes);
+ AttributeKey(nsMapAttributesFunc aMapFunc, nsIHTMLAttributes* aAttributes);
virtual ~AttributeKey(void);
PRBool Equals(const nsHashKey* aOther) const;
@@ -120,31 +118,29 @@ private:
AttributeKey& operator=(const AttributeKey& aCopy);
public:
- nsIAtom* mTag;
+ nsMapAttributesFunc mMapFunc;
nsIHTMLAttributes* mAttributes;
PRUint32 mHashSet: 1;
PRUint32 mHashCode: 31;
};
-AttributeKey::AttributeKey(nsIAtom* aTag, nsIHTMLAttributes* aAttributes)
- : mTag(aTag),
+AttributeKey::AttributeKey(nsMapAttributesFunc aMapFunc, nsIHTMLAttributes* aAttributes)
+ : mMapFunc(aMapFunc),
mAttributes(aAttributes)
{
- NS_ADDREF(mTag);
NS_ADDREF(mAttributes);
mHashSet = 0;
}
AttributeKey::~AttributeKey(void)
{
- NS_RELEASE(mTag);
NS_RELEASE(mAttributes);
}
PRBool AttributeKey::Equals(const nsHashKey* aOther) const
{
const AttributeKey* other = (const AttributeKey*)aOther;
- if (mTag == other->mTag) {
+ if (mMapFunc == other->mMapFunc) {
PRBool equals;
mAttributes->Equals(other->mAttributes, equals);
return equals;
@@ -159,7 +155,7 @@ PRUint32 AttributeKey::HashValue(void) const
PRUint32 hash;
mAttributes->HashValue(hash);
self->mHashCode = (0x7FFFFFFF & hash);
- self->mHashCode |= (0x7FFFFFFF & PRUint32(mTag));
+ self->mHashCode |= (0x7FFFFFFF & PRUint32(mMapFunc));
self->mHashSet = 1;
}
return mHashCode;
@@ -167,7 +163,7 @@ PRUint32 AttributeKey::HashValue(void) const
nsHashKey* AttributeKey::Clone(void) const
{
- AttributeKey* clown = new AttributeKey(mTag, mAttributes);
+ AttributeKey* clown = new AttributeKey(mMapFunc, mAttributes);
if (nsnull != clown) {
clown->mHashSet = mHashSet;
clown->mHashCode = mHashCode;
@@ -206,14 +202,19 @@ public:
NS_IMETHOD SetVisitedLinkColor(nscolor aColor);
// Attribute management methods, aAttributes is an in/out param
- NS_IMETHOD SetAttributesFor(nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetIDFor(nsIAtom* aID, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue, nsIAtom* aTag,
+ NS_IMETHOD SetAttributesFor(nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent,
+ nsIHTMLAttributes*& aAttributes);
+ NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsString& aValue,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue, nsIAtom* aTag,
+ NS_IMETHOD SetAttributeFor(nsIAtom* aAttribute, const nsHTMLValue& aValue,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
- NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIAtom* aTag,
+ NS_IMETHOD UnsetAttributeFor(nsIAtom* aAttribute, nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes);
@@ -230,11 +231,11 @@ protected:
virtual ~HTMLStyleSheetImpl();
NS_IMETHOD EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRBool aCreate,
nsIHTMLAttributes*& aSingleAttrs);
NS_IMETHOD UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRInt32 aAttrCount,
nsIHTMLAttributes*& aAttributes);
@@ -379,6 +380,7 @@ PRInt32 AppendRulesFrom(nsIFrame* aFrame, nsIPresContext* aPresContext, PRInt32&
AppendData data(backstopCount, aInsertPoint, aResults);
rules->EnumerateForwards(AppendFunc, &data);
aInsertPoint = data.mInsert;
+ NS_RELEASE(rules);
}
NS_RELEASE(context);
}
@@ -563,12 +565,14 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor)
return NS_OK;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsIHTMLAttributes* attrs = aAttributes;
if (nsnull != attrs) {
- AttributeKey key(aTag, attrs);
+ nsMapAttributesFunc mapFunc;
+ aContent->GetAttributeMappingFunction(mapFunc);
+ AttributeKey key(mapFunc, attrs);
nsIHTMLAttributes* sharedAttrs = (nsIHTMLAttributes*)mAttrTable.Get(&key);
if (nsnull == sharedAttrs) { // we have a new unique set
mAttrTable.Put(&key, attrs);
@@ -588,37 +592,43 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributesFor(nsIAtom* aTag, nsIHTMLAttribu
return NS_OK;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetIDFor(nsIAtom* aID, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetIDFor(nsIAtom* aID, nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(nsnull != aID);
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetID(aID, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
}
-NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIAtom* aTag, nsIHTMLAttributes*& aAttributes)
+NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(nsnull != aClass);
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetClass(aClass, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
@@ -627,19 +637,22 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetClassFor(nsIAtom* aClass, nsIAtom* aTag, ns
NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
const nsString& aValue,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, PR_TRUE, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, PR_TRUE, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetAttribute(aAttribute, aValue, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
@@ -647,7 +660,7 @@ NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
NS_IMETHODIMP
HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRBool aCreate,
nsIHTMLAttributes*& aSingleAttrs)
{
@@ -659,9 +672,10 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
if (nsnull != mRecycledAttrs) {
aSingleAttrs = mRecycledAttrs;
mRecycledAttrs = nsnull;
+ aSingleAttrs->SetMappingFunction(aMapFunc);
}
else {
- result = NS_NewHTMLAttributes(&aSingleAttrs);
+ result = NS_NewHTMLAttributes(&aSingleAttrs, aMapFunc);
}
}
else {
@@ -688,7 +702,7 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
}
else { // one content ref, ok to use, remove from table because hash may change
if (1 == contentRefCount) {
- AttributeKey key(aTag, aSingleAttrs);
+ AttributeKey key(aMapFunc, aSingleAttrs);
mAttrTable.Remove(&key);
NS_ADDREF(aSingleAttrs); // add a local ref so we match up
}
@@ -703,14 +717,14 @@ HTMLStyleSheetImpl::EnsureSingleAttributes(nsIHTMLAttributes*& aAttributes,
NS_IMETHODIMP
HTMLStyleSheetImpl::UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
- nsIAtom* aTag,
+ nsMapAttributesFunc aMapFunc,
PRInt32 aAttrCount,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
if (0 < aAttrCount) {
- AttributeKey key(aTag, aSingleAttrs);
+ AttributeKey key(aMapFunc, aSingleAttrs);
nsIHTMLAttributes* sharedAttrs = (nsIHTMLAttributes*)mAttrTable.Get(&key);
if (nsnull == sharedAttrs) { // we have a new unique set
mAttrTable.Put(&key, aSingleAttrs);
@@ -757,39 +771,45 @@ HTMLStyleSheetImpl::UniqueAttributes(nsIHTMLAttributes*& aSingleAttrs,
NS_IMETHODIMP HTMLStyleSheetImpl::SetAttributeFor(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
PRBool hasValue = PRBool(eHTMLUnit_Null != aValue.GetUnit());
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, hasValue, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, hasValue, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->SetAttribute(aAttribute, aValue, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;
}
NS_IMETHODIMP HTMLStyleSheetImpl::UnsetAttributeFor(nsIAtom* aAttribute,
- nsIAtom* aTag,
+ nsIHTMLContent* aContent,
nsIHTMLAttributes*& aAttributes)
{
nsresult result = NS_OK;
nsIHTMLAttributes* attrs;
+ nsMapAttributesFunc mapFunc;
- result = EnsureSingleAttributes(aAttributes, aTag, PR_FALSE, attrs);
+ aContent->GetAttributeMappingFunction(mapFunc);
+
+ result = EnsureSingleAttributes(aAttributes, mapFunc, PR_FALSE, attrs);
if ((NS_OK == result) && (nsnull != attrs)) {
PRInt32 count;
attrs->UnsetAttribute(aAttribute, count);
- result = UniqueAttributes(attrs, aTag, count, aAttributes);
+ result = UniqueAttributes(attrs, mapFunc, count, aAttributes);
}
return result;