implemented nsHTMLDocument::GetElementsByName

This commit is contained in:
vidur%netscape.com 1999-02-04 23:23:07 +00:00
Родитель f69c92b269
Коммит e0542e23e1
8 изменённых файлов: 146 добавлений и 144 удалений

Просмотреть файл

@ -58,15 +58,18 @@ nsContentList::nsContentList(nsIDocument *aDocument,
}
mMatchNameSpaceId = aMatchNameSpaceId;
mFunc = nsnull;
mData = nsnull;
mRootContent = aRootContent;
Init(aDocument);
}
nsContentList::nsContentList(nsIDocument *aDocument,
nsContentListMatchFunc aFunc,
void* aData,
nsIContent* aRootContent)
{
mFunc = aFunc;
mData = aData;
mMatchAtom = nsnull;
mRootContent = aRootContent;
mMatchAll = PR_FALSE;
@ -96,6 +99,12 @@ nsContentList::~nsContentList()
}
NS_IF_RELEASE(mMatchAtom);
// XXX This is absolutely gross, since this is allocated
// elsewhere.
if (nsnull != mData) {
delete mData;
}
}
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
@ -336,7 +345,7 @@ nsContentList::Match(nsIContent *aContent, PRBool *aMatch)
NS_IF_RELEASE(name);
}
else if (nsnull != mFunc) {
*aMatch = (*mFunc)(aContent);
*aMatch = (*mFunc)(aContent, mData);
}
else {
*aMatch = PR_FALSE;

Просмотреть файл

@ -26,7 +26,7 @@
#include "nsIDocumentObserver.h"
#include "nsIScriptObjectOwner.h"
typedef PRBool (*nsContentListMatchFunc)(nsIContent *aContent);
typedef PRBool (*nsContentListMatchFunc)(nsIContent* aContent, void* aData);
class nsIDocument;
@ -43,6 +43,7 @@ public:
nsIContent* aRootContent=nsnull);
nsContentList(nsIDocument *aDocument,
nsContentListMatchFunc aFunc,
void* aData,
nsIContent* aRootContent=nsnull);
virtual ~nsContentList();
@ -129,6 +130,7 @@ protected:
nsIAtom* mMatchAtom;
PRInt32 mMatchNameSpaceId;
nsContentListMatchFunc mFunc;
void* mData;
nsVoidArray mContent;
void *mScriptObject;
nsIDocument *mDocument;

Просмотреть файл

@ -1110,7 +1110,7 @@ nsHTMLDocument::GetApplets(nsIDOMHTMLCollection** aApplets)
}
PRBool
nsHTMLDocument::MatchLinks(nsIContent *aContent)
nsHTMLDocument::MatchLinks(nsIContent *aContent, void* aData)
{
nsIAtom *name;
aContent->GetTag(name);
@ -1131,7 +1131,7 @@ NS_IMETHODIMP
nsHTMLDocument::GetLinks(nsIDOMHTMLCollection** aLinks)
{
if (nsnull == mLinks) {
mLinks = new nsContentList(this, MatchLinks);
mLinks = new nsContentList(this, MatchLinks, nsnull);
if (nsnull == mLinks) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1145,7 +1145,7 @@ nsHTMLDocument::GetLinks(nsIDOMHTMLCollection** aLinks)
}
PRBool
nsHTMLDocument::MatchAnchors(nsIContent *aContent)
nsHTMLDocument::MatchAnchors(nsIContent *aContent, void* aData)
{
nsIAtom *name;
aContent->GetTag(name);
@ -1166,7 +1166,7 @@ NS_IMETHODIMP
nsHTMLDocument::GetAnchors(nsIDOMHTMLCollection** aAnchors)
{
if (nsnull == mAnchors) {
mAnchors = new nsContentList(this, MatchAnchors);
mAnchors = new nsContentList(this, MatchAnchors, nsnull);
if (nsnull == mAnchors) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1393,25 +1393,46 @@ nsHTMLDocument::GetElementById(const nsString& aElementId, nsIDOMElement** aRetu
return NS_OK;
}
NS_IMETHODIMP
nsHTMLDocument::GetElementsByName(const nsString& aElementName, nsIDOMNodeList** aReturn)
PRBool
nsHTMLDocument::MatchNameAttribute(nsIContent* aContent, void* aData)
{
//XXX TBI
return NS_ERROR_NOT_IMPLEMENTED;
nsresult result;
nsAutoString name;
char* matchName = (char*)aData;
result = aContent->GetAttribute(kNameSpaceID_None,
nsHTMLAtoms::name,
name);
if ((result == NS_OK) && name.Equals(matchName)) {
return PR_TRUE;
}
else {
return PR_FALSE;
}
}
NS_IMETHODIMP
nsHTMLDocument::GetElementsByName(const nsString& aElementName,
nsIDOMNodeList** aReturn)
{
char* name = aElementName.ToNewCString();
nsContentList* elements = new nsContentList(this,
MatchNameAttribute,
name);
if (nsnull == elements) {
return NS_ERROR_OUT_OF_MEMORY;
}
return elements->QueryInterface(kIDOMNodeListIID, (void**)aReturn);
}
NS_IMETHODIMP
nsHTMLDocument::GetAlinkColor(nsString& aAlinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetALink(aAlinkColor);
NS_RELEASE(body);
@ -1423,15 +1444,10 @@ nsHTMLDocument::GetAlinkColor(nsString& aAlinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetAlinkColor(const nsString& aAlinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetALink(aAlinkColor);
NS_RELEASE(body);
@ -1443,15 +1459,10 @@ nsHTMLDocument::SetAlinkColor(const nsString& aAlinkColor)
NS_IMETHODIMP
nsHTMLDocument::GetLinkColor(nsString& aLinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetLink(aLinkColor);
NS_RELEASE(body);
@ -1463,15 +1474,10 @@ nsHTMLDocument::GetLinkColor(nsString& aLinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetLinkColor(const nsString& aLinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetLink(aLinkColor);
NS_RELEASE(body);
@ -1483,15 +1489,10 @@ nsHTMLDocument::SetLinkColor(const nsString& aLinkColor)
NS_IMETHODIMP
nsHTMLDocument::GetVlinkColor(nsString& aVlinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetVLink(aVlinkColor);
NS_RELEASE(body);
@ -1503,15 +1504,10 @@ nsHTMLDocument::GetVlinkColor(nsString& aVlinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetVlinkColor(const nsString& aVlinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetVLink(aVlinkColor);
NS_RELEASE(body);
@ -1523,15 +1519,10 @@ nsHTMLDocument::SetVlinkColor(const nsString& aVlinkColor)
NS_IMETHODIMP
nsHTMLDocument::GetBgColor(nsString& aBgColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetBgColor(aBgColor);
NS_RELEASE(body);
@ -1543,15 +1534,10 @@ nsHTMLDocument::GetBgColor(nsString& aBgColor)
NS_IMETHODIMP
nsHTMLDocument::SetBgColor(const nsString& aBgColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetBgColor(aBgColor);
NS_RELEASE(body);
@ -1563,15 +1549,10 @@ nsHTMLDocument::SetBgColor(const nsString& aBgColor)
NS_IMETHODIMP
nsHTMLDocument::GetFgColor(nsString& aFgColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetText(aFgColor);
NS_RELEASE(body);
@ -1583,15 +1564,10 @@ nsHTMLDocument::GetFgColor(nsString& aFgColor)
NS_IMETHODIMP
nsHTMLDocument::SetFgColor(const nsString& aFgColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetText(aFgColor);
NS_RELEASE(body);
@ -2777,6 +2753,17 @@ nsHTMLDocument::GetBodyContent()
return PR_FALSE;
}
nsresult
nsHTMLDocument::GetBodyElement(nsIDOMHTMLBodyElement** aBody)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
return mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)aBody);
}
// forms related stuff
NS_IMETHODIMP

Просмотреть файл

@ -24,6 +24,7 @@
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMNSHTMLDocument.h"
#include "nsIDOMNode.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsIHTMLContentContainer.h"
#include "plhash.h"
@ -160,10 +161,12 @@ protected:
nsIContent *MatchName(nsIContent *aContent, const nsString& aName);
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet);
static PRBool MatchLinks(nsIContent *aContent);
static PRBool MatchAnchors(nsIContent *aContent);
static PRBool MatchLinks(nsIContent *aContent, void* aData);
static PRBool MatchAnchors(nsIContent *aContent, void* aData);
static PRBool MatchNameAttribute(nsIContent* aContent, void* aData);
PRBool GetBodyContent();
nsresult GetBodyElement(nsIDOMHTMLBodyElement** aBody);
virtual nsresult Reset(nsIURL *aURL);
nsresult WriteCommon(JSContext *cx,

Просмотреть файл

@ -58,15 +58,18 @@ nsContentList::nsContentList(nsIDocument *aDocument,
}
mMatchNameSpaceId = aMatchNameSpaceId;
mFunc = nsnull;
mData = nsnull;
mRootContent = aRootContent;
Init(aDocument);
}
nsContentList::nsContentList(nsIDocument *aDocument,
nsContentListMatchFunc aFunc,
void* aData,
nsIContent* aRootContent)
{
mFunc = aFunc;
mData = aData;
mMatchAtom = nsnull;
mRootContent = aRootContent;
mMatchAll = PR_FALSE;
@ -96,6 +99,12 @@ nsContentList::~nsContentList()
}
NS_IF_RELEASE(mMatchAtom);
// XXX This is absolutely gross, since this is allocated
// elsewhere.
if (nsnull != mData) {
delete mData;
}
}
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
@ -336,7 +345,7 @@ nsContentList::Match(nsIContent *aContent, PRBool *aMatch)
NS_IF_RELEASE(name);
}
else if (nsnull != mFunc) {
*aMatch = (*mFunc)(aContent);
*aMatch = (*mFunc)(aContent, mData);
}
else {
*aMatch = PR_FALSE;

Просмотреть файл

@ -26,7 +26,7 @@
#include "nsIDocumentObserver.h"
#include "nsIScriptObjectOwner.h"
typedef PRBool (*nsContentListMatchFunc)(nsIContent *aContent);
typedef PRBool (*nsContentListMatchFunc)(nsIContent* aContent, void* aData);
class nsIDocument;
@ -43,6 +43,7 @@ public:
nsIContent* aRootContent=nsnull);
nsContentList(nsIDocument *aDocument,
nsContentListMatchFunc aFunc,
void* aData,
nsIContent* aRootContent=nsnull);
virtual ~nsContentList();
@ -129,6 +130,7 @@ protected:
nsIAtom* mMatchAtom;
PRInt32 mMatchNameSpaceId;
nsContentListMatchFunc mFunc;
void* mData;
nsVoidArray mContent;
void *mScriptObject;
nsIDocument *mDocument;

Просмотреть файл

@ -1110,7 +1110,7 @@ nsHTMLDocument::GetApplets(nsIDOMHTMLCollection** aApplets)
}
PRBool
nsHTMLDocument::MatchLinks(nsIContent *aContent)
nsHTMLDocument::MatchLinks(nsIContent *aContent, void* aData)
{
nsIAtom *name;
aContent->GetTag(name);
@ -1131,7 +1131,7 @@ NS_IMETHODIMP
nsHTMLDocument::GetLinks(nsIDOMHTMLCollection** aLinks)
{
if (nsnull == mLinks) {
mLinks = new nsContentList(this, MatchLinks);
mLinks = new nsContentList(this, MatchLinks, nsnull);
if (nsnull == mLinks) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1145,7 +1145,7 @@ nsHTMLDocument::GetLinks(nsIDOMHTMLCollection** aLinks)
}
PRBool
nsHTMLDocument::MatchAnchors(nsIContent *aContent)
nsHTMLDocument::MatchAnchors(nsIContent *aContent, void* aData)
{
nsIAtom *name;
aContent->GetTag(name);
@ -1166,7 +1166,7 @@ NS_IMETHODIMP
nsHTMLDocument::GetAnchors(nsIDOMHTMLCollection** aAnchors)
{
if (nsnull == mAnchors) {
mAnchors = new nsContentList(this, MatchAnchors);
mAnchors = new nsContentList(this, MatchAnchors, nsnull);
if (nsnull == mAnchors) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1393,25 +1393,46 @@ nsHTMLDocument::GetElementById(const nsString& aElementId, nsIDOMElement** aRetu
return NS_OK;
}
NS_IMETHODIMP
nsHTMLDocument::GetElementsByName(const nsString& aElementName, nsIDOMNodeList** aReturn)
PRBool
nsHTMLDocument::MatchNameAttribute(nsIContent* aContent, void* aData)
{
//XXX TBI
return NS_ERROR_NOT_IMPLEMENTED;
nsresult result;
nsAutoString name;
char* matchName = (char*)aData;
result = aContent->GetAttribute(kNameSpaceID_None,
nsHTMLAtoms::name,
name);
if ((result == NS_OK) && name.Equals(matchName)) {
return PR_TRUE;
}
else {
return PR_FALSE;
}
}
NS_IMETHODIMP
nsHTMLDocument::GetElementsByName(const nsString& aElementName,
nsIDOMNodeList** aReturn)
{
char* name = aElementName.ToNewCString();
nsContentList* elements = new nsContentList(this,
MatchNameAttribute,
name);
if (nsnull == elements) {
return NS_ERROR_OUT_OF_MEMORY;
}
return elements->QueryInterface(kIDOMNodeListIID, (void**)aReturn);
}
NS_IMETHODIMP
nsHTMLDocument::GetAlinkColor(nsString& aAlinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetALink(aAlinkColor);
NS_RELEASE(body);
@ -1423,15 +1444,10 @@ nsHTMLDocument::GetAlinkColor(nsString& aAlinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetAlinkColor(const nsString& aAlinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetALink(aAlinkColor);
NS_RELEASE(body);
@ -1443,15 +1459,10 @@ nsHTMLDocument::SetAlinkColor(const nsString& aAlinkColor)
NS_IMETHODIMP
nsHTMLDocument::GetLinkColor(nsString& aLinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetLink(aLinkColor);
NS_RELEASE(body);
@ -1463,15 +1474,10 @@ nsHTMLDocument::GetLinkColor(nsString& aLinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetLinkColor(const nsString& aLinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetLink(aLinkColor);
NS_RELEASE(body);
@ -1483,15 +1489,10 @@ nsHTMLDocument::SetLinkColor(const nsString& aLinkColor)
NS_IMETHODIMP
nsHTMLDocument::GetVlinkColor(nsString& aVlinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetVLink(aVlinkColor);
NS_RELEASE(body);
@ -1503,15 +1504,10 @@ nsHTMLDocument::GetVlinkColor(nsString& aVlinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetVlinkColor(const nsString& aVlinkColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetVLink(aVlinkColor);
NS_RELEASE(body);
@ -1523,15 +1519,10 @@ nsHTMLDocument::SetVlinkColor(const nsString& aVlinkColor)
NS_IMETHODIMP
nsHTMLDocument::GetBgColor(nsString& aBgColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetBgColor(aBgColor);
NS_RELEASE(body);
@ -1543,15 +1534,10 @@ nsHTMLDocument::GetBgColor(nsString& aBgColor)
NS_IMETHODIMP
nsHTMLDocument::SetBgColor(const nsString& aBgColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetBgColor(aBgColor);
NS_RELEASE(body);
@ -1563,15 +1549,10 @@ nsHTMLDocument::SetBgColor(const nsString& aBgColor)
NS_IMETHODIMP
nsHTMLDocument::GetFgColor(nsString& aFgColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->GetText(aFgColor);
NS_RELEASE(body);
@ -1583,15 +1564,10 @@ nsHTMLDocument::GetFgColor(nsString& aFgColor)
NS_IMETHODIMP
nsHTMLDocument::SetFgColor(const nsString& aFgColor)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
nsresult result = NS_OK;
nsIDOMHTMLBodyElement* body;
result = mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)&body);
result = GetBodyElement(&body);
if (NS_OK == result) {
result = body->SetText(aFgColor);
NS_RELEASE(body);
@ -2777,6 +2753,17 @@ nsHTMLDocument::GetBodyContent()
return PR_FALSE;
}
nsresult
nsHTMLDocument::GetBodyElement(nsIDOMHTMLBodyElement** aBody)
{
if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
return mBodyContent->QueryInterface(kIDOMHTMLBodyElementIID,
(void**)aBody);
}
// forms related stuff
NS_IMETHODIMP

Просмотреть файл

@ -24,6 +24,7 @@
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMNSHTMLDocument.h"
#include "nsIDOMNode.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsIHTMLContentContainer.h"
#include "plhash.h"
@ -160,10 +161,12 @@ protected:
nsIContent *MatchName(nsIContent *aContent, const nsString& aName);
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet);
static PRBool MatchLinks(nsIContent *aContent);
static PRBool MatchAnchors(nsIContent *aContent);
static PRBool MatchLinks(nsIContent *aContent, void* aData);
static PRBool MatchAnchors(nsIContent *aContent, void* aData);
static PRBool MatchNameAttribute(nsIContent* aContent, void* aData);
PRBool GetBodyContent();
nsresult GetBodyElement(nsIDOMHTMLBodyElement** aBody);
virtual nsresult Reset(nsIURL *aURL);
nsresult WriteCommon(JSContext *cx,