зеркало из https://github.com/mozilla/gecko-dev.git
Added document.forms. Specialized interfaces for images and forms. Better handling of childNodes collection.
This commit is contained in:
Родитель
ccef2b6c79
Коммит
856891ed81
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define nsDOMEvent_h__
|
||||
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPrivateDOMEvent.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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define nsDOMEvent_h__
|
||||
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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___ */
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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 <UL>
|
||||
*
|
||||
* <LI>If the attribute is not set and has no default value, return
|
||||
* eContentAttr_NotThere.
|
||||
*
|
||||
* <LI>If the attribute exists, but has no value, return
|
||||
* eContentAttr_NoValue.
|
||||
*
|
||||
* <LI>If the attribute has a value, empty or otherwise, set ret to
|
||||
* be the value, and return eContentAttr_HasValue.
|
||||
*
|
||||
* </UL> */
|
||||
virtual nsContentAttr GetAttribute(const nsString& aName,
|
||||
nsString& aResult) const = 0;
|
||||
/**
|
||||
* Set the named attribute of this manager
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
#include "nsIRadioButton.h"
|
||||
#include "nsInputFile.h"
|
||||
#include "nsDocument.h"
|
||||
#include "nsHTMLContainer.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
#include "net.h"
|
||||
#include "xp_file.h"
|
||||
|
@ -47,6 +51,12 @@
|
|||
#include "prmem.h"
|
||||
#include "prenv.h"
|
||||
|
||||
// XXX Microsoft has a macro called GetClassName that conflicts
|
||||
// with the DOM HTMLElement::GetClassName method
|
||||
#ifdef GetClassName
|
||||
#undef GetClassName
|
||||
#endif
|
||||
|
||||
#define CRLF "\015\012"
|
||||
|
||||
// netlib has a general function (netlib\modules\liburl\src\escape.c)
|
||||
|
@ -94,7 +104,8 @@ nsString* URLEncode(nsString& aString)
|
|||
|
||||
static NS_DEFINE_IID(kIFormManagerIID, NS_IFORMMANAGER_IID);
|
||||
|
||||
class nsForm : public nsIFormManager
|
||||
class nsFormElementList;
|
||||
class nsForm : public nsHTMLContainer, public nsIFormManager, public nsIDOMHTMLFormElement
|
||||
{
|
||||
public:
|
||||
// Construct a new Form Element with no attributes. This needs to be
|
||||
|
@ -137,7 +148,7 @@ public:
|
|||
|
||||
virtual void SetAttribute(const nsString& aName, const nsString& aValue);
|
||||
|
||||
virtual PRBool GetAttribute(const nsString& aName,
|
||||
virtual nsContentAttr GetAttribute(const nsString& aName,
|
||||
nsString& aResult) const;
|
||||
|
||||
virtual nsresult GetRefCount() const;
|
||||
|
@ -147,6 +158,14 @@ public:
|
|||
virtual nsFormRenderingMode GetMode() const { return mRenderingMode; }
|
||||
virtual void SetMode(nsFormRenderingMode aMode) { mRenderingMode = aMode; }
|
||||
|
||||
NS_FORWARD_IDOMNODE(nsHTMLContainer)
|
||||
NS_FORWARD_IDOMELEMENT(nsHTMLContainer)
|
||||
NS_FORWARD_IDOMHTMLELEMENT(nsHTMLContainer)
|
||||
|
||||
NS_DECL_IDOMHTMLFORMELEMENT
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
|
||||
static nsString* gGET;
|
||||
static nsString* gPOST;
|
||||
static nsString* gMULTIPART;
|
||||
|
@ -173,8 +192,32 @@ protected:
|
|||
PRInt32 mMethod;
|
||||
PRBool mInited;
|
||||
nsFormRenderingMode mRenderingMode;
|
||||
nsFormElementList *mElements;
|
||||
};
|
||||
|
||||
class nsFormElementList : public nsIDOMHTMLCollection, public nsIScriptObjectOwner {
|
||||
public:
|
||||
nsFormElementList(nsForm *aForm);
|
||||
virtual ~nsFormElementList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD ResetScriptObject();
|
||||
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_DECL_IDOMHTMLCOLLECTION
|
||||
|
||||
// Called to tell us that the form is going away and that we
|
||||
// should drop our (non ref-counted) reference to it
|
||||
void ReleaseForm();
|
||||
|
||||
private:
|
||||
nsForm *mForm;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
|
||||
#define METHOD_UNSET 0
|
||||
#define METHOD_GET 1
|
||||
#define METHOD_POST 2
|
||||
|
@ -186,12 +229,13 @@ nsString* nsForm::gPOST = new nsString("post");
|
|||
nsString* nsForm::gMULTIPART = new nsString("multipart/form-data");
|
||||
|
||||
// Note: operator new zeros our memory
|
||||
nsForm::nsForm(nsIAtom* aTag)
|
||||
nsForm::nsForm(nsIAtom* aTag) : nsHTMLContainer(aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mTag = aTag;
|
||||
NS_IF_ADDREF(aTag);
|
||||
mInited = PR_FALSE;
|
||||
mElements = nsnull;
|
||||
}
|
||||
|
||||
nsForm::~nsForm()
|
||||
|
@ -209,9 +253,26 @@ nsForm::~nsForm()
|
|||
if (nsnull != mTarget) delete mTarget;
|
||||
|
||||
RemoveRadioGroups();
|
||||
|
||||
if (nsnull != mElements) {
|
||||
mElements->ReleaseForm();
|
||||
NS_RELEASE(mElements);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsForm,kIFormManagerIID);
|
||||
nsresult nsForm::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult res = nsHTMLContainer::QueryInterface(aIID, aInstancePtr);
|
||||
if (NS_NOINTERFACE == res) {
|
||||
if (aIID.Equals(kIFormManagerIID)) {
|
||||
*aInstancePtr = (void*)(nsIFormManager*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
NS_IMPL_ADDREF(nsForm);
|
||||
|
||||
nsrefcnt nsForm::GetRefCount() const
|
||||
|
@ -778,29 +839,29 @@ void nsForm::SetAttribute(const nsString& aName, const nsString& aValue)
|
|||
NS_RELEASE(atom);
|
||||
}
|
||||
|
||||
PRBool nsForm::GetAttribute(const nsString& aName,
|
||||
nsContentAttr nsForm::GetAttribute(const nsString& aName,
|
||||
nsString& aResult) const
|
||||
{
|
||||
nsAutoString tmp(aName);
|
||||
tmp.ToUpperCase();
|
||||
nsIAtom* atom = NS_NewAtom(tmp);
|
||||
PRBool rv = PR_FALSE;
|
||||
nsContentAttr rv = eContentAttr_NoValue;
|
||||
if (atom == nsHTMLAtoms::action) {
|
||||
if (nsnull != mAction) {
|
||||
aResult = *mAction;
|
||||
rv = PR_TRUE;
|
||||
rv = eContentAttr_HasValue;
|
||||
}
|
||||
}
|
||||
else if (atom == nsHTMLAtoms::encoding) {
|
||||
if (nsnull != mEncoding) {
|
||||
aResult = *mEncoding;
|
||||
rv = PR_TRUE;
|
||||
rv = eContentAttr_HasValue;
|
||||
}
|
||||
}
|
||||
else if (atom == nsHTMLAtoms::target) {
|
||||
if (nsnull != mTarget) {
|
||||
aResult = *mTarget;
|
||||
rv = PR_TRUE;
|
||||
rv = eContentAttr_HasValue;
|
||||
}
|
||||
}
|
||||
else if (atom == nsHTMLAtoms::method) {
|
||||
|
@ -811,17 +872,20 @@ PRBool nsForm::GetAttribute(const nsString& aName,
|
|||
else {
|
||||
aResult = "get";
|
||||
}
|
||||
rv = PR_TRUE;
|
||||
rv = eContentAttr_HasValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Use default storage for unknown attributes
|
||||
if (nsnull != mAttributes) {
|
||||
nsHTMLValue value;
|
||||
if (eContentAttr_HasValue == mAttributes->GetAttribute(atom, value)) {
|
||||
rv = mAttributes->GetAttribute(atom, value);
|
||||
if (eContentAttr_HasValue == rv) {
|
||||
if (value.GetUnit() == eHTMLUnit_String) {
|
||||
value.GetStringValue(aResult);
|
||||
rv = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
rv = eContentAttr_NoValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -912,6 +976,120 @@ nsForm::OnRadioChecked(nsIFormControl& aControl)
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::GetElements(nsIDOMHTMLCollection** aElements)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aElements, "null pointer");
|
||||
if (nsnull == mElements) {
|
||||
mElements = new nsFormElementList(this);
|
||||
NS_ADDREF(mElements);
|
||||
}
|
||||
*aElements = mElements;
|
||||
NS_ADDREF(mElements);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::GetName(nsString& aName)
|
||||
{
|
||||
// XXX The explicit class was required to get MSVC to be happy.
|
||||
// It doesn't make sense.
|
||||
((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::name, aName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::GetAcceptCharset(nsString& aAcceptCharset)
|
||||
{
|
||||
((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::acceptcharset, aAcceptCharset);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::SetAcceptCharset(const nsString& aAcceptCharset)
|
||||
{
|
||||
((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::acceptcharset, aAcceptCharset);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::GetAction(nsString& aAction)
|
||||
{
|
||||
((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::action, aAction);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::SetAction(const nsString& aAction)
|
||||
{
|
||||
((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::action, aAction);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::GetEnctype(nsString& aEnctype)
|
||||
{
|
||||
((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::enctype, aEnctype);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::SetEnctype(const nsString& aEnctype)
|
||||
{
|
||||
((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::enctype, aEnctype);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::GetMethod(nsString& aMethod)
|
||||
{
|
||||
((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::method, aMethod);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::SetMethod(const nsString& aMethod)
|
||||
{
|
||||
((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::method, aMethod);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::GetTarget(nsString& aTarget)
|
||||
{
|
||||
((nsHTMLContainer *)this)->GetAttribute(nsHTMLAtoms::target, aTarget);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsForm::SetTarget(const nsString& aTarget)
|
||||
{
|
||||
((nsHTMLContainer *)this)->SetAttribute(nsHTMLAtoms::target, aTarget);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsForm::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptHTMLFormElement(aContext, this, nsnull, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLForm(nsIFormManager** aInstancePtrResult,
|
||||
nsIAtom* aTag)
|
||||
|
@ -1092,4 +1270,141 @@ char* nsForm::Temp_GenerateTempFileName(PRInt32 aMaxSize, char* file_buf)
|
|||
|
||||
}
|
||||
|
||||
//
|
||||
// Implementation of nsFormElementList
|
||||
//
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
|
||||
nsFormElementList::nsFormElementList(nsForm *aForm) : mForm(aForm)
|
||||
{
|
||||
// Note that we don't add a reference to the form (to avoid
|
||||
// circular references). The form will tell us if it's going
|
||||
// away.
|
||||
mRefCnt = 0;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
nsFormElementList::~nsFormElementList()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult nsFormElementList::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
if (aIID.Equals(kIDOMHTMLCollectionIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMHTMLCollection*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aInstancePtr = (void*)(nsIScriptObjectOwner*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIDOMHTMLCollection*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsFormElementList)
|
||||
NS_IMPL_RELEASE(nsFormElementList)
|
||||
|
||||
|
||||
nsresult nsFormElementList::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptHTMLCollection(aContext, this, nsnull, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsFormElementList::ResetScriptObject()
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_IMETHODIMP
|
||||
nsFormElementList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
if (nsnull != mForm) {
|
||||
*aLength = mForm->GetFormControlCount();
|
||||
}
|
||||
else {
|
||||
*aLength = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormElementList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsIFormControl *control = nsnull;
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull != mForm) {
|
||||
control = mForm->GetFormControlAt(aIndex);
|
||||
if (nsnull != control) {
|
||||
res = control->QueryInterface(kIDOMNodeIID, (void**)aReturn);
|
||||
NS_RELEASE(control);
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormElementList::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
PRInt32 i, count = mForm->GetFormControlCount();
|
||||
nsresult result = NS_OK;
|
||||
|
||||
*aReturn = nsnull;
|
||||
for (i = 0; i < count, *aReturn == nsnull; i++) {
|
||||
nsIFormControl *control = (nsIFormControl *)mForm->GetFormControlAt(i);
|
||||
if (nsnull != control) {
|
||||
nsIContent *content;
|
||||
|
||||
result = control->QueryInterface(kIContentIID, (void **)&content);
|
||||
if (NS_OK == result) {
|
||||
nsAutoString name;
|
||||
// XXX Should it be an EqualsIgnoreCase?
|
||||
if (((content->GetAttribute("NAME", name) == eContentAttr_HasValue) &&
|
||||
(aName.Equals(name))) ||
|
||||
((content->GetAttribute("ID", name) == eContentAttr_HasValue) &&
|
||||
(aName.Equals(name)))) {
|
||||
result = control->QueryInterface(kIDOMNodeIID, (void **)aReturn);
|
||||
}
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
NS_RELEASE(control);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nsFormElementList::ReleaseForm()
|
||||
{
|
||||
if (nsnull != mForm) {
|
||||
mForm = nsnull;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче