diff --git a/mozilla/content/html/content/src/makefile.win b/mozilla/content/html/content/src/makefile.win
index 3c4f2c65101..edb5651f808 100644
--- a/mozilla/content/html/content/src/makefile.win
+++ b/mozilla/content/html/content/src/makefile.win
@@ -70,6 +70,7 @@ CPPSRCS= \
nsHTMLQuoteElement.cpp \
nsHTMLScriptElement.cpp \
nsHTMLSelectElement.cpp \
+ nsHTMLSpanElement.cpp \
nsHTMLStyleElement.cpp \
nsHTMLTableElement.cpp \
nsHTMLTableCaptionElement.cpp \
@@ -130,6 +131,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsHTMLQuoteElement.obj \
.\$(OBJDIR)\nsHTMLScriptElement.obj \
.\$(OBJDIR)\nsHTMLSelectElement.obj \
+ .\$(OBJDIR)\nsHTMLSpanElement.obj \
.\$(OBJDIR)\nsHTMLStyleElement.obj \
.\$(OBJDIR)\nsHTMLTableElement.obj \
.\$(OBJDIR)\nsHTMLTableCaptionElement.obj \
diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
index 841ccb9cb7c..5d7806755e2 100644
--- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
@@ -51,6 +51,7 @@
#include "nsIEventStateManager.h"
#include "nsDOMEvent.h"
#include "nsIPrivateDOMEvent.h"
+#include "nsBodyFrame.h"
#include "prprf.h"
// XXX todo: add in missing out-of-memory checks
@@ -611,7 +612,7 @@ static void ReleaseAttributes(nsIHTMLAttributes*& aAttributes)
}
-nsHTMLGenericContent::nsHTMLGenericContent()
+nsGenericHTMLElement::nsGenericHTMLElement()
{
mDocument = nsnull;
mParent = nsnull;
@@ -631,7 +632,7 @@ nsHTMLGenericContent::nsHTMLGenericContent()
NS_ADDREF(gContentDelegate);
}
-nsHTMLGenericContent::~nsHTMLGenericContent()
+nsGenericHTMLElement::~nsGenericHTMLElement()
{
if (nsnull != mAttributes) {
ReleaseAttributes(mAttributes);
@@ -652,7 +653,7 @@ nsHTMLGenericContent::~nsHTMLGenericContent()
}
void
-nsHTMLGenericContent::Init(nsIHTMLContent* aOuterContentObject,
+nsGenericHTMLElement::Init(nsIHTMLContent* aOuterContentObject,
nsIAtom* aTag)
{
NS_ASSERTION((nsnull == mContent) && (nsnull != aOuterContentObject),
@@ -663,33 +664,33 @@ nsHTMLGenericContent::Init(nsIHTMLContent* aOuterContentObject,
}
nsresult
-nsHTMLGenericContent::GetNodeName(nsString& aNodeName)
+nsGenericHTMLElement::GetNodeName(nsString& aNodeName)
{
return GetTagName(aNodeName);
}
nsresult
-nsHTMLGenericContent::GetNodeValue(nsString& aNodeValue)
+nsGenericHTMLElement::GetNodeValue(nsString& aNodeValue)
{
aNodeValue.Truncate();
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetNodeValue(const nsString& aNodeValue)
+nsGenericHTMLElement::SetNodeValue(const nsString& aNodeValue)
{
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetNodeType(PRInt32* aNodeType)
+nsGenericHTMLElement::GetNodeType(PRInt32* aNodeType)
{
*aNodeType = nsIDOMNode::ELEMENT;
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetParentNode(nsIDOMNode** aParentNode)
+nsGenericHTMLElement::GetParentNode(nsIDOMNode** aParentNode)
{
if (nsnull != mParent) {
nsresult res = mParent->QueryInterface(kIDOMNodeIID, (void**)aParentNode);
@@ -703,7 +704,7 @@ nsHTMLGenericContent::GetParentNode(nsIDOMNode** aParentNode)
}
nsresult
-nsHTMLGenericContent::GetPreviousSibling(nsIDOMNode** aNode)
+nsGenericHTMLElement::GetPreviousSibling(nsIDOMNode** aNode)
{
if (nsnull != mParent) {
PRInt32 pos;
@@ -724,7 +725,7 @@ nsHTMLGenericContent::GetPreviousSibling(nsIDOMNode** aNode)
}
nsresult
-nsHTMLGenericContent::GetNextSibling(nsIDOMNode** aNextSibling)
+nsGenericHTMLElement::GetNextSibling(nsIDOMNode** aNextSibling)
{
if (nsnull != mParent) {
PRInt32 pos;
@@ -745,7 +746,7 @@ nsHTMLGenericContent::GetNextSibling(nsIDOMNode** aNextSibling)
}
nsresult
-nsHTMLGenericContent::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
+nsGenericHTMLElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
{
NS_PRECONDITION(nsnull != aAttributes, "null pointer argument");
if (nsnull != mAttributes) {
@@ -762,7 +763,7 @@ nsHTMLGenericContent::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
}
nsresult
-nsHTMLGenericContent::GetTagName(nsString& aTagName)
+nsGenericHTMLElement::GetTagName(nsString& aTagName)
{
aTagName.Truncate();
if (nsnull != mTag) {
@@ -772,14 +773,14 @@ nsHTMLGenericContent::GetTagName(nsString& aTagName)
}
nsresult
-nsHTMLGenericContent::GetDOMAttribute(const nsString& aName, nsString& aReturn)
+nsGenericHTMLElement::GetDOMAttribute(const nsString& aName, nsString& aReturn)
{
GetAttribute(aName, aReturn);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetDOMAttribute(const nsString& aName,
+nsGenericHTMLElement::SetDOMAttribute(const nsString& aName,
const nsString& aValue)
{
SetAttribute(aName, aValue, PR_TRUE);
@@ -787,7 +788,7 @@ nsHTMLGenericContent::SetDOMAttribute(const nsString& aName,
}
nsresult
-nsHTMLGenericContent::RemoveAttribute(const nsString& aName)
+nsGenericHTMLElement::RemoveAttribute(const nsString& aName)
{
nsAutoString upper;
aName.ToUpperCase(upper);
@@ -798,7 +799,7 @@ nsHTMLGenericContent::RemoveAttribute(const nsString& aName)
}
nsresult
-nsHTMLGenericContent::GetAttributeNode(const nsString& aName,
+nsGenericHTMLElement::GetAttributeNode(const nsString& aName,
nsIDOMAttribute** aReturn)
{
nsAutoString value;
@@ -809,7 +810,7 @@ nsHTMLGenericContent::GetAttributeNode(const nsString& aName,
}
nsresult
-nsHTMLGenericContent::SetAttributeNode(nsIDOMAttribute* aAttribute)
+nsGenericHTMLElement::SetAttributeNode(nsIDOMAttribute* aAttribute)
{
NS_PRECONDITION(nsnull != aAttribute, "null attribute");
@@ -829,7 +830,7 @@ nsHTMLGenericContent::SetAttributeNode(nsIDOMAttribute* aAttribute)
}
nsresult
-nsHTMLGenericContent::RemoveAttributeNode(nsIDOMAttribute* aAttribute)
+nsGenericHTMLElement::RemoveAttributeNode(nsIDOMAttribute* aAttribute)
{
NS_PRECONDITION(nsnull != aAttribute, "null attribute");
@@ -850,90 +851,90 @@ nsHTMLGenericContent::RemoveAttributeNode(nsIDOMAttribute* aAttribute)
}
nsresult
-nsHTMLGenericContent::GetElementsByTagName(const nsString& aTagname,
+nsGenericHTMLElement::GetElementsByTagName(const nsString& aTagname,
nsIDOMNodeList** aReturn)
{
return NS_ERROR_NOT_IMPLEMENTED;/* XXX */
}
nsresult
-nsHTMLGenericContent::Normalize()
+nsGenericHTMLElement::Normalize()
{
return NS_ERROR_NOT_IMPLEMENTED;/* XXX */
}
nsresult
-nsHTMLGenericContent::GetId(nsString& aId)
+nsGenericHTMLElement::GetId(nsString& aId)
{
GetAttribute(nsHTMLAtoms::id, aId);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetId(const nsString& aId)
+nsGenericHTMLElement::SetId(const nsString& aId)
{
SetAttr(nsHTMLAtoms::id, aId, eSetAttrNotify_Restart);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetTitle(nsString& aTitle)
+nsGenericHTMLElement::GetTitle(nsString& aTitle)
{
GetAttribute(nsHTMLAtoms::title, aTitle);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetTitle(const nsString& aTitle)
+nsGenericHTMLElement::SetTitle(const nsString& aTitle)
{
SetAttr(nsHTMLAtoms::title, aTitle, eSetAttrNotify_None);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetLang(nsString& aLang)
+nsGenericHTMLElement::GetLang(nsString& aLang)
{
GetAttribute(nsHTMLAtoms::lang, aLang);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetLang(const nsString& aLang)
+nsGenericHTMLElement::SetLang(const nsString& aLang)
{
SetAttr(nsHTMLAtoms::lang, aLang, eSetAttrNotify_Reflow);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetDir(nsString& aDir)
+nsGenericHTMLElement::GetDir(nsString& aDir)
{
GetAttribute(nsHTMLAtoms::dir, aDir);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetDir(const nsString& aDir)
+nsGenericHTMLElement::SetDir(const nsString& aDir)
{
SetAttr(nsHTMLAtoms::dir, aDir, eSetAttrNotify_Reflow);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetClassName(nsString& aClassName)
+nsGenericHTMLElement::GetClassName(nsString& aClassName)
{
GetAttribute(nsHTMLAtoms::kClass, aClassName);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetClassName(const nsString& aClassName)
+nsGenericHTMLElement::SetClassName(const nsString& aClassName)
{
SetAttr(nsHTMLAtoms::kClass, aClassName, eSetAttrNotify_Restart);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetDocument(nsIDocument*& aResult) const
+nsGenericHTMLElement::GetDocument(nsIDocument*& aResult) const
{
aResult = mDocument;
NS_IF_ADDREF(mDocument);
@@ -955,7 +956,7 @@ static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
}
nsresult
-nsHTMLGenericContent::SetDocument(nsIDocument* aDocument)
+nsGenericHTMLElement::SetDocument(nsIDocument* aDocument)
{
mDocument = aDocument;
@@ -1005,7 +1006,7 @@ nsHTMLGenericContent::SetDocument(nsIDocument* aDocument)
}
nsresult
-nsHTMLGenericContent::GetParent(nsIContent*& aResult) const
+nsGenericHTMLElement::GetParent(nsIContent*& aResult) const
{
NS_IF_ADDREF(mParent);
aResult = mParent;
@@ -1013,21 +1014,21 @@ nsHTMLGenericContent::GetParent(nsIContent*& aResult) const
}
nsresult
-nsHTMLGenericContent::SetParent(nsIContent* aParent)
+nsGenericHTMLElement::SetParent(nsIContent* aParent)
{
mParent = aParent;
return NS_OK;
}
nsresult
-nsHTMLGenericContent::IsSynthetic(PRBool& aResult)
+nsGenericHTMLElement::IsSynthetic(PRBool& aResult)
{
return PR_FALSE;
}
nsresult
-nsHTMLGenericContent::GetTag(nsIAtom*& aResult) const
+nsGenericHTMLElement::GetTag(nsIAtom*& aResult) const
{
NS_IF_ADDREF(mTag);
aResult = mTag;
@@ -1046,7 +1047,7 @@ nsHTMLGenericContent::GetTag(nsIAtom*& aResult) const
//}
nsresult
-nsHTMLGenericContent::HandleDOMEvent(nsIPresContext& aPresContext,
+nsGenericHTMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
@@ -1099,7 +1100,7 @@ nsHTMLGenericContent::HandleDOMEvent(nsIPresContext& aPresContext,
}
nsresult
-nsHTMLGenericContent::SetAttribute(const nsString& aName,
+nsGenericHTMLElement::SetAttribute(const nsString& aName,
const nsString& aValue,
PRBool aNotify)
{
@@ -1111,12 +1112,38 @@ nsHTMLGenericContent::SetAttribute(const nsString& aName,
return rv;
}
+#if 0
+static nsGenericHTMLElement::EnumTable kDirTable[] = {
+ { "ltr", NS_STYLE_DIRECTION_LTR },
+ { "rtl", NS_STYLE_DIRECTION_RTL },
+ { 0 }
+};
+#endif
+
nsresult
-nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute,
+nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
const nsString& aValue,
PRBool aNotify)
{
nsresult result = NS_OK;
+#if 0
+ if (nsHTMLAtoms::dir == aAttribute) {
+ nsHTMLValue val;
+ if (ParseEnumValue(aValue, kDirTable, val)) {
+ result = SetAttribute(aAttribute, val, aNotify);
+ }
+ else {
+ result = SetStringAttribute(aAttribute, aValue, aNotify);
+ }
+ }
+ else if (nsHTMLAtoms::lang == aAttribute) {
+ result = SetStringAttribute(aAttribute, aValue, aNotify);
+ }
+ else if (nsHTMLAtoms::title == aAttribute) {
+ result = SetStringAttribute(aAttribute, aValue, aNotify);
+ }
+ else
+#endif
if (nsHTMLAtoms::style == aAttribute) {
// XXX the style sheet language is a document property that
// should be used to lookup the style sheet parser to parse the
@@ -1148,7 +1175,7 @@ nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute,
+nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
PRBool aNotify)
{
@@ -1170,8 +1197,27 @@ nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute,
return result;
}
+/**
+ * Handle attributes common to all html elements
+ */
nsresult
-nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute,
+nsGenericHTMLElement::MapAttributesInto(nsIStyleContext* aStyleContext,
+ nsIPresContext* aPresContext)
+{
+ if (nsnull != mAttributes) {
+ nsHTMLValue value;
+ GetAttribute(nsHTMLAtoms::dir, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ nsStyleDisplay* display = (nsStyleDisplay*)
+ aStyleContext->GetMutableStyleData(eStyleStruct_Display);
+ display->mDirection = value.GetIntValue();
+ }
+ }
+ return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::SetAttr(nsIAtom* aAttribute,
const nsString& aValue,
nsSetAttrNotify aNotify)
{
@@ -1180,7 +1226,7 @@ nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute,
+nsGenericHTMLElement::SetAttr(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
nsSetAttrNotify aNotify)
{
@@ -1189,7 +1235,7 @@ nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::UnsetAttribute(nsIAtom* aAttribute)
+nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute)
{
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
@@ -1210,7 +1256,7 @@ nsHTMLGenericContent::UnsetAttribute(nsIAtom* aAttribute)
}
nsresult
-nsHTMLGenericContent::GetAttribute(const nsString& aName,
+nsGenericHTMLElement::GetAttribute(const nsString& aName,
nsString& aResult) const
{
nsAutoString upper;
@@ -1222,7 +1268,7 @@ nsHTMLGenericContent::GetAttribute(const nsString& aName,
}
nsresult
-nsHTMLGenericContent::GetAttribute(nsIAtom *aAttribute,
+nsGenericHTMLElement::GetAttribute(nsIAtom *aAttribute,
nsString &aResult) const
{
nsHTMLValue value;
@@ -1283,7 +1329,7 @@ nsHTMLGenericContent::GetAttribute(nsIAtom *aAttribute,
}
nsresult
-nsHTMLGenericContent::GetAttribute(nsIAtom* aAttribute,
+nsGenericHTMLElement::GetAttribute(nsIAtom* aAttribute,
nsHTMLValue& aValue) const
{
if (nsnull != mAttributes) {
@@ -1294,7 +1340,7 @@ nsHTMLGenericContent::GetAttribute(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::GetAllAttributeNames(nsISupportsArray* aArray,
+nsGenericHTMLElement::GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const
{
if (nsnull != mAttributes) {
@@ -1305,7 +1351,7 @@ nsHTMLGenericContent::GetAllAttributeNames(nsISupportsArray* aArray,
}
nsresult
-nsHTMLGenericContent::GetAttributeCount(PRInt32& aCount) const
+nsGenericHTMLElement::GetAttributeCount(PRInt32& aCount) const
{
if (nsnull != mAttributes) {
return mAttributes->Count(aCount);
@@ -1315,7 +1361,7 @@ nsHTMLGenericContent::GetAttributeCount(PRInt32& aCount) const
}
nsresult
-nsHTMLGenericContent::SetID(nsIAtom* aID)
+nsGenericHTMLElement::SetID(nsIAtom* aID)
{
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
@@ -1336,7 +1382,7 @@ nsHTMLGenericContent::SetID(nsIAtom* aID)
}
nsresult
-nsHTMLGenericContent::GetID(nsIAtom*& aResult) const
+nsGenericHTMLElement::GetID(nsIAtom*& aResult) const
{
if (nsnull != mAttributes) {
return mAttributes->GetID(aResult);
@@ -1346,7 +1392,7 @@ nsHTMLGenericContent::GetID(nsIAtom*& aResult) const
}
nsresult
-nsHTMLGenericContent::SetClass(nsIAtom* aClass)
+nsGenericHTMLElement::SetClass(nsIAtom* aClass)
{
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
@@ -1367,7 +1413,7 @@ nsHTMLGenericContent::SetClass(nsIAtom* aClass)
}
nsresult
-nsHTMLGenericContent::GetClass(nsIAtom*& aResult) const
+nsGenericHTMLElement::GetClass(nsIAtom*& aResult) const
{
if (nsnull != mAttributes) {
return mAttributes->GetClass(aResult);
@@ -1377,7 +1423,7 @@ nsHTMLGenericContent::GetClass(nsIAtom*& aResult) const
}
nsresult
-nsHTMLGenericContent::GetStyleRule(nsIStyleRule*& aResult)
+nsGenericHTMLElement::GetStyleRule(nsIStyleRule*& aResult)
{
nsIStyleRule* result = nsnull;
@@ -1389,14 +1435,14 @@ nsHTMLGenericContent::GetStyleRule(nsIStyleRule*& aResult)
}
nsIContentDelegate*
-nsHTMLGenericContent::GetDelegate(nsIPresContext* aCX)
+nsGenericHTMLElement::GetDelegate(nsIPresContext* aCX)
{
gContentDelegate->AddRef();
return gContentDelegate;
}
void
-nsHTMLGenericContent::ListAttributes(FILE* out) const
+nsGenericHTMLElement::ListAttributes(FILE* out) const
{
nsISupportsArray* attrs;
if (NS_OK == NS_NewISupportsArray(&attrs)) {
@@ -1423,7 +1469,7 @@ nsHTMLGenericContent::ListAttributes(FILE* out) const
}
nsresult
-nsHTMLGenericContent::List(FILE* out, PRInt32 aIndent) const
+nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
{
NS_PRECONDITION(nsnull != mDocument, "bad content");
@@ -1465,7 +1511,7 @@ nsHTMLGenericContent::List(FILE* out, PRInt32 aIndent) const
}
nsresult
-nsHTMLGenericContent::ToHTML(FILE* out) const
+nsGenericHTMLElement::ToHTML(FILE* out) const
{
nsAutoString tmp;
nsresult rv = ToHTMLString(tmp);
@@ -1502,7 +1548,7 @@ QuoteForHTML(const nsString& aValue, nsString& aResult)
}
nsresult
-nsHTMLGenericContent::ToHTMLString(nsString& aBuf) const
+nsGenericHTMLElement::ToHTMLString(nsString& aBuf) const
{
aBuf.Truncate(0);
aBuf.Append('<');
@@ -1555,7 +1601,7 @@ extern nsresult NS_NewObjectFrame(nsIContent* aContent, nsIFrame* aParentFrame,
nsIFrame*& aNewFrame);
nsresult
-nsHTMLGenericContent::CreateFrame(nsIPresContext* aPresContext,
+nsGenericHTMLElement::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
@@ -1567,6 +1613,9 @@ nsHTMLGenericContent::CreateFrame(nsIPresContext* aPresContext,
if (mTag == nsHTMLAtoms::applet) {
rv = NS_NewObjectFrame(mContent, aParentFrame, frame);
}
+ else if (mTag == nsHTMLAtoms::body) {
+ rv = nsBodyFrame::NewFrame(&frame, mContent, aParentFrame);
+ }
else if (mTag == nsHTMLAtoms::br) {
rv = NS_NewBRFrame(mContent, aParentFrame, frame);
}
@@ -1625,7 +1674,7 @@ nsHTMLGenericContent::CreateFrame(nsIPresContext* aPresContext,
// nsIScriptObjectOwner implementation
nsresult
-nsHTMLGenericContent::GetScriptObject(nsIScriptContext* aContext,
+nsGenericHTMLElement::GetScriptObject(nsIScriptContext* aContext,
void** aScriptObject)
{
nsresult res = NS_OK;
@@ -1640,7 +1689,7 @@ nsHTMLGenericContent::GetScriptObject(nsIScriptContext* aContext,
}
nsresult
-nsHTMLGenericContent::ResetScriptObject()
+nsGenericHTMLElement::ResetScriptObject()
{
mScriptObject = nsnull;
return NS_OK;
@@ -1651,7 +1700,7 @@ nsHTMLGenericContent::ResetScriptObject()
// nsIDOMEventReceiver implementation
nsresult
-nsHTMLGenericContent::GetListenerManager(nsIEventListenerManager** aResult)
+nsGenericHTMLElement::GetListenerManager(nsIEventListenerManager** aResult)
{
if (nsnull != mListenerManager) {
NS_ADDREF(mListenerManager);
@@ -1667,13 +1716,13 @@ nsHTMLGenericContent::GetListenerManager(nsIEventListenerManager** aResult)
}
nsresult
-nsHTMLGenericContent::GetNewListenerManager(nsIEventListenerManager** aResult)
+nsGenericHTMLElement::GetNewListenerManager(nsIEventListenerManager** aResult)
{
return NS_NewEventListenerManager(aResult);
}
nsresult
-nsHTMLGenericContent::AddEventListener(nsIDOMEventListener* aListener,
+nsGenericHTMLElement::AddEventListener(nsIDOMEventListener* aListener,
const nsIID& aIID)
{
nsIEventListenerManager *manager;
@@ -1687,7 +1736,7 @@ nsHTMLGenericContent::AddEventListener(nsIDOMEventListener* aListener,
}
nsresult
-nsHTMLGenericContent::RemoveEventListener(nsIDOMEventListener* aListener,
+nsGenericHTMLElement::RemoveEventListener(nsIDOMEventListener* aListener,
const nsIID& aIID)
{
if (nsnull != mListenerManager) {
@@ -1700,7 +1749,7 @@ nsHTMLGenericContent::RemoveEventListener(nsIDOMEventListener* aListener,
//----------------------------------------------------------------------
nsresult
-nsHTMLGenericContent::AddScriptEventListener(nsIAtom* aAttribute,
+nsGenericHTMLElement::AddScriptEventListener(nsIAtom* aAttribute,
nsHTMLValue& aValue,
REFNSIID aIID)
{
@@ -1754,7 +1803,7 @@ nsHTMLGenericContent::AddScriptEventListener(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::AttributeToString(nsIAtom* aAttribute,
+nsGenericHTMLElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const
{
@@ -1771,7 +1820,7 @@ nsHTMLGenericContent::AttributeToString(nsIAtom* aAttribute,
}
PRBool
-nsHTMLGenericContent::ParseEnumValue(const nsString& aValue,
+nsGenericHTMLElement::ParseEnumValue(const nsString& aValue,
EnumTable* aTable,
nsHTMLValue& aResult)
{
@@ -1786,7 +1835,7 @@ nsHTMLGenericContent::ParseEnumValue(const nsString& aValue,
}
PRBool
-nsHTMLGenericContent::EnumValueToString(const nsHTMLValue& aValue,
+nsGenericHTMLElement::EnumValueToString(const nsHTMLValue& aValue,
EnumTable* aTable,
nsString& aResult)
{
@@ -1805,7 +1854,7 @@ nsHTMLGenericContent::EnumValueToString(const nsHTMLValue& aValue,
}
PRBool
-nsHTMLGenericContent::ParseValueOrPercent(const nsString& aString,
+nsGenericHTMLElement::ParseValueOrPercent(const nsString& aString,
nsHTMLValue& aResult,
nsHTMLUnit aValueUnit)
{ // XXX should vave min/max values?
@@ -1839,7 +1888,7 @@ nsHTMLGenericContent::ParseValueOrPercent(const nsString& aString,
* or proportional (n*)
*/
void
-nsHTMLGenericContent::ParseValueOrPercentOrProportional(const nsString& aString,
+nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsString& aString,
nsHTMLValue& aResult,
nsHTMLUnit aValueUnit)
{ // XXX should have min/max values?
@@ -1864,7 +1913,7 @@ nsHTMLGenericContent::ParseValueOrPercentOrProportional(const nsString& aString,
}
PRBool
-nsHTMLGenericContent::ValueOrPercentToString(const nsHTMLValue& aValue,
+nsGenericHTMLElement::ValueOrPercentToString(const nsHTMLValue& aValue,
nsString& aResult)
{
aResult.Truncate(0);
@@ -1884,7 +1933,7 @@ nsHTMLGenericContent::ValueOrPercentToString(const nsHTMLValue& aValue,
}
PRBool
-nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin,
+nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin,
nsHTMLValue& aResult, nsHTMLUnit aValueUnit)
{
PRInt32 ec, val = aString.ToInteger(&ec);
@@ -1905,7 +1954,7 @@ nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin,
}
PRBool
-nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin,
+nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin,
PRInt32 aMax,
nsHTMLValue& aResult, nsHTMLUnit aValueUnit)
{
@@ -1928,7 +1977,7 @@ nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin,
}
PRBool
-nsHTMLGenericContent::ParseColor(const nsString& aString,
+nsGenericHTMLElement::ParseColor(const nsString& aString,
nsHTMLValue& aResult)
{
if (aString.Length() > 0) {
@@ -1953,7 +2002,7 @@ nsHTMLGenericContent::ParseColor(const nsString& aString,
}
PRBool
-nsHTMLGenericContent::ColorToString(const nsHTMLValue& aValue,
+nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue,
nsString& aResult)
{
if (aValue.GetUnit() == eHTMLUnit_Color) {
@@ -1977,7 +2026,7 @@ nsHTMLGenericContent::ColorToString(const nsHTMLValue& aValue,
}
// XXX check all mappings against ebina's usage
-static nsHTMLGenericContent::EnumTable kAlignTable[] = {
+static nsGenericHTMLElement::EnumTable kAlignTable[] = {
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
{ "texttop", NS_STYLE_VERTICAL_ALIGN_TEXT_TOP },
@@ -1992,22 +2041,45 @@ static nsHTMLGenericContent::EnumTable kAlignTable[] = {
{ 0 }
};
+static nsGenericHTMLElement::EnumTable kDivAlignTable[] = {
+ { "left", NS_STYLE_TEXT_ALIGN_LEFT },
+ { "right", NS_STYLE_TEXT_ALIGN_RIGHT },
+ { "center", NS_STYLE_TEXT_ALIGN_CENTER },
+ { "middle", NS_STYLE_TEXT_ALIGN_CENTER },
+ { "justify", NS_STYLE_TEXT_ALIGN_JUSTIFY },
+ { 0 }
+};
+
PRBool
-nsHTMLGenericContent::ParseAlignValue(const nsString& aString,
+nsGenericHTMLElement::ParseAlignValue(const nsString& aString,
nsHTMLValue& aResult)
{
return ParseEnumValue(aString, kAlignTable, aResult);
}
PRBool
-nsHTMLGenericContent::AlignValueToString(const nsHTMLValue& aValue,
+nsGenericHTMLElement::AlignValueToString(const nsHTMLValue& aValue,
nsString& aResult)
{
return EnumValueToString(aValue, kAlignTable, aResult);
}
PRBool
-nsHTMLGenericContent::ParseImageAttribute(nsIAtom* aAttribute,
+nsGenericHTMLElement::ParseDivAlignValue(const nsString& aString,
+ nsHTMLValue& aResult)
+{
+ return ParseEnumValue(aString, kDivAlignTable, aResult);
+}
+
+PRBool
+nsGenericHTMLElement::DivAlignValueToString(const nsHTMLValue& aValue,
+ nsString& aResult)
+{
+ return EnumValueToString(aValue, kDivAlignTable, aResult);
+}
+
+PRBool
+nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute,
const nsString& aString,
nsHTMLValue& aResult)
{
@@ -2026,7 +2098,7 @@ nsHTMLGenericContent::ParseImageAttribute(nsIAtom* aAttribute,
}
PRBool
-nsHTMLGenericContent::ImageAttributeToString(nsIAtom* aAttribute,
+nsGenericHTMLElement::ImageAttributeToString(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
nsString& aResult)
{
@@ -2041,7 +2113,7 @@ nsHTMLGenericContent::ImageAttributeToString(nsIAtom* aAttribute,
}
void
-nsHTMLGenericContent::MapImageAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
if (nsnull != mAttributes) {
@@ -2098,7 +2170,7 @@ nsHTMLGenericContent::MapImageAttributesInto(nsIStyleContext* aContext,
}
void
-nsHTMLGenericContent::MapImageAlignAttributeInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageAlignAttributeInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
if (nsnull != mAttributes) {
@@ -2134,7 +2206,7 @@ nsHTMLGenericContent::MapImageAlignAttributeInto(nsIStyleContext* aContext,
}
void
-nsHTMLGenericContent::MapImageBorderAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageBorderAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext,
nscolor aBorderColors[4])
{
@@ -2192,7 +2264,63 @@ nsHTMLGenericContent::MapImageBorderAttributesInto(nsIStyleContext* aContext,
}
void
-nsHTMLGenericContent::TriggerLink(nsIPresContext& aPresContext,
+nsGenericHTMLElement::MapBackgroundAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
+{
+ nsHTMLValue value;
+
+ // background
+ if (NS_CONTENT_ATTR_HAS_VALUE ==
+ GetAttribute(nsHTMLAtoms::background, value)) {
+ if (eHTMLUnit_String == value.GetUnit()) {
+ nsAutoString absURLSpec;
+ nsAutoString spec;
+ value.GetStringValue(spec);
+ if (spec.Length() > 0) {
+ // Resolve url to an absolute url
+ nsIURL* docURL = nsnull;
+ nsIDocument* doc = mDocument;
+ if (nsnull != doc) {
+ docURL = doc->GetDocumentURL();
+ }
+
+ nsresult rv = NS_MakeAbsoluteURL(docURL, "", spec, absURLSpec);
+ if (nsnull != docURL) {
+ NS_RELEASE(docURL);
+ }
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ color->mBackgroundImage = absURLSpec;
+ color->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE;
+ color->mBackgroundRepeat = NS_STYLE_BG_REPEAT_XY;
+ }
+ }
+ }
+
+ // bgcolor
+ if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::bgcolor, value)) {
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ nsStyleColor* 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));
+
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ NS_ColorNameToRGB(cbuf, &(color->mBackgroundColor));
+ color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
+ }
+ }
+}
+
+void
+nsGenericHTMLElement::TriggerLink(nsIPresContext& aPresContext,
const nsString& aBase,
const nsString& aURLSpec,
const nsString& aTargetSpec,
@@ -2233,17 +2361,17 @@ nsHTMLGenericContent::TriggerLink(nsIPresContext& aPresContext,
//----------------------------------------------------------------------
-nsHTMLGenericLeafContent::nsHTMLGenericLeafContent()
+nsGenericHTMLLeafElement::nsGenericHTMLLeafElement()
{
}
-nsHTMLGenericLeafContent::~nsHTMLGenericLeafContent()
+nsGenericHTMLLeafElement::~nsGenericHTMLLeafElement()
{
}
nsresult
-nsHTMLGenericLeafContent::CopyInnerTo(nsIHTMLContent* aSrcContent,
- nsHTMLGenericLeafContent* aDst)
+nsGenericHTMLLeafElement::CopyInnerTo(nsIHTMLContent* aSrcContent,
+ nsGenericHTMLLeafElement* aDst)
{
aDst->mContent = aSrcContent;
// XXX should the node's document be set?
@@ -2252,7 +2380,7 @@ nsHTMLGenericLeafContent::CopyInnerTo(nsIHTMLContent* aSrcContent,
}
nsresult
-nsHTMLGenericLeafContent::Equals(nsIDOMNode* aNode, PRBool aDeep,
+nsGenericHTMLLeafElement::Equals(nsIDOMNode* aNode, PRBool aDeep,
PRBool* aReturn)
{
// XXX not yet implemented
@@ -2261,7 +2389,7 @@ nsHTMLGenericLeafContent::Equals(nsIDOMNode* aNode, PRBool aDeep,
}
nsresult
-nsHTMLGenericLeafContent::BeginConvertToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLLeafElement::BeginConvertToXIF(nsXIFConverter& aConverter) const
{
nsresult rv = NS_OK;
if (nsnull != mTag)
@@ -2298,13 +2426,13 @@ nsHTMLGenericLeafContent::BeginConvertToXIF(nsXIFConverter& aConverter) const
}
nsresult
-nsHTMLGenericLeafContent::ConvertContentToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLLeafElement::ConvertContentToXIF(nsXIFConverter& aConverter) const
{
return NS_OK;
}
nsresult
-nsHTMLGenericLeafContent::FinishConvertToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLLeafElement::FinishConvertToXIF(nsXIFConverter& aConverter) const
{
if (nsnull != mTag)
{
@@ -2317,7 +2445,7 @@ nsHTMLGenericLeafContent::FinishConvertToXIF(nsXIFConverter& aConverter) const
// XXX not really implemented (yet)
nsresult
-nsHTMLGenericLeafContent::SizeOf(nsISizeOfHandler* aHandler) const
+nsGenericHTMLLeafElement::SizeOf(nsISizeOfHandler* aHandler) const
{
aHandler->Add(sizeof(*this));
return NS_OK;
@@ -2325,11 +2453,11 @@ nsHTMLGenericLeafContent::SizeOf(nsISizeOfHandler* aHandler) const
//----------------------------------------------------------------------
-nsHTMLGenericContainerContent::nsHTMLGenericContainerContent()
+nsGenericHTMLContainerElement::nsGenericHTMLContainerElement()
{
}
-nsHTMLGenericContainerContent::~nsHTMLGenericContainerContent()
+nsGenericHTMLContainerElement::~nsGenericHTMLContainerElement()
{
PRInt32 n = mChildren.Count();
for (PRInt32 i = 0; i < n; i++) {
@@ -2343,8 +2471,8 @@ nsHTMLGenericContainerContent::~nsHTMLGenericContainerContent()
}
nsresult
-nsHTMLGenericContainerContent:: CopyInnerTo(nsIHTMLContent* aSrcContent,
- nsHTMLGenericContainerContent* aDst)
+nsGenericHTMLContainerElement::CopyInnerTo(nsIHTMLContent* aSrcContent,
+ nsGenericHTMLContainerElement* aDst)
{
aDst->mContent = aSrcContent;
// XXX should the node's document be set?
@@ -2354,7 +2482,7 @@ nsHTMLGenericContainerContent:: CopyInnerTo(nsIHTMLContent* aSrcContent,
}
nsresult
-nsHTMLGenericContainerContent::Equals(nsIDOMNode* aNode, PRBool aDeep,
+nsGenericHTMLContainerElement::Equals(nsIDOMNode* aNode, PRBool aDeep,
PRBool* aReturn)
{
// XXX not yet implemented
@@ -2363,7 +2491,7 @@ nsHTMLGenericContainerContent::Equals(nsIDOMNode* aNode, PRBool aDeep,
}
nsresult
-nsHTMLGenericContainerContent::GetChildNodes(nsIDOMNodeList** aChildNodes)
+nsGenericHTMLContainerElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
{
*aChildNodes = nsnull;
return NS_OK;
@@ -2378,7 +2506,7 @@ nsHTMLGenericContainerContent::GetChildNodes(nsIDOMNodeList** aChildNodes)
}
nsresult
-nsHTMLGenericContainerContent::GetHasChildNodes(PRBool* aReturn)
+nsGenericHTMLContainerElement::GetHasChildNodes(PRBool* aReturn)
{
if (0 != mChildren.Count()) {
*aReturn = PR_TRUE;
@@ -2390,7 +2518,7 @@ nsHTMLGenericContainerContent::GetHasChildNodes(PRBool* aReturn)
}
nsresult
-nsHTMLGenericContainerContent::GetFirstChild(nsIDOMNode** aNode)
+nsGenericHTMLContainerElement::GetFirstChild(nsIDOMNode** aNode)
{
nsIContent *child = (nsIContent*) mChildren.ElementAt(0);
if (nsnull != child) {
@@ -2403,7 +2531,7 @@ nsHTMLGenericContainerContent::GetFirstChild(nsIDOMNode** aNode)
}
nsresult
-nsHTMLGenericContainerContent::GetLastChild(nsIDOMNode** aNode)
+nsGenericHTMLContainerElement::GetLastChild(nsIDOMNode** aNode)
{
nsIContent *child = (nsIContent*) mChildren.ElementAt(mChildren.Count()-1);
if (nsnull != child) {
@@ -2435,7 +2563,7 @@ SetDocumentInChildrenOf(nsIContent* aContent, nsIDocument* aDocument)
// was before placing it in it's new home
nsresult
-nsHTMLGenericContainerContent::InsertBefore(nsIDOMNode* aNewChild,
+nsGenericHTMLContainerElement::InsertBefore(nsIDOMNode* aNewChild,
nsIDOMNode* aRefChild,
nsIDOMNode** aReturn)
{
@@ -2482,7 +2610,7 @@ nsHTMLGenericContainerContent::InsertBefore(nsIDOMNode* aNewChild,
}
nsresult
-nsHTMLGenericContainerContent::ReplaceChild(nsIDOMNode* aNewChild,
+nsGenericHTMLContainerElement::ReplaceChild(nsIDOMNode* aNewChild,
nsIDOMNode* aOldChild,
nsIDOMNode** aReturn)
{
@@ -2511,7 +2639,7 @@ nsHTMLGenericContainerContent::ReplaceChild(nsIDOMNode* aNewChild,
}
nsresult
-nsHTMLGenericContainerContent::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
+nsGenericHTMLContainerElement::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
{
nsIContent* content = nsnull;
*aReturn = nsnull;
@@ -2532,20 +2660,20 @@ nsHTMLGenericContainerContent::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** a
}
nsresult
-nsHTMLGenericContainerContent::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
+nsGenericHTMLContainerElement::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
{
return InsertBefore(aNewChild, nsnull, aReturn);
}
nsresult
-nsHTMLGenericContainerContent::SizeOf(nsISizeOfHandler* aHandler) const
+nsGenericHTMLContainerElement::SizeOf(nsISizeOfHandler* aHandler) const
{
aHandler->Add(sizeof(*this));
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::BeginConvertToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLContainerElement::BeginConvertToXIF(nsXIFConverter& aConverter) const
{
nsresult rv = NS_OK;
if (nsnull != mTag)
@@ -2582,13 +2710,13 @@ nsHTMLGenericContainerContent::BeginConvertToXIF(nsXIFConverter& aConverter) con
}
nsresult
-nsHTMLGenericContainerContent::ConvertContentToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLContainerElement::ConvertContentToXIF(nsXIFConverter& aConverter) const
{
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::FinishConvertToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLContainerElement::FinishConvertToXIF(nsXIFConverter& aConverter) const
{
if (nsnull != mTag)
{
@@ -2600,28 +2728,28 @@ nsHTMLGenericContainerContent::FinishConvertToXIF(nsXIFConverter& aConverter) co
}
nsresult
-nsHTMLGenericContainerContent::Compact()
+nsGenericHTMLContainerElement::Compact()
{
mChildren.Compact();
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::CanContainChildren(PRBool& aResult) const
+nsGenericHTMLContainerElement::CanContainChildren(PRBool& aResult) const
{
aResult = PR_TRUE;
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::ChildCount(PRInt32& aCount) const
+nsGenericHTMLContainerElement::ChildCount(PRInt32& aCount) const
{
aCount = mChildren.Count();
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::ChildAt(PRInt32 aIndex,
+nsGenericHTMLContainerElement::ChildAt(PRInt32 aIndex,
nsIContent*& aResult) const
{
nsIContent *child = (nsIContent*) mChildren.ElementAt(aIndex);
@@ -2633,7 +2761,7 @@ nsHTMLGenericContainerContent::ChildAt(PRInt32 aIndex,
}
nsresult
-nsHTMLGenericContainerContent::IndexOf(nsIContent* aPossibleChild,
+nsGenericHTMLContainerElement::IndexOf(nsIContent* aPossibleChild,
PRInt32& aIndex) const
{
NS_PRECONDITION(nsnull != aPossibleChild, "null ptr");
@@ -2642,7 +2770,7 @@ nsHTMLGenericContainerContent::IndexOf(nsIContent* aPossibleChild,
}
nsresult
-nsHTMLGenericContainerContent::InsertChildAt(nsIContent* aKid,
+nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid,
PRInt32 aIndex,
PRBool aNotify)
{
@@ -2663,7 +2791,7 @@ nsHTMLGenericContainerContent::InsertChildAt(nsIContent* aKid,
}
nsresult
-nsHTMLGenericContainerContent::ReplaceChildAt(nsIContent* aKid,
+nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid,
PRInt32 aIndex,
PRBool aNotify)
{
@@ -2688,7 +2816,7 @@ nsHTMLGenericContainerContent::ReplaceChildAt(nsIContent* aKid,
}
nsresult
-nsHTMLGenericContainerContent::AppendChildTo(nsIContent* aKid, PRBool aNotify)
+nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify)
{
NS_PRECONDITION((nsnull != aKid) && (aKid != mContent), "null ptr");
PRBool rv = mChildren.AppendElement(aKid);
@@ -2707,7 +2835,7 @@ nsHTMLGenericContainerContent::AppendChildTo(nsIContent* aKid, PRBool aNotify)
}
nsresult
-nsHTMLGenericContainerContent::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
+nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
{
nsIContent* oldKid = (nsIContent*) mChildren.ElementAt(aIndex);
if (nsnull != oldKid ) {
diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h
index cc65be72ebb..b3c43f34824 100644
--- a/mozilla/content/html/content/src/nsGenericHTMLElement.h
+++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h
@@ -16,8 +16,8 @@
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
-#ifndef nsHTMLGenericContent_h___
-#define nsHTMLGenericContent_h___
+#ifndef nsGenericHTMLElement_h___
+#define nsGenericHTMLElement_h___
#include "nsIDOMHTMLElement.h"
#include "nsIContent.h"
@@ -51,9 +51,9 @@ enum nsSetAttrNotify {
eSetAttrNotify_Restart = 3
};
-struct nsHTMLGenericContent {
- nsHTMLGenericContent();
- ~nsHTMLGenericContent();
+struct nsGenericHTMLElement {
+ nsGenericHTMLElement();
+ ~nsGenericHTMLElement();
void Init(nsIHTMLContent* aOuterContentObject, nsIAtom* aTag);
@@ -212,9 +212,15 @@ struct nsHTMLGenericContent {
static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult);
+ static PRBool ParseDivAlignValue(const nsString& aString,
+ nsHTMLValue& aResult);
+
static PRBool AlignValueToString(const nsHTMLValue& aValue,
nsString& aResult);
+ static PRBool DivAlignValueToString(const nsHTMLValue& aValue,
+ nsString& aResult);
+
static PRBool ParseImageAttribute(nsIAtom* aAttribute,
const nsString& aString,
nsHTMLValue& aResult);
@@ -233,6 +239,9 @@ struct nsHTMLGenericContent {
nsIPresContext* aPresContext,
nscolor aBorderColors[4]);
+ void MapBackgroundAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
+
// Up pointer to the real content object that we are
// supporting. Sometimes there is work that we just can't do
// ourselves, so this is needed to ask the real object to do the
@@ -249,12 +258,12 @@ struct nsHTMLGenericContent {
//----------------------------------------------------------------------
-struct nsHTMLGenericLeafContent : public nsHTMLGenericContent {
- nsHTMLGenericLeafContent();
- ~nsHTMLGenericLeafContent();
+struct nsGenericHTMLLeafElement : public nsGenericHTMLElement {
+ nsGenericHTMLLeafElement();
+ ~nsGenericHTMLLeafElement();
nsresult CopyInnerTo(nsIHTMLContent* aSrcContent,
- nsHTMLGenericLeafContent* aDest);
+ nsGenericHTMLLeafElement* aDest);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn);
@@ -329,12 +338,12 @@ struct nsHTMLGenericLeafContent : public nsHTMLGenericContent {
//----------------------------------------------------------------------
-struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
- nsHTMLGenericContainerContent();
- ~nsHTMLGenericContainerContent();
+struct nsGenericHTMLContainerElement : public nsGenericHTMLElement {
+ nsGenericHTMLContainerElement();
+ ~nsGenericHTMLContainerElement();
nsresult CopyInnerTo(nsIHTMLContent* aSrcContent,
- nsHTMLGenericContainerContent* aDest);
+ nsGenericHTMLContainerElement* aDest);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn);
@@ -371,8 +380,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Mostly implement the nsIDOMNode API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*
* Note that classes using this macro will need to implement:
* NS_IMETHOD CloneNode(nsIDOMNode** aReturn);
@@ -435,8 +444,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Implement the nsIDOMElement API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*/
#define NS_IMPL_IDOMELEMENT_USING_GENERIC(_g) \
NS_IMETHOD GetTagName(nsString& aTagName) { \
@@ -471,8 +480,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Implement the nsIDOMHTMLElement API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*/
#define NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(_g) \
NS_IMETHOD GetId(nsString& aId) { \
@@ -508,8 +517,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Implement the nsIDOMEventReceiver API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*/
#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(_g) \
NS_IMETHOD AddEventListener(nsIDOMEventListener *aListener, \
@@ -529,8 +538,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*/
#define NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(_g) \
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, \
@@ -685,6 +694,71 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \
nsIPresContext* aPresContext);
+#define NS_IMPL_IHTMLCONTENT_USING_GENERIC2(_g) \
+ NS_IMETHOD Compact() { \
+ return _g.Compact(); \
+ } \
+ NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, \
+ PRBool aNotify) { \
+ return _g.SetAttribute(aAttribute, aValue, aNotify); \
+ } \
+ NS_IMETHOD SetAttribute(nsIAtom* aAttribute, \
+ const nsHTMLValue& aValue, PRBool aNotify) { \
+ return _g.SetAttribute(aAttribute, aValue, aNotify); \
+ } \
+ NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) { \
+ return _g.UnsetAttribute(aAttribute); \
+ } \
+ NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
+ nsString &aResult) const { \
+ return _g.GetAttribute(aAttribute, aResult); \
+ } \
+ NS_IMETHOD GetAttribute(nsIAtom* aAttribute, \
+ nsHTMLValue& aValue) const { \
+ return _g.GetAttribute(aAttribute, aValue); \
+ } \
+ NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
+ PRInt32& aResult) const { \
+ return _g.GetAllAttributeNames(aArray, aResult); \
+ } \
+ NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
+ return _g.GetAttributeCount(aResult); \
+ } \
+ NS_IMETHOD SetID(nsIAtom* aID) { \
+ return _g.SetID(aID); \
+ } \
+ NS_IMETHOD GetID(nsIAtom*& aResult) const { \
+ return _g.GetID(aResult); \
+ } \
+ NS_IMETHOD SetClass(nsIAtom* aClass) { \
+ return _g.SetClass(aClass); \
+ } \
+ NS_IMETHOD GetClass(nsIAtom*& aResult) const { \
+ return _g.GetClass(aResult); \
+ } \
+ NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult); \
+ NS_IMETHOD ToHTMLString(nsString& aResult) const { \
+ return _g.ToHTMLString(aResult); \
+ } \
+ NS_IMETHOD ToHTML(FILE* out) const { \
+ return _g.ToHTML(out); \
+ } \
+ NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, \
+ nsIFrame* aParentFrame, \
+ nsIStyleContext* aStyleContext, \
+ nsIFrame*& aResult) { \
+ return _g.CreateFrame(aPresContext, aParentFrame, aStyleContext, \
+ aResult); \
+ } \
+ NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, \
+ const nsString& aValue, \
+ nsHTMLValue& aResult); \
+ NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
+ nsHTMLValue& aValue, \
+ nsString& aResult) const; \
+ NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \
+ nsIPresContext* aPresContext);
+
/**
* This macro implements the portion of query interface that is
* generic to all html content objects.
@@ -811,4 +885,4 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
return mInner.SetAttr(nsHTMLAtoms::_atom, value, _notify); \
}
-#endif /* nsHTMLLeafContent_h___ */
+#endif /* nsGenericHTMLElement_h___ */
diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
index 05e7072a7f2..e703b396929 100644
--- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -30,6 +30,11 @@
#include "nsIEventStateManager.h"
#include "nsDOMEvent.h"
+// XXX suppress
+
+// XXX either suppress is handled in the event code below OR we need a
+// custom frame
+
static NS_DEFINE_IID(kIDOMHTMLAnchorElementIID, NS_IDOMHTMLANCHORELEMENT_IID);
class nsHTMLAnchorElement : public nsIDOMHTMLAnchorElement,
@@ -94,7 +99,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -182,10 +187,22 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::tabindex) {
- nsHTMLGenericContent::ParseValue(aValue, 0, 32767, aResult,
+ nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult,
eHTMLUnit_Integer);
return NS_CONTENT_ATTR_HAS_VALUE;
}
+ if (aAttribute == nsHTMLAtoms::href) {
+ nsAutoString href(aValue);
+ href.StripWhitespace();
+ aResult.SetStringValue(href);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::suppress) {
+ if (aValue.EqualsIgnoreCase("true")) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
@@ -201,9 +218,10 @@ NS_IMETHODIMP
nsHTMLAnchorElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
+// XXX support suppress in here
NS_IMETHODIMP
nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp
index e4f369d17a0..daea436a92b 100644
--- a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp
@@ -87,7 +87,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -160,11 +160,11 @@ nsHTMLAppletElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -178,11 +178,11 @@ nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -196,7 +196,7 @@ nsHTMLAppletElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp
index 19cfa3b1f76..59db5608d4e 100644
--- a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp
@@ -81,7 +81,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -165,7 +165,7 @@ NS_IMETHODIMP
nsHTMLAreaElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLBRElement.cpp b/mozilla/content/html/content/src/nsHTMLBRElement.cpp
index ecb0c1ec88c..43ca4b5b07c 100644
--- a/mozilla/content/html/content/src/nsHTMLBRElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLBRElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -124,7 +124,7 @@ nsHTMLBRElement::CloneNode(nsIDOMNode** aReturn)
NS_IMPL_STRING_ATTR(nsHTMLBRElement, Clear, clear, eSetAttrNotify_Reflow)
-static nsHTMLGenericContent::EnumTable kClearTable[] = {
+static nsGenericHTMLElement::EnumTable kClearTable[] = {
{ "left", NS_STYLE_CLEAR_LEFT },
{ "right", NS_STYLE_CLEAR_RIGHT },
{ "all", NS_STYLE_CLEAR_LEFT_AND_RIGHT },
@@ -138,7 +138,7 @@ nsHTMLBRElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::clear) {
- if (nsHTMLGenericContent::ParseEnumValue(aValue, kClearTable, aResult)) {
+ if (nsGenericHTMLElement::ParseEnumValue(aValue, kClearTable, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -152,7 +152,7 @@ nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::clear) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::EnumValueToString(aValue, kClearTable, aResult);
+ nsGenericHTMLElement::EnumValueToString(aValue, kClearTable, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -172,7 +172,7 @@ nsHTMLBRElement::MapAttributesInto(nsIStyleContext* aContext,
display->mBreakType = value.GetIntValue();
}
}
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLBaseElement.cpp b/mozilla/content/html/content/src/nsHTMLBaseElement.cpp
index f3f53eadb9d..cb9264388d6 100644
--- a/mozilla/content/html/content/src/nsHTMLBaseElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLBaseElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -147,7 +147,7 @@ NS_IMETHODIMP
nsHTMLBaseElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp b/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp
index 40726de9282..b86eaab74b0 100644
--- a/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp
@@ -71,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -153,7 +153,7 @@ nsHTMLBaseFontElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me?
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp
index 688d348e1df..7ded91b806e 100644
--- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp
@@ -26,9 +26,20 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsStyleUtil.h"
+#include "nsIDocument.h"
+#include "nsIHTMLDocument.h"
+#include "nsIHTMLStyleSheet.h"
+#include "nsIStyleRule.h"
+#include "nsIWebShell.h"
+static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
+static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
+static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIDOMHTMLBodyElementIID, NS_IDOMHTMLBODYELEMENT_IID);
+class BodyRule;
+
class nsHTMLBodyElement : public nsIDOMHTMLBodyElement,
public nsIScriptObjectOwner,
public nsIDOMEventReceiver,
@@ -74,12 +85,134 @@ public:
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
// nsIHTMLContent
- NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
+ NS_IMPL_IHTMLCONTENT_USING_GENERIC2(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
+ BodyRule* mStyleRule;
};
+class BodyRule: public nsIStyleRule {
+public:
+ BodyRule(nsHTMLBodyElement* aPart);
+ ~BodyRule();
+
+ NS_DECL_ISUPPORTS
+
+ NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aResult) const;
+ NS_IMETHOD HashValue(PRUint32& aValue) const;
+
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext,
+ nsIContent* aContent);
+
+ NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
+
+ nsHTMLBodyElement* mPart;
+};
+
+//----------------------------------------------------------------------
+
+BodyRule::BodyRule(nsHTMLBodyElement* aPart)
+{
+ NS_INIT_REFCNT();
+ mPart = aPart;
+}
+
+BodyRule::~BodyRule()
+{
+}
+
+NS_IMPL_ISUPPORTS(BodyRule, kIStyleRuleIID);
+
+NS_IMETHODIMP
+BodyRule::Equals(const nsIStyleRule* aRule, PRBool& aResult) const
+{
+ aResult = PRBool(this == aRule);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+BodyRule::HashValue(PRUint32& aValue) const
+{
+ aValue = (PRUint32)(mPart);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
+ nsIContent* aContent)
+{
+ NS_ASSERTION(aContent == mPart, "bad content mapping");
+ if (nsnull != mPart) {
+
+ nsStyleSpacing* styleSpacing = (nsStyleSpacing*)(aContext->GetMutableStyleData(eStyleStruct_Spacing));
+
+ if (nsnull != styleSpacing) {
+ nsHTMLValue value;
+ nsStyleCoord zero(0);
+ PRInt32 count = 0;
+ PRInt32 attrCount;
+ mPart->GetAttributeCount(attrCount);
+
+ if (0 < attrCount) {
+ // if marginwidth/marginheigth is set in our attribute zero out left,right/top,bottom padding
+ // nsBodyFrame::DidSetStyleContext will add the appropriate values to padding
+ mPart->GetAttribute(nsHTMLAtoms::marginwidth, value);
+ if (eHTMLUnit_Pixel == value.GetUnit()) {
+ styleSpacing->mPadding.SetLeft(zero);
+ styleSpacing->mPadding.SetRight(zero);
+ count++;
+ }
+
+ mPart->GetAttribute(nsHTMLAtoms::marginheight, value);
+ if (eHTMLUnit_Pixel == value.GetUnit()) {
+ styleSpacing->mPadding.SetTop(zero);
+ styleSpacing->mPadding.SetBottom(zero);
+ count++;
+ }
+
+ if (count < attrCount) { // more to go...
+ mPart->MapAttributesInto(aContext, aPresContext);
+ }
+ }
+
+ if (count < 2) {
+ // if marginwidth or marginheight is set in the web shell zero out left,right,top,bottom padding
+ // nsBodyFrame::DidSetStyleContext will add the appropriate values to padding
+ nsISupports* container;
+ aPresContext->GetContainer(&container);
+ if (nsnull != container) {
+ nsIWebShell* webShell = nsnull;
+ container->QueryInterface(kIWebShellIID, (void**) &webShell);
+ if (nsnull != webShell) {
+ PRInt32 marginWidth, marginHeight;
+ webShell->GetMarginWidth(marginWidth);
+ webShell->GetMarginHeight(marginHeight);
+ if ((marginWidth >= 0) || (marginHeight >= 0)) { // nav quirk
+ styleSpacing->mPadding.SetLeft(zero);
+ styleSpacing->mPadding.SetRight(zero);
+ styleSpacing->mPadding.SetTop(zero);
+ styleSpacing->mPadding.SetBottom(zero);
+ }
+ NS_RELEASE(webShell);
+ }
+ NS_RELEASE(container);
+ }
+ }
+ }
+ }
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+BodyRule::List(FILE* out, PRInt32 aIndent) const
+{
+ return NS_OK;
+}
+
+//----------------------------------------------------------------------
+
nsresult
NS_NewHTMLBodyElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
{
@@ -95,6 +228,7 @@ NS_NewHTMLBodyElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
}
nsHTMLBodyElement::nsHTMLBodyElement(nsIAtom* aTag)
+ : mStyleRule(nsnull)
{
NS_INIT_REFCNT();
mInner.Init(this, aTag);
@@ -102,6 +236,10 @@ nsHTMLBodyElement::nsHTMLBodyElement(nsIAtom* aTag)
nsHTMLBodyElement::~nsHTMLBodyElement()
{
+ if (nsnull != mStyleRule) {
+ mStyleRule->mPart = nsnull;
+ NS_RELEASE(mStyleRule);
+ }
}
NS_IMPL_ADDREF(nsHTMLBodyElement)
@@ -144,7 +282,25 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,
nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::background) {
+ nsAutoString href(aValue);
+ href.StripWhitespace();
+ aResult.SetStringValue(href);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if ((aAttribute == nsHTMLAtoms::bgcolor) ||
+ (aAttribute == nsHTMLAtoms::text) ||
+ (aAttribute == nsHTMLAtoms::link) ||
+ (aAttribute == nsHTMLAtoms::alink) ||
+ (aAttribute == nsHTMLAtoms::vlink)) {
+ nsGenericHTMLElement::ParseColor(aValue, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if ((aAttribute == nsHTMLAtoms::marginwidth) ||
+ (aAttribute == nsHTMLAtoms::marginheight)) {
+ nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
@@ -153,7 +309,6 @@ nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const
{
- // XXX write me
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
@@ -161,8 +316,52 @@ NS_IMETHODIMP
nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (mInner.mAttributes) {
+ nsHTMLValue value;
+ mInner.MapBackgroundAttributesInto(aContext, aPresContext);
+ GetAttribute(nsHTMLAtoms::text, value);
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ color->mColor = value.GetColorValue();
+ 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());
+ }
+
+ 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());
+ }
+ }
+ NS_RELEASE(htmlDoc);
+ }
+
+ // marginwidth/height get set by a special style rule
+
+ // set up the basefont (defaults to 3)
+ nsStyleFont* font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font);
+ const nsFont& defaultFont = aPresContext->GetDefaultFont();
+ const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFont();
+ PRInt32 scaler = aPresContext->GetFontScaler();
+ float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
+ 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);
}
NS_IMETHODIMP
@@ -175,3 +374,15 @@ nsHTMLBodyElement::HandleDOMEvent(nsIPresContext& aPresContext,
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
}
+
+NS_IMETHODIMP
+nsHTMLBodyElement::GetStyleRule(nsIStyleRule*& aResult)
+{
+ if (nsnull == mStyleRule) {
+ mStyleRule = new BodyRule(this);
+ NS_IF_ADDREF(mStyleRule);
+ }
+ NS_IF_ADDREF(mStyleRule);
+ aResult = mStyleRule;
+ return NS_OK;
+}
diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp
index 6ac6bd8cf94..e4a2ca9a27d 100644
--- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp
@@ -82,7 +82,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -162,7 +162,7 @@ nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::tabindex) {
- nsHTMLGenericContent::ParseValue(aValue, 0, 32767, aResult,
+ nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult,
eHTMLUnit_Integer);
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -181,7 +181,7 @@ NS_IMETHODIMP
nsHTMLButtonElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLDListElement.cpp b/mozilla/content/html/content/src/nsHTMLDListElement.cpp
index 66c536cdcbc..41f99ccad0e 100644
--- a/mozilla/content/html/content/src/nsHTMLDListElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLDListElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -129,7 +129,10 @@ nsHTMLDListElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,
nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
@@ -138,7 +141,6 @@ nsHTMLDListElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const
{
- // XXX write me
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
@@ -146,8 +148,18 @@ NS_IMETHODIMP
nsHTMLDListElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLDelElement.cpp b/mozilla/content/html/content/src/nsHTMLDelElement.cpp
index 4db504ac163..f36ab407a4c 100644
--- a/mozilla/content/html/content/src/nsHTMLDelElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLDelElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLDelElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp b/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp
index aea1a95b0a9..5102ab4843d 100644
--- a/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp
@@ -27,12 +27,16 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+// XXX nav4 has type= start= (same as OL/UL)
+
+extern nsGenericHTMLElement::EnumTable kListTypeTable[];
+
static NS_DEFINE_IID(kIDOMHTMLDirectoryElementIID, NS_IDOMHTMLDIRECTORYELEMENT_IID);
class nsHTMLDirectoryElement : public nsIDOMHTMLDirectoryElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLDirectoryElement(nsIAtom* aTag);
@@ -67,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -126,36 +130,69 @@ NS_IMPL_BOOL_ATTR(nsHTMLDirectoryElement, Compact, compact, eSetAttrNotify_Reflo
NS_IMETHODIMP
nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
+ aResult)) {
+ aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
+ }
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::start) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLDirectoryElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListTypeTable, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLDirectoryElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLDirectoryElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLDivElement.cpp b/mozilla/content/html/content/src/nsHTMLDivElement.cpp
index 28bee113049..dc2a4d964ee 100644
--- a/mozilla/content/html/content/src/nsHTMLDivElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLDivElement.cpp
@@ -27,14 +27,14 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
-// XXX missing nav attributes
+// XXX support missing nav attributes? gutter, cols, width
static NS_DEFINE_IID(kIDOMHTMLDivElementIID, NS_IDOMHTMLDIVELEMENT_IID);
class nsHTMLDivElement : public nsIDOMHTMLDivElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLDivElement(nsIAtom* aTag);
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -128,25 +128,38 @@ NS_IMPL_STRING_ATTR(nsHTMLDivElement, Align, align, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseDivAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
+ if (aAttribute == nsHTMLAtoms::cols) {
+ nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::gutter) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Pixel);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::width) {
+ nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult,
+ eHTMLUnit_Pixel);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::DivAlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -155,18 +168,26 @@ nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLDivElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ 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);
}
NS_IMETHODIMP
nsHTMLDivElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp b/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp
index 660906d04a2..d13ee91e26e 100644
--- a/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -130,11 +130,11 @@ nsHTMLEmbedElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -148,11 +148,11 @@ nsHTMLEmbedElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -166,7 +166,7 @@ nsHTMLEmbedElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLFontElement.cpp b/mozilla/content/html/content/src/nsHTMLFontElement.cpp
index 3daf247b8b2..4d4c67cef18 100644
--- a/mozilla/content/html/content/src/nsHTMLFontElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFontElement.cpp
@@ -23,16 +23,18 @@
#include "nsGenericHTMLElement.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
+#include "nsIDeviceContext.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
+#include "nsStyleUtil.h"
#include "nsIPresContext.h"
static NS_DEFINE_IID(kIDOMHTMLFontElementIID, NS_IDOMHTMLFONTELEMENT_IID);
class nsHTMLFontElement : public nsIDOMHTMLFontElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLFontElement(nsIAtom* aTag);
@@ -71,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -135,33 +137,182 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,
nsHTMLValue& aResult)
{
- // XXX write me
+ if ((aAttribute == nsHTMLAtoms::size) ||
+ (aAttribute == nsHTMLAtoms::pointSize) ||
+ (aAttribute == nsHTMLAtoms::fontWeight)) {
+ nsAutoString tmp(aValue);
+ PRInt32 ec, v = tmp.ToInteger(&ec);
+ tmp.CompressWhitespace(PR_TRUE, PR_FALSE);
+ PRUnichar ch = tmp.First();
+ aResult.SetIntValue(v, ((ch == '+') || (ch == '-')) ?
+ eHTMLUnit_Integer : eHTMLUnit_Enumerated);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::color) {
+ nsGenericHTMLElement::ParseColor(aValue, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if ((aAttribute == nsHTMLAtoms::size) ||
+ (aAttribute == nsHTMLAtoms::pointSize) ||
+ (aAttribute == nsHTMLAtoms::fontWeight)) {
+ aResult.Truncate();
+ if (aValue.GetUnit() == eHTMLUnit_Enumerated) {
+ aResult.Append(aValue.GetIntValue(), 10);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ else if (aValue.GetUnit() == eHTMLUnit_Integer) {
+ PRInt32 value = aValue.GetIntValue();
+ if (value >= 0) {
+ aResult.Append('+');
+ }
+ aResult.Append(value, 10);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ return NS_CONTENT_ATTR_NOT_THERE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleFont* font = (nsStyleFont*)
+ aContext->GetMutableStyleData(eStyleStruct_Font);
+ const nsStyleFont* parentFont = font;
+ nsIStyleContext* parentContext = aContext->GetParent();
+ if (nsnull != parentContext) {
+ parentFont = (const nsStyleFont*)
+ parentContext->GetStyleData(eStyleStruct_Font);
+ }
+ const nsFont& defaultFont = aPresContext->GetDefaultFont();
+ const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFont();
+
+ // face: string list
+ GetAttribute(nsHTMLAtoms::face, value);
+ if (value.GetUnit() == eHTMLUnit_String) {
+
+ nsIDeviceContext* dc = aPresContext->GetDeviceContext();
+ if (nsnull != dc) {
+ nsAutoString familyList;
+
+ value.GetStringValue(familyList);
+
+ font->mFont.name = familyList;
+ nsAutoString face;
+ if (NS_OK == dc->FirstExistingFont(font->mFont, face)) {
+ if (face.EqualsIgnoreCase("monospace")) {
+ font->mFont = font->mFixedFont;
+ }
+ else {
+ font->mFixedFont.name = familyList;
+ }
+ }
+ else {
+ font->mFont.name = defaultFont.name;
+ font->mFixedFont.name= defaultFixedFont.name;
+ }
+ font->mFlags |= NS_STYLE_FONT_FACE_EXPLICIT;
+ NS_RELEASE(dc);
+ }
+ }
+
+ // pointSize: int, enum
+ GetAttribute(nsHTMLAtoms::pointSize, value);
+ if (value.GetUnit() == eHTMLUnit_Integer) {
+ // XXX should probably sanitize value
+ font->mFont.size = parentFont->mFont.size +
+ NSIntPointsToTwips(value.GetIntValue());
+ font->mFixedFont.size = parentFont->mFixedFont.size +
+ NSIntPointsToTwips(value.GetIntValue());
+ font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;
+ }
+ else if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ font->mFont.size = NSIntPointsToTwips(value.GetIntValue());
+ font->mFixedFont.size = NSIntPointsToTwips(value.GetIntValue());
+ font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;
+ }
+ else {
+ // 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);
+ if ((value.GetUnit() == eHTMLUnit_Integer) ||
+ (value.GetUnit() == eHTMLUnit_Enumerated)) {
+ PRInt32 size = value.GetIntValue();
+
+ if (value.GetUnit() == eHTMLUnit_Integer) { // int (+/-)
+ size = 3 + size; // XXX should be BASEFONT, not three
+ }
+ size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
+ PRInt32 scaler = aPresContext->GetFontScaler();
+ float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
+ font->mFont.size =
+ nsStyleUtil::CalcFontPointSize(size, (PRInt32)defaultFont.size,
+ scaleFactor);
+ font->mFixedFont.size =
+ nsStyleUtil::CalcFontPointSize(size,
+ (PRInt32)defaultFixedFont.size,
+ scaleFactor);
+ }
+ }
+ }
+
+ // fontWeight: int, enum
+ GetAttribute(nsHTMLAtoms::fontWeight, value);
+ if (value.GetUnit() == eHTMLUnit_Integer) { // +/-
+ PRInt32 weight = parentFont->mFont.weight + value.GetIntValue();
+ font->mFont.weight =
+ ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);
+ font->mFixedFont.weight =
+ ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);
+ }
+ else if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ PRInt32 weight = value.GetIntValue();
+ weight = ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);
+ font->mFont.weight = weight;
+ font->mFixedFont.weight = weight;
+ }
+
+ // color: color
+ GetAttribute(nsHTMLAtoms::color, value);
+ if (value.GetUnit() == eHTMLUnit_Color) {
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ color->mColor = value.GetColorValue();
+ }
+ else if (value.GetUnit() == eHTMLUnit_String) {
+ nsAutoString buffer;
+ value.GetStringValue(buffer);
+ char cbuf[40];
+ buffer.ToCString(cbuf, sizeof(cbuf));
+
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ NS_ColorNameToRGB(cbuf, &(color->mColor));
+ }
+
+ NS_IF_RELEASE(parentContext);
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLFontElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp
index c0e070be8e2..3db62773f3b 100644
--- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp
@@ -79,7 +79,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -191,7 +191,7 @@ nsHTMLFormElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp
index c6947dafc7c..6c293dcc41f 100644
--- a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp
@@ -81,7 +81,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -168,7 +168,7 @@ nsHTMLFrameElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp
index 9eb22def7d4..e0378c59d7b 100644
--- a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLFrameSetElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLHRElement.cpp b/mozilla/content/html/content/src/nsHTMLHRElement.cpp
index 6c6c4f8fcbe..b0911864657 100644
--- a/mozilla/content/html/content/src/nsHTMLHRElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLHRElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -133,7 +133,7 @@ NS_IMPL_BOOL_ATTR(nsHTMLHRElement, NoShade, noshade, eSetAttrNotify_Render)
NS_IMPL_STRING_ATTR(nsHTMLHRElement, Size, size, eSetAttrNotify_Reflow)
NS_IMPL_STRING_ATTR(nsHTMLHRElement, Width, width, eSetAttrNotify_Reflow)
-static nsHTMLGenericContent::EnumTable kAlignTable[] = {
+static nsGenericHTMLElement::EnumTable kAlignTable[] = {
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
{ "center", NS_STYLE_TEXT_ALIGN_CENTER },
@@ -146,12 +146,12 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::width) {
- nsHTMLGenericContent::ParseValueOrPercent(aValue, aResult,
+ nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult,
eHTMLUnit_Pixel);
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::size) {
- nsHTMLGenericContent::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel);
+ nsGenericHTMLElement::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel);
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::noshade) {
@@ -159,7 +159,7 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute,
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseEnumValue(aValue, kAlignTable, aResult)) {
+ if (nsGenericHTMLElement::ParseEnumValue(aValue, kAlignTable, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -173,7 +173,7 @@ nsHTMLHRElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::EnumValueToString(aValue, kAlignTable, aResult);
+ nsGenericHTMLElement::EnumValueToString(aValue, kAlignTable, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -207,7 +207,7 @@ nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext,
pos->mWidth.SetPercentValue(value.GetPercentValue());
}
}
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLHeadElement.cpp b/mozilla/content/html/content/src/nsHTMLHeadElement.cpp
index 1e8ab45bd27..562a3230486 100644
--- a/mozilla/content/html/content/src/nsHTMLHeadElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLHeadElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -144,7 +144,7 @@ NS_IMETHODIMP
nsHTMLHeadElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp
index cb6ef14aff0..4dbf8375056 100644
--- a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp
@@ -30,9 +30,9 @@
static NS_DEFINE_IID(kIDOMHTMLHeadingElementIID, NS_IDOMHTMLHEADINGELEMENT_IID);
class nsHTMLHeadingElement : public nsIDOMHTMLHeadingElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLHeadingElement(nsIAtom* aTag);
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -126,36 +126,53 @@ NS_IMPL_STRING_ATTR(nsHTMLHeadingElement, Align, align, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLHeadingElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::align) {
+ if (nsGenericHTMLElement::ParseDivAlignValue(aValue, aResult)) {
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLHeadingElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::align) {
+ if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
+ nsGenericHTMLElement::DivAlignValueToString(aValue, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLHeadingElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ 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);
}
NS_IMETHODIMP
nsHTMLHeadingElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp b/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp
index 6ed7c41f22d..d2f97cebe74 100644
--- a/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -144,7 +144,7 @@ NS_IMETHODIMP
nsHTMLHtmlElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp
index 6306b11c837..3e2e5806fe7 100644
--- a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp
@@ -85,7 +85,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -174,7 +174,7 @@ nsHTMLIFrameElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp
index e0b60a3bb6f..7da315045f9 100644
--- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp
@@ -91,7 +91,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -166,11 +166,11 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -184,11 +184,11 @@ nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -202,7 +202,7 @@ nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp
index bfbdcebec5e..a8a17278eaf 100644
--- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp
@@ -105,7 +105,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -242,7 +242,7 @@ nsHTMLInputElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX align
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLInsElement.cpp b/mozilla/content/html/content/src/nsHTMLInsElement.cpp
index bdd8b1fb01a..7ceff2510b5 100644
--- a/mozilla/content/html/content/src/nsHTMLInsElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLInsElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLInsElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp b/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp
index 3ed14aff59d..84bfe6fb19d 100644
--- a/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -162,7 +162,7 @@ nsHTMLIsIndexElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLLIElement.cpp b/mozilla/content/html/content/src/nsHTMLLIElement.cpp
index 80e2d2ebabd..8be6117f6af 100644
--- a/mozilla/content/html/content/src/nsHTMLLIElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLLIElement.cpp
@@ -30,9 +30,9 @@
static NS_DEFINE_IID(kIDOMHTMLLIElementIID, NS_IDOMHTMLLIELEMENT_IID);
class nsHTMLLIElement : public nsIDOMHTMLLIElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLLIElement(nsIAtom* aTag);
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -127,38 +127,72 @@ nsHTMLLIElement::CloneNode(nsIDOMNode** aReturn)
NS_IMPL_STRING_ATTR(nsHTMLLIElement, Type, type, eSetAttrNotify_Reflow)
NS_IMPL_INT_ATTR(nsHTMLLIElement, Value, value, eSetAttrNotify_Reflow)
+static nsGenericHTMLElement::EnumTable kListItemTypeTable[] = {
+ { "circle", NS_STYLE_LIST_STYLE_CIRCLE },
+ { "round", NS_STYLE_LIST_STYLE_CIRCLE },
+ { "square", NS_STYLE_LIST_STYLE_SQUARE },
+ { "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
+ { "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
+ { "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
+ { "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
+ { 0 }
+};
+
NS_IMETHODIMP
nsHTMLLIElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (nsGenericHTMLElement::ParseEnumValue(aValue, kListItemTypeTable,
+ aResult)) {
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
+ else if (aAttribute == nsHTMLAtoms::value) {
+ nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLLIElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListItemTypeTable,
+ aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLLIElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLLIElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLLabelElement.cpp b/mozilla/content/html/content/src/nsHTMLLabelElement.cpp
index 9404513c32d..bc159662ff9 100644
--- a/mozilla/content/html/content/src/nsHTMLLabelElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLLabelElement.cpp
@@ -71,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -165,7 +165,7 @@ nsHTMLLabelElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp
index 1313ee788db..4389532d22d 100644
--- a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp
@@ -71,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -165,7 +165,7 @@ nsHTMLLegendElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp
index 3dfd93f064e..89bf51d93ab 100644
--- a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp
@@ -83,7 +83,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -168,7 +168,7 @@ NS_IMETHODIMP
nsHTMLLinkElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLMapElement.cpp b/mozilla/content/html/content/src/nsHTMLMapElement.cpp
index 5668db1c1b0..f4ec4c062be 100644
--- a/mozilla/content/html/content/src/nsHTMLMapElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLMapElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -163,7 +163,7 @@ nsHTMLMapElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLMenuElement.cpp b/mozilla/content/html/content/src/nsHTMLMenuElement.cpp
index 1880cb63c50..62add355dce 100644
--- a/mozilla/content/html/content/src/nsHTMLMenuElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLMenuElement.cpp
@@ -27,12 +27,16 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+// XXX nav4 has type= start= (same as OL/UL)
+
+extern nsGenericHTMLElement::EnumTable kListTypeTable[];
+
static NS_DEFINE_IID(kIDOMHTMLMenuElementIID, NS_IDOMHTMLMENUELEMENT_IID);
class nsHTMLMenuElement : public nsIDOMHTMLMenuElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLMenuElement(nsIAtom* aTag);
@@ -67,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -126,36 +130,69 @@ NS_IMPL_BOOL_ATTR(nsHTMLMenuElement, Compact, compact, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLMenuElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
+ aResult)) {
+ aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
+ }
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::start) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLMenuElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListTypeTable, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLMenuElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLMenuElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLMetaElement.cpp b/mozilla/content/html/content/src/nsHTMLMetaElement.cpp
index 21c93653bdb..b81f8396c8a 100644
--- a/mozilla/content/html/content/src/nsHTMLMetaElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLMetaElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -153,7 +153,7 @@ NS_IMETHODIMP
nsHTMLMetaElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLModElement.cpp b/mozilla/content/html/content/src/nsHTMLModElement.cpp
index 31f684098ba..9115745b06f 100644
--- a/mozilla/content/html/content/src/nsHTMLModElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLModElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLModElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLOListElement.cpp b/mozilla/content/html/content/src/nsHTMLOListElement.cpp
index 206ab62f18c..c483ab5b2d4 100644
--- a/mozilla/content/html/content/src/nsHTMLOListElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLOListElement.cpp
@@ -30,9 +30,9 @@
static NS_DEFINE_IID(kIDOMHTMLOListElementIID, NS_IDOMHTMLOLISTELEMENT_IID);
class nsHTMLOListElement : public nsIDOMHTMLOListElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLOListElement(nsIAtom* aTag);
@@ -71,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -127,41 +127,92 @@ nsHTMLOListElement::CloneNode(nsIDOMNode** aReturn)
}
NS_IMPL_BOOL_ATTR(nsHTMLOListElement, Compact, compact, eSetAttrNotify_Reflow)
-NS_IMPL_INT_ATTR(nsHTMLOListElement, Start, compact, eSetAttrNotify_Reflow)
-NS_IMPL_STRING_ATTR(nsHTMLOListElement, Type, compact, eSetAttrNotify_Reflow)
+NS_IMPL_INT_ATTR(nsHTMLOListElement, Start, start, eSetAttrNotify_Reflow)
+NS_IMPL_STRING_ATTR(nsHTMLOListElement, Type, type, eSetAttrNotify_Reflow)
+
+nsGenericHTMLElement::EnumTable kListTypeTable[] = {
+ { "none", NS_STYLE_LIST_STYLE_NONE },
+ { "disc", NS_STYLE_LIST_STYLE_DISC },
+ { "circle", NS_STYLE_LIST_STYLE_CIRCLE },
+ { "round", NS_STYLE_LIST_STYLE_CIRCLE },
+ { "square", NS_STYLE_LIST_STYLE_SQUARE },
+ { "decimal", NS_STYLE_LIST_STYLE_DECIMAL },
+ { "lower-roman", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
+ { "upper-roman", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
+ { "lower-alpha", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
+ { "upper-alpha", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
+ { "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
+ { "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
+ { "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
+ { "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
+ { 0 }
+};
NS_IMETHODIMP
nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
+ aResult)) {
+ aResult.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eHTMLUnit_Enumerated);
+ }
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::start) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLOListElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListTypeTable, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLOListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLOListElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp
index 8837ceed6d1..6e12754af5c 100644
--- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp
@@ -101,7 +101,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -193,11 +193,11 @@ nsHTMLObjectElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -211,11 +211,11 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -229,7 +229,7 @@ nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp
index 2bc599fcd92..17f5799f1b2 100644
--- a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLOptGroupElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp
index cab9b6a3655..26c87b3c42b 100644
--- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp
@@ -81,7 +81,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -174,7 +174,7 @@ nsHTMLOptionElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp
index fa3bffa68d9..1af3c821244 100644
--- a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp
@@ -32,9 +32,9 @@
static NS_DEFINE_IID(kIDOMHTMLParagraphElementIID, NS_IDOMHTMLPARAGRAPHELEMENT_IID);
class nsHTMLParagraphElement : public nsIDOMHTMLParagraphElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLParagraphElement(nsIAtom* aTag);
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -128,11 +128,11 @@ NS_IMPL_STRING_ATTR(nsHTMLParagraphElement, Align, align, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLParagraphElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseDivAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -141,12 +141,12 @@ nsHTMLParagraphElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::DivAlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -155,18 +155,26 @@ nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLParagraphElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ 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);
}
NS_IMETHODIMP
nsHTMLParagraphElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLParamElement.cpp b/mozilla/content/html/content/src/nsHTMLParamElement.cpp
index 1efbffa79e6..b0b3888e855 100644
--- a/mozilla/content/html/content/src/nsHTMLParamElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLParamElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -156,7 +156,7 @@ nsHTMLParamElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLPreElement.cpp b/mozilla/content/html/content/src/nsHTMLPreElement.cpp
index 507574ec6aa..967506382ed 100644
--- a/mozilla/content/html/content/src/nsHTMLPreElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLPreElement.cpp
@@ -27,14 +27,14 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
-// XXX missing nav attributes
+// XXX wrap, variable, cols, tabstop
static NS_DEFINE_IID(kIDOMHTMLPreElementIID, NS_IDOMHTMLPREELEMENT_IID);
class nsHTMLPreElement : public nsIDOMHTMLPreElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLPreElement(nsIAtom* aTag);
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -128,45 +128,86 @@ NS_IMPL_INT_ATTR(nsHTMLPreElement, Width, width, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLPreElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if ((aAttribute == nsHTMLAtoms::wrap) ||
+ (aAttribute == nsHTMLAtoms::variable)) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::cols) {
+ if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult,
+ eHTMLUnit_Integer)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
+ if (aAttribute == nsHTMLAtoms::width) {
+ if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult,
+ eHTMLUnit_Integer)) {
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
+ if (aAttribute == nsHTMLAtoms::tabstop) {
+ PRInt32 ec, tabstop = aValue.ToInteger(&ec);
+ if (tabstop <= 0) {
+ tabstop = 8;
+ }
+ aResult.SetIntValue(tabstop, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLPreElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- if (aAttribute == nsHTMLAtoms::align) {
- if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
- return NS_CONTENT_ATTR_HAS_VALUE;
- }
- }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLPreElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+
+ // wrap: empty
+ GetAttribute(nsHTMLAtoms::wrap, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+
+ // variable: empty
+ GetAttribute(nsHTMLAtoms::variable, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ nsStyleFont* font = (nsStyleFont*)
+ aContext->GetMutableStyleData(eStyleStruct_Font);
+ font->mFont.name = "serif";
+ }
+
+ // cols: int
+ GetAttribute(nsHTMLAtoms::cols, value);
+ if (value.GetUnit() == eHTMLUnit_Integer) {
+ // XXX set
+ }
+
+ // tabstop: int
+ if (value.GetUnit() == eHTMLUnit_Integer) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLPreElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp b/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp
index f0b4522dd57..91130983f78 100644
--- a/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -147,7 +147,7 @@ nsHTMLQuoteElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp
index 504436522b0..745e5fd3747 100644
--- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp
@@ -79,7 +79,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
nsString mText;
};
@@ -208,7 +208,7 @@ NS_IMETHODIMP
nsHTMLScriptElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp
index b5c4e777b41..4291d57a267 100644
--- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp
@@ -91,7 +91,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -219,7 +219,7 @@ nsHTMLSelectElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp
index 8837ceed6d1..6e12754af5c 100644
--- a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp
@@ -101,7 +101,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -193,11 +193,11 @@ nsHTMLObjectElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -211,11 +211,11 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -229,7 +229,7 @@ nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp
index db961cf8f80..f64f6a5a46d 100644
--- a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -152,7 +152,7 @@ NS_IMETHODIMP
nsHTMLStyleElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp
index 35178ad56d9..e3a2081b48e 100644
--- a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -147,7 +147,7 @@ nsHTMLTableCaptionElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp
index 29cb75d57de..29c4f471aee 100644
--- a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp
@@ -95,7 +95,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -202,7 +202,7 @@ nsHTMLTableCellElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp
index 7dc7a63480c..a630d307144 100644
--- a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp
@@ -77,7 +77,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -162,7 +162,7 @@ nsHTMLTableColElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp
index be711b1cfb0..4daf4bdf8e9 100644
--- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp
@@ -101,7 +101,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -306,7 +306,7 @@ nsHTMLTableElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp
index 6188c52f93c..1902ec8b710 100644
--- a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp
@@ -83,7 +83,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -227,7 +227,7 @@ nsHTMLTableRowElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp
index aa0ec1cced0..a2fb451d713 100644
--- a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -184,7 +184,7 @@ nsHTMLTableSectionElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp
index 831f18aeca1..8a9c2be8642 100644
--- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -86,7 +86,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -207,7 +207,7 @@ nsHTMLTextAreaElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/content/html/content/src/nsHTMLTitleElement.cpp b/mozilla/content/html/content/src/nsHTMLTitleElement.cpp
index 49b24c1c3dd..59833e452a5 100644
--- a/mozilla/content/html/content/src/nsHTMLTitleElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLTitleElement.cpp
@@ -1,152 +1,160 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
- * Version 1.0 (the "NPL"); you may not use this file except in
- * compliance with the NPL. You may obtain a copy of the NPL at
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
- * Software distributed under the NPL is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
- * for the specific language governing rights and limitations under the
- * NPL.
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
*
- * The Initial Developer of this code under the NPL is Netscape
- * Communications Corporation. Portions created by Netscape are
- * Copyright (C) 1998 Netscape Communications Corporation. All Rights
- * Reserved.
+ * The Original Code is Mozilla Communicator client code.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
*/
-#include "nsHTMLParts.h"
-#include "nsHTMLContainer.h"
-#include "nsFrame.h"
+#include "nsIDOMHTMLTitleElement.h"
+#include "nsIScriptObjectOwner.h"
+#include "nsIDOMEventReceiver.h"
+#include "nsIHTMLContent.h"
+#include "nsGenericHTMLElement.h"
+#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
+#include "nsIStyleContext.h"
+#include "nsStyleConsts.h"
+#include "nsIPresContext.h"
#include "nsXIFConverter.h"
-#define nsHTMLTitleElementSuper nsHTMLTagContent
+static NS_DEFINE_IID(kIDOMHTMLTitleElementIID, NS_IDOMHTMLTITLEELEMENT_IID);
-class nsHTMLTitleElement : public nsHTMLTitleElementSuper {
+class nsHTMLTitleElement : public nsIDOMHTMLTitleElement,
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
+{
public:
- nsHTMLTitleElement(nsIAtom* aTag, const nsString& aTitle);
+ nsHTMLTitleElement(nsIAtom* aTag);
+ ~nsHTMLTitleElement();
- NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
- nsIFrame* aParentFrame,
- nsIStyleContext* aStyleContext,
- nsIFrame*& aResult);
+ // nsISupports
+ NS_DECL_ISUPPORTS
- NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
+ // nsIDOMNode
+ NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
+ // nsIDOMElement
+ NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
- NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const;
- NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const;
- NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const;
+ // nsIDOMHTMLElement
+ NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
+
+ // nsIDOMHTMLTitleElement
+ NS_IMETHOD GetText(nsString& aType);
+ NS_IMETHOD SetText(const nsString& aType);
+
+ // nsIScriptObjectOwner
+ NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
+
+ // nsIDOMEventReceiver
+ NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
+
+ // nsIContent
+ NS_IMPL_ICONTENT_USING_GENERIC(mInner)
+
+ // nsIHTMLContent
+ NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- virtual ~nsHTMLTitleElement();
- nsString mTitle;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
-NS_NewHTMLTitle(nsIHTMLContent** aInstancePtrResult,
- nsIAtom* aTag, const nsString& aTitle)
+NS_NewHTMLTitleElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
- nsIHTMLContent* it = new nsHTMLTitleElement(aTag, aTitle);
+ nsIHTMLContent* it = new nsHTMLTitleElement(aTag);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
- return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult);
+ return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
}
-nsHTMLTitleElement::nsHTMLTitleElement(nsIAtom* aTag, const nsString& aTitle)
- : nsHTMLTitleElementSuper(aTag), mTitle(aTitle)
+nsHTMLTitleElement::nsHTMLTitleElement(nsIAtom* aTag)
{
+ NS_INIT_REFCNT();
+ mInner.Init(this, aTag);
}
nsHTMLTitleElement::~nsHTMLTitleElement()
{
}
-NS_IMETHODIMP
-nsHTMLTitleElement::CreateFrame(nsIPresContext* aPresContext,
- nsIFrame* aParentFrame,
- nsIStyleContext* aStyleContext,
- nsIFrame*& aResult)
+NS_IMPL_ADDREF(nsHTMLTitleElement)
+
+NS_IMPL_RELEASE(nsHTMLTitleElement)
+
+nsresult
+nsHTMLTitleElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
- nsIFrame* frame;
- nsFrame::NewFrame(&frame, this, aParentFrame);
- if (nsnull == frame) {
+ NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
+ if (aIID.Equals(kIDOMHTMLTitleElementIID)) {
+ nsIDOMHTMLTitleElement* tmp = this;
+ *aInstancePtr = (void*) tmp;
+ mRefCnt++;
+ return NS_OK;
+ }
+ return NS_NOINTERFACE;
+}
+
+nsresult
+nsHTMLTitleElement::CloneNode(nsIDOMNode** aReturn)
+{
+ nsHTMLTitleElement* it = new nsHTMLTitleElement(mInner.mTag);
+ if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
- frame->SetStyleContext(aPresContext, aStyleContext);
- aResult = frame;
- return NS_OK;
+ mInner.CopyInnerTo(this, &it->mInner);
+ return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
+}
+
+NS_IMPL_STRING_ATTR(nsHTMLTitleElement, Text, text, eSetAttrNotify_Reflow)
+
+NS_IMETHODIMP
+nsHTMLTitleElement::StringToAttribute(nsIAtom* aAttribute,
+ const nsString& aValue,
+ nsHTMLValue& aResult)
+{
+ return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
-nsHTMLTitleElement::List(FILE* out, PRInt32 aIndent) const
+nsHTMLTitleElement::AttributeToString(nsIAtom* aAttribute,
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- NS_PRECONDITION(nsnull != mDocument, "bad content");
-
- PRInt32 index;
- for (index = aIndent; --index >= 0; ) fputs(" ", out);
-
- nsIAtom* tag;
- GetTag(tag);
- if (tag != nsnull) {
- nsAutoString buf;
- tag->ToString(buf);
- fputs(buf, out);
- NS_RELEASE(tag);
- }
-
- ListAttributes(out);
-
- fprintf(out, " RefCount=%d<", mRefCnt);
- fputs(mTitle, out);
- fputs(">\n", out);
- return NS_OK;
-}
-
-/**
- * Translate the content object into the (XIF) XML Interchange Format
- * XIF is an intermediate form of the content model, the buffer
- * will then be parsed into any number of formats including HTML, TXT, etc.
- * These methods must be called in the following order:
-
- BeginConvertToXIF
- ConvertContentToXIF
- EndConvertToXIF
- */
-
-NS_IMETHODIMP
-nsHTMLTitleElement::BeginConvertToXIF(nsXIFConverter& aConverter) const
-{
- if (nsnull != mTag)
- {
- nsAutoString name;
- mTag->ToString(name);
- aConverter.BeginContainer(name);
- }
- return NS_OK;
+ return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
-nsHTMLTitleElement::ConvertContentToXIF(nsXIFConverter& aConverter) const
+nsHTMLTitleElement::MapAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- aConverter.AddContent(mTitle);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
-nsHTMLTitleElement::FinishConvertToXIF(nsXIFConverter& aConverter) const
+nsHTMLTitleElement::HandleDOMEvent(nsIPresContext& aPresContext,
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
- if (nsnull != mTag)
- {
- nsAutoString name;
- mTag->ToString(name);
- aConverter.EndContainer(name);
- }
- return NS_OK;
+ return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
+ aFlags, aEventStatus);
}
diff --git a/mozilla/content/html/content/src/nsHTMLUListElement.cpp b/mozilla/content/html/content/src/nsHTMLUListElement.cpp
index fb7fbaba07a..e461d9a36ca 100644
--- a/mozilla/content/html/content/src/nsHTMLUListElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLUListElement.cpp
@@ -27,12 +27,14 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+extern nsGenericHTMLElement::EnumTable kListTypeTable[];
+
static NS_DEFINE_IID(kIDOMHTMLUListElementIID, NS_IDOMHTMLULISTELEMENT_IID);
class nsHTMLUListElement : public nsIDOMHTMLUListElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLUListElement(nsIAtom* aTag);
@@ -69,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -125,40 +127,73 @@ nsHTMLUListElement::CloneNode(nsIDOMNode** aReturn)
}
NS_IMPL_BOOL_ATTR(nsHTMLUListElement, Compact, compact, eSetAttrNotify_Reflow)
-NS_IMPL_STRING_ATTR(nsHTMLUListElement, Type, compact, eSetAttrNotify_Reflow)
+NS_IMPL_STRING_ATTR(nsHTMLUListElement, Type, type, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
+ aResult)) {
+ aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
+ }
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::start) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLUListElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListTypeTable, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLUListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLUListElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/Makefile b/mozilla/layout/html/content/src/Makefile
index a4e4761d456..27a67422bd5 100644
--- a/mozilla/layout/html/content/src/Makefile
+++ b/mozilla/layout/html/content/src/Makefile
@@ -68,6 +68,7 @@ CPPSRCS= \
nsHTMLQuoteElement.cpp \
nsHTMLScriptElement.cpp \
nsHTMLSelectElement.cpp \
+ nsHTMLSpanElement.cpp \
nsHTMLStyleElement.cpp \
nsHTMLTableElement.cpp \
nsHTMLTableCaptionElement.cpp \
diff --git a/mozilla/layout/html/content/src/makefile.win b/mozilla/layout/html/content/src/makefile.win
index 3c4f2c65101..edb5651f808 100644
--- a/mozilla/layout/html/content/src/makefile.win
+++ b/mozilla/layout/html/content/src/makefile.win
@@ -70,6 +70,7 @@ CPPSRCS= \
nsHTMLQuoteElement.cpp \
nsHTMLScriptElement.cpp \
nsHTMLSelectElement.cpp \
+ nsHTMLSpanElement.cpp \
nsHTMLStyleElement.cpp \
nsHTMLTableElement.cpp \
nsHTMLTableCaptionElement.cpp \
@@ -130,6 +131,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsHTMLQuoteElement.obj \
.\$(OBJDIR)\nsHTMLScriptElement.obj \
.\$(OBJDIR)\nsHTMLSelectElement.obj \
+ .\$(OBJDIR)\nsHTMLSpanElement.obj \
.\$(OBJDIR)\nsHTMLStyleElement.obj \
.\$(OBJDIR)\nsHTMLTableElement.obj \
.\$(OBJDIR)\nsHTMLTableCaptionElement.obj \
diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
index 841ccb9cb7c..5d7806755e2 100644
--- a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
@@ -51,6 +51,7 @@
#include "nsIEventStateManager.h"
#include "nsDOMEvent.h"
#include "nsIPrivateDOMEvent.h"
+#include "nsBodyFrame.h"
#include "prprf.h"
// XXX todo: add in missing out-of-memory checks
@@ -611,7 +612,7 @@ static void ReleaseAttributes(nsIHTMLAttributes*& aAttributes)
}
-nsHTMLGenericContent::nsHTMLGenericContent()
+nsGenericHTMLElement::nsGenericHTMLElement()
{
mDocument = nsnull;
mParent = nsnull;
@@ -631,7 +632,7 @@ nsHTMLGenericContent::nsHTMLGenericContent()
NS_ADDREF(gContentDelegate);
}
-nsHTMLGenericContent::~nsHTMLGenericContent()
+nsGenericHTMLElement::~nsGenericHTMLElement()
{
if (nsnull != mAttributes) {
ReleaseAttributes(mAttributes);
@@ -652,7 +653,7 @@ nsHTMLGenericContent::~nsHTMLGenericContent()
}
void
-nsHTMLGenericContent::Init(nsIHTMLContent* aOuterContentObject,
+nsGenericHTMLElement::Init(nsIHTMLContent* aOuterContentObject,
nsIAtom* aTag)
{
NS_ASSERTION((nsnull == mContent) && (nsnull != aOuterContentObject),
@@ -663,33 +664,33 @@ nsHTMLGenericContent::Init(nsIHTMLContent* aOuterContentObject,
}
nsresult
-nsHTMLGenericContent::GetNodeName(nsString& aNodeName)
+nsGenericHTMLElement::GetNodeName(nsString& aNodeName)
{
return GetTagName(aNodeName);
}
nsresult
-nsHTMLGenericContent::GetNodeValue(nsString& aNodeValue)
+nsGenericHTMLElement::GetNodeValue(nsString& aNodeValue)
{
aNodeValue.Truncate();
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetNodeValue(const nsString& aNodeValue)
+nsGenericHTMLElement::SetNodeValue(const nsString& aNodeValue)
{
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetNodeType(PRInt32* aNodeType)
+nsGenericHTMLElement::GetNodeType(PRInt32* aNodeType)
{
*aNodeType = nsIDOMNode::ELEMENT;
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetParentNode(nsIDOMNode** aParentNode)
+nsGenericHTMLElement::GetParentNode(nsIDOMNode** aParentNode)
{
if (nsnull != mParent) {
nsresult res = mParent->QueryInterface(kIDOMNodeIID, (void**)aParentNode);
@@ -703,7 +704,7 @@ nsHTMLGenericContent::GetParentNode(nsIDOMNode** aParentNode)
}
nsresult
-nsHTMLGenericContent::GetPreviousSibling(nsIDOMNode** aNode)
+nsGenericHTMLElement::GetPreviousSibling(nsIDOMNode** aNode)
{
if (nsnull != mParent) {
PRInt32 pos;
@@ -724,7 +725,7 @@ nsHTMLGenericContent::GetPreviousSibling(nsIDOMNode** aNode)
}
nsresult
-nsHTMLGenericContent::GetNextSibling(nsIDOMNode** aNextSibling)
+nsGenericHTMLElement::GetNextSibling(nsIDOMNode** aNextSibling)
{
if (nsnull != mParent) {
PRInt32 pos;
@@ -745,7 +746,7 @@ nsHTMLGenericContent::GetNextSibling(nsIDOMNode** aNextSibling)
}
nsresult
-nsHTMLGenericContent::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
+nsGenericHTMLElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
{
NS_PRECONDITION(nsnull != aAttributes, "null pointer argument");
if (nsnull != mAttributes) {
@@ -762,7 +763,7 @@ nsHTMLGenericContent::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
}
nsresult
-nsHTMLGenericContent::GetTagName(nsString& aTagName)
+nsGenericHTMLElement::GetTagName(nsString& aTagName)
{
aTagName.Truncate();
if (nsnull != mTag) {
@@ -772,14 +773,14 @@ nsHTMLGenericContent::GetTagName(nsString& aTagName)
}
nsresult
-nsHTMLGenericContent::GetDOMAttribute(const nsString& aName, nsString& aReturn)
+nsGenericHTMLElement::GetDOMAttribute(const nsString& aName, nsString& aReturn)
{
GetAttribute(aName, aReturn);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetDOMAttribute(const nsString& aName,
+nsGenericHTMLElement::SetDOMAttribute(const nsString& aName,
const nsString& aValue)
{
SetAttribute(aName, aValue, PR_TRUE);
@@ -787,7 +788,7 @@ nsHTMLGenericContent::SetDOMAttribute(const nsString& aName,
}
nsresult
-nsHTMLGenericContent::RemoveAttribute(const nsString& aName)
+nsGenericHTMLElement::RemoveAttribute(const nsString& aName)
{
nsAutoString upper;
aName.ToUpperCase(upper);
@@ -798,7 +799,7 @@ nsHTMLGenericContent::RemoveAttribute(const nsString& aName)
}
nsresult
-nsHTMLGenericContent::GetAttributeNode(const nsString& aName,
+nsGenericHTMLElement::GetAttributeNode(const nsString& aName,
nsIDOMAttribute** aReturn)
{
nsAutoString value;
@@ -809,7 +810,7 @@ nsHTMLGenericContent::GetAttributeNode(const nsString& aName,
}
nsresult
-nsHTMLGenericContent::SetAttributeNode(nsIDOMAttribute* aAttribute)
+nsGenericHTMLElement::SetAttributeNode(nsIDOMAttribute* aAttribute)
{
NS_PRECONDITION(nsnull != aAttribute, "null attribute");
@@ -829,7 +830,7 @@ nsHTMLGenericContent::SetAttributeNode(nsIDOMAttribute* aAttribute)
}
nsresult
-nsHTMLGenericContent::RemoveAttributeNode(nsIDOMAttribute* aAttribute)
+nsGenericHTMLElement::RemoveAttributeNode(nsIDOMAttribute* aAttribute)
{
NS_PRECONDITION(nsnull != aAttribute, "null attribute");
@@ -850,90 +851,90 @@ nsHTMLGenericContent::RemoveAttributeNode(nsIDOMAttribute* aAttribute)
}
nsresult
-nsHTMLGenericContent::GetElementsByTagName(const nsString& aTagname,
+nsGenericHTMLElement::GetElementsByTagName(const nsString& aTagname,
nsIDOMNodeList** aReturn)
{
return NS_ERROR_NOT_IMPLEMENTED;/* XXX */
}
nsresult
-nsHTMLGenericContent::Normalize()
+nsGenericHTMLElement::Normalize()
{
return NS_ERROR_NOT_IMPLEMENTED;/* XXX */
}
nsresult
-nsHTMLGenericContent::GetId(nsString& aId)
+nsGenericHTMLElement::GetId(nsString& aId)
{
GetAttribute(nsHTMLAtoms::id, aId);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetId(const nsString& aId)
+nsGenericHTMLElement::SetId(const nsString& aId)
{
SetAttr(nsHTMLAtoms::id, aId, eSetAttrNotify_Restart);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetTitle(nsString& aTitle)
+nsGenericHTMLElement::GetTitle(nsString& aTitle)
{
GetAttribute(nsHTMLAtoms::title, aTitle);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetTitle(const nsString& aTitle)
+nsGenericHTMLElement::SetTitle(const nsString& aTitle)
{
SetAttr(nsHTMLAtoms::title, aTitle, eSetAttrNotify_None);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetLang(nsString& aLang)
+nsGenericHTMLElement::GetLang(nsString& aLang)
{
GetAttribute(nsHTMLAtoms::lang, aLang);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetLang(const nsString& aLang)
+nsGenericHTMLElement::SetLang(const nsString& aLang)
{
SetAttr(nsHTMLAtoms::lang, aLang, eSetAttrNotify_Reflow);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetDir(nsString& aDir)
+nsGenericHTMLElement::GetDir(nsString& aDir)
{
GetAttribute(nsHTMLAtoms::dir, aDir);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetDir(const nsString& aDir)
+nsGenericHTMLElement::SetDir(const nsString& aDir)
{
SetAttr(nsHTMLAtoms::dir, aDir, eSetAttrNotify_Reflow);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetClassName(nsString& aClassName)
+nsGenericHTMLElement::GetClassName(nsString& aClassName)
{
GetAttribute(nsHTMLAtoms::kClass, aClassName);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::SetClassName(const nsString& aClassName)
+nsGenericHTMLElement::SetClassName(const nsString& aClassName)
{
SetAttr(nsHTMLAtoms::kClass, aClassName, eSetAttrNotify_Restart);
return NS_OK;
}
nsresult
-nsHTMLGenericContent::GetDocument(nsIDocument*& aResult) const
+nsGenericHTMLElement::GetDocument(nsIDocument*& aResult) const
{
aResult = mDocument;
NS_IF_ADDREF(mDocument);
@@ -955,7 +956,7 @@ static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
}
nsresult
-nsHTMLGenericContent::SetDocument(nsIDocument* aDocument)
+nsGenericHTMLElement::SetDocument(nsIDocument* aDocument)
{
mDocument = aDocument;
@@ -1005,7 +1006,7 @@ nsHTMLGenericContent::SetDocument(nsIDocument* aDocument)
}
nsresult
-nsHTMLGenericContent::GetParent(nsIContent*& aResult) const
+nsGenericHTMLElement::GetParent(nsIContent*& aResult) const
{
NS_IF_ADDREF(mParent);
aResult = mParent;
@@ -1013,21 +1014,21 @@ nsHTMLGenericContent::GetParent(nsIContent*& aResult) const
}
nsresult
-nsHTMLGenericContent::SetParent(nsIContent* aParent)
+nsGenericHTMLElement::SetParent(nsIContent* aParent)
{
mParent = aParent;
return NS_OK;
}
nsresult
-nsHTMLGenericContent::IsSynthetic(PRBool& aResult)
+nsGenericHTMLElement::IsSynthetic(PRBool& aResult)
{
return PR_FALSE;
}
nsresult
-nsHTMLGenericContent::GetTag(nsIAtom*& aResult) const
+nsGenericHTMLElement::GetTag(nsIAtom*& aResult) const
{
NS_IF_ADDREF(mTag);
aResult = mTag;
@@ -1046,7 +1047,7 @@ nsHTMLGenericContent::GetTag(nsIAtom*& aResult) const
//}
nsresult
-nsHTMLGenericContent::HandleDOMEvent(nsIPresContext& aPresContext,
+nsGenericHTMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
@@ -1099,7 +1100,7 @@ nsHTMLGenericContent::HandleDOMEvent(nsIPresContext& aPresContext,
}
nsresult
-nsHTMLGenericContent::SetAttribute(const nsString& aName,
+nsGenericHTMLElement::SetAttribute(const nsString& aName,
const nsString& aValue,
PRBool aNotify)
{
@@ -1111,12 +1112,38 @@ nsHTMLGenericContent::SetAttribute(const nsString& aName,
return rv;
}
+#if 0
+static nsGenericHTMLElement::EnumTable kDirTable[] = {
+ { "ltr", NS_STYLE_DIRECTION_LTR },
+ { "rtl", NS_STYLE_DIRECTION_RTL },
+ { 0 }
+};
+#endif
+
nsresult
-nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute,
+nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
const nsString& aValue,
PRBool aNotify)
{
nsresult result = NS_OK;
+#if 0
+ if (nsHTMLAtoms::dir == aAttribute) {
+ nsHTMLValue val;
+ if (ParseEnumValue(aValue, kDirTable, val)) {
+ result = SetAttribute(aAttribute, val, aNotify);
+ }
+ else {
+ result = SetStringAttribute(aAttribute, aValue, aNotify);
+ }
+ }
+ else if (nsHTMLAtoms::lang == aAttribute) {
+ result = SetStringAttribute(aAttribute, aValue, aNotify);
+ }
+ else if (nsHTMLAtoms::title == aAttribute) {
+ result = SetStringAttribute(aAttribute, aValue, aNotify);
+ }
+ else
+#endif
if (nsHTMLAtoms::style == aAttribute) {
// XXX the style sheet language is a document property that
// should be used to lookup the style sheet parser to parse the
@@ -1148,7 +1175,7 @@ nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute,
+nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
PRBool aNotify)
{
@@ -1170,8 +1197,27 @@ nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute,
return result;
}
+/**
+ * Handle attributes common to all html elements
+ */
nsresult
-nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute,
+nsGenericHTMLElement::MapAttributesInto(nsIStyleContext* aStyleContext,
+ nsIPresContext* aPresContext)
+{
+ if (nsnull != mAttributes) {
+ nsHTMLValue value;
+ GetAttribute(nsHTMLAtoms::dir, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ nsStyleDisplay* display = (nsStyleDisplay*)
+ aStyleContext->GetMutableStyleData(eStyleStruct_Display);
+ display->mDirection = value.GetIntValue();
+ }
+ }
+ return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::SetAttr(nsIAtom* aAttribute,
const nsString& aValue,
nsSetAttrNotify aNotify)
{
@@ -1180,7 +1226,7 @@ nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute,
+nsGenericHTMLElement::SetAttr(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
nsSetAttrNotify aNotify)
{
@@ -1189,7 +1235,7 @@ nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::UnsetAttribute(nsIAtom* aAttribute)
+nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute)
{
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
@@ -1210,7 +1256,7 @@ nsHTMLGenericContent::UnsetAttribute(nsIAtom* aAttribute)
}
nsresult
-nsHTMLGenericContent::GetAttribute(const nsString& aName,
+nsGenericHTMLElement::GetAttribute(const nsString& aName,
nsString& aResult) const
{
nsAutoString upper;
@@ -1222,7 +1268,7 @@ nsHTMLGenericContent::GetAttribute(const nsString& aName,
}
nsresult
-nsHTMLGenericContent::GetAttribute(nsIAtom *aAttribute,
+nsGenericHTMLElement::GetAttribute(nsIAtom *aAttribute,
nsString &aResult) const
{
nsHTMLValue value;
@@ -1283,7 +1329,7 @@ nsHTMLGenericContent::GetAttribute(nsIAtom *aAttribute,
}
nsresult
-nsHTMLGenericContent::GetAttribute(nsIAtom* aAttribute,
+nsGenericHTMLElement::GetAttribute(nsIAtom* aAttribute,
nsHTMLValue& aValue) const
{
if (nsnull != mAttributes) {
@@ -1294,7 +1340,7 @@ nsHTMLGenericContent::GetAttribute(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::GetAllAttributeNames(nsISupportsArray* aArray,
+nsGenericHTMLElement::GetAllAttributeNames(nsISupportsArray* aArray,
PRInt32& aCount) const
{
if (nsnull != mAttributes) {
@@ -1305,7 +1351,7 @@ nsHTMLGenericContent::GetAllAttributeNames(nsISupportsArray* aArray,
}
nsresult
-nsHTMLGenericContent::GetAttributeCount(PRInt32& aCount) const
+nsGenericHTMLElement::GetAttributeCount(PRInt32& aCount) const
{
if (nsnull != mAttributes) {
return mAttributes->Count(aCount);
@@ -1315,7 +1361,7 @@ nsHTMLGenericContent::GetAttributeCount(PRInt32& aCount) const
}
nsresult
-nsHTMLGenericContent::SetID(nsIAtom* aID)
+nsGenericHTMLElement::SetID(nsIAtom* aID)
{
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
@@ -1336,7 +1382,7 @@ nsHTMLGenericContent::SetID(nsIAtom* aID)
}
nsresult
-nsHTMLGenericContent::GetID(nsIAtom*& aResult) const
+nsGenericHTMLElement::GetID(nsIAtom*& aResult) const
{
if (nsnull != mAttributes) {
return mAttributes->GetID(aResult);
@@ -1346,7 +1392,7 @@ nsHTMLGenericContent::GetID(nsIAtom*& aResult) const
}
nsresult
-nsHTMLGenericContent::SetClass(nsIAtom* aClass)
+nsGenericHTMLElement::SetClass(nsIAtom* aClass)
{
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
@@ -1367,7 +1413,7 @@ nsHTMLGenericContent::SetClass(nsIAtom* aClass)
}
nsresult
-nsHTMLGenericContent::GetClass(nsIAtom*& aResult) const
+nsGenericHTMLElement::GetClass(nsIAtom*& aResult) const
{
if (nsnull != mAttributes) {
return mAttributes->GetClass(aResult);
@@ -1377,7 +1423,7 @@ nsHTMLGenericContent::GetClass(nsIAtom*& aResult) const
}
nsresult
-nsHTMLGenericContent::GetStyleRule(nsIStyleRule*& aResult)
+nsGenericHTMLElement::GetStyleRule(nsIStyleRule*& aResult)
{
nsIStyleRule* result = nsnull;
@@ -1389,14 +1435,14 @@ nsHTMLGenericContent::GetStyleRule(nsIStyleRule*& aResult)
}
nsIContentDelegate*
-nsHTMLGenericContent::GetDelegate(nsIPresContext* aCX)
+nsGenericHTMLElement::GetDelegate(nsIPresContext* aCX)
{
gContentDelegate->AddRef();
return gContentDelegate;
}
void
-nsHTMLGenericContent::ListAttributes(FILE* out) const
+nsGenericHTMLElement::ListAttributes(FILE* out) const
{
nsISupportsArray* attrs;
if (NS_OK == NS_NewISupportsArray(&attrs)) {
@@ -1423,7 +1469,7 @@ nsHTMLGenericContent::ListAttributes(FILE* out) const
}
nsresult
-nsHTMLGenericContent::List(FILE* out, PRInt32 aIndent) const
+nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
{
NS_PRECONDITION(nsnull != mDocument, "bad content");
@@ -1465,7 +1511,7 @@ nsHTMLGenericContent::List(FILE* out, PRInt32 aIndent) const
}
nsresult
-nsHTMLGenericContent::ToHTML(FILE* out) const
+nsGenericHTMLElement::ToHTML(FILE* out) const
{
nsAutoString tmp;
nsresult rv = ToHTMLString(tmp);
@@ -1502,7 +1548,7 @@ QuoteForHTML(const nsString& aValue, nsString& aResult)
}
nsresult
-nsHTMLGenericContent::ToHTMLString(nsString& aBuf) const
+nsGenericHTMLElement::ToHTMLString(nsString& aBuf) const
{
aBuf.Truncate(0);
aBuf.Append('<');
@@ -1555,7 +1601,7 @@ extern nsresult NS_NewObjectFrame(nsIContent* aContent, nsIFrame* aParentFrame,
nsIFrame*& aNewFrame);
nsresult
-nsHTMLGenericContent::CreateFrame(nsIPresContext* aPresContext,
+nsGenericHTMLElement::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aResult)
@@ -1567,6 +1613,9 @@ nsHTMLGenericContent::CreateFrame(nsIPresContext* aPresContext,
if (mTag == nsHTMLAtoms::applet) {
rv = NS_NewObjectFrame(mContent, aParentFrame, frame);
}
+ else if (mTag == nsHTMLAtoms::body) {
+ rv = nsBodyFrame::NewFrame(&frame, mContent, aParentFrame);
+ }
else if (mTag == nsHTMLAtoms::br) {
rv = NS_NewBRFrame(mContent, aParentFrame, frame);
}
@@ -1625,7 +1674,7 @@ nsHTMLGenericContent::CreateFrame(nsIPresContext* aPresContext,
// nsIScriptObjectOwner implementation
nsresult
-nsHTMLGenericContent::GetScriptObject(nsIScriptContext* aContext,
+nsGenericHTMLElement::GetScriptObject(nsIScriptContext* aContext,
void** aScriptObject)
{
nsresult res = NS_OK;
@@ -1640,7 +1689,7 @@ nsHTMLGenericContent::GetScriptObject(nsIScriptContext* aContext,
}
nsresult
-nsHTMLGenericContent::ResetScriptObject()
+nsGenericHTMLElement::ResetScriptObject()
{
mScriptObject = nsnull;
return NS_OK;
@@ -1651,7 +1700,7 @@ nsHTMLGenericContent::ResetScriptObject()
// nsIDOMEventReceiver implementation
nsresult
-nsHTMLGenericContent::GetListenerManager(nsIEventListenerManager** aResult)
+nsGenericHTMLElement::GetListenerManager(nsIEventListenerManager** aResult)
{
if (nsnull != mListenerManager) {
NS_ADDREF(mListenerManager);
@@ -1667,13 +1716,13 @@ nsHTMLGenericContent::GetListenerManager(nsIEventListenerManager** aResult)
}
nsresult
-nsHTMLGenericContent::GetNewListenerManager(nsIEventListenerManager** aResult)
+nsGenericHTMLElement::GetNewListenerManager(nsIEventListenerManager** aResult)
{
return NS_NewEventListenerManager(aResult);
}
nsresult
-nsHTMLGenericContent::AddEventListener(nsIDOMEventListener* aListener,
+nsGenericHTMLElement::AddEventListener(nsIDOMEventListener* aListener,
const nsIID& aIID)
{
nsIEventListenerManager *manager;
@@ -1687,7 +1736,7 @@ nsHTMLGenericContent::AddEventListener(nsIDOMEventListener* aListener,
}
nsresult
-nsHTMLGenericContent::RemoveEventListener(nsIDOMEventListener* aListener,
+nsGenericHTMLElement::RemoveEventListener(nsIDOMEventListener* aListener,
const nsIID& aIID)
{
if (nsnull != mListenerManager) {
@@ -1700,7 +1749,7 @@ nsHTMLGenericContent::RemoveEventListener(nsIDOMEventListener* aListener,
//----------------------------------------------------------------------
nsresult
-nsHTMLGenericContent::AddScriptEventListener(nsIAtom* aAttribute,
+nsGenericHTMLElement::AddScriptEventListener(nsIAtom* aAttribute,
nsHTMLValue& aValue,
REFNSIID aIID)
{
@@ -1754,7 +1803,7 @@ nsHTMLGenericContent::AddScriptEventListener(nsIAtom* aAttribute,
}
nsresult
-nsHTMLGenericContent::AttributeToString(nsIAtom* aAttribute,
+nsGenericHTMLElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const
{
@@ -1771,7 +1820,7 @@ nsHTMLGenericContent::AttributeToString(nsIAtom* aAttribute,
}
PRBool
-nsHTMLGenericContent::ParseEnumValue(const nsString& aValue,
+nsGenericHTMLElement::ParseEnumValue(const nsString& aValue,
EnumTable* aTable,
nsHTMLValue& aResult)
{
@@ -1786,7 +1835,7 @@ nsHTMLGenericContent::ParseEnumValue(const nsString& aValue,
}
PRBool
-nsHTMLGenericContent::EnumValueToString(const nsHTMLValue& aValue,
+nsGenericHTMLElement::EnumValueToString(const nsHTMLValue& aValue,
EnumTable* aTable,
nsString& aResult)
{
@@ -1805,7 +1854,7 @@ nsHTMLGenericContent::EnumValueToString(const nsHTMLValue& aValue,
}
PRBool
-nsHTMLGenericContent::ParseValueOrPercent(const nsString& aString,
+nsGenericHTMLElement::ParseValueOrPercent(const nsString& aString,
nsHTMLValue& aResult,
nsHTMLUnit aValueUnit)
{ // XXX should vave min/max values?
@@ -1839,7 +1888,7 @@ nsHTMLGenericContent::ParseValueOrPercent(const nsString& aString,
* or proportional (n*)
*/
void
-nsHTMLGenericContent::ParseValueOrPercentOrProportional(const nsString& aString,
+nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsString& aString,
nsHTMLValue& aResult,
nsHTMLUnit aValueUnit)
{ // XXX should have min/max values?
@@ -1864,7 +1913,7 @@ nsHTMLGenericContent::ParseValueOrPercentOrProportional(const nsString& aString,
}
PRBool
-nsHTMLGenericContent::ValueOrPercentToString(const nsHTMLValue& aValue,
+nsGenericHTMLElement::ValueOrPercentToString(const nsHTMLValue& aValue,
nsString& aResult)
{
aResult.Truncate(0);
@@ -1884,7 +1933,7 @@ nsHTMLGenericContent::ValueOrPercentToString(const nsHTMLValue& aValue,
}
PRBool
-nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin,
+nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin,
nsHTMLValue& aResult, nsHTMLUnit aValueUnit)
{
PRInt32 ec, val = aString.ToInteger(&ec);
@@ -1905,7 +1954,7 @@ nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin,
}
PRBool
-nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin,
+nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin,
PRInt32 aMax,
nsHTMLValue& aResult, nsHTMLUnit aValueUnit)
{
@@ -1928,7 +1977,7 @@ nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin,
}
PRBool
-nsHTMLGenericContent::ParseColor(const nsString& aString,
+nsGenericHTMLElement::ParseColor(const nsString& aString,
nsHTMLValue& aResult)
{
if (aString.Length() > 0) {
@@ -1953,7 +2002,7 @@ nsHTMLGenericContent::ParseColor(const nsString& aString,
}
PRBool
-nsHTMLGenericContent::ColorToString(const nsHTMLValue& aValue,
+nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue,
nsString& aResult)
{
if (aValue.GetUnit() == eHTMLUnit_Color) {
@@ -1977,7 +2026,7 @@ nsHTMLGenericContent::ColorToString(const nsHTMLValue& aValue,
}
// XXX check all mappings against ebina's usage
-static nsHTMLGenericContent::EnumTable kAlignTable[] = {
+static nsGenericHTMLElement::EnumTable kAlignTable[] = {
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
{ "texttop", NS_STYLE_VERTICAL_ALIGN_TEXT_TOP },
@@ -1992,22 +2041,45 @@ static nsHTMLGenericContent::EnumTable kAlignTable[] = {
{ 0 }
};
+static nsGenericHTMLElement::EnumTable kDivAlignTable[] = {
+ { "left", NS_STYLE_TEXT_ALIGN_LEFT },
+ { "right", NS_STYLE_TEXT_ALIGN_RIGHT },
+ { "center", NS_STYLE_TEXT_ALIGN_CENTER },
+ { "middle", NS_STYLE_TEXT_ALIGN_CENTER },
+ { "justify", NS_STYLE_TEXT_ALIGN_JUSTIFY },
+ { 0 }
+};
+
PRBool
-nsHTMLGenericContent::ParseAlignValue(const nsString& aString,
+nsGenericHTMLElement::ParseAlignValue(const nsString& aString,
nsHTMLValue& aResult)
{
return ParseEnumValue(aString, kAlignTable, aResult);
}
PRBool
-nsHTMLGenericContent::AlignValueToString(const nsHTMLValue& aValue,
+nsGenericHTMLElement::AlignValueToString(const nsHTMLValue& aValue,
nsString& aResult)
{
return EnumValueToString(aValue, kAlignTable, aResult);
}
PRBool
-nsHTMLGenericContent::ParseImageAttribute(nsIAtom* aAttribute,
+nsGenericHTMLElement::ParseDivAlignValue(const nsString& aString,
+ nsHTMLValue& aResult)
+{
+ return ParseEnumValue(aString, kDivAlignTable, aResult);
+}
+
+PRBool
+nsGenericHTMLElement::DivAlignValueToString(const nsHTMLValue& aValue,
+ nsString& aResult)
+{
+ return EnumValueToString(aValue, kDivAlignTable, aResult);
+}
+
+PRBool
+nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute,
const nsString& aString,
nsHTMLValue& aResult)
{
@@ -2026,7 +2098,7 @@ nsHTMLGenericContent::ParseImageAttribute(nsIAtom* aAttribute,
}
PRBool
-nsHTMLGenericContent::ImageAttributeToString(nsIAtom* aAttribute,
+nsGenericHTMLElement::ImageAttributeToString(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
nsString& aResult)
{
@@ -2041,7 +2113,7 @@ nsHTMLGenericContent::ImageAttributeToString(nsIAtom* aAttribute,
}
void
-nsHTMLGenericContent::MapImageAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
if (nsnull != mAttributes) {
@@ -2098,7 +2170,7 @@ nsHTMLGenericContent::MapImageAttributesInto(nsIStyleContext* aContext,
}
void
-nsHTMLGenericContent::MapImageAlignAttributeInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageAlignAttributeInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
if (nsnull != mAttributes) {
@@ -2134,7 +2206,7 @@ nsHTMLGenericContent::MapImageAlignAttributeInto(nsIStyleContext* aContext,
}
void
-nsHTMLGenericContent::MapImageBorderAttributesInto(nsIStyleContext* aContext,
+nsGenericHTMLElement::MapImageBorderAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext,
nscolor aBorderColors[4])
{
@@ -2192,7 +2264,63 @@ nsHTMLGenericContent::MapImageBorderAttributesInto(nsIStyleContext* aContext,
}
void
-nsHTMLGenericContent::TriggerLink(nsIPresContext& aPresContext,
+nsGenericHTMLElement::MapBackgroundAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
+{
+ nsHTMLValue value;
+
+ // background
+ if (NS_CONTENT_ATTR_HAS_VALUE ==
+ GetAttribute(nsHTMLAtoms::background, value)) {
+ if (eHTMLUnit_String == value.GetUnit()) {
+ nsAutoString absURLSpec;
+ nsAutoString spec;
+ value.GetStringValue(spec);
+ if (spec.Length() > 0) {
+ // Resolve url to an absolute url
+ nsIURL* docURL = nsnull;
+ nsIDocument* doc = mDocument;
+ if (nsnull != doc) {
+ docURL = doc->GetDocumentURL();
+ }
+
+ nsresult rv = NS_MakeAbsoluteURL(docURL, "", spec, absURLSpec);
+ if (nsnull != docURL) {
+ NS_RELEASE(docURL);
+ }
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ color->mBackgroundImage = absURLSpec;
+ color->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE;
+ color->mBackgroundRepeat = NS_STYLE_BG_REPEAT_XY;
+ }
+ }
+ }
+
+ // bgcolor
+ if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(nsHTMLAtoms::bgcolor, value)) {
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ nsStyleColor* 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));
+
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ NS_ColorNameToRGB(cbuf, &(color->mBackgroundColor));
+ color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
+ }
+ }
+}
+
+void
+nsGenericHTMLElement::TriggerLink(nsIPresContext& aPresContext,
const nsString& aBase,
const nsString& aURLSpec,
const nsString& aTargetSpec,
@@ -2233,17 +2361,17 @@ nsHTMLGenericContent::TriggerLink(nsIPresContext& aPresContext,
//----------------------------------------------------------------------
-nsHTMLGenericLeafContent::nsHTMLGenericLeafContent()
+nsGenericHTMLLeafElement::nsGenericHTMLLeafElement()
{
}
-nsHTMLGenericLeafContent::~nsHTMLGenericLeafContent()
+nsGenericHTMLLeafElement::~nsGenericHTMLLeafElement()
{
}
nsresult
-nsHTMLGenericLeafContent::CopyInnerTo(nsIHTMLContent* aSrcContent,
- nsHTMLGenericLeafContent* aDst)
+nsGenericHTMLLeafElement::CopyInnerTo(nsIHTMLContent* aSrcContent,
+ nsGenericHTMLLeafElement* aDst)
{
aDst->mContent = aSrcContent;
// XXX should the node's document be set?
@@ -2252,7 +2380,7 @@ nsHTMLGenericLeafContent::CopyInnerTo(nsIHTMLContent* aSrcContent,
}
nsresult
-nsHTMLGenericLeafContent::Equals(nsIDOMNode* aNode, PRBool aDeep,
+nsGenericHTMLLeafElement::Equals(nsIDOMNode* aNode, PRBool aDeep,
PRBool* aReturn)
{
// XXX not yet implemented
@@ -2261,7 +2389,7 @@ nsHTMLGenericLeafContent::Equals(nsIDOMNode* aNode, PRBool aDeep,
}
nsresult
-nsHTMLGenericLeafContent::BeginConvertToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLLeafElement::BeginConvertToXIF(nsXIFConverter& aConverter) const
{
nsresult rv = NS_OK;
if (nsnull != mTag)
@@ -2298,13 +2426,13 @@ nsHTMLGenericLeafContent::BeginConvertToXIF(nsXIFConverter& aConverter) const
}
nsresult
-nsHTMLGenericLeafContent::ConvertContentToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLLeafElement::ConvertContentToXIF(nsXIFConverter& aConverter) const
{
return NS_OK;
}
nsresult
-nsHTMLGenericLeafContent::FinishConvertToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLLeafElement::FinishConvertToXIF(nsXIFConverter& aConverter) const
{
if (nsnull != mTag)
{
@@ -2317,7 +2445,7 @@ nsHTMLGenericLeafContent::FinishConvertToXIF(nsXIFConverter& aConverter) const
// XXX not really implemented (yet)
nsresult
-nsHTMLGenericLeafContent::SizeOf(nsISizeOfHandler* aHandler) const
+nsGenericHTMLLeafElement::SizeOf(nsISizeOfHandler* aHandler) const
{
aHandler->Add(sizeof(*this));
return NS_OK;
@@ -2325,11 +2453,11 @@ nsHTMLGenericLeafContent::SizeOf(nsISizeOfHandler* aHandler) const
//----------------------------------------------------------------------
-nsHTMLGenericContainerContent::nsHTMLGenericContainerContent()
+nsGenericHTMLContainerElement::nsGenericHTMLContainerElement()
{
}
-nsHTMLGenericContainerContent::~nsHTMLGenericContainerContent()
+nsGenericHTMLContainerElement::~nsGenericHTMLContainerElement()
{
PRInt32 n = mChildren.Count();
for (PRInt32 i = 0; i < n; i++) {
@@ -2343,8 +2471,8 @@ nsHTMLGenericContainerContent::~nsHTMLGenericContainerContent()
}
nsresult
-nsHTMLGenericContainerContent:: CopyInnerTo(nsIHTMLContent* aSrcContent,
- nsHTMLGenericContainerContent* aDst)
+nsGenericHTMLContainerElement::CopyInnerTo(nsIHTMLContent* aSrcContent,
+ nsGenericHTMLContainerElement* aDst)
{
aDst->mContent = aSrcContent;
// XXX should the node's document be set?
@@ -2354,7 +2482,7 @@ nsHTMLGenericContainerContent:: CopyInnerTo(nsIHTMLContent* aSrcContent,
}
nsresult
-nsHTMLGenericContainerContent::Equals(nsIDOMNode* aNode, PRBool aDeep,
+nsGenericHTMLContainerElement::Equals(nsIDOMNode* aNode, PRBool aDeep,
PRBool* aReturn)
{
// XXX not yet implemented
@@ -2363,7 +2491,7 @@ nsHTMLGenericContainerContent::Equals(nsIDOMNode* aNode, PRBool aDeep,
}
nsresult
-nsHTMLGenericContainerContent::GetChildNodes(nsIDOMNodeList** aChildNodes)
+nsGenericHTMLContainerElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
{
*aChildNodes = nsnull;
return NS_OK;
@@ -2378,7 +2506,7 @@ nsHTMLGenericContainerContent::GetChildNodes(nsIDOMNodeList** aChildNodes)
}
nsresult
-nsHTMLGenericContainerContent::GetHasChildNodes(PRBool* aReturn)
+nsGenericHTMLContainerElement::GetHasChildNodes(PRBool* aReturn)
{
if (0 != mChildren.Count()) {
*aReturn = PR_TRUE;
@@ -2390,7 +2518,7 @@ nsHTMLGenericContainerContent::GetHasChildNodes(PRBool* aReturn)
}
nsresult
-nsHTMLGenericContainerContent::GetFirstChild(nsIDOMNode** aNode)
+nsGenericHTMLContainerElement::GetFirstChild(nsIDOMNode** aNode)
{
nsIContent *child = (nsIContent*) mChildren.ElementAt(0);
if (nsnull != child) {
@@ -2403,7 +2531,7 @@ nsHTMLGenericContainerContent::GetFirstChild(nsIDOMNode** aNode)
}
nsresult
-nsHTMLGenericContainerContent::GetLastChild(nsIDOMNode** aNode)
+nsGenericHTMLContainerElement::GetLastChild(nsIDOMNode** aNode)
{
nsIContent *child = (nsIContent*) mChildren.ElementAt(mChildren.Count()-1);
if (nsnull != child) {
@@ -2435,7 +2563,7 @@ SetDocumentInChildrenOf(nsIContent* aContent, nsIDocument* aDocument)
// was before placing it in it's new home
nsresult
-nsHTMLGenericContainerContent::InsertBefore(nsIDOMNode* aNewChild,
+nsGenericHTMLContainerElement::InsertBefore(nsIDOMNode* aNewChild,
nsIDOMNode* aRefChild,
nsIDOMNode** aReturn)
{
@@ -2482,7 +2610,7 @@ nsHTMLGenericContainerContent::InsertBefore(nsIDOMNode* aNewChild,
}
nsresult
-nsHTMLGenericContainerContent::ReplaceChild(nsIDOMNode* aNewChild,
+nsGenericHTMLContainerElement::ReplaceChild(nsIDOMNode* aNewChild,
nsIDOMNode* aOldChild,
nsIDOMNode** aReturn)
{
@@ -2511,7 +2639,7 @@ nsHTMLGenericContainerContent::ReplaceChild(nsIDOMNode* aNewChild,
}
nsresult
-nsHTMLGenericContainerContent::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
+nsGenericHTMLContainerElement::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
{
nsIContent* content = nsnull;
*aReturn = nsnull;
@@ -2532,20 +2660,20 @@ nsHTMLGenericContainerContent::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** a
}
nsresult
-nsHTMLGenericContainerContent::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
+nsGenericHTMLContainerElement::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
{
return InsertBefore(aNewChild, nsnull, aReturn);
}
nsresult
-nsHTMLGenericContainerContent::SizeOf(nsISizeOfHandler* aHandler) const
+nsGenericHTMLContainerElement::SizeOf(nsISizeOfHandler* aHandler) const
{
aHandler->Add(sizeof(*this));
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::BeginConvertToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLContainerElement::BeginConvertToXIF(nsXIFConverter& aConverter) const
{
nsresult rv = NS_OK;
if (nsnull != mTag)
@@ -2582,13 +2710,13 @@ nsHTMLGenericContainerContent::BeginConvertToXIF(nsXIFConverter& aConverter) con
}
nsresult
-nsHTMLGenericContainerContent::ConvertContentToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLContainerElement::ConvertContentToXIF(nsXIFConverter& aConverter) const
{
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::FinishConvertToXIF(nsXIFConverter& aConverter) const
+nsGenericHTMLContainerElement::FinishConvertToXIF(nsXIFConverter& aConverter) const
{
if (nsnull != mTag)
{
@@ -2600,28 +2728,28 @@ nsHTMLGenericContainerContent::FinishConvertToXIF(nsXIFConverter& aConverter) co
}
nsresult
-nsHTMLGenericContainerContent::Compact()
+nsGenericHTMLContainerElement::Compact()
{
mChildren.Compact();
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::CanContainChildren(PRBool& aResult) const
+nsGenericHTMLContainerElement::CanContainChildren(PRBool& aResult) const
{
aResult = PR_TRUE;
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::ChildCount(PRInt32& aCount) const
+nsGenericHTMLContainerElement::ChildCount(PRInt32& aCount) const
{
aCount = mChildren.Count();
return NS_OK;
}
nsresult
-nsHTMLGenericContainerContent::ChildAt(PRInt32 aIndex,
+nsGenericHTMLContainerElement::ChildAt(PRInt32 aIndex,
nsIContent*& aResult) const
{
nsIContent *child = (nsIContent*) mChildren.ElementAt(aIndex);
@@ -2633,7 +2761,7 @@ nsHTMLGenericContainerContent::ChildAt(PRInt32 aIndex,
}
nsresult
-nsHTMLGenericContainerContent::IndexOf(nsIContent* aPossibleChild,
+nsGenericHTMLContainerElement::IndexOf(nsIContent* aPossibleChild,
PRInt32& aIndex) const
{
NS_PRECONDITION(nsnull != aPossibleChild, "null ptr");
@@ -2642,7 +2770,7 @@ nsHTMLGenericContainerContent::IndexOf(nsIContent* aPossibleChild,
}
nsresult
-nsHTMLGenericContainerContent::InsertChildAt(nsIContent* aKid,
+nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid,
PRInt32 aIndex,
PRBool aNotify)
{
@@ -2663,7 +2791,7 @@ nsHTMLGenericContainerContent::InsertChildAt(nsIContent* aKid,
}
nsresult
-nsHTMLGenericContainerContent::ReplaceChildAt(nsIContent* aKid,
+nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid,
PRInt32 aIndex,
PRBool aNotify)
{
@@ -2688,7 +2816,7 @@ nsHTMLGenericContainerContent::ReplaceChildAt(nsIContent* aKid,
}
nsresult
-nsHTMLGenericContainerContent::AppendChildTo(nsIContent* aKid, PRBool aNotify)
+nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify)
{
NS_PRECONDITION((nsnull != aKid) && (aKid != mContent), "null ptr");
PRBool rv = mChildren.AppendElement(aKid);
@@ -2707,7 +2835,7 @@ nsHTMLGenericContainerContent::AppendChildTo(nsIContent* aKid, PRBool aNotify)
}
nsresult
-nsHTMLGenericContainerContent::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
+nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
{
nsIContent* oldKid = (nsIContent*) mChildren.ElementAt(aIndex);
if (nsnull != oldKid ) {
diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.h b/mozilla/layout/html/content/src/nsGenericHTMLElement.h
index cc65be72ebb..b3c43f34824 100644
--- a/mozilla/layout/html/content/src/nsGenericHTMLElement.h
+++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.h
@@ -16,8 +16,8 @@
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
-#ifndef nsHTMLGenericContent_h___
-#define nsHTMLGenericContent_h___
+#ifndef nsGenericHTMLElement_h___
+#define nsGenericHTMLElement_h___
#include "nsIDOMHTMLElement.h"
#include "nsIContent.h"
@@ -51,9 +51,9 @@ enum nsSetAttrNotify {
eSetAttrNotify_Restart = 3
};
-struct nsHTMLGenericContent {
- nsHTMLGenericContent();
- ~nsHTMLGenericContent();
+struct nsGenericHTMLElement {
+ nsGenericHTMLElement();
+ ~nsGenericHTMLElement();
void Init(nsIHTMLContent* aOuterContentObject, nsIAtom* aTag);
@@ -212,9 +212,15 @@ struct nsHTMLGenericContent {
static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult);
+ static PRBool ParseDivAlignValue(const nsString& aString,
+ nsHTMLValue& aResult);
+
static PRBool AlignValueToString(const nsHTMLValue& aValue,
nsString& aResult);
+ static PRBool DivAlignValueToString(const nsHTMLValue& aValue,
+ nsString& aResult);
+
static PRBool ParseImageAttribute(nsIAtom* aAttribute,
const nsString& aString,
nsHTMLValue& aResult);
@@ -233,6 +239,9 @@ struct nsHTMLGenericContent {
nsIPresContext* aPresContext,
nscolor aBorderColors[4]);
+ void MapBackgroundAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
+
// Up pointer to the real content object that we are
// supporting. Sometimes there is work that we just can't do
// ourselves, so this is needed to ask the real object to do the
@@ -249,12 +258,12 @@ struct nsHTMLGenericContent {
//----------------------------------------------------------------------
-struct nsHTMLGenericLeafContent : public nsHTMLGenericContent {
- nsHTMLGenericLeafContent();
- ~nsHTMLGenericLeafContent();
+struct nsGenericHTMLLeafElement : public nsGenericHTMLElement {
+ nsGenericHTMLLeafElement();
+ ~nsGenericHTMLLeafElement();
nsresult CopyInnerTo(nsIHTMLContent* aSrcContent,
- nsHTMLGenericLeafContent* aDest);
+ nsGenericHTMLLeafElement* aDest);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn);
@@ -329,12 +338,12 @@ struct nsHTMLGenericLeafContent : public nsHTMLGenericContent {
//----------------------------------------------------------------------
-struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
- nsHTMLGenericContainerContent();
- ~nsHTMLGenericContainerContent();
+struct nsGenericHTMLContainerElement : public nsGenericHTMLElement {
+ nsGenericHTMLContainerElement();
+ ~nsGenericHTMLContainerElement();
nsresult CopyInnerTo(nsIHTMLContent* aSrcContent,
- nsHTMLGenericContainerContent* aDest);
+ nsGenericHTMLContainerElement* aDest);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn);
@@ -371,8 +380,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Mostly implement the nsIDOMNode API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*
* Note that classes using this macro will need to implement:
* NS_IMETHOD CloneNode(nsIDOMNode** aReturn);
@@ -435,8 +444,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Implement the nsIDOMElement API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*/
#define NS_IMPL_IDOMELEMENT_USING_GENERIC(_g) \
NS_IMETHOD GetTagName(nsString& aTagName) { \
@@ -471,8 +480,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Implement the nsIDOMHTMLElement API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*/
#define NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(_g) \
NS_IMETHOD GetId(nsString& aId) { \
@@ -508,8 +517,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Implement the nsIDOMEventReceiver API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*/
#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(_g) \
NS_IMETHOD AddEventListener(nsIDOMEventListener *aListener, \
@@ -529,8 +538,8 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
/**
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
- * generic content object (either nsHTMLGenericLeafContent or
- * nsHTMLGenericContainerContent)
+ * generic content object (either nsGenericHTMLLeafElement or
+ * nsGenericHTMLContainerContent)
*/
#define NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(_g) \
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, \
@@ -685,6 +694,71 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \
nsIPresContext* aPresContext);
+#define NS_IMPL_IHTMLCONTENT_USING_GENERIC2(_g) \
+ NS_IMETHOD Compact() { \
+ return _g.Compact(); \
+ } \
+ NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, \
+ PRBool aNotify) { \
+ return _g.SetAttribute(aAttribute, aValue, aNotify); \
+ } \
+ NS_IMETHOD SetAttribute(nsIAtom* aAttribute, \
+ const nsHTMLValue& aValue, PRBool aNotify) { \
+ return _g.SetAttribute(aAttribute, aValue, aNotify); \
+ } \
+ NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) { \
+ return _g.UnsetAttribute(aAttribute); \
+ } \
+ NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
+ nsString &aResult) const { \
+ return _g.GetAttribute(aAttribute, aResult); \
+ } \
+ NS_IMETHOD GetAttribute(nsIAtom* aAttribute, \
+ nsHTMLValue& aValue) const { \
+ return _g.GetAttribute(aAttribute, aValue); \
+ } \
+ NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
+ PRInt32& aResult) const { \
+ return _g.GetAllAttributeNames(aArray, aResult); \
+ } \
+ NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
+ return _g.GetAttributeCount(aResult); \
+ } \
+ NS_IMETHOD SetID(nsIAtom* aID) { \
+ return _g.SetID(aID); \
+ } \
+ NS_IMETHOD GetID(nsIAtom*& aResult) const { \
+ return _g.GetID(aResult); \
+ } \
+ NS_IMETHOD SetClass(nsIAtom* aClass) { \
+ return _g.SetClass(aClass); \
+ } \
+ NS_IMETHOD GetClass(nsIAtom*& aResult) const { \
+ return _g.GetClass(aResult); \
+ } \
+ NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult); \
+ NS_IMETHOD ToHTMLString(nsString& aResult) const { \
+ return _g.ToHTMLString(aResult); \
+ } \
+ NS_IMETHOD ToHTML(FILE* out) const { \
+ return _g.ToHTML(out); \
+ } \
+ NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, \
+ nsIFrame* aParentFrame, \
+ nsIStyleContext* aStyleContext, \
+ nsIFrame*& aResult) { \
+ return _g.CreateFrame(aPresContext, aParentFrame, aStyleContext, \
+ aResult); \
+ } \
+ NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, \
+ const nsString& aValue, \
+ nsHTMLValue& aResult); \
+ NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
+ nsHTMLValue& aValue, \
+ nsString& aResult) const; \
+ NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \
+ nsIPresContext* aPresContext);
+
/**
* This macro implements the portion of query interface that is
* generic to all html content objects.
@@ -811,4 +885,4 @@ struct nsHTMLGenericContainerContent : public nsHTMLGenericContent {
return mInner.SetAttr(nsHTMLAtoms::_atom, value, _notify); \
}
-#endif /* nsHTMLLeafContent_h___ */
+#endif /* nsGenericHTMLElement_h___ */
diff --git a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp
index 05e7072a7f2..e703b396929 100644
--- a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp
@@ -30,6 +30,11 @@
#include "nsIEventStateManager.h"
#include "nsDOMEvent.h"
+// XXX suppress
+
+// XXX either suppress is handled in the event code below OR we need a
+// custom frame
+
static NS_DEFINE_IID(kIDOMHTMLAnchorElementIID, NS_IDOMHTMLANCHORELEMENT_IID);
class nsHTMLAnchorElement : public nsIDOMHTMLAnchorElement,
@@ -94,7 +99,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -182,10 +187,22 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::tabindex) {
- nsHTMLGenericContent::ParseValue(aValue, 0, 32767, aResult,
+ nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult,
eHTMLUnit_Integer);
return NS_CONTENT_ATTR_HAS_VALUE;
}
+ if (aAttribute == nsHTMLAtoms::href) {
+ nsAutoString href(aValue);
+ href.StripWhitespace();
+ aResult.SetStringValue(href);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::suppress) {
+ if (aValue.EqualsIgnoreCase("true")) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
@@ -201,9 +218,10 @@ NS_IMETHODIMP
nsHTMLAnchorElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
+// XXX support suppress in here
NS_IMETHODIMP
nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
diff --git a/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp b/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp
index e4f369d17a0..daea436a92b 100644
--- a/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp
@@ -87,7 +87,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -160,11 +160,11 @@ nsHTMLAppletElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -178,11 +178,11 @@ nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -196,7 +196,7 @@ nsHTMLAppletElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp b/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp
index 19cfa3b1f76..59db5608d4e 100644
--- a/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp
@@ -81,7 +81,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -165,7 +165,7 @@ NS_IMETHODIMP
nsHTMLAreaElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLBRElement.cpp b/mozilla/layout/html/content/src/nsHTMLBRElement.cpp
index ecb0c1ec88c..43ca4b5b07c 100644
--- a/mozilla/layout/html/content/src/nsHTMLBRElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLBRElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -124,7 +124,7 @@ nsHTMLBRElement::CloneNode(nsIDOMNode** aReturn)
NS_IMPL_STRING_ATTR(nsHTMLBRElement, Clear, clear, eSetAttrNotify_Reflow)
-static nsHTMLGenericContent::EnumTable kClearTable[] = {
+static nsGenericHTMLElement::EnumTable kClearTable[] = {
{ "left", NS_STYLE_CLEAR_LEFT },
{ "right", NS_STYLE_CLEAR_RIGHT },
{ "all", NS_STYLE_CLEAR_LEFT_AND_RIGHT },
@@ -138,7 +138,7 @@ nsHTMLBRElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::clear) {
- if (nsHTMLGenericContent::ParseEnumValue(aValue, kClearTable, aResult)) {
+ if (nsGenericHTMLElement::ParseEnumValue(aValue, kClearTable, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -152,7 +152,7 @@ nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::clear) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::EnumValueToString(aValue, kClearTable, aResult);
+ nsGenericHTMLElement::EnumValueToString(aValue, kClearTable, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -172,7 +172,7 @@ nsHTMLBRElement::MapAttributesInto(nsIStyleContext* aContext,
display->mBreakType = value.GetIntValue();
}
}
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp b/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp
index f3f53eadb9d..cb9264388d6 100644
--- a/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -147,7 +147,7 @@ NS_IMETHODIMP
nsHTMLBaseElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp b/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp
index 40726de9282..b86eaab74b0 100644
--- a/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp
@@ -71,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -153,7 +153,7 @@ nsHTMLBaseFontElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me?
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp b/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp
index 688d348e1df..7ded91b806e 100644
--- a/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp
@@ -26,9 +26,20 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsStyleUtil.h"
+#include "nsIDocument.h"
+#include "nsIHTMLDocument.h"
+#include "nsIHTMLStyleSheet.h"
+#include "nsIStyleRule.h"
+#include "nsIWebShell.h"
+static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
+static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
+static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIDOMHTMLBodyElementIID, NS_IDOMHTMLBODYELEMENT_IID);
+class BodyRule;
+
class nsHTMLBodyElement : public nsIDOMHTMLBodyElement,
public nsIScriptObjectOwner,
public nsIDOMEventReceiver,
@@ -74,12 +85,134 @@ public:
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
// nsIHTMLContent
- NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
+ NS_IMPL_IHTMLCONTENT_USING_GENERIC2(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
+ BodyRule* mStyleRule;
};
+class BodyRule: public nsIStyleRule {
+public:
+ BodyRule(nsHTMLBodyElement* aPart);
+ ~BodyRule();
+
+ NS_DECL_ISUPPORTS
+
+ NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aResult) const;
+ NS_IMETHOD HashValue(PRUint32& aValue) const;
+
+ NS_IMETHOD MapStyleInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext,
+ nsIContent* aContent);
+
+ NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
+
+ nsHTMLBodyElement* mPart;
+};
+
+//----------------------------------------------------------------------
+
+BodyRule::BodyRule(nsHTMLBodyElement* aPart)
+{
+ NS_INIT_REFCNT();
+ mPart = aPart;
+}
+
+BodyRule::~BodyRule()
+{
+}
+
+NS_IMPL_ISUPPORTS(BodyRule, kIStyleRuleIID);
+
+NS_IMETHODIMP
+BodyRule::Equals(const nsIStyleRule* aRule, PRBool& aResult) const
+{
+ aResult = PRBool(this == aRule);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+BodyRule::HashValue(PRUint32& aValue) const
+{
+ aValue = (PRUint32)(mPart);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext,
+ nsIContent* aContent)
+{
+ NS_ASSERTION(aContent == mPart, "bad content mapping");
+ if (nsnull != mPart) {
+
+ nsStyleSpacing* styleSpacing = (nsStyleSpacing*)(aContext->GetMutableStyleData(eStyleStruct_Spacing));
+
+ if (nsnull != styleSpacing) {
+ nsHTMLValue value;
+ nsStyleCoord zero(0);
+ PRInt32 count = 0;
+ PRInt32 attrCount;
+ mPart->GetAttributeCount(attrCount);
+
+ if (0 < attrCount) {
+ // if marginwidth/marginheigth is set in our attribute zero out left,right/top,bottom padding
+ // nsBodyFrame::DidSetStyleContext will add the appropriate values to padding
+ mPart->GetAttribute(nsHTMLAtoms::marginwidth, value);
+ if (eHTMLUnit_Pixel == value.GetUnit()) {
+ styleSpacing->mPadding.SetLeft(zero);
+ styleSpacing->mPadding.SetRight(zero);
+ count++;
+ }
+
+ mPart->GetAttribute(nsHTMLAtoms::marginheight, value);
+ if (eHTMLUnit_Pixel == value.GetUnit()) {
+ styleSpacing->mPadding.SetTop(zero);
+ styleSpacing->mPadding.SetBottom(zero);
+ count++;
+ }
+
+ if (count < attrCount) { // more to go...
+ mPart->MapAttributesInto(aContext, aPresContext);
+ }
+ }
+
+ if (count < 2) {
+ // if marginwidth or marginheight is set in the web shell zero out left,right,top,bottom padding
+ // nsBodyFrame::DidSetStyleContext will add the appropriate values to padding
+ nsISupports* container;
+ aPresContext->GetContainer(&container);
+ if (nsnull != container) {
+ nsIWebShell* webShell = nsnull;
+ container->QueryInterface(kIWebShellIID, (void**) &webShell);
+ if (nsnull != webShell) {
+ PRInt32 marginWidth, marginHeight;
+ webShell->GetMarginWidth(marginWidth);
+ webShell->GetMarginHeight(marginHeight);
+ if ((marginWidth >= 0) || (marginHeight >= 0)) { // nav quirk
+ styleSpacing->mPadding.SetLeft(zero);
+ styleSpacing->mPadding.SetRight(zero);
+ styleSpacing->mPadding.SetTop(zero);
+ styleSpacing->mPadding.SetBottom(zero);
+ }
+ NS_RELEASE(webShell);
+ }
+ NS_RELEASE(container);
+ }
+ }
+ }
+ }
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+BodyRule::List(FILE* out, PRInt32 aIndent) const
+{
+ return NS_OK;
+}
+
+//----------------------------------------------------------------------
+
nsresult
NS_NewHTMLBodyElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
{
@@ -95,6 +228,7 @@ NS_NewHTMLBodyElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
}
nsHTMLBodyElement::nsHTMLBodyElement(nsIAtom* aTag)
+ : mStyleRule(nsnull)
{
NS_INIT_REFCNT();
mInner.Init(this, aTag);
@@ -102,6 +236,10 @@ nsHTMLBodyElement::nsHTMLBodyElement(nsIAtom* aTag)
nsHTMLBodyElement::~nsHTMLBodyElement()
{
+ if (nsnull != mStyleRule) {
+ mStyleRule->mPart = nsnull;
+ NS_RELEASE(mStyleRule);
+ }
}
NS_IMPL_ADDREF(nsHTMLBodyElement)
@@ -144,7 +282,25 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,
nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::background) {
+ nsAutoString href(aValue);
+ href.StripWhitespace();
+ aResult.SetStringValue(href);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if ((aAttribute == nsHTMLAtoms::bgcolor) ||
+ (aAttribute == nsHTMLAtoms::text) ||
+ (aAttribute == nsHTMLAtoms::link) ||
+ (aAttribute == nsHTMLAtoms::alink) ||
+ (aAttribute == nsHTMLAtoms::vlink)) {
+ nsGenericHTMLElement::ParseColor(aValue, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if ((aAttribute == nsHTMLAtoms::marginwidth) ||
+ (aAttribute == nsHTMLAtoms::marginheight)) {
+ nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
@@ -153,7 +309,6 @@ nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const
{
- // XXX write me
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
@@ -161,8 +316,52 @@ NS_IMETHODIMP
nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (mInner.mAttributes) {
+ nsHTMLValue value;
+ mInner.MapBackgroundAttributesInto(aContext, aPresContext);
+ GetAttribute(nsHTMLAtoms::text, value);
+ if (eHTMLUnit_Color == value.GetUnit()) {
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ color->mColor = value.GetColorValue();
+ 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());
+ }
+
+ 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());
+ }
+ }
+ NS_RELEASE(htmlDoc);
+ }
+
+ // marginwidth/height get set by a special style rule
+
+ // set up the basefont (defaults to 3)
+ nsStyleFont* font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font);
+ const nsFont& defaultFont = aPresContext->GetDefaultFont();
+ const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFont();
+ PRInt32 scaler = aPresContext->GetFontScaler();
+ float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
+ 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);
}
NS_IMETHODIMP
@@ -175,3 +374,15 @@ nsHTMLBodyElement::HandleDOMEvent(nsIPresContext& aPresContext,
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
}
+
+NS_IMETHODIMP
+nsHTMLBodyElement::GetStyleRule(nsIStyleRule*& aResult)
+{
+ if (nsnull == mStyleRule) {
+ mStyleRule = new BodyRule(this);
+ NS_IF_ADDREF(mStyleRule);
+ }
+ NS_IF_ADDREF(mStyleRule);
+ aResult = mStyleRule;
+ return NS_OK;
+}
diff --git a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp
index 6ac6bd8cf94..e4a2ca9a27d 100644
--- a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp
@@ -82,7 +82,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -162,7 +162,7 @@ nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::tabindex) {
- nsHTMLGenericContent::ParseValue(aValue, 0, 32767, aResult,
+ nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult,
eHTMLUnit_Integer);
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -181,7 +181,7 @@ NS_IMETHODIMP
nsHTMLButtonElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLDListElement.cpp b/mozilla/layout/html/content/src/nsHTMLDListElement.cpp
index 66c536cdcbc..41f99ccad0e 100644
--- a/mozilla/layout/html/content/src/nsHTMLDListElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLDListElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -129,7 +129,10 @@ nsHTMLDListElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,
nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
@@ -138,7 +141,6 @@ nsHTMLDListElement::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,
nsString& aResult) const
{
- // XXX write me
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
@@ -146,8 +148,18 @@ NS_IMETHODIMP
nsHTMLDListElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLDelElement.cpp b/mozilla/layout/html/content/src/nsHTMLDelElement.cpp
index 4db504ac163..f36ab407a4c 100644
--- a/mozilla/layout/html/content/src/nsHTMLDelElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLDelElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLDelElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp b/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp
index aea1a95b0a9..5102ab4843d 100644
--- a/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp
@@ -27,12 +27,16 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+// XXX nav4 has type= start= (same as OL/UL)
+
+extern nsGenericHTMLElement::EnumTable kListTypeTable[];
+
static NS_DEFINE_IID(kIDOMHTMLDirectoryElementIID, NS_IDOMHTMLDIRECTORYELEMENT_IID);
class nsHTMLDirectoryElement : public nsIDOMHTMLDirectoryElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLDirectoryElement(nsIAtom* aTag);
@@ -67,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -126,36 +130,69 @@ NS_IMPL_BOOL_ATTR(nsHTMLDirectoryElement, Compact, compact, eSetAttrNotify_Reflo
NS_IMETHODIMP
nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
+ aResult)) {
+ aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
+ }
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::start) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLDirectoryElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListTypeTable, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLDirectoryElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLDirectoryElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLDivElement.cpp b/mozilla/layout/html/content/src/nsHTMLDivElement.cpp
index 28bee113049..dc2a4d964ee 100644
--- a/mozilla/layout/html/content/src/nsHTMLDivElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLDivElement.cpp
@@ -27,14 +27,14 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
-// XXX missing nav attributes
+// XXX support missing nav attributes? gutter, cols, width
static NS_DEFINE_IID(kIDOMHTMLDivElementIID, NS_IDOMHTMLDIVELEMENT_IID);
class nsHTMLDivElement : public nsIDOMHTMLDivElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLDivElement(nsIAtom* aTag);
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -128,25 +128,38 @@ NS_IMPL_STRING_ATTR(nsHTMLDivElement, Align, align, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseDivAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
+ if (aAttribute == nsHTMLAtoms::cols) {
+ nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::gutter) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Pixel);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::width) {
+ nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult,
+ eHTMLUnit_Pixel);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::DivAlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -155,18 +168,26 @@ nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLDivElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ 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);
}
NS_IMETHODIMP
nsHTMLDivElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp b/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp
index 660906d04a2..d13ee91e26e 100644
--- a/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -130,11 +130,11 @@ nsHTMLEmbedElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -148,11 +148,11 @@ nsHTMLEmbedElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -166,7 +166,7 @@ nsHTMLEmbedElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLFontElement.cpp b/mozilla/layout/html/content/src/nsHTMLFontElement.cpp
index 3daf247b8b2..4d4c67cef18 100644
--- a/mozilla/layout/html/content/src/nsHTMLFontElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLFontElement.cpp
@@ -23,16 +23,18 @@
#include "nsGenericHTMLElement.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
+#include "nsIDeviceContext.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
+#include "nsStyleUtil.h"
#include "nsIPresContext.h"
static NS_DEFINE_IID(kIDOMHTMLFontElementIID, NS_IDOMHTMLFONTELEMENT_IID);
class nsHTMLFontElement : public nsIDOMHTMLFontElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLFontElement(nsIAtom* aTag);
@@ -71,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -135,33 +137,182 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,
nsHTMLValue& aResult)
{
- // XXX write me
+ if ((aAttribute == nsHTMLAtoms::size) ||
+ (aAttribute == nsHTMLAtoms::pointSize) ||
+ (aAttribute == nsHTMLAtoms::fontWeight)) {
+ nsAutoString tmp(aValue);
+ PRInt32 ec, v = tmp.ToInteger(&ec);
+ tmp.CompressWhitespace(PR_TRUE, PR_FALSE);
+ PRUnichar ch = tmp.First();
+ aResult.SetIntValue(v, ((ch == '+') || (ch == '-')) ?
+ eHTMLUnit_Integer : eHTMLUnit_Enumerated);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::color) {
+ nsGenericHTMLElement::ParseColor(aValue, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if ((aAttribute == nsHTMLAtoms::size) ||
+ (aAttribute == nsHTMLAtoms::pointSize) ||
+ (aAttribute == nsHTMLAtoms::fontWeight)) {
+ aResult.Truncate();
+ if (aValue.GetUnit() == eHTMLUnit_Enumerated) {
+ aResult.Append(aValue.GetIntValue(), 10);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ else if (aValue.GetUnit() == eHTMLUnit_Integer) {
+ PRInt32 value = aValue.GetIntValue();
+ if (value >= 0) {
+ aResult.Append('+');
+ }
+ aResult.Append(value, 10);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ return NS_CONTENT_ATTR_NOT_THERE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleFont* font = (nsStyleFont*)
+ aContext->GetMutableStyleData(eStyleStruct_Font);
+ const nsStyleFont* parentFont = font;
+ nsIStyleContext* parentContext = aContext->GetParent();
+ if (nsnull != parentContext) {
+ parentFont = (const nsStyleFont*)
+ parentContext->GetStyleData(eStyleStruct_Font);
+ }
+ const nsFont& defaultFont = aPresContext->GetDefaultFont();
+ const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFont();
+
+ // face: string list
+ GetAttribute(nsHTMLAtoms::face, value);
+ if (value.GetUnit() == eHTMLUnit_String) {
+
+ nsIDeviceContext* dc = aPresContext->GetDeviceContext();
+ if (nsnull != dc) {
+ nsAutoString familyList;
+
+ value.GetStringValue(familyList);
+
+ font->mFont.name = familyList;
+ nsAutoString face;
+ if (NS_OK == dc->FirstExistingFont(font->mFont, face)) {
+ if (face.EqualsIgnoreCase("monospace")) {
+ font->mFont = font->mFixedFont;
+ }
+ else {
+ font->mFixedFont.name = familyList;
+ }
+ }
+ else {
+ font->mFont.name = defaultFont.name;
+ font->mFixedFont.name= defaultFixedFont.name;
+ }
+ font->mFlags |= NS_STYLE_FONT_FACE_EXPLICIT;
+ NS_RELEASE(dc);
+ }
+ }
+
+ // pointSize: int, enum
+ GetAttribute(nsHTMLAtoms::pointSize, value);
+ if (value.GetUnit() == eHTMLUnit_Integer) {
+ // XXX should probably sanitize value
+ font->mFont.size = parentFont->mFont.size +
+ NSIntPointsToTwips(value.GetIntValue());
+ font->mFixedFont.size = parentFont->mFixedFont.size +
+ NSIntPointsToTwips(value.GetIntValue());
+ font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;
+ }
+ else if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ font->mFont.size = NSIntPointsToTwips(value.GetIntValue());
+ font->mFixedFont.size = NSIntPointsToTwips(value.GetIntValue());
+ font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;
+ }
+ else {
+ // 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);
+ if ((value.GetUnit() == eHTMLUnit_Integer) ||
+ (value.GetUnit() == eHTMLUnit_Enumerated)) {
+ PRInt32 size = value.GetIntValue();
+
+ if (value.GetUnit() == eHTMLUnit_Integer) { // int (+/-)
+ size = 3 + size; // XXX should be BASEFONT, not three
+ }
+ size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
+ PRInt32 scaler = aPresContext->GetFontScaler();
+ float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
+ font->mFont.size =
+ nsStyleUtil::CalcFontPointSize(size, (PRInt32)defaultFont.size,
+ scaleFactor);
+ font->mFixedFont.size =
+ nsStyleUtil::CalcFontPointSize(size,
+ (PRInt32)defaultFixedFont.size,
+ scaleFactor);
+ }
+ }
+ }
+
+ // fontWeight: int, enum
+ GetAttribute(nsHTMLAtoms::fontWeight, value);
+ if (value.GetUnit() == eHTMLUnit_Integer) { // +/-
+ PRInt32 weight = parentFont->mFont.weight + value.GetIntValue();
+ font->mFont.weight =
+ ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);
+ font->mFixedFont.weight =
+ ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);
+ }
+ else if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ PRInt32 weight = value.GetIntValue();
+ weight = ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);
+ font->mFont.weight = weight;
+ font->mFixedFont.weight = weight;
+ }
+
+ // color: color
+ GetAttribute(nsHTMLAtoms::color, value);
+ if (value.GetUnit() == eHTMLUnit_Color) {
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ color->mColor = value.GetColorValue();
+ }
+ else if (value.GetUnit() == eHTMLUnit_String) {
+ nsAutoString buffer;
+ value.GetStringValue(buffer);
+ char cbuf[40];
+ buffer.ToCString(cbuf, sizeof(cbuf));
+
+ nsStyleColor* color = (nsStyleColor*)
+ aContext->GetMutableStyleData(eStyleStruct_Color);
+ NS_ColorNameToRGB(cbuf, &(color->mColor));
+ }
+
+ NS_IF_RELEASE(parentContext);
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLFontElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLFormElement.cpp b/mozilla/layout/html/content/src/nsHTMLFormElement.cpp
index c0e070be8e2..3db62773f3b 100644
--- a/mozilla/layout/html/content/src/nsHTMLFormElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLFormElement.cpp
@@ -79,7 +79,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -191,7 +191,7 @@ nsHTMLFormElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp b/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp
index c6947dafc7c..6c293dcc41f 100644
--- a/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp
@@ -81,7 +81,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -168,7 +168,7 @@ nsHTMLFrameElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp b/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp
index 9eb22def7d4..e0378c59d7b 100644
--- a/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLFrameSetElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLHRElement.cpp b/mozilla/layout/html/content/src/nsHTMLHRElement.cpp
index 6c6c4f8fcbe..b0911864657 100644
--- a/mozilla/layout/html/content/src/nsHTMLHRElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLHRElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -133,7 +133,7 @@ NS_IMPL_BOOL_ATTR(nsHTMLHRElement, NoShade, noshade, eSetAttrNotify_Render)
NS_IMPL_STRING_ATTR(nsHTMLHRElement, Size, size, eSetAttrNotify_Reflow)
NS_IMPL_STRING_ATTR(nsHTMLHRElement, Width, width, eSetAttrNotify_Reflow)
-static nsHTMLGenericContent::EnumTable kAlignTable[] = {
+static nsGenericHTMLElement::EnumTable kAlignTable[] = {
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
{ "center", NS_STYLE_TEXT_ALIGN_CENTER },
@@ -146,12 +146,12 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::width) {
- nsHTMLGenericContent::ParseValueOrPercent(aValue, aResult,
+ nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult,
eHTMLUnit_Pixel);
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::size) {
- nsHTMLGenericContent::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel);
+ nsGenericHTMLElement::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel);
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::noshade) {
@@ -159,7 +159,7 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute,
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseEnumValue(aValue, kAlignTable, aResult)) {
+ if (nsGenericHTMLElement::ParseEnumValue(aValue, kAlignTable, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -173,7 +173,7 @@ nsHTMLHRElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::EnumValueToString(aValue, kAlignTable, aResult);
+ nsGenericHTMLElement::EnumValueToString(aValue, kAlignTable, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -207,7 +207,7 @@ nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext,
pos->mWidth.SetPercentValue(value.GetPercentValue());
}
}
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp b/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp
index 1e8ab45bd27..562a3230486 100644
--- a/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -144,7 +144,7 @@ NS_IMETHODIMP
nsHTMLHeadElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp b/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp
index cb6ef14aff0..4dbf8375056 100644
--- a/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp
@@ -30,9 +30,9 @@
static NS_DEFINE_IID(kIDOMHTMLHeadingElementIID, NS_IDOMHTMLHEADINGELEMENT_IID);
class nsHTMLHeadingElement : public nsIDOMHTMLHeadingElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLHeadingElement(nsIAtom* aTag);
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -126,36 +126,53 @@ NS_IMPL_STRING_ATTR(nsHTMLHeadingElement, Align, align, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLHeadingElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::align) {
+ if (nsGenericHTMLElement::ParseDivAlignValue(aValue, aResult)) {
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLHeadingElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::align) {
+ if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
+ nsGenericHTMLElement::DivAlignValueToString(aValue, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLHeadingElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ 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);
}
NS_IMETHODIMP
nsHTMLHeadingElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp b/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp
index 6ed7c41f22d..d2f97cebe74 100644
--- a/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -144,7 +144,7 @@ NS_IMETHODIMP
nsHTMLHtmlElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp
index 6306b11c837..3e2e5806fe7 100644
--- a/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp
@@ -85,7 +85,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -174,7 +174,7 @@ nsHTMLIFrameElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLImageElement.cpp b/mozilla/layout/html/content/src/nsHTMLImageElement.cpp
index e0b60a3bb6f..7da315045f9 100644
--- a/mozilla/layout/html/content/src/nsHTMLImageElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLImageElement.cpp
@@ -91,7 +91,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -166,11 +166,11 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -184,11 +184,11 @@ nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -202,7 +202,7 @@ nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
index bfbdcebec5e..a8a17278eaf 100644
--- a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
@@ -105,7 +105,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -242,7 +242,7 @@ nsHTMLInputElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX align
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLInsElement.cpp b/mozilla/layout/html/content/src/nsHTMLInsElement.cpp
index bdd8b1fb01a..7ceff2510b5 100644
--- a/mozilla/layout/html/content/src/nsHTMLInsElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLInsElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLInsElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp b/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp
index 3ed14aff59d..84bfe6fb19d 100644
--- a/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -162,7 +162,7 @@ nsHTMLIsIndexElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLLIElement.cpp b/mozilla/layout/html/content/src/nsHTMLLIElement.cpp
index 80e2d2ebabd..8be6117f6af 100644
--- a/mozilla/layout/html/content/src/nsHTMLLIElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLIElement.cpp
@@ -30,9 +30,9 @@
static NS_DEFINE_IID(kIDOMHTMLLIElementIID, NS_IDOMHTMLLIELEMENT_IID);
class nsHTMLLIElement : public nsIDOMHTMLLIElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLLIElement(nsIAtom* aTag);
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -127,38 +127,72 @@ nsHTMLLIElement::CloneNode(nsIDOMNode** aReturn)
NS_IMPL_STRING_ATTR(nsHTMLLIElement, Type, type, eSetAttrNotify_Reflow)
NS_IMPL_INT_ATTR(nsHTMLLIElement, Value, value, eSetAttrNotify_Reflow)
+static nsGenericHTMLElement::EnumTable kListItemTypeTable[] = {
+ { "circle", NS_STYLE_LIST_STYLE_CIRCLE },
+ { "round", NS_STYLE_LIST_STYLE_CIRCLE },
+ { "square", NS_STYLE_LIST_STYLE_SQUARE },
+ { "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
+ { "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
+ { "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
+ { "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
+ { 0 }
+};
+
NS_IMETHODIMP
nsHTMLLIElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (nsGenericHTMLElement::ParseEnumValue(aValue, kListItemTypeTable,
+ aResult)) {
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
+ else if (aAttribute == nsHTMLAtoms::value) {
+ nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLLIElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListItemTypeTable,
+ aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLLIElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLLIElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp b/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp
index 9404513c32d..bc159662ff9 100644
--- a/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp
@@ -71,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -165,7 +165,7 @@ nsHTMLLabelElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp b/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp
index 642809f348f..48e2ab28970 100644
--- a/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -126,7 +126,7 @@ nsHTMLLayerElement::CloneNode(nsIDOMNode** aReturn)
NS_IMPL_STRING_ATTR(nsHTMLLayerElement, Cite, cite, eSetAttrNotify_None)
-static nsHTMLGenericContent::EnumTable kVisibilityTable[] = {
+static nsGenericHTMLElement::EnumTable kVisibilityTable[] = {
{"hide", NS_STYLE_VISIBILITY_HIDDEN},
{"visible", NS_STYLE_VISIBILITY_VISIBLE},
{0}
@@ -194,7 +194,7 @@ nsHTMLLayerElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::visibility) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::EnumValueToString(aValue, kVisibilityTable, aResult);
+ nsGenericHTMLElement::EnumValueToString(aValue, kVisibilityTable, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -263,9 +263,9 @@ nsHTMLLayerElement::MapAttributesInto(nsIStyleContext* aContext,
}
// Background and bgcolor
-//XXX MapBackgroundAttributesInto(aContext, aPresContext);
+ mInner.MapBackgroundAttributesInto(aContext, aPresContext);
}
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp b/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp
index 1313ee788db..4389532d22d 100644
--- a/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp
@@ -71,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -165,7 +165,7 @@ nsHTMLLegendElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp b/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp
index 3dfd93f064e..89bf51d93ab 100644
--- a/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp
@@ -83,7 +83,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -168,7 +168,7 @@ NS_IMETHODIMP
nsHTMLLinkElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLMapElement.cpp b/mozilla/layout/html/content/src/nsHTMLMapElement.cpp
index 5668db1c1b0..f4ec4c062be 100644
--- a/mozilla/layout/html/content/src/nsHTMLMapElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLMapElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -163,7 +163,7 @@ nsHTMLMapElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp b/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp
index 1880cb63c50..62add355dce 100644
--- a/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp
@@ -27,12 +27,16 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+// XXX nav4 has type= start= (same as OL/UL)
+
+extern nsGenericHTMLElement::EnumTable kListTypeTable[];
+
static NS_DEFINE_IID(kIDOMHTMLMenuElementIID, NS_IDOMHTMLMENUELEMENT_IID);
class nsHTMLMenuElement : public nsIDOMHTMLMenuElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLMenuElement(nsIAtom* aTag);
@@ -67,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -126,36 +130,69 @@ NS_IMPL_BOOL_ATTR(nsHTMLMenuElement, Compact, compact, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLMenuElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
+ aResult)) {
+ aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
+ }
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::start) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLMenuElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListTypeTable, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLMenuElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLMenuElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp b/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp
index 21c93653bdb..b81f8396c8a 100644
--- a/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -153,7 +153,7 @@ NS_IMETHODIMP
nsHTMLMetaElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLModElement.cpp b/mozilla/layout/html/content/src/nsHTMLModElement.cpp
index 31f684098ba..9115745b06f 100644
--- a/mozilla/layout/html/content/src/nsHTMLModElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLModElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLModElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLOListElement.cpp b/mozilla/layout/html/content/src/nsHTMLOListElement.cpp
index 206ab62f18c..c483ab5b2d4 100644
--- a/mozilla/layout/html/content/src/nsHTMLOListElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLOListElement.cpp
@@ -30,9 +30,9 @@
static NS_DEFINE_IID(kIDOMHTMLOListElementIID, NS_IDOMHTMLOLISTELEMENT_IID);
class nsHTMLOListElement : public nsIDOMHTMLOListElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLOListElement(nsIAtom* aTag);
@@ -71,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -127,41 +127,92 @@ nsHTMLOListElement::CloneNode(nsIDOMNode** aReturn)
}
NS_IMPL_BOOL_ATTR(nsHTMLOListElement, Compact, compact, eSetAttrNotify_Reflow)
-NS_IMPL_INT_ATTR(nsHTMLOListElement, Start, compact, eSetAttrNotify_Reflow)
-NS_IMPL_STRING_ATTR(nsHTMLOListElement, Type, compact, eSetAttrNotify_Reflow)
+NS_IMPL_INT_ATTR(nsHTMLOListElement, Start, start, eSetAttrNotify_Reflow)
+NS_IMPL_STRING_ATTR(nsHTMLOListElement, Type, type, eSetAttrNotify_Reflow)
+
+nsGenericHTMLElement::EnumTable kListTypeTable[] = {
+ { "none", NS_STYLE_LIST_STYLE_NONE },
+ { "disc", NS_STYLE_LIST_STYLE_DISC },
+ { "circle", NS_STYLE_LIST_STYLE_CIRCLE },
+ { "round", NS_STYLE_LIST_STYLE_CIRCLE },
+ { "square", NS_STYLE_LIST_STYLE_SQUARE },
+ { "decimal", NS_STYLE_LIST_STYLE_DECIMAL },
+ { "lower-roman", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
+ { "upper-roman", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
+ { "lower-alpha", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
+ { "upper-alpha", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
+ { "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
+ { "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
+ { "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
+ { "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
+ { 0 }
+};
NS_IMETHODIMP
nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
+ aResult)) {
+ aResult.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eHTMLUnit_Enumerated);
+ }
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::start) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLOListElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListTypeTable, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLOListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLOListElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp b/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp
index 8837ceed6d1..6e12754af5c 100644
--- a/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp
@@ -101,7 +101,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -193,11 +193,11 @@ nsHTMLObjectElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute,
+ else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -211,11 +211,11 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
- else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute,
+ else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
@@ -229,7 +229,7 @@ nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext,
mInner.MapImageAlignAttributeInto(aContext, aPresContext);
mInner.MapImageAttributesInto(aContext, aPresContext);
mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp
index 2bc599fcd92..17f5799f1b2 100644
--- a/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -150,7 +150,7 @@ nsHTMLOptGroupElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp b/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp
index cab9b6a3655..26c87b3c42b 100644
--- a/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp
@@ -81,7 +81,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -174,7 +174,7 @@ nsHTMLOptionElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp b/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp
index fa3bffa68d9..1af3c821244 100644
--- a/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp
@@ -32,9 +32,9 @@
static NS_DEFINE_IID(kIDOMHTMLParagraphElementIID, NS_IDOMHTMLPARAGRAPHELEMENT_IID);
class nsHTMLParagraphElement : public nsIDOMHTMLParagraphElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLParagraphElement(nsIAtom* aTag);
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -128,11 +128,11 @@ NS_IMPL_STRING_ATTR(nsHTMLParagraphElement, Align, align, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLParagraphElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if (nsGenericHTMLElement::ParseDivAlignValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -141,12 +141,12 @@ nsHTMLParagraphElement::StringToAttribute(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
if (aAttribute == nsHTMLAtoms::align) {
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
+ nsGenericHTMLElement::DivAlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -155,18 +155,26 @@ nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute,
NS_IMETHODIMP
nsHTMLParagraphElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ 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);
}
NS_IMETHODIMP
nsHTMLParagraphElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLParamElement.cpp b/mozilla/layout/html/content/src/nsHTMLParamElement.cpp
index 1efbffa79e6..b0b3888e855 100644
--- a/mozilla/layout/html/content/src/nsHTMLParamElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLParamElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -156,7 +156,7 @@ nsHTMLParamElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLPreElement.cpp b/mozilla/layout/html/content/src/nsHTMLPreElement.cpp
index 507574ec6aa..967506382ed 100644
--- a/mozilla/layout/html/content/src/nsHTMLPreElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLPreElement.cpp
@@ -27,14 +27,14 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
-// XXX missing nav attributes
+// XXX wrap, variable, cols, tabstop
static NS_DEFINE_IID(kIDOMHTMLPreElementIID, NS_IDOMHTMLPREELEMENT_IID);
class nsHTMLPreElement : public nsIDOMHTMLPreElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLPreElement(nsIAtom* aTag);
@@ -69,7 +69,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -128,45 +128,86 @@ NS_IMPL_INT_ATTR(nsHTMLPreElement, Width, width, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLPreElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- if (aAttribute == nsHTMLAtoms::align) {
- if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) {
+ if ((aAttribute == nsHTMLAtoms::wrap) ||
+ (aAttribute == nsHTMLAtoms::variable)) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::cols) {
+ if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult,
+ eHTMLUnit_Integer)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
+ if (aAttribute == nsHTMLAtoms::width) {
+ if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult,
+ eHTMLUnit_Integer)) {
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ }
+ if (aAttribute == nsHTMLAtoms::tabstop) {
+ PRInt32 ec, tabstop = aValue.ToInteger(&ec);
+ if (tabstop <= 0) {
+ tabstop = 8;
+ }
+ aResult.SetIntValue(tabstop, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLPreElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- if (aAttribute == nsHTMLAtoms::align) {
- if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- nsHTMLGenericContent::AlignValueToString(aValue, aResult);
- return NS_CONTENT_ATTR_HAS_VALUE;
- }
- }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLPreElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+
+ // wrap: empty
+ GetAttribute(nsHTMLAtoms::wrap, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+
+ // variable: empty
+ GetAttribute(nsHTMLAtoms::variable, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ nsStyleFont* font = (nsStyleFont*)
+ aContext->GetMutableStyleData(eStyleStruct_Font);
+ font->mFont.name = "serif";
+ }
+
+ // cols: int
+ GetAttribute(nsHTMLAtoms::cols, value);
+ if (value.GetUnit() == eHTMLUnit_Integer) {
+ // XXX set
+ }
+
+ // tabstop: int
+ if (value.GetUnit() == eHTMLUnit_Integer) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLPreElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp b/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp
index f0b4522dd57..91130983f78 100644
--- a/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -147,7 +147,7 @@ nsHTMLQuoteElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp b/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp
index 504436522b0..745e5fd3747 100644
--- a/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp
@@ -79,7 +79,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
nsString mText;
};
@@ -208,7 +208,7 @@ NS_IMETHODIMP
nsHTMLScriptElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp
index b5c4e777b41..4291d57a267 100644
--- a/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp
@@ -91,7 +91,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -219,7 +219,7 @@ nsHTMLSelectElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp b/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp
index db961cf8f80..f64f6a5a46d 100644
--- a/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericLeafContent mInner;
+ nsGenericHTMLLeafElement mInner;
};
nsresult
@@ -152,7 +152,7 @@ NS_IMETHODIMP
nsHTMLStyleElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp
index 35178ad56d9..e3a2081b48e 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp
@@ -67,7 +67,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -147,7 +147,7 @@ nsHTMLTableCaptionElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp
index 29cb75d57de..29c4f471aee 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp
@@ -95,7 +95,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -202,7 +202,7 @@ nsHTMLTableCellElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp
index 7dc7a63480c..a630d307144 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp
@@ -77,7 +77,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -162,7 +162,7 @@ nsHTMLTableColElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLTableElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableElement.cpp
index be711b1cfb0..4daf4bdf8e9 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableElement.cpp
@@ -101,7 +101,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -306,7 +306,7 @@ nsHTMLTableElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp
index 6188c52f93c..1902ec8b710 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp
@@ -83,7 +83,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -227,7 +227,7 @@ nsHTMLTableRowElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp
index aa0ec1cced0..a2fb451d713 100644
--- a/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp
@@ -73,7 +73,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -184,7 +184,7 @@ nsHTMLTableSectionElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp
index 831f18aeca1..8a9c2be8642 100644
--- a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp
@@ -86,7 +86,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -207,7 +207,7 @@ nsHTMLTextAreaElement::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
diff --git a/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp b/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp
index 49b24c1c3dd..59833e452a5 100644
--- a/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp
@@ -1,152 +1,160 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
- * Version 1.0 (the "NPL"); you may not use this file except in
- * compliance with the NPL. You may obtain a copy of the NPL at
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
- * Software distributed under the NPL is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
- * for the specific language governing rights and limitations under the
- * NPL.
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
*
- * The Initial Developer of this code under the NPL is Netscape
- * Communications Corporation. Portions created by Netscape are
- * Copyright (C) 1998 Netscape Communications Corporation. All Rights
- * Reserved.
+ * The Original Code is Mozilla Communicator client code.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are Copyright (C) 1998
+ * Netscape Communications Corporation. All Rights Reserved.
*/
-#include "nsHTMLParts.h"
-#include "nsHTMLContainer.h"
-#include "nsFrame.h"
+#include "nsIDOMHTMLTitleElement.h"
+#include "nsIScriptObjectOwner.h"
+#include "nsIDOMEventReceiver.h"
+#include "nsIHTMLContent.h"
+#include "nsGenericHTMLElement.h"
+#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
+#include "nsIStyleContext.h"
+#include "nsStyleConsts.h"
+#include "nsIPresContext.h"
#include "nsXIFConverter.h"
-#define nsHTMLTitleElementSuper nsHTMLTagContent
+static NS_DEFINE_IID(kIDOMHTMLTitleElementIID, NS_IDOMHTMLTITLEELEMENT_IID);
-class nsHTMLTitleElement : public nsHTMLTitleElementSuper {
+class nsHTMLTitleElement : public nsIDOMHTMLTitleElement,
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
+{
public:
- nsHTMLTitleElement(nsIAtom* aTag, const nsString& aTitle);
+ nsHTMLTitleElement(nsIAtom* aTag);
+ ~nsHTMLTitleElement();
- NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
- nsIFrame* aParentFrame,
- nsIStyleContext* aStyleContext,
- nsIFrame*& aResult);
+ // nsISupports
+ NS_DECL_ISUPPORTS
- NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
+ // nsIDOMNode
+ NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
+ // nsIDOMElement
+ NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
- NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const;
- NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const;
- NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const;
+ // nsIDOMHTMLElement
+ NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
+
+ // nsIDOMHTMLTitleElement
+ NS_IMETHOD GetText(nsString& aType);
+ NS_IMETHOD SetText(const nsString& aType);
+
+ // nsIScriptObjectOwner
+ NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
+
+ // nsIDOMEventReceiver
+ NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
+
+ // nsIContent
+ NS_IMPL_ICONTENT_USING_GENERIC(mInner)
+
+ // nsIHTMLContent
+ NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- virtual ~nsHTMLTitleElement();
- nsString mTitle;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
-NS_NewHTMLTitle(nsIHTMLContent** aInstancePtrResult,
- nsIAtom* aTag, const nsString& aTitle)
+NS_NewHTMLTitleElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
- nsIHTMLContent* it = new nsHTMLTitleElement(aTag, aTitle);
+ nsIHTMLContent* it = new nsHTMLTitleElement(aTag);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
- return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult);
+ return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
}
-nsHTMLTitleElement::nsHTMLTitleElement(nsIAtom* aTag, const nsString& aTitle)
- : nsHTMLTitleElementSuper(aTag), mTitle(aTitle)
+nsHTMLTitleElement::nsHTMLTitleElement(nsIAtom* aTag)
{
+ NS_INIT_REFCNT();
+ mInner.Init(this, aTag);
}
nsHTMLTitleElement::~nsHTMLTitleElement()
{
}
-NS_IMETHODIMP
-nsHTMLTitleElement::CreateFrame(nsIPresContext* aPresContext,
- nsIFrame* aParentFrame,
- nsIStyleContext* aStyleContext,
- nsIFrame*& aResult)
+NS_IMPL_ADDREF(nsHTMLTitleElement)
+
+NS_IMPL_RELEASE(nsHTMLTitleElement)
+
+nsresult
+nsHTMLTitleElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
- nsIFrame* frame;
- nsFrame::NewFrame(&frame, this, aParentFrame);
- if (nsnull == frame) {
+ NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
+ if (aIID.Equals(kIDOMHTMLTitleElementIID)) {
+ nsIDOMHTMLTitleElement* tmp = this;
+ *aInstancePtr = (void*) tmp;
+ mRefCnt++;
+ return NS_OK;
+ }
+ return NS_NOINTERFACE;
+}
+
+nsresult
+nsHTMLTitleElement::CloneNode(nsIDOMNode** aReturn)
+{
+ nsHTMLTitleElement* it = new nsHTMLTitleElement(mInner.mTag);
+ if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
- frame->SetStyleContext(aPresContext, aStyleContext);
- aResult = frame;
- return NS_OK;
+ mInner.CopyInnerTo(this, &it->mInner);
+ return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
+}
+
+NS_IMPL_STRING_ATTR(nsHTMLTitleElement, Text, text, eSetAttrNotify_Reflow)
+
+NS_IMETHODIMP
+nsHTMLTitleElement::StringToAttribute(nsIAtom* aAttribute,
+ const nsString& aValue,
+ nsHTMLValue& aResult)
+{
+ return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
-nsHTMLTitleElement::List(FILE* out, PRInt32 aIndent) const
+nsHTMLTitleElement::AttributeToString(nsIAtom* aAttribute,
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- NS_PRECONDITION(nsnull != mDocument, "bad content");
-
- PRInt32 index;
- for (index = aIndent; --index >= 0; ) fputs(" ", out);
-
- nsIAtom* tag;
- GetTag(tag);
- if (tag != nsnull) {
- nsAutoString buf;
- tag->ToString(buf);
- fputs(buf, out);
- NS_RELEASE(tag);
- }
-
- ListAttributes(out);
-
- fprintf(out, " RefCount=%d<", mRefCnt);
- fputs(mTitle, out);
- fputs(">\n", out);
- return NS_OK;
-}
-
-/**
- * Translate the content object into the (XIF) XML Interchange Format
- * XIF is an intermediate form of the content model, the buffer
- * will then be parsed into any number of formats including HTML, TXT, etc.
- * These methods must be called in the following order:
-
- BeginConvertToXIF
- ConvertContentToXIF
- EndConvertToXIF
- */
-
-NS_IMETHODIMP
-nsHTMLTitleElement::BeginConvertToXIF(nsXIFConverter& aConverter) const
-{
- if (nsnull != mTag)
- {
- nsAutoString name;
- mTag->ToString(name);
- aConverter.BeginContainer(name);
- }
- return NS_OK;
+ return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
-nsHTMLTitleElement::ConvertContentToXIF(nsXIFConverter& aConverter) const
+nsHTMLTitleElement::MapAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
{
- aConverter.AddContent(mTitle);
- return NS_OK;
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
-nsHTMLTitleElement::FinishConvertToXIF(nsXIFConverter& aConverter) const
+nsHTMLTitleElement::HandleDOMEvent(nsIPresContext& aPresContext,
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
- if (nsnull != mTag)
- {
- nsAutoString name;
- mTag->ToString(name);
- aConverter.EndContainer(name);
- }
- return NS_OK;
+ return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
+ aFlags, aEventStatus);
}
diff --git a/mozilla/layout/html/content/src/nsHTMLUListElement.cpp b/mozilla/layout/html/content/src/nsHTMLUListElement.cpp
index fb7fbaba07a..e461d9a36ca 100644
--- a/mozilla/layout/html/content/src/nsHTMLUListElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLUListElement.cpp
@@ -27,12 +27,14 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+extern nsGenericHTMLElement::EnumTable kListTypeTable[];
+
static NS_DEFINE_IID(kIDOMHTMLUListElementIID, NS_IDOMHTMLULISTELEMENT_IID);
class nsHTMLUListElement : public nsIDOMHTMLUListElement,
- public nsIScriptObjectOwner,
- public nsIDOMEventReceiver,
- public nsIHTMLContent
+ public nsIScriptObjectOwner,
+ public nsIDOMEventReceiver,
+ public nsIHTMLContent
{
public:
nsHTMLUListElement(nsIAtom* aTag);
@@ -69,7 +71,7 @@ public:
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
protected:
- nsHTMLGenericContainerContent mInner;
+ nsGenericHTMLContainerElement mInner;
};
nsresult
@@ -125,40 +127,73 @@ nsHTMLUListElement::CloneNode(nsIDOMNode** aReturn)
}
NS_IMPL_BOOL_ATTR(nsHTMLUListElement, Compact, compact, eSetAttrNotify_Reflow)
-NS_IMPL_STRING_ATTR(nsHTMLUListElement, Type, compact, eSetAttrNotify_Reflow)
+NS_IMPL_STRING_ATTR(nsHTMLUListElement, Type, type, eSetAttrNotify_Reflow)
NS_IMETHODIMP
nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute,
- const nsString& aValue,
- nsHTMLValue& aResult)
+ const nsString& aValue,
+ nsHTMLValue& aResult)
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
+ aResult)) {
+ aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
+ }
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::start) {
+ nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
+ if (aAttribute == nsHTMLAtoms::compact) {
+ aResult.SetEmptyValue();
+ return NS_CONTENT_ATTR_NO_VALUE;
+ }
return NS_CONTENT_ATTR_NOT_THERE;
}
NS_IMETHODIMP
nsHTMLUListElement::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
+ nsHTMLValue& aValue,
+ nsString& aResult) const
{
- // XXX write me
+ if (aAttribute == nsHTMLAtoms::type) {
+ nsGenericHTMLElement::EnumValueToString(aValue, kListTypeTable, aResult);
+ return NS_CONTENT_ATTR_HAS_VALUE;
+ }
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
NS_IMETHODIMP
nsHTMLUListElement::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
+ nsIPresContext* aPresContext)
{
- // XXX write me
- return NS_OK;
+ if (nsnull != mInner.mAttributes) {
+ nsHTMLValue value;
+ nsStyleList* list = (nsStyleList*)
+ aContext->GetMutableStyleData(eStyleStruct_List);
+
+ // type: enum
+ GetAttribute(nsHTMLAtoms::type, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ list->mListStyleType = value.GetIntValue();
+ }
+
+ // compact: empty
+ GetAttribute(nsHTMLAtoms::compact, value);
+ if (value.GetUnit() == eHTMLUnit_Empty) {
+ // XXX set
+ }
+ }
+ return mInner.MapAttributesInto(aContext, aPresContext);
}
NS_IMETHODIMP
nsHTMLUListElement::HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus)
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
diff --git a/mozilla/layout/html/content/src/nsObjectContent.cpp b/mozilla/layout/html/content/src/nsObjectContent.cpp
deleted file mode 100644
index 1b2b340a7d4..00000000000
--- a/mozilla/layout/html/content/src/nsObjectContent.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * The contents of this file are subject to the Netscape Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/NPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is Netscape Communications
- * Corporation. Portions created by Netscape are Copyright (C) 1998
- * Netscape Communications Corporation. All Rights Reserved.
- */
-#include "nsObjectContent.h"
-#include "nsHTMLParts.h"
-#include "nsHTMLIIDs.h"
-#include "nsHTMLAtoms.h"
-#include "nsIStyleContext.h"
-#include "nsIPresContext.h"
-#include "nsStyleConsts.h"
-
-nsObjectContent::nsObjectContent(nsIAtom* aTag)
- : nsObjectContentSuper(aTag)
-{
-}
-
-nsObjectContent::~nsObjectContent()
-{
-}
-
-NS_IMETHODIMP
-nsObjectContent::CreateFrame(nsIPresContext* aPresContext,
- nsIFrame* aParentFrame,
- nsIStyleContext* aStyleContext,
- nsIFrame*& aResult)
-{
- nsIFrame* frame;
- nsresult rv = NS_NewObjectFrame(this, aParentFrame, frame);
- if (NS_OK != rv) {
- return rv;
- }
- frame->SetStyleContext(aPresContext, aStyleContext);
- aResult = frame;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsObjectContent::SetAttribute(nsIAtom* aAttribute, const nsString& aString,
- PRBool aNotify)
-{
- nsHTMLValue val;
- if (aAttribute == nsHTMLAtoms::align) {
- if (ParseAlignParam(aString, val)) {
- // Reflect the attribute into the syle system
- return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify);
- }
- }
- else if (ParseImageProperty(aAttribute, aString, val)) {
- return nsHTMLTagContent::SetAttribute(aAttribute, val, aNotify);
- }
- return nsObjectContentSuper::SetAttribute(aAttribute, aString, aNotify);
-}
-
-NS_IMETHODIMP
-nsObjectContent::AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const
-{
- nsresult ca = NS_CONTENT_ATTR_NOT_THERE;
- if (aAttribute == nsHTMLAtoms::align) {
- if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
- AlignParamToString(aValue, aResult);
- ca = NS_CONTENT_ATTR_HAS_VALUE;
- }
- }
- else if (ImagePropertyToString(aAttribute, aValue, aResult)) {
- ca = NS_CONTENT_ATTR_HAS_VALUE;
- }
- return ca;
-}
-
-NS_IMETHODIMP
-nsObjectContent::MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext)
-{
- if (nsnull != mAttributes) {
- nsHTMLValue value;
- GetAttribute(nsHTMLAtoms::align, value);
- if (value.GetUnit() == eHTMLUnit_Enumerated) {
- PRUint8 align = value.GetIntValue();
- nsStyleDisplay* display = (nsStyleDisplay*)
- aContext->GetMutableStyleData(eStyleStruct_Display);
- nsStyleText* text = (nsStyleText*)
- aContext->GetMutableStyleData(eStyleStruct_Text);
- nsStyleSpacing* spacing = (nsStyleSpacing*)
- aContext->GetMutableStyleData(eStyleStruct_Spacing);
- float p2t = aPresContext->GetPixelsToTwips();
- nsStyleCoord three(NSIntPixelsToTwips(3, p2t));
- switch (align) {
- case NS_STYLE_TEXT_ALIGN_LEFT:
- display->mFloats = NS_STYLE_FLOAT_LEFT;
- spacing->mMargin.SetLeft(three);
- spacing->mMargin.SetRight(three);
- break;
- case NS_STYLE_TEXT_ALIGN_RIGHT:
- display->mFloats = NS_STYLE_FLOAT_RIGHT;
- spacing->mMargin.SetLeft(three);
- spacing->mMargin.SetRight(three);
- break;
- default:
- text->mVerticalAlign.SetIntValue(align, eStyleUnit_Enumerated);
- break;
- }
- }
- }
- MapImagePropertiesInto(aContext, aPresContext);
- MapImageBorderInto(aContext, aPresContext, nsnull);
- return NS_OK;
-}
diff --git a/mozilla/layout/html/content/src/nsObjectContent.h b/mozilla/layout/html/content/src/nsObjectContent.h
deleted file mode 100644
index 727b649bf55..00000000000
--- a/mozilla/layout/html/content/src/nsObjectContent.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * The contents of this file are subject to the Netscape Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/NPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is Netscape Communications
- * Corporation. Portions created by Netscape are Copyright (C) 1998
- * Netscape Communications Corporation. All Rights Reserved.
- */
-#ifndef nsObjectContent_h___
-#define nsObjectContent_h___
-
-#include "nsHTMLContainer.h"
-#include "nsFrame.h"
-
-#define nsObjectContentSuper nsHTMLContainer
-
-class nsObjectContent : public nsObjectContentSuper {
-public:
- NS_IMETHOD CreateFrame(nsIPresContext* aPresContext,
- nsIFrame* aParentFrame,
- nsIStyleContext* aStyleContext,
- nsIFrame*& aResult);
- NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aString,
- PRBool aNotify);
- NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext,
- nsIPresContext* aPresContext);
- NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
- nsHTMLValue& aValue,
- nsString& aResult) const;
-
-protected:
- nsObjectContent(nsIAtom* aTag);
- virtual ~nsObjectContent();
-};
-
-#endif /* nsObjectContent_h___ */