From 9679502c543d857223cd79859da27bfdb96d5fd3 Mon Sep 17 00:00:00 2001 From: "vidur%netscape.com" Date: Tue, 18 Jan 2000 23:35:47 +0000 Subject: [PATCH] Fix for bug 9378. document.layers now returns undefined, not null. r=pollmann --- content/html/document/src/nsHTMLDocument.cpp | 5 ++-- dom/public/html/nsIDOMNSHTMLDocument.h | 4 --- dom/public/idl/html/HTMLDocument.idl | 1 - dom/src/html/nsJSHTMLDocument.cpp | 31 +------------------- layout/html/document/src/nsHTMLDocument.cpp | 5 ++-- 5 files changed, 5 insertions(+), 41 deletions(-) diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 296b9f1c5f5..2e5a4c2207f 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -2291,10 +2291,10 @@ nsHTMLDocument::MatchLayers(nsIContent *aContent, nsString* aData) return result; } +#ifdef NS_IMPLEMENT_DOCUMENT_LAYERS NS_IMETHODIMP nsHTMLDocument::GetLayers(nsIDOMHTMLCollection** aLayers) { -#ifdef NS_IMPLEMENT_DOCUMENT_LAYERS if (nsnull == mLayers) { mLayers = new nsContentList(this, MatchLayers, nsnull); if (nsnull == mLayers) { @@ -2305,12 +2305,11 @@ nsHTMLDocument::GetLayers(nsIDOMHTMLCollection** aLayers) *aLayers = (nsIDOMHTMLCollection *)mLayers; NS_ADDREF(mLayers); -#else *aLayers = nsnull; -#endif return NS_OK; } +#endif NS_IMETHODIMP nsHTMLDocument::GetPlugins(nsIDOMHTMLCollection** aPlugins) diff --git a/dom/public/html/nsIDOMNSHTMLDocument.h b/dom/public/html/nsIDOMNSHTMLDocument.h index 31ab86b37c2..16f061eccdf 100644 --- a/dom/public/html/nsIDOMNSHTMLDocument.h +++ b/dom/public/html/nsIDOMNSHTMLDocument.h @@ -60,8 +60,6 @@ public: NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds)=0; - NS_IMETHOD GetLayers(nsIDOMHTMLCollection** aLayers)=0; - NS_IMETHOD GetPlugins(nsIDOMHTMLCollection** aPlugins)=0; NS_IMETHOD GetSelection(nsString& aReturn)=0; @@ -97,7 +95,6 @@ public: NS_IMETHOD SetFgColor(const nsString& aFgColor); \ NS_IMETHOD GetLastModified(nsString& aLastModified); \ NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds); \ - NS_IMETHOD GetLayers(nsIDOMHTMLCollection** aLayers); \ NS_IMETHOD GetPlugins(nsIDOMHTMLCollection** aPlugins); \ NS_IMETHOD GetSelection(nsString& aReturn); \ NS_IMETHOD NamedItem(const nsString& aName, nsIDOMElement** aReturn); \ @@ -124,7 +121,6 @@ public: NS_IMETHOD SetFgColor(const nsString& aFgColor) { return _to SetFgColor(aFgColor); } \ NS_IMETHOD GetLastModified(nsString& aLastModified) { return _to GetLastModified(aLastModified); } \ NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds) { return _to GetEmbeds(aEmbeds); } \ - NS_IMETHOD GetLayers(nsIDOMHTMLCollection** aLayers) { return _to GetLayers(aLayers); } \ NS_IMETHOD GetPlugins(nsIDOMHTMLCollection** aPlugins) { return _to GetPlugins(aPlugins); } \ NS_IMETHOD GetSelection(nsString& aReturn) { return _to GetSelection(aReturn); } \ NS_IMETHOD NamedItem(const nsString& aName, nsIDOMElement** aReturn) { return _to NamedItem(aName, aReturn); } \ diff --git a/dom/public/idl/html/HTMLDocument.idl b/dom/public/idl/html/HTMLDocument.idl index 47ebf158221..209a673e04c 100644 --- a/dom/public/idl/html/HTMLDocument.idl +++ b/dom/public/idl/html/HTMLDocument.idl @@ -34,7 +34,6 @@ readonly attribute wstring lastModified; readonly attribute HTMLCollection embeds; - readonly attribute HTMLCollection layers; readonly attribute HTMLCollection plugins; wstring getSelection(); diff --git a/dom/src/html/nsJSHTMLDocument.cpp b/dom/src/html/nsJSHTMLDocument.cpp index 633a6ebf0e4..e7d6d5b72ea 100644 --- a/dom/src/html/nsJSHTMLDocument.cpp +++ b/dom/src/html/nsJSHTMLDocument.cpp @@ -76,8 +76,7 @@ enum HTMLDocument_slots { NSHTMLDOCUMENT_FGCOLOR = -16, NSHTMLDOCUMENT_LASTMODIFIED = -17, NSHTMLDOCUMENT_EMBEDS = -18, - NSHTMLDOCUMENT_LAYERS = -19, - NSHTMLDOCUMENT_PLUGINS = -20 + NSHTMLDOCUMENT_PLUGINS = -19 }; /***********************************************************************/ @@ -491,33 +490,6 @@ GetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } - case NSHTMLDOCUMENT_LAYERS: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSHTMLDOCUMENT_LAYERS, PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR); - } - nsIDOMHTMLCollection* prop; - nsIDOMNSHTMLDocument* b; - if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) { - nsresult result = NS_OK; - result = b->GetLayers(&prop); - if(NS_SUCCEEDED(result)) { - // get the js object - nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp); - NS_RELEASE(b); - } - else { - NS_RELEASE(b); - return nsJSUtils::nsReportError(cx, obj, result); - } - } - else { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR); - } - break; - } case NSHTMLDOCUMENT_PLUGINS: { PRBool ok = PR_FALSE; @@ -1492,7 +1464,6 @@ static JSPropertySpec HTMLDocumentProperties[] = {"fgColor", NSHTMLDOCUMENT_FGCOLOR, JSPROP_ENUMERATE}, {"lastModified", NSHTMLDOCUMENT_LASTMODIFIED, JSPROP_ENUMERATE | JSPROP_READONLY}, {"embeds", NSHTMLDOCUMENT_EMBEDS, JSPROP_ENUMERATE | JSPROP_READONLY}, - {"layers", NSHTMLDOCUMENT_LAYERS, JSPROP_ENUMERATE | JSPROP_READONLY}, {"plugins", NSHTMLDOCUMENT_PLUGINS, JSPROP_ENUMERATE | JSPROP_READONLY}, {0} }; diff --git a/layout/html/document/src/nsHTMLDocument.cpp b/layout/html/document/src/nsHTMLDocument.cpp index 296b9f1c5f5..2e5a4c2207f 100644 --- a/layout/html/document/src/nsHTMLDocument.cpp +++ b/layout/html/document/src/nsHTMLDocument.cpp @@ -2291,10 +2291,10 @@ nsHTMLDocument::MatchLayers(nsIContent *aContent, nsString* aData) return result; } +#ifdef NS_IMPLEMENT_DOCUMENT_LAYERS NS_IMETHODIMP nsHTMLDocument::GetLayers(nsIDOMHTMLCollection** aLayers) { -#ifdef NS_IMPLEMENT_DOCUMENT_LAYERS if (nsnull == mLayers) { mLayers = new nsContentList(this, MatchLayers, nsnull); if (nsnull == mLayers) { @@ -2305,12 +2305,11 @@ nsHTMLDocument::GetLayers(nsIDOMHTMLCollection** aLayers) *aLayers = (nsIDOMHTMLCollection *)mLayers; NS_ADDREF(mLayers); -#else *aLayers = nsnull; -#endif return NS_OK; } +#endif NS_IMETHODIMP nsHTMLDocument::GetPlugins(nsIDOMHTMLCollection** aPlugins)