зеркало из https://github.com/mozilla/gecko-dev.git
Fixing bug 57534. document.open() is defined to not return anything in the DOM spec but for backwards compatibility it needs to return the document itself. r=blakeross@telocity.com, sr=brendan@mozilla.org
This commit is contained in:
Родитель
4b8940586c
Коммит
96702bc8a2
|
@ -2157,7 +2157,8 @@ nsHTMLDocument::Open()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc)
|
||||
nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc,
|
||||
nsIDOMDocument** aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsIURI* sourceURL;
|
||||
|
@ -2175,6 +2176,8 @@ nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc)
|
|||
NS_RELEASE(sourceURL);
|
||||
}
|
||||
|
||||
QueryInterface(NS_GET_IID(nsIDOMDocument), (void **)aReturn);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2183,7 +2186,9 @@ nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Clear(JSContext* cx, jsval* argv, PRUint32 argc)
|
||||
{
|
||||
return Open(cx, argv, argc);
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
|
||||
return Open(cx, argv, argc, getter_AddRefs(doc));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2294,22 +2299,26 @@ nsHTMLDocument::ScriptWriteCommon(JSContext *cx,
|
|||
}
|
||||
}
|
||||
|
||||
if (nsnull == mParser) {
|
||||
result = Open(cx, argv, argc);
|
||||
if (NS_OK != result) {
|
||||
if (!mParser) {
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
|
||||
result = Open(cx, argv, argc, getter_AddRefs(doc));
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (argc > 0) {
|
||||
PRUint32 index;
|
||||
nsAutoString str;
|
||||
str.Truncate();
|
||||
|
||||
for (index = 0; index < argc; index++) {
|
||||
JSString *jsstring = JS_ValueToString(cx, argv[index]);
|
||||
|
||||
if (nsnull != jsstring) {
|
||||
str.Append(NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars(jsstring)), JS_GetStringLength(jsstring));
|
||||
if (jsstring) {
|
||||
str.Append(NS_REINTERPRET_CAST(const PRUnichar*,
|
||||
JS_GetStringChars(jsstring)),
|
||||
JS_GetStringLength(jsstring));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsIScriptContext.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMEvent;
|
||||
class nsIDOMHTMLCollection;
|
||||
|
||||
|
@ -67,7 +68,7 @@ public:
|
|||
|
||||
NS_IMETHOD NamedItem(JSContext* cx, jsval* argv, PRUint32 argc, jsval* aReturn)=0;
|
||||
|
||||
NS_IMETHOD Open(JSContext* cx, jsval* argv, PRUint32 argc)=0;
|
||||
NS_IMETHOD Open(JSContext* cx, jsval* argv, PRUint32 argc, nsIDOMDocument** aReturn)=0;
|
||||
|
||||
NS_IMETHOD Write(JSContext* cx, jsval* argv, PRUint32 argc)=0;
|
||||
|
||||
|
@ -100,7 +101,7 @@ public:
|
|||
NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds); \
|
||||
NS_IMETHOD GetSelection(nsAWritableString& aReturn); \
|
||||
NS_IMETHOD NamedItem(JSContext* cx, jsval* argv, PRUint32 argc, jsval* aReturn); \
|
||||
NS_IMETHOD Open(JSContext* cx, jsval* argv, PRUint32 argc); \
|
||||
NS_IMETHOD Open(JSContext* cx, jsval* argv, PRUint32 argc, nsIDOMDocument** aReturn); \
|
||||
NS_IMETHOD Write(JSContext* cx, jsval* argv, PRUint32 argc); \
|
||||
NS_IMETHOD Writeln(JSContext* cx, jsval* argv, PRUint32 argc); \
|
||||
NS_IMETHOD Clear(JSContext* cx, jsval* argv, PRUint32 argc); \
|
||||
|
@ -127,7 +128,7 @@ public:
|
|||
NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds) { return _to GetEmbeds(aEmbeds); } \
|
||||
NS_IMETHOD GetSelection(nsAWritableString& aReturn) { return _to GetSelection(aReturn); } \
|
||||
NS_IMETHOD NamedItem(JSContext* cx, jsval* argv, PRUint32 argc, jsval* aReturn) { return _to NamedItem(cx, argv, argc, aReturn); } \
|
||||
NS_IMETHOD Open(JSContext* cx, jsval* argv, PRUint32 argc) { return _to Open(cx, argv, argc); } \
|
||||
NS_IMETHOD Open(JSContext* cx, jsval* argv, PRUint32 argc, nsIDOMDocument** aReturn) { return _to Open(cx, argv, argc, aReturn); } \
|
||||
NS_IMETHOD Write(JSContext* cx, jsval* argv, PRUint32 argc) { return _to Write(cx, argv, argc); } \
|
||||
NS_IMETHOD Writeln(JSContext* cx, jsval* argv, PRUint32 argc) { return _to Writeln(cx, argv, argc); } \
|
||||
NS_IMETHOD Clear(JSContext* cx, jsval* argv, PRUint32 argc) { return _to Clear(cx, argv, argc); } \
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
wstring getSelection();
|
||||
jsval namedItem(/* ... */);
|
||||
|
||||
void open(/* ... */);
|
||||
Document open(/* ... */);
|
||||
void write(/* ... */);
|
||||
void writeln(/* ... */);
|
||||
void clear(/* ... */);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "nsString.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNSHTMLDocument.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
|
@ -47,6 +48,7 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
|||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINSHTMLDocumentIID, NS_IDOMNSHTMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIEventIID, NS_IDOMEVENT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
|
||||
|
@ -858,6 +860,7 @@ NSHTMLDocumentOpen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR);
|
||||
}
|
||||
|
||||
nsIDOMDocument* nativeRet;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (!nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -873,12 +876,12 @@ NSHTMLDocumentOpen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
result = nativeThis->Open(cx, argv+0, argc-0);
|
||||
result = nativeThis->Open(cx, argv+0, argc-0, &nativeRet);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, obj, rval);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
|
|
@ -2157,7 +2157,8 @@ nsHTMLDocument::Open()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc)
|
||||
nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc,
|
||||
nsIDOMDocument** aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsIURI* sourceURL;
|
||||
|
@ -2175,6 +2176,8 @@ nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc)
|
|||
NS_RELEASE(sourceURL);
|
||||
}
|
||||
|
||||
QueryInterface(NS_GET_IID(nsIDOMDocument), (void **)aReturn);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2183,7 +2186,9 @@ nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Clear(JSContext* cx, jsval* argv, PRUint32 argc)
|
||||
{
|
||||
return Open(cx, argv, argc);
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
|
||||
return Open(cx, argv, argc, getter_AddRefs(doc));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2294,22 +2299,26 @@ nsHTMLDocument::ScriptWriteCommon(JSContext *cx,
|
|||
}
|
||||
}
|
||||
|
||||
if (nsnull == mParser) {
|
||||
result = Open(cx, argv, argc);
|
||||
if (NS_OK != result) {
|
||||
if (!mParser) {
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
|
||||
result = Open(cx, argv, argc, getter_AddRefs(doc));
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (argc > 0) {
|
||||
PRUint32 index;
|
||||
nsAutoString str;
|
||||
str.Truncate();
|
||||
|
||||
for (index = 0; index < argc; index++) {
|
||||
JSString *jsstring = JS_ValueToString(cx, argv[index]);
|
||||
|
||||
if (nsnull != jsstring) {
|
||||
str.Append(NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars(jsstring)), JS_GetStringLength(jsstring));
|
||||
if (jsstring) {
|
||||
str.Append(NS_REINTERPRET_CAST(const PRUnichar*,
|
||||
JS_GetStringChars(jsstring)),
|
||||
JS_GetStringLength(jsstring));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче