diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index f7d47d62a6f..d3700fca760 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -22,6 +22,14 @@ #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" +nsContentList::nsContentList(nsIDocument *aDocument) +{ + NS_INIT_REFCNT(); + mScriptObject = nsnull; + mFunc = nsnull; + mMatchTag = nsnull; + mDocument = aDocument; +} nsContentList::nsContentList(nsIDocument *aDocument, const nsString& aMatchTag) @@ -189,7 +197,7 @@ nsContentList::NamedItem(const nsString& aName, nsIDOMNode** aReturn) nsAutoString name; // XXX Should it be an EqualsIgnoreCase? if (((content->GetAttribute("NAME", name) == eContentAttr_HasValue) && - (aName.Equals(name))) || + (aName.Equals(name))) || ((content->GetAttribute("ID", name) == eContentAttr_HasValue) && (aName.Equals(name)))) { return content->QueryInterface(kIDOMNodeIID, (void **)aReturn); diff --git a/mozilla/content/base/src/nsContentList.h b/mozilla/content/base/src/nsContentList.h index 0fcf652e2e7..be8ef4dff47 100644 --- a/mozilla/content/base/src/nsContentList.h +++ b/mozilla/content/base/src/nsContentList.h @@ -31,6 +31,8 @@ typedef PRBool (*nsContentListMatchFunc)(nsIContent *aContent); class nsIDocument; class nsContentList : public nsIDOMNodeList, public nsIDOMHTMLCollection, public nsIScriptObjectOwner, public nsIDocumentObserver { +protected: + nsContentList(nsIDocument *aDocument); public: nsContentList(nsIDocument *aDocument, const nsString& aMatchTag); nsContentList(nsIDocument *aDocument, nsContentListMatchFunc aFunc); diff --git a/mozilla/content/events/src/nsDOMEvent.h b/mozilla/content/events/src/nsDOMEvent.h index 578b9d1fa0a..ddd4a0b1f10 100644 --- a/mozilla/content/events/src/nsDOMEvent.h +++ b/mozilla/content/events/src/nsDOMEvent.h @@ -20,6 +20,7 @@ #define nsDOMEvent_h__ #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsISupports.h" #include "nsIPrivateDOMEvent.h" diff --git a/mozilla/content/html/content/public/nsIHTMLContent.h b/mozilla/content/html/content/public/nsIHTMLContent.h index a493b9945b5..8313a240cb5 100644 --- a/mozilla/content/html/content/public/nsIHTMLContent.h +++ b/mozilla/content/html/content/public/nsIHTMLContent.h @@ -51,6 +51,8 @@ public: virtual nsContentAttr GetAttribute(const nsString& aName, nsString& aResult) const = 0; + virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const = 0; virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const = 0; virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const = 0; diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.cpp b/mozilla/content/html/content/src/nsHTMLAtoms.cpp index a6c3a416407..de882862c20 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.cpp +++ b/mozilla/content/html/content/src/nsHTMLAtoms.cpp @@ -21,6 +21,7 @@ nsIAtom* nsHTMLAtoms::_baseHref; nsIAtom* nsHTMLAtoms::_baseTarget; nsIAtom* nsHTMLAtoms::a; nsIAtom* nsHTMLAtoms::above; +nsIAtom* nsHTMLAtoms::acceptcharset; nsIAtom* nsHTMLAtoms::action; nsIAtom* nsHTMLAtoms::active; nsIAtom* nsHTMLAtoms::align; @@ -56,6 +57,7 @@ nsIAtom* nsHTMLAtoms::disabled; nsIAtom* nsHTMLAtoms::div; nsIAtom* nsHTMLAtoms::dl; nsIAtom* nsHTMLAtoms::encoding; +nsIAtom* nsHTMLAtoms::enctype; nsIAtom* nsHTMLAtoms::face; nsIAtom* nsHTMLAtoms::font; nsIAtom* nsHTMLAtoms::fontWeight; @@ -83,6 +85,7 @@ nsIAtom* nsHTMLAtoms::li; nsIAtom* nsHTMLAtoms::link; nsIAtom* nsHTMLAtoms::left; nsIAtom* nsHTMLAtoms::leftpadding; +nsIAtom* nsHTMLAtoms::longdesc; nsIAtom* nsHTMLAtoms::lowsrc; nsIAtom* nsHTMLAtoms::marginheight; nsIAtom* nsHTMLAtoms::marginwidth; @@ -143,6 +146,7 @@ nsIAtom* nsHTMLAtoms::table; nsIAtom* nsHTMLAtoms::tabstop; nsIAtom* nsHTMLAtoms::target; nsIAtom* nsHTMLAtoms::text; +nsIAtom* nsHTMLAtoms::title; nsIAtom* nsHTMLAtoms::top; nsIAtom* nsHTMLAtoms::toppadding; nsIAtom* nsHTMLAtoms::type; @@ -169,6 +173,7 @@ void nsHTMLAtoms::AddrefAtoms() _baseTarget = NS_NewAtom(NS_HTML_BASE_TARGET); a = NS_NewAtom("A"); above = NS_NewAtom("ABOVE"); + acceptcharset = NS_NewAtom("ACCEPTCHARSET"); action = NS_NewAtom("ACTION"); active = NS_NewAtom("ACTIVE"); align = NS_NewAtom("ALIGN"); @@ -204,6 +209,7 @@ void nsHTMLAtoms::AddrefAtoms() dl = NS_NewAtom("DL"); data = NS_NewAtom("DATA"); encoding = NS_NewAtom("ENCODING"); + enctype = NS_NewAtom("ENCTYPE"); face = NS_NewAtom("FACE"); font = NS_NewAtom("FONT"); fontWeight = NS_NewAtom("FONT-WEIGHT"); @@ -291,6 +297,7 @@ void nsHTMLAtoms::AddrefAtoms() tabstop = NS_NewAtom("TABSTOP"); target = NS_NewAtom("TARGET"); text = NS_NewAtom("TEXT"); + title = NS_NewAtom("TITLE"); top = NS_NewAtom("TOP"); toppadding = NS_NewAtom("TOPPADDING"); type = NS_NewAtom("TYPE"); diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.h b/mozilla/content/html/content/src/nsHTMLAtoms.h index 124d1a1c55b..af9c02d3082 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.h +++ b/mozilla/content/html/content/src/nsHTMLAtoms.h @@ -42,6 +42,7 @@ public: // Alphabetical list of html attribute atoms static nsIAtom* a; static nsIAtom* above; + static nsIAtom* acceptcharset; static nsIAtom* action; static nsIAtom* active; static nsIAtom* align; @@ -81,6 +82,7 @@ public: static nsIAtom* dl; static nsIAtom* encoding; + static nsIAtom* enctype; static nsIAtom* face; static nsIAtom* font; @@ -113,6 +115,7 @@ public: static nsIAtom* link; static nsIAtom* left; static nsIAtom* leftpadding; + static nsIAtom* longdesc; static nsIAtom* lowsrc; static nsIAtom* marginheight; @@ -180,6 +183,7 @@ public: static nsIAtom* tabstop; static nsIAtom* target; static nsIAtom* text; + static nsIAtom* title; static nsIAtom* top; static nsIAtom* toppadding; static nsIAtom* type; diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 385f21b4429..6e5c708e015 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -563,6 +563,9 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode) GetAttributeValueAt(aNode, i, v); mCurrentForm->SetAttribute(k, v); } + // XXX Temporary code till forms become real content + // Add the form to the document + ((nsHTMLDocument*)mDocument)->AddForm(mCurrentForm); } return NS_OK; diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 244522739f2..847e30d7fff 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -40,6 +40,7 @@ #include "nsIScriptGlobalObject.h" #include "nsContentList.h" #include "nsINetService.h" +#include "nsIFormManager.h" #include "nsRepository.h" #include "nsParserCIID.h" @@ -50,6 +51,7 @@ static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID); +static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID); static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID); static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID); static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); @@ -71,17 +73,31 @@ nsHTMLDocument::nsHTMLDocument() mEmbeds = nsnull; mLinks = nsnull; mAnchors = nsnull; + mForms = nsnull; + mNamedItems = nsnull; mParser = nsnull; nsHTMLAtoms::AddrefAtoms(); } nsHTMLDocument::~nsHTMLDocument() { + // XXX Temporary code till forms become real content + int i, count = mTempForms.Count(); + for (i = 0; i < count; i++) { + nsIFormManager *form = (nsIFormManager *)mTempForms.ElementAt(i); + if (nsnull != form) { + NS_RELEASE(form); + } + } + if (nsnull != mNamedItems) { + PL_HashTableDestroy(mNamedItems); + } NS_IF_RELEASE(mImages); NS_IF_RELEASE(mApplets); NS_IF_RELEASE(mEmbeds); NS_IF_RELEASE(mLinks); NS_IF_RELEASE(mAnchors); + NS_IF_RELEASE(mForms); NS_IF_RELEASE(mAttrStyleSheet); NS_IF_RELEASE(mParser); // XXX don't bother doing this until the dll is unloaded??? @@ -274,6 +290,55 @@ NS_IMETHODIMP nsHTMLDocument::GetImageMap(const nsString& aMapName, return 1;/* XXX NS_NOT_FOUND */ } +// XXX Temporary form methods. Forms will soon become actual content +// elements. For now, the document keeps a list of them. +NS_IMETHODIMP +nsHTMLDocument::AddForm(nsIFormManager *aForm) +{ + NS_PRECONDITION(nsnull != aForm, "null ptr"); + if (nsnull == aForm) { + return NS_ERROR_NULL_POINTER; + } + if (mTempForms.AppendElement(aForm)) { + NS_ADDREF(aForm); + return NS_OK; + } + return NS_ERROR_OUT_OF_MEMORY; +} + +NS_IMETHODIMP_(PRInt32) +nsHTMLDocument::GetFormCount() const +{ + return mTempForms.Count(); +} + +NS_IMETHODIMP +nsHTMLDocument::GetFormAt(PRInt32 aIndex, nsIFormManager **aForm) const +{ + *aForm = (nsIFormManager *)mTempForms.ElementAt(aIndex); + + if (nsnull != *aForm) { + NS_ADDREF(*aForm); + return NS_OK; + } + + return 1;/* XXX NS_NOT_FOUND */ +} + +NS_IMETHODIMP +nsHTMLDocument::AddNamedItem(const nsString& aName, nsIContent *aContent) +{ + //XXX TBI + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsHTMLDocument::RemoveNamedItem(const nsString& aName) +{ + //XXX TBI + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsHTMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult) { NS_PRECONDITION(nsnull != aResult, "null ptr"); @@ -287,7 +352,6 @@ NS_IMETHODIMP nsHTMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult return NS_OK; } - void nsHTMLDocument::AddStyleSheetToSet(nsIStyleSheet* aSheet, nsIStyleSet* aSet) { if ((nsnull != mAttrStyleSheet) && (aSheet != mAttrStyleSheet)) { @@ -480,13 +544,57 @@ nsHTMLDocument::GetLinks(nsIDOMHTMLCollection** aLinks) return NS_OK; } +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + +// XXX Temporary till form becomes real content + +class nsTempFormContentList : public nsContentList { +public: + nsTempFormContentList(nsHTMLDocument *aDocument); + ~nsTempFormContentList(); +}; + +nsTempFormContentList::nsTempFormContentList(nsHTMLDocument *aDocument) : nsContentList(aDocument) +{ + PRInt32 i, count = aDocument->GetFormCount(); + for (i=0; i < count; i++) { + nsIFormManager *form; + + if (NS_OK == aDocument->GetFormAt(i, &form)) { + nsIContent *content; + if (NS_OK == form->QueryInterface(kIContentIID, (void **)&content)) { + Add(content); + NS_RELEASE(content); + } + NS_RELEASE(form); + } + } +} + +nsTempFormContentList::~nsTempFormContentList() +{ + mDocument = nsnull; +} + NS_IMETHODIMP nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms) { - //XXX TBI - return NS_ERROR_NOT_IMPLEMENTED; + if (nsnull == mForms) { + mForms = new nsTempFormContentList(this); + if (nsnull == mForms) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mForms); + } + + *aForms = (nsIDOMHTMLCollection *)mForms; + NS_ADDREF(mForms); + + return NS_OK; } +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + PRBool nsHTMLDocument::MatchAnchors(nsIContent *aContent) { @@ -637,6 +745,11 @@ nsHTMLDocument::GetElementsByName(const nsString& aElementName, nsIDOMNodeList** return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsHTMLDocument::GetNamedItem(const nsString& aName, nsIDOMElement **aReturn) +{ + return NS_OK; +} NS_IMETHODIMP nsHTMLDocument::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 854724a26e5..7fe15b68570 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -22,6 +22,7 @@ #include "nsMarkupDocument.h" #include "nsIHTMLDocument.h" #include "nsIDOMHTMLDocument.h" +#include "plhash.h" class nsIHTMLStyleSheet; class nsContentList; @@ -50,6 +51,21 @@ public: NS_IMETHOD GetImageMap(const nsString& aMapName, nsIImageMap** aResult); + // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + // XXX Temporary form methods. Forms will soon become actual content + // elements. For now, the document keeps a list of them. + NS_IMETHOD AddForm(nsIFormManager *aForm); + + NS_IMETHOD_(PRInt32) GetFormCount() const; + + NS_IMETHOD GetFormAt(PRInt32 aIndex, nsIFormManager **aForm) const; + // XXX + // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + + NS_IMETHOD AddNamedItem(const nsString& aName, nsIContent *aContent); + + NS_IMETHOD RemoveNamedItem(const nsString& aName); + NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aStyleSheet); // nsIDOMDocument interface @@ -78,40 +94,7 @@ public: { return nsDocument::GetElementsByTagName(aTagname, aReturn); } // nsIDOMNode interface - NS_IMETHOD GetNodeName(nsString& aNodeName) - { return nsDocument::GetNodeName(aNodeName); } - NS_IMETHOD GetNodeValue(nsString& aNodeValue) - { return nsDocument::GetNodeValue(aNodeValue); } - NS_IMETHOD SetNodeValue(const nsString& aNodeValue) - { return nsDocument::SetNodeValue(aNodeValue); } - NS_IMETHOD GetNodeType(PRInt32* aNodeType) - { return nsDocument::GetNodeType(aNodeType); } - NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) - { return nsDocument::GetParentNode(aParentNode); } - NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) - { return nsDocument::GetChildNodes(aChildNodes); } - NS_IMETHOD GetHasChildNodes(PRBool* aHasChildNodes) - { return nsDocument::GetHasChildNodes(aHasChildNodes); } - NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) - { return nsDocument::GetFirstChild(aFirstChild); } - NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) - { return nsDocument::GetLastChild(aLastChild); } - NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) - { return nsDocument::GetPreviousSibling(aPreviousSibling); } - NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) - { return nsDocument::GetNextSibling(aNextSibling); } - NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) - { return nsDocument::GetAttributes(aAttributes); } - NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn) - { return nsDocument::InsertBefore(aNewChild, aRefChild, aReturn); } - NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn) - { return nsDocument::ReplaceChild(aNewChild, aOldChild, aReturn); } - NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) - { return nsDocument::RemoveChild(aOldChild, aReturn); } - NS_IMETHOD CloneNode(nsIDOMNode** aReturn) - { return nsDocument::CloneNode(aReturn); } - NS_IMETHOD Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn) - { return nsDocument::Equals(aNode, aDeep, aReturn); } + NS_FORWARD_IDOMNODE(nsDocument) // nsIDOMHTMLDocument interface NS_IMETHOD GetTitle(nsString& aTitle); @@ -137,6 +120,7 @@ public: NS_IMETHOD Writeln(JSContext *cx, jsval *argv, PRUint32 argc); NS_IMETHOD GetElementById(const nsString& aElementId, nsIDOMElement** aReturn); NS_IMETHOD GetElementsByName(const nsString& aElementName, nsIDOMNodeList** aReturn); + NS_IMETHOD GetNamedItem(const nsString& aName, nsIDOMElement **aReturn); // From nsIScriptObjectOwner interface, implemented by nsDocument NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); @@ -148,12 +132,16 @@ protected: nsIHTMLStyleSheet* mAttrStyleSheet; nsVoidArray mImageMaps; + nsVoidArray mTempForms; // XXX Temporary nsContentList *mImages; nsContentList *mApplets; nsContentList *mEmbeds; nsContentList *mLinks; nsContentList *mAnchors; + nsContentList *mForms; + + PLHashTable *mNamedItems; nsIParser *mParser; }; diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h index 29a35ecfa02..1b2e04482f2 100644 --- a/mozilla/content/html/document/src/nsIHTMLDocument.h +++ b/mozilla/content/html/document/src/nsIHTMLDocument.h @@ -21,6 +21,7 @@ #include "nsISupports.h" class nsIImageMap; class nsString; +class nsIFormManager; class nsIHTMLStyleSheet; /* b2a848b0-d0a9-11d1-89b1-006008911b81 */ @@ -38,6 +39,21 @@ public: NS_IMETHOD GetImageMap(const nsString& aMapName, nsIImageMap** aResult) = 0; + // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + // XXX Temporary form methods. Forms will soon become actual content + // elements. For now, the document keeps a list of them. + NS_IMETHOD AddForm(nsIFormManager *aForm) = 0; + + NS_IMETHOD_(PRInt32) GetFormCount() const = 0; + + NS_IMETHOD GetFormAt(PRInt32 aIndex, nsIFormManager **aForm) const = 0; + // XXX + // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + + NS_IMETHOD AddNamedItem(const nsString& aName, nsIContent *aContent) = 0; + + NS_IMETHOD RemoveNamedItem(const nsString& aName) = 0; + NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aStyleSheet) = 0; }; diff --git a/mozilla/content/shared/public/nsHTMLAtoms.h b/mozilla/content/shared/public/nsHTMLAtoms.h index 124d1a1c55b..af9c02d3082 100644 --- a/mozilla/content/shared/public/nsHTMLAtoms.h +++ b/mozilla/content/shared/public/nsHTMLAtoms.h @@ -42,6 +42,7 @@ public: // Alphabetical list of html attribute atoms static nsIAtom* a; static nsIAtom* above; + static nsIAtom* acceptcharset; static nsIAtom* action; static nsIAtom* active; static nsIAtom* align; @@ -81,6 +82,7 @@ public: static nsIAtom* dl; static nsIAtom* encoding; + static nsIAtom* enctype; static nsIAtom* face; static nsIAtom* font; @@ -113,6 +115,7 @@ public: static nsIAtom* link; static nsIAtom* left; static nsIAtom* leftpadding; + static nsIAtom* longdesc; static nsIAtom* lowsrc; static nsIAtom* marginheight; @@ -180,6 +183,7 @@ public: static nsIAtom* tabstop; static nsIAtom* target; static nsIAtom* text; + static nsIAtom* title; static nsIAtom* top; static nsIAtom* toppadding; static nsIAtom* type; diff --git a/mozilla/content/shared/src/nsHTMLAtoms.cpp b/mozilla/content/shared/src/nsHTMLAtoms.cpp index a6c3a416407..de882862c20 100644 --- a/mozilla/content/shared/src/nsHTMLAtoms.cpp +++ b/mozilla/content/shared/src/nsHTMLAtoms.cpp @@ -21,6 +21,7 @@ nsIAtom* nsHTMLAtoms::_baseHref; nsIAtom* nsHTMLAtoms::_baseTarget; nsIAtom* nsHTMLAtoms::a; nsIAtom* nsHTMLAtoms::above; +nsIAtom* nsHTMLAtoms::acceptcharset; nsIAtom* nsHTMLAtoms::action; nsIAtom* nsHTMLAtoms::active; nsIAtom* nsHTMLAtoms::align; @@ -56,6 +57,7 @@ nsIAtom* nsHTMLAtoms::disabled; nsIAtom* nsHTMLAtoms::div; nsIAtom* nsHTMLAtoms::dl; nsIAtom* nsHTMLAtoms::encoding; +nsIAtom* nsHTMLAtoms::enctype; nsIAtom* nsHTMLAtoms::face; nsIAtom* nsHTMLAtoms::font; nsIAtom* nsHTMLAtoms::fontWeight; @@ -83,6 +85,7 @@ nsIAtom* nsHTMLAtoms::li; nsIAtom* nsHTMLAtoms::link; nsIAtom* nsHTMLAtoms::left; nsIAtom* nsHTMLAtoms::leftpadding; +nsIAtom* nsHTMLAtoms::longdesc; nsIAtom* nsHTMLAtoms::lowsrc; nsIAtom* nsHTMLAtoms::marginheight; nsIAtom* nsHTMLAtoms::marginwidth; @@ -143,6 +146,7 @@ nsIAtom* nsHTMLAtoms::table; nsIAtom* nsHTMLAtoms::tabstop; nsIAtom* nsHTMLAtoms::target; nsIAtom* nsHTMLAtoms::text; +nsIAtom* nsHTMLAtoms::title; nsIAtom* nsHTMLAtoms::top; nsIAtom* nsHTMLAtoms::toppadding; nsIAtom* nsHTMLAtoms::type; @@ -169,6 +173,7 @@ void nsHTMLAtoms::AddrefAtoms() _baseTarget = NS_NewAtom(NS_HTML_BASE_TARGET); a = NS_NewAtom("A"); above = NS_NewAtom("ABOVE"); + acceptcharset = NS_NewAtom("ACCEPTCHARSET"); action = NS_NewAtom("ACTION"); active = NS_NewAtom("ACTIVE"); align = NS_NewAtom("ALIGN"); @@ -204,6 +209,7 @@ void nsHTMLAtoms::AddrefAtoms() dl = NS_NewAtom("DL"); data = NS_NewAtom("DATA"); encoding = NS_NewAtom("ENCODING"); + enctype = NS_NewAtom("ENCTYPE"); face = NS_NewAtom("FACE"); font = NS_NewAtom("FONT"); fontWeight = NS_NewAtom("FONT-WEIGHT"); @@ -291,6 +297,7 @@ void nsHTMLAtoms::AddrefAtoms() tabstop = NS_NewAtom("TABSTOP"); target = NS_NewAtom("TARGET"); text = NS_NewAtom("TEXT"); + title = NS_NewAtom("TITLE"); top = NS_NewAtom("TOP"); toppadding = NS_NewAtom("TOPPADDING"); type = NS_NewAtom("TYPE"); diff --git a/mozilla/layout/base/src/nsContentList.cpp b/mozilla/layout/base/src/nsContentList.cpp index f7d47d62a6f..d3700fca760 100644 --- a/mozilla/layout/base/src/nsContentList.cpp +++ b/mozilla/layout/base/src/nsContentList.cpp @@ -22,6 +22,14 @@ #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" +nsContentList::nsContentList(nsIDocument *aDocument) +{ + NS_INIT_REFCNT(); + mScriptObject = nsnull; + mFunc = nsnull; + mMatchTag = nsnull; + mDocument = aDocument; +} nsContentList::nsContentList(nsIDocument *aDocument, const nsString& aMatchTag) @@ -189,7 +197,7 @@ nsContentList::NamedItem(const nsString& aName, nsIDOMNode** aReturn) nsAutoString name; // XXX Should it be an EqualsIgnoreCase? if (((content->GetAttribute("NAME", name) == eContentAttr_HasValue) && - (aName.Equals(name))) || + (aName.Equals(name))) || ((content->GetAttribute("ID", name) == eContentAttr_HasValue) && (aName.Equals(name)))) { return content->QueryInterface(kIDOMNodeIID, (void **)aReturn); diff --git a/mozilla/layout/base/src/nsContentList.h b/mozilla/layout/base/src/nsContentList.h index 0fcf652e2e7..be8ef4dff47 100644 --- a/mozilla/layout/base/src/nsContentList.h +++ b/mozilla/layout/base/src/nsContentList.h @@ -31,6 +31,8 @@ typedef PRBool (*nsContentListMatchFunc)(nsIContent *aContent); class nsIDocument; class nsContentList : public nsIDOMNodeList, public nsIDOMHTMLCollection, public nsIScriptObjectOwner, public nsIDocumentObserver { +protected: + nsContentList(nsIDocument *aDocument); public: nsContentList(nsIDocument *aDocument, const nsString& aMatchTag); nsContentList(nsIDocument *aDocument, nsContentListMatchFunc aFunc); diff --git a/mozilla/layout/events/src/nsDOMEvent.h b/mozilla/layout/events/src/nsDOMEvent.h index 578b9d1fa0a..ddd4a0b1f10 100644 --- a/mozilla/layout/events/src/nsDOMEvent.h +++ b/mozilla/layout/events/src/nsDOMEvent.h @@ -20,6 +20,7 @@ #define nsDOMEvent_h__ #include "nsIDOMEvent.h" +#include "nsIDOMNSEvent.h" #include "nsISupports.h" #include "nsIPrivateDOMEvent.h" diff --git a/mozilla/layout/html/base/src/nsDOMNodeList.cpp b/mozilla/layout/html/base/src/nsDOMNodeList.cpp index 977ae6cb053..6374fec4d5c 100644 --- a/mozilla/layout/html/base/src/nsDOMNodeList.cpp +++ b/mozilla/layout/html/base/src/nsDOMNodeList.cpp @@ -21,20 +21,17 @@ static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID); -nsDOMNodeList::nsDOMNodeList(nsIContent &aContent) : mContent(aContent) +nsDOMNodeList::nsDOMNodeList(nsIContent *aContent) : mContent(aContent) { - mRefCnt = 1; - - // keep the content alive so the array of children - // does not go away without "this" to know - mContent.AddRef(); - + // Note that we don't add a reference to the content (to avoid + // circular references). The content will tell us if it's going + // away. + mRefCnt = 0; mScriptObject = nsnull; } nsDOMNodeList::~nsDOMNodeList() { - mContent.Release(); } nsresult nsDOMNodeList::QueryInterface(REFNSIID aIID, void** aInstancePtr) @@ -88,7 +85,12 @@ nsresult nsDOMNodeList::ResetScriptObject() NS_IMETHODIMP nsDOMNodeList::GetLength(PRUint32* aLength) { - *aLength = mContent.ChildCount(); + if (nsnull != mContent) { + *aLength = mContent->ChildCount(); + } + else { + *aLength = 0; + } return NS_OK; } @@ -97,10 +99,15 @@ nsDOMNodeList::Item(PRUint32 aIndex, nsIDOMNode** aReturn) { nsIContent *content = nsnull; nsresult res = NS_OK; - content = mContent.ChildAt(aIndex); - if (nsnull != content) { - res = content->QueryInterface(kIDOMNodeIID, (void**)aReturn); - NS_RELEASE(content); + if (nsnull != mContent) { + content = mContent->ChildAt(aIndex); + if (nsnull != content) { + res = content->QueryInterface(kIDOMNodeIID, (void**)aReturn); + NS_RELEASE(content); + } + else { + *aReturn = nsnull; + } } else { *aReturn = nsnull; @@ -109,5 +116,12 @@ nsDOMNodeList::Item(PRUint32 aIndex, nsIDOMNode** aReturn) return res; } +void +nsDOMNodeList::ReleaseContent() +{ + if (nsnull != mContent) { + mContent = nsnull; + } +} diff --git a/mozilla/layout/html/base/src/nsDOMNodeList.h b/mozilla/layout/html/base/src/nsDOMNodeList.h index d6834a48785..ae949385095 100644 --- a/mozilla/layout/html/base/src/nsDOMNodeList.h +++ b/mozilla/layout/html/base/src/nsDOMNodeList.h @@ -25,7 +25,7 @@ class nsDOMNodeList : public nsIDOMNodeList, public nsIScriptObjectOwner { public: - nsDOMNodeList(nsIContent &aContent); + nsDOMNodeList(nsIContent *aContent); virtual ~nsDOMNodeList(); NS_DECL_ISUPPORTS @@ -34,12 +34,14 @@ public: NS_IMETHOD ResetScriptObject(); // nsIDOMNodeList interface - NS_IMETHOD GetLength(PRUint32* aLength); + NS_DECL_IDOMNODELIST - NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn); + // Called to tell us that the content is going away and that we + // should drop our (non ref-counted) reference to it + void ReleaseContent(); private: - nsIContent &mContent; + nsIContent *mContent; void *mScriptObject; }; diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp index a6c3a416407..de882862c20 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp @@ -21,6 +21,7 @@ nsIAtom* nsHTMLAtoms::_baseHref; nsIAtom* nsHTMLAtoms::_baseTarget; nsIAtom* nsHTMLAtoms::a; nsIAtom* nsHTMLAtoms::above; +nsIAtom* nsHTMLAtoms::acceptcharset; nsIAtom* nsHTMLAtoms::action; nsIAtom* nsHTMLAtoms::active; nsIAtom* nsHTMLAtoms::align; @@ -56,6 +57,7 @@ nsIAtom* nsHTMLAtoms::disabled; nsIAtom* nsHTMLAtoms::div; nsIAtom* nsHTMLAtoms::dl; nsIAtom* nsHTMLAtoms::encoding; +nsIAtom* nsHTMLAtoms::enctype; nsIAtom* nsHTMLAtoms::face; nsIAtom* nsHTMLAtoms::font; nsIAtom* nsHTMLAtoms::fontWeight; @@ -83,6 +85,7 @@ nsIAtom* nsHTMLAtoms::li; nsIAtom* nsHTMLAtoms::link; nsIAtom* nsHTMLAtoms::left; nsIAtom* nsHTMLAtoms::leftpadding; +nsIAtom* nsHTMLAtoms::longdesc; nsIAtom* nsHTMLAtoms::lowsrc; nsIAtom* nsHTMLAtoms::marginheight; nsIAtom* nsHTMLAtoms::marginwidth; @@ -143,6 +146,7 @@ nsIAtom* nsHTMLAtoms::table; nsIAtom* nsHTMLAtoms::tabstop; nsIAtom* nsHTMLAtoms::target; nsIAtom* nsHTMLAtoms::text; +nsIAtom* nsHTMLAtoms::title; nsIAtom* nsHTMLAtoms::top; nsIAtom* nsHTMLAtoms::toppadding; nsIAtom* nsHTMLAtoms::type; @@ -169,6 +173,7 @@ void nsHTMLAtoms::AddrefAtoms() _baseTarget = NS_NewAtom(NS_HTML_BASE_TARGET); a = NS_NewAtom("A"); above = NS_NewAtom("ABOVE"); + acceptcharset = NS_NewAtom("ACCEPTCHARSET"); action = NS_NewAtom("ACTION"); active = NS_NewAtom("ACTIVE"); align = NS_NewAtom("ALIGN"); @@ -204,6 +209,7 @@ void nsHTMLAtoms::AddrefAtoms() dl = NS_NewAtom("DL"); data = NS_NewAtom("DATA"); encoding = NS_NewAtom("ENCODING"); + enctype = NS_NewAtom("ENCTYPE"); face = NS_NewAtom("FACE"); font = NS_NewAtom("FONT"); fontWeight = NS_NewAtom("FONT-WEIGHT"); @@ -291,6 +297,7 @@ void nsHTMLAtoms::AddrefAtoms() tabstop = NS_NewAtom("TABSTOP"); target = NS_NewAtom("TARGET"); text = NS_NewAtom("TEXT"); + title = NS_NewAtom("TITLE"); top = NS_NewAtom("TOP"); toppadding = NS_NewAtom("TOPPADDING"); type = NS_NewAtom("TYPE"); diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.h b/mozilla/layout/html/base/src/nsHTMLAtoms.h index 124d1a1c55b..af9c02d3082 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.h +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.h @@ -42,6 +42,7 @@ public: // Alphabetical list of html attribute atoms static nsIAtom* a; static nsIAtom* above; + static nsIAtom* acceptcharset; static nsIAtom* action; static nsIAtom* active; static nsIAtom* align; @@ -81,6 +82,7 @@ public: static nsIAtom* dl; static nsIAtom* encoding; + static nsIAtom* enctype; static nsIAtom* face; static nsIAtom* font; @@ -113,6 +115,7 @@ public: static nsIAtom* link; static nsIAtom* left; static nsIAtom* leftpadding; + static nsIAtom* longdesc; static nsIAtom* lowsrc; static nsIAtom* marginheight; @@ -180,6 +183,7 @@ public: static nsIAtom* tabstop; static nsIAtom* target; static nsIAtom* text; + static nsIAtom* title; static nsIAtom* top; static nsIAtom* toppadding; static nsIAtom* type; diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.cpp b/mozilla/layout/html/base/src/nsHTMLContainer.cpp index 54d3af3e37c..d4a52be6639 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainer.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainer.cpp @@ -65,11 +65,13 @@ NS_NewHTMLContainer(nsIHTMLContent** aInstancePtrResult, nsHTMLContainer::nsHTMLContainer() { + mChildNodes = nsnull; } nsHTMLContainer::nsHTMLContainer(nsIAtom* aTag) : nsHTMLTagContent(aTag) { + mChildNodes = nsnull; } nsHTMLContainer::~nsHTMLContainer() @@ -79,6 +81,11 @@ nsHTMLContainer::~nsHTMLContainer() nsIContent* kid = (nsIContent*) mChildren.ElementAt(i); NS_RELEASE(kid); } + + if (nsnull != mChildNodes) { + mChildNodes->ReleaseContent(); + NS_RELEASE(mChildNodes); + } } NS_IMETHODIMP @@ -886,7 +893,12 @@ NS_IMETHODIMP nsHTMLContainer::GetChildNodes(nsIDOMNodeList** aChildNodes) { NS_PRECONDITION(nsnull != aChildNodes, "null pointer"); - *aChildNodes = new nsDOMNodeList(*this); + if (nsnull == mChildNodes) { + mChildNodes = new nsDOMNodeList(this); + NS_ADDREF(mChildNodes); + } + *aChildNodes = mChildNodes; + NS_ADDREF(mChildNodes); return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.h b/mozilla/layout/html/base/src/nsHTMLContainer.h index 8c25cd667c4..21967d3df2b 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainer.h +++ b/mozilla/layout/html/base/src/nsHTMLContainer.h @@ -21,6 +21,7 @@ #include "nsHTMLTagContent.h" #include "nsVoidArray.h" +class nsDOMNodeList; // Generic HTML container class. This code manages an array of // children nodes that can be any kind of nsIContent class nsHTMLContainer : public nsHTMLTagContent { @@ -79,6 +80,7 @@ protected: nsIPresContext* aPresContext); nsVoidArray mChildren; + nsDOMNodeList *mChildNodes; }; #endif /* nsHTMLContainer_h___ */ diff --git a/mozilla/layout/html/base/src/nsHTMLContent.cpp b/mozilla/layout/html/base/src/nsHTMLContent.cpp index 0b273c6398b..15f49e70b89 100644 --- a/mozilla/layout/html/base/src/nsHTMLContent.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContent.cpp @@ -297,6 +297,13 @@ void nsHTMLContent::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) { } +nsContentAttr nsHTMLContent::GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const +{ + aResult.SetLength(0); + return eContentAttr_NotThere; +} + void nsHTMLContent::SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue) { } diff --git a/mozilla/layout/html/base/src/nsHTMLContent.h b/mozilla/layout/html/base/src/nsHTMLContent.h index 173f2aee9e8..020c28059cd 100644 --- a/mozilla/layout/html/base/src/nsHTMLContent.h +++ b/mozilla/layout/html/base/src/nsHTMLContent.h @@ -82,6 +82,8 @@ public: nsString& aResult) const; virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); + virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const; virtual void SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue = nsHTMLValue::kNull); virtual void UnsetAttribute(nsIAtom* aAttribute); diff --git a/mozilla/layout/html/base/src/nsHTMLImage.cpp b/mozilla/layout/html/base/src/nsHTMLImage.cpp index 6ddb330d72b..f8393e3ade9 100644 --- a/mozilla/layout/html/base/src/nsHTMLImage.cpp +++ b/mozilla/layout/html/base/src/nsHTMLImage.cpp @@ -44,6 +44,7 @@ #include "nsISizeOfHandler.h" #include "nsIFontMetrics.h" #include "nsCSSRendering.h" +#include "nsIDOMHTMLImageElement.h" #define BROKEN_IMAGE_URL "resource:/res/html/broken-image.gif" @@ -56,10 +57,12 @@ static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); #define nsHTMLImageSuper nsHTMLTagContent -class nsHTMLImage : public nsHTMLImageSuper { +class nsHTMLImage : public nsHTMLImageSuper, public nsIDOMHTMLImageElement { public: nsHTMLImage(nsIAtom* aTag); + NS_DECL_ISUPPORTS + NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; virtual nsresult CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, @@ -70,6 +73,14 @@ public: virtual void MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); + NS_FORWARD_IDOMNODE(nsHTMLImageSuper) + NS_FORWARD_IDOMELEMENT(nsHTMLImageSuper) + NS_FORWARD_IDOMHTMLELEMENT(nsHTMLImageSuper) + + NS_DECL_IDOMHTMLIMAGEELEMENT + + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + protected: virtual ~nsHTMLImage(); void SizeOfWithoutThis(nsISizeOfHandler* aHandler) const; @@ -910,6 +921,33 @@ nsHTMLImage::~nsHTMLImage() { } +static NS_DEFINE_IID(kIDOMHTMLImageElementIID, NS_IDOMHTMLIMAGEELEMENT_IID); + +nsresult nsHTMLImage::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + nsresult res = nsHTMLTagContent::QueryInterface(aIID, aInstancePtr); + if (NS_NOINTERFACE == res) { + if (aIID.Equals(kIDOMHTMLImageElementIID)) { + *aInstancePtr = (void*)(nsIDOMHTMLImageElement*)this; + AddRef(); + return NS_OK; + } + } + + return res; +} + +nsrefcnt nsHTMLImage::AddRef(void) +{ + return nsHTMLTagContent::AddRef(); +} + +nsrefcnt nsHTMLImage::Release(void) +{ + return nsHTMLTagContent::Release(); +} + + NS_IMETHODIMP nsHTMLImage::SizeOf(nsISizeOfHandler* aHandler) const { @@ -1073,6 +1111,232 @@ nsHTMLImage::CreateFrame(nsIPresContext* aPresContext, return NS_OK; } +NS_IMETHODIMP +nsHTMLImage::GetLowSrc(nsString& aLowSrc) +{ + GetAttribute(nsHTMLAtoms::lowsrc, aLowSrc); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetLowSrc(const nsString& aLowSrc) +{ + SetAttribute(nsHTMLAtoms::lowsrc, aLowSrc); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetName(nsString& aName) +{ + GetAttribute(nsHTMLAtoms::name, aName); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetName(const nsString& aName) +{ + SetAttribute(nsHTMLAtoms::name, aName); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetAlign(nsString& aAlign) +{ + GetAttribute(nsHTMLAtoms::align, aAlign); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetAlign(const nsString& aAlign) +{ + SetAttribute(nsHTMLAtoms::align, aAlign); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetAlt(nsString& aAlt) +{ + GetAttribute(nsHTMLAtoms::alt, aAlt); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetAlt(const nsString& aAlt) +{ + SetAttribute(nsHTMLAtoms::alt, aAlt); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetBorder(nsString& aBorder) +{ + GetAttribute(nsHTMLAtoms::border, aBorder); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetBorder(const nsString& aBorder) +{ + SetAttribute(nsHTMLAtoms::border, aBorder); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetHeight(nsString& aHeight) +{ + GetAttribute(nsHTMLAtoms::height, aHeight); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetHeight(const nsString& aHeight) +{ + SetAttribute(nsHTMLAtoms::height, aHeight); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetHspace(nsString& aHspace) +{ + GetAttribute(nsHTMLAtoms::hspace, aHspace); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetHspace(const nsString& aHspace) +{ + SetAttribute(nsHTMLAtoms::hspace, aHspace); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetIsMap(PRBool* aIsMap) +{ + nsAutoString result; + + *aIsMap = (PRBool)(eContentAttr_HasValue == GetAttribute(nsHTMLAtoms::ismap, result)); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetIsMap(PRBool aIsMap) +{ + if (PR_TRUE == aIsMap) { + SetAttribute(nsHTMLAtoms::ismap, ""); + } + else { + UnsetAttribute(nsHTMLAtoms::ismap); + } + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetLongDesc(nsString& aLongDesc) +{ + GetAttribute(nsHTMLAtoms::longdesc, aLongDesc); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetLongDesc(const nsString& aLongDesc) +{ + SetAttribute(nsHTMLAtoms::longdesc, aLongDesc); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetSrc(nsString& aSrc) +{ + GetAttribute(nsHTMLAtoms::src, aSrc); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetSrc(const nsString& aSrc) +{ + SetAttribute(nsHTMLAtoms::src, aSrc); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetUseMap(nsString& aUseMap) +{ + GetAttribute(nsHTMLAtoms::usemap, aUseMap); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetUseMap(const nsString& aUseMap) +{ + SetAttribute(nsHTMLAtoms::usemap, aUseMap); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetVspace(nsString& aVspace) +{ + GetAttribute(nsHTMLAtoms::vspace, aVspace); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetVspace(const nsString& aVspace) +{ + SetAttribute(nsHTMLAtoms::vspace, aVspace); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetWidth(nsString& aWidth) +{ + GetAttribute(nsHTMLAtoms::width, aWidth); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::SetWidth(const nsString& aWidth) +{ + SetAttribute(nsHTMLAtoms::width, aWidth); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImage::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + if (nsnull == mScriptObject) { + res = NS_NewScriptHTMLImageElement(aContext, this, mParent, (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + return res; +} + nsresult NS_NewHTMLImage(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) diff --git a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp index 72ffde689d1..ad0b3b00e2d 100644 --- a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp +++ b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp @@ -45,6 +45,7 @@ static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID); +static NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID); static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID); static NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID); static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); @@ -153,7 +154,12 @@ nsresult nsHTMLTagContent::QueryInterface(REFNSIID aIID, void** aInstancePtr) nsresult res = nsHTMLContent::QueryInterface(aIID, aInstancePtr); if (NS_NOINTERFACE == res) { if (aIID.Equals(kIDOMElementIID)) { - *aInstancePtr = (void*)(nsIDOMElement*)this; + *aInstancePtr = (void*)(nsIDOMElement*)(nsIDOMHTMLElement*)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIDOMHTMLElementIID)) { + *aInstancePtr = (void*)(nsIDOMHTMLElement*)this; AddRef(); return NS_OK; } @@ -297,21 +303,17 @@ void nsHTMLTagContent::SetAttribute(const nsString& aName, NS_RELEASE(attr); } -nsContentAttr nsHTMLTagContent::GetAttribute(const nsString& aName, - nsString& aResult) const +nsContentAttr nsHTMLTagContent::GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const { - nsAutoString upper; - aName.ToUpperCase(upper); - nsIAtom* attr = NS_NewAtom(upper); - nsHTMLValue value; - nsContentAttr result = GetAttribute(attr, value); + nsContentAttr result = GetAttribute(aAttribute, value); char cbuf[20]; nscolor color; if (eContentAttr_HasValue == result) { // Try subclass conversion routine first - if (eContentAttr_HasValue == AttributeToString(attr, value, aResult)) { + if (eContentAttr_HasValue == AttributeToString(aAttribute, value, aResult)) { return result; } @@ -357,6 +359,19 @@ nsContentAttr nsHTMLTagContent::GetAttribute(const nsString& aName, break; } } + + return result; +} + +nsContentAttr nsHTMLTagContent::GetAttribute(const nsString& aName, + nsString& aResult) const +{ + nsAutoString upper; + aName.ToUpperCase(upper); + nsIAtom* attr = NS_NewAtom(upper); + nsContentAttr result; + + result = GetAttribute(attr, aResult); NS_RELEASE(attr); return result; @@ -938,6 +953,90 @@ nsHTMLTagContent::Normalize() return NS_ERROR_NOT_IMPLEMENTED; } +// +// Implementation of nsIDOMHTMLElement interface +// +NS_IMETHODIMP +nsHTMLTagContent::GetId(nsString& aId) +{ + GetAttribute(nsHTMLAtoms::id, aId); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::SetId(const nsString& aId) +{ + SetAttribute(nsHTMLAtoms::id, aId); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::GetTitle(nsString& aTitle) +{ + GetAttribute(nsHTMLAtoms::title, aTitle); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::SetTitle(const nsString& aTitle) +{ + SetAttribute(nsHTMLAtoms::title, aTitle); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::GetLang(nsString& aLang) +{ + GetAttribute(nsHTMLAtoms::lang, aLang); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::SetLang(const nsString& aLang) +{ + SetAttribute(nsHTMLAtoms::lang, aLang); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::GetDir(nsString& aDir) +{ + GetAttribute(nsHTMLAtoms::dir, aDir); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::SetDir(const nsString& aDir) +{ + SetAttribute(nsHTMLAtoms::dir, aDir); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::GetClassName(nsString& aClassName) +{ + GetAttribute(nsHTMLAtoms::kClass, aClassName); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTagContent::SetClassName(const nsString& aClassName) +{ + SetAttribute(nsHTMLAtoms::kClass, aClassName); + + return NS_OK; +} + + void nsHTMLTagContent::TriggerLink(nsIPresContext& aPresContext, const nsString& aBase, const nsString& aURLSpec, diff --git a/mozilla/layout/html/base/src/nsHTMLTagContent.h b/mozilla/layout/html/base/src/nsHTMLTagContent.h index 15a4f25163e..3f4c66a750f 100644 --- a/mozilla/layout/html/base/src/nsHTMLTagContent.h +++ b/mozilla/layout/html/base/src/nsHTMLTagContent.h @@ -21,6 +21,7 @@ #include "nsHTMLContent.h" #include "nsHTMLValue.h" #include "nsIDOMElement.h" +#include "nsIDOMHTMLElement.h" #include "nsIJSScriptObject.h" class nsIHTMLAttributes; @@ -30,7 +31,7 @@ class nsIStyleContext; /** * Base class for tagged html content objects, holds attributes. */ -class nsHTMLTagContent : public nsHTMLContent, public nsIDOMElement, public nsIJSScriptObject { +class nsHTMLTagContent : public nsHTMLContent, public nsIDOMHTMLElement, public nsIJSScriptObject { public: // nsIContent @@ -78,6 +79,9 @@ public: virtual nsContentAttr GetAttribute(const nsString& aName, nsString& aResult) const; + virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const; + virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); virtual void SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue); @@ -126,34 +130,13 @@ public: NS_IMETHOD_(nsrefcnt) Release(void); // nsIDOMNode interface - NS_IMETHOD GetNodeName(nsString& aNodeName); - NS_IMETHOD GetNodeValue(nsString& aNodeValue); - NS_IMETHOD SetNodeValue(const nsString& aNodeValue); - NS_IMETHOD GetNodeType(PRInt32* aNodeType); - NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes); - NS_IMETHOD CloneNode(nsIDOMNode** aReturn); - NS_IMETHOD Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn); - NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode); - NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes); - NS_IMETHOD GetHasChildNodes(PRBool* aHasChildNodes); - NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild); - NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild); - NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling); - NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling); - NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn); - NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn); - NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn); + NS_DECL_IDOMNODE // nsIDOMElement interface - NS_IMETHOD GetTagName(nsString& aTagName); - NS_IMETHOD GetDOMAttribute(const nsString& aName, nsString& aReturn); - NS_IMETHOD SetDOMAttribute(const nsString& aName, const nsString& aValue); - NS_IMETHOD RemoveAttribute(const nsString& aName); - NS_IMETHOD GetAttributeNode(const nsString& aName, nsIDOMAttribute** aReturn); - NS_IMETHOD SetAttributeNode(nsIDOMAttribute* aNewAttr); - NS_IMETHOD RemoveAttributeNode(nsIDOMAttribute* aOldAttr); - NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn); - NS_IMETHOD Normalize(); + NS_DECL_IDOMELEMENT + + // nsIDOMHTMLElement interface + NS_DECL_IDOMHTMLELEMENT // nsIDOMEventReceiver interface NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, diff --git a/mozilla/layout/html/base/src/nsIHTMLContent.h b/mozilla/layout/html/base/src/nsIHTMLContent.h index a493b9945b5..8313a240cb5 100644 --- a/mozilla/layout/html/base/src/nsIHTMLContent.h +++ b/mozilla/layout/html/base/src/nsIHTMLContent.h @@ -51,6 +51,8 @@ public: virtual nsContentAttr GetAttribute(const nsString& aName, nsString& aResult) const = 0; + virtual nsContentAttr GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const = 0; virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const = 0; virtual PRInt32 GetAllAttributeNames(nsISupportsArray* aArray) const = 0; diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 385f21b4429..6e5c708e015 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -563,6 +563,9 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode) GetAttributeValueAt(aNode, i, v); mCurrentForm->SetAttribute(k, v); } + // XXX Temporary code till forms become real content + // Add the form to the document + ((nsHTMLDocument*)mDocument)->AddForm(mCurrentForm); } return NS_OK; diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 244522739f2..847e30d7fff 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -40,6 +40,7 @@ #include "nsIScriptGlobalObject.h" #include "nsContentList.h" #include "nsINetService.h" +#include "nsIFormManager.h" #include "nsRepository.h" #include "nsParserCIID.h" @@ -50,6 +51,7 @@ static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID); +static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID); static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID); static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID); static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); @@ -71,17 +73,31 @@ nsHTMLDocument::nsHTMLDocument() mEmbeds = nsnull; mLinks = nsnull; mAnchors = nsnull; + mForms = nsnull; + mNamedItems = nsnull; mParser = nsnull; nsHTMLAtoms::AddrefAtoms(); } nsHTMLDocument::~nsHTMLDocument() { + // XXX Temporary code till forms become real content + int i, count = mTempForms.Count(); + for (i = 0; i < count; i++) { + nsIFormManager *form = (nsIFormManager *)mTempForms.ElementAt(i); + if (nsnull != form) { + NS_RELEASE(form); + } + } + if (nsnull != mNamedItems) { + PL_HashTableDestroy(mNamedItems); + } NS_IF_RELEASE(mImages); NS_IF_RELEASE(mApplets); NS_IF_RELEASE(mEmbeds); NS_IF_RELEASE(mLinks); NS_IF_RELEASE(mAnchors); + NS_IF_RELEASE(mForms); NS_IF_RELEASE(mAttrStyleSheet); NS_IF_RELEASE(mParser); // XXX don't bother doing this until the dll is unloaded??? @@ -274,6 +290,55 @@ NS_IMETHODIMP nsHTMLDocument::GetImageMap(const nsString& aMapName, return 1;/* XXX NS_NOT_FOUND */ } +// XXX Temporary form methods. Forms will soon become actual content +// elements. For now, the document keeps a list of them. +NS_IMETHODIMP +nsHTMLDocument::AddForm(nsIFormManager *aForm) +{ + NS_PRECONDITION(nsnull != aForm, "null ptr"); + if (nsnull == aForm) { + return NS_ERROR_NULL_POINTER; + } + if (mTempForms.AppendElement(aForm)) { + NS_ADDREF(aForm); + return NS_OK; + } + return NS_ERROR_OUT_OF_MEMORY; +} + +NS_IMETHODIMP_(PRInt32) +nsHTMLDocument::GetFormCount() const +{ + return mTempForms.Count(); +} + +NS_IMETHODIMP +nsHTMLDocument::GetFormAt(PRInt32 aIndex, nsIFormManager **aForm) const +{ + *aForm = (nsIFormManager *)mTempForms.ElementAt(aIndex); + + if (nsnull != *aForm) { + NS_ADDREF(*aForm); + return NS_OK; + } + + return 1;/* XXX NS_NOT_FOUND */ +} + +NS_IMETHODIMP +nsHTMLDocument::AddNamedItem(const nsString& aName, nsIContent *aContent) +{ + //XXX TBI + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsHTMLDocument::RemoveNamedItem(const nsString& aName) +{ + //XXX TBI + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsHTMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult) { NS_PRECONDITION(nsnull != aResult, "null ptr"); @@ -287,7 +352,6 @@ NS_IMETHODIMP nsHTMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult return NS_OK; } - void nsHTMLDocument::AddStyleSheetToSet(nsIStyleSheet* aSheet, nsIStyleSet* aSet) { if ((nsnull != mAttrStyleSheet) && (aSheet != mAttrStyleSheet)) { @@ -480,13 +544,57 @@ nsHTMLDocument::GetLinks(nsIDOMHTMLCollection** aLinks) return NS_OK; } +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + +// XXX Temporary till form becomes real content + +class nsTempFormContentList : public nsContentList { +public: + nsTempFormContentList(nsHTMLDocument *aDocument); + ~nsTempFormContentList(); +}; + +nsTempFormContentList::nsTempFormContentList(nsHTMLDocument *aDocument) : nsContentList(aDocument) +{ + PRInt32 i, count = aDocument->GetFormCount(); + for (i=0; i < count; i++) { + nsIFormManager *form; + + if (NS_OK == aDocument->GetFormAt(i, &form)) { + nsIContent *content; + if (NS_OK == form->QueryInterface(kIContentIID, (void **)&content)) { + Add(content); + NS_RELEASE(content); + } + NS_RELEASE(form); + } + } +} + +nsTempFormContentList::~nsTempFormContentList() +{ + mDocument = nsnull; +} + NS_IMETHODIMP nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms) { - //XXX TBI - return NS_ERROR_NOT_IMPLEMENTED; + if (nsnull == mForms) { + mForms = new nsTempFormContentList(this); + if (nsnull == mForms) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mForms); + } + + *aForms = (nsIDOMHTMLCollection *)mForms; + NS_ADDREF(mForms); + + return NS_OK; } +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + PRBool nsHTMLDocument::MatchAnchors(nsIContent *aContent) { @@ -637,6 +745,11 @@ nsHTMLDocument::GetElementsByName(const nsString& aElementName, nsIDOMNodeList** return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsHTMLDocument::GetNamedItem(const nsString& aName, nsIDOMElement **aReturn) +{ + return NS_OK; +} NS_IMETHODIMP nsHTMLDocument::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.h b/mozilla/layout/html/document/src/nsHTMLDocument.h index 854724a26e5..7fe15b68570 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.h +++ b/mozilla/layout/html/document/src/nsHTMLDocument.h @@ -22,6 +22,7 @@ #include "nsMarkupDocument.h" #include "nsIHTMLDocument.h" #include "nsIDOMHTMLDocument.h" +#include "plhash.h" class nsIHTMLStyleSheet; class nsContentList; @@ -50,6 +51,21 @@ public: NS_IMETHOD GetImageMap(const nsString& aMapName, nsIImageMap** aResult); + // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + // XXX Temporary form methods. Forms will soon become actual content + // elements. For now, the document keeps a list of them. + NS_IMETHOD AddForm(nsIFormManager *aForm); + + NS_IMETHOD_(PRInt32) GetFormCount() const; + + NS_IMETHOD GetFormAt(PRInt32 aIndex, nsIFormManager **aForm) const; + // XXX + // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + + NS_IMETHOD AddNamedItem(const nsString& aName, nsIContent *aContent); + + NS_IMETHOD RemoveNamedItem(const nsString& aName); + NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aStyleSheet); // nsIDOMDocument interface @@ -78,40 +94,7 @@ public: { return nsDocument::GetElementsByTagName(aTagname, aReturn); } // nsIDOMNode interface - NS_IMETHOD GetNodeName(nsString& aNodeName) - { return nsDocument::GetNodeName(aNodeName); } - NS_IMETHOD GetNodeValue(nsString& aNodeValue) - { return nsDocument::GetNodeValue(aNodeValue); } - NS_IMETHOD SetNodeValue(const nsString& aNodeValue) - { return nsDocument::SetNodeValue(aNodeValue); } - NS_IMETHOD GetNodeType(PRInt32* aNodeType) - { return nsDocument::GetNodeType(aNodeType); } - NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) - { return nsDocument::GetParentNode(aParentNode); } - NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) - { return nsDocument::GetChildNodes(aChildNodes); } - NS_IMETHOD GetHasChildNodes(PRBool* aHasChildNodes) - { return nsDocument::GetHasChildNodes(aHasChildNodes); } - NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) - { return nsDocument::GetFirstChild(aFirstChild); } - NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) - { return nsDocument::GetLastChild(aLastChild); } - NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) - { return nsDocument::GetPreviousSibling(aPreviousSibling); } - NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) - { return nsDocument::GetNextSibling(aNextSibling); } - NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) - { return nsDocument::GetAttributes(aAttributes); } - NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn) - { return nsDocument::InsertBefore(aNewChild, aRefChild, aReturn); } - NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn) - { return nsDocument::ReplaceChild(aNewChild, aOldChild, aReturn); } - NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) - { return nsDocument::RemoveChild(aOldChild, aReturn); } - NS_IMETHOD CloneNode(nsIDOMNode** aReturn) - { return nsDocument::CloneNode(aReturn); } - NS_IMETHOD Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn) - { return nsDocument::Equals(aNode, aDeep, aReturn); } + NS_FORWARD_IDOMNODE(nsDocument) // nsIDOMHTMLDocument interface NS_IMETHOD GetTitle(nsString& aTitle); @@ -137,6 +120,7 @@ public: NS_IMETHOD Writeln(JSContext *cx, jsval *argv, PRUint32 argc); NS_IMETHOD GetElementById(const nsString& aElementId, nsIDOMElement** aReturn); NS_IMETHOD GetElementsByName(const nsString& aElementName, nsIDOMNodeList** aReturn); + NS_IMETHOD GetNamedItem(const nsString& aName, nsIDOMElement **aReturn); // From nsIScriptObjectOwner interface, implemented by nsDocument NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); @@ -148,12 +132,16 @@ protected: nsIHTMLStyleSheet* mAttrStyleSheet; nsVoidArray mImageMaps; + nsVoidArray mTempForms; // XXX Temporary nsContentList *mImages; nsContentList *mApplets; nsContentList *mEmbeds; nsContentList *mLinks; nsContentList *mAnchors; + nsContentList *mForms; + + PLHashTable *mNamedItems; nsIParser *mParser; }; diff --git a/mozilla/layout/html/document/src/nsIHTMLDocument.h b/mozilla/layout/html/document/src/nsIHTMLDocument.h index 29a35ecfa02..1b2e04482f2 100644 --- a/mozilla/layout/html/document/src/nsIHTMLDocument.h +++ b/mozilla/layout/html/document/src/nsIHTMLDocument.h @@ -21,6 +21,7 @@ #include "nsISupports.h" class nsIImageMap; class nsString; +class nsIFormManager; class nsIHTMLStyleSheet; /* b2a848b0-d0a9-11d1-89b1-006008911b81 */ @@ -38,6 +39,21 @@ public: NS_IMETHOD GetImageMap(const nsString& aMapName, nsIImageMap** aResult) = 0; + // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + // XXX Temporary form methods. Forms will soon become actual content + // elements. For now, the document keeps a list of them. + NS_IMETHOD AddForm(nsIFormManager *aForm) = 0; + + NS_IMETHOD_(PRInt32) GetFormCount() const = 0; + + NS_IMETHOD GetFormAt(PRInt32 aIndex, nsIFormManager **aForm) const = 0; + // XXX + // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + + NS_IMETHOD AddNamedItem(const nsString& aName, nsIContent *aContent) = 0; + + NS_IMETHOD RemoveNamedItem(const nsString& aName) = 0; + NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aStyleSheet) = 0; }; diff --git a/mozilla/layout/html/forms/public/nsIFormManager.h b/mozilla/layout/html/forms/public/nsIFormManager.h index 14b3cf66585..cec730869d1 100644 --- a/mozilla/layout/html/forms/public/nsIFormManager.h +++ b/mozilla/layout/html/forms/public/nsIFormManager.h @@ -19,6 +19,7 @@ #define nsIFormManager_h___ #include "nsISupports.h" +#include "nsIContent.h" class nsIFormControl; class nsIPresContext; class nsIFrame; @@ -119,9 +120,19 @@ public: * Get the named attribute of this manager * @param aName the name of the attribute * @param aResult the value of the attribute - * @return PR_TRUE if there is an attribute with name aName - */ - virtual PRBool GetAttribute(const nsString& aName, + * @return