mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 658213. Just pass an JSContext to ReparentContentWrappersInScope. r=peterv
This commit is contained in:
parent
c414bf437c
commit
7e1dd99351
@ -216,7 +216,8 @@ public:
|
||||
* When a document's scope changes (e.g., from document.open(), call this
|
||||
* function to move all content wrappers from the old scope to the new one.
|
||||
*/
|
||||
static nsresult ReparentContentWrappersInScope(nsIScriptGlobalObject *aOldScope,
|
||||
static nsresult ReparentContentWrappersInScope(JSContext *cx,
|
||||
nsIScriptGlobalObject *aOldScope,
|
||||
nsIScriptGlobalObject *aNewScope);
|
||||
|
||||
static PRBool IsCallerChrome();
|
||||
|
@ -1336,42 +1336,10 @@ nsContentUtils::GetContextAndScope(nsIDocument *aOldDocument,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentUtils::ReparentContentWrappersInScope(nsIScriptGlobalObject *aOldScope,
|
||||
nsContentUtils::ReparentContentWrappersInScope(JSContext *cx,
|
||||
nsIScriptGlobalObject *aOldScope,
|
||||
nsIScriptGlobalObject *aNewScope)
|
||||
{
|
||||
JSContext *cx = nsnull;
|
||||
|
||||
// Try really hard to find a context to work on.
|
||||
nsIScriptContext *context = aOldScope->GetContext();
|
||||
if (context) {
|
||||
cx = static_cast<JSContext *>(context->GetNativeContext());
|
||||
}
|
||||
|
||||
if (!cx) {
|
||||
context = aNewScope->GetContext();
|
||||
if (context) {
|
||||
cx = static_cast<JSContext *>(context->GetNativeContext());
|
||||
}
|
||||
|
||||
if (!cx) {
|
||||
sThreadJSContextStack->Peek(&cx);
|
||||
|
||||
if (!cx) {
|
||||
sThreadJSContextStack->GetSafeJSContext(&cx);
|
||||
|
||||
if (!cx) {
|
||||
// Wow, this is really bad!
|
||||
NS_WARNING("No context reachable in ReparentContentWrappers()!");
|
||||
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we have a context, let's get the global objects from the two
|
||||
// scopes and ask XPConnect to do the rest of the work.
|
||||
|
||||
JSObject *oldScopeObj = aOldScope->GetGlobalJSObject();
|
||||
JSObject *newScopeObj = aNewScope->GetGlobalJSObject();
|
||||
|
||||
|
@ -1518,7 +1518,8 @@ nsHTMLDocument::SetCookie(const nsAString& aCookie)
|
||||
|
||||
// XXX TBI: accepting arguments to the open method.
|
||||
nsresult
|
||||
nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
nsHTMLDocument::OpenCommon(JSContext *cx, const nsACString& aContentType,
|
||||
PRBool aReplace)
|
||||
{
|
||||
if (!IsHTML() || mDisableDocWrite) {
|
||||
// No calling document.open() on XHTML
|
||||
@ -1686,7 +1687,7 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> newScope(do_QueryReferent(mScopeObject));
|
||||
if (oldScope && newScope != oldScope) {
|
||||
nsContentUtils::ReparentContentWrappersInScope(oldScope, newScope);
|
||||
nsContentUtils::ReparentContentWrappersInScope(cx, oldScope, newScope);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1767,9 +1768,9 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Open(const nsACString& aContentType, PRBool aReplace,
|
||||
nsIDOMDocument** aReturn)
|
||||
JSContext *cx, nsIDOMDocument** aReturn)
|
||||
{
|
||||
nsresult rv = OpenCommon(aContentType, aReplace);
|
||||
nsresult rv = OpenCommon(cx, aContentType, aReplace);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(this, aReturn);
|
||||
@ -1843,7 +1844,8 @@ nsHTMLDocument::Close()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLDocument::WriteCommon(const nsAString& aText,
|
||||
nsHTMLDocument::WriteCommon(JSContext *cx,
|
||||
const nsAString& aText,
|
||||
PRBool aNewlineTerminate)
|
||||
{
|
||||
mTooDeepWriteRecursion =
|
||||
@ -1892,7 +1894,7 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMDocument> ignored;
|
||||
rv = Open(NS_LITERAL_CSTRING("text/html"), PR_FALSE,
|
||||
rv = Open(NS_LITERAL_CSTRING("text/html"), PR_FALSE, cx,
|
||||
getter_AddRefs(ignored));
|
||||
|
||||
// If Open() fails, or if it didn't create a parser (as it won't
|
||||
@ -1940,15 +1942,15 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Write(const nsAString& aText)
|
||||
nsHTMLDocument::Write(const nsAString& aText, JSContext *cx)
|
||||
{
|
||||
return WriteCommon(aText, PR_FALSE);
|
||||
return WriteCommon(cx, aText, PR_FALSE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Writeln(const nsAString& aText)
|
||||
nsHTMLDocument::Writeln(const nsAString& aText, JSContext *cx)
|
||||
{
|
||||
return WriteCommon(aText, PR_TRUE);
|
||||
return WriteCommon(cx, aText, PR_TRUE);
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -233,9 +233,10 @@ protected:
|
||||
|
||||
void GetDomainURI(nsIURI **uri);
|
||||
|
||||
nsresult WriteCommon(const nsAString& aText,
|
||||
nsresult WriteCommon(JSContext *cx, const nsAString& aText,
|
||||
PRBool aNewlineTerminate);
|
||||
nsresult OpenCommon(const nsACString& aContentType, PRBool aReplace);
|
||||
nsresult OpenCommon(JSContext *cx, const nsACString& aContentType,
|
||||
PRBool aReplace);
|
||||
|
||||
nsresult CreateAndAddWyciwygChannel(void);
|
||||
nsresult RemoveWyciwygChannel(void);
|
||||
|
@ -8986,7 +8986,7 @@ nsHTMLDocumentSH::DocumentOpen(JSContext *cx, uintN argc, jsval *vp)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> retval;
|
||||
nsresult rv = doc->Open(contentType, replace, getter_AddRefs(retval));
|
||||
nsresult rv = doc->Open(contentType, replace, cx, getter_AddRefs(retval));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, rv);
|
||||
|
||||
|
@ -39,6 +39,10 @@
|
||||
|
||||
#include "nsIDOMDocument.idl"
|
||||
|
||||
%{C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLDocument interface is the interface to a [X]HTML
|
||||
* document object.
|
||||
@ -46,7 +50,7 @@
|
||||
* @see <http://www.whatwg.org/html/>
|
||||
*/
|
||||
|
||||
[scriptable, uuid(6dd39b10-65ec-46f3-8c41-939300f6a7ce)]
|
||||
[scriptable, uuid(3c0ca40f-72c5-4d15-935e-ccaff7953f2c)]
|
||||
interface nsIDOMHTMLDocument : nsIDOMDocument
|
||||
{
|
||||
readonly attribute DOMString URL;
|
||||
@ -74,11 +78,14 @@ interface nsIDOMHTMLDocument : nsIDOMDocument
|
||||
// probably throw.
|
||||
// Pass aReplace = true to trigger a replacement of the previous
|
||||
// document in session history; pass false for normal history handling.
|
||||
[implicit_jscontext]
|
||||
nsIDOMDocument open(in ACString aContentType,
|
||||
in boolean aReplace);
|
||||
void close();
|
||||
|
||||
[implicit_jscontext]
|
||||
void write([optional, Null(Stringify)] in DOMString text);
|
||||
[implicit_jscontext]
|
||||
void writeln([optional, Null(Stringify)] in DOMString text);
|
||||
|
||||
/**
|
||||
|
@ -553,7 +553,7 @@ nsIDOMHTMLDocument_Write_customMethodCallCode = """
|
||||
str.Append(next_arg);
|
||||
}
|
||||
|
||||
rv = self->%s(arg0);
|
||||
rv = self->%s(arg0, cx);
|
||||
"""
|
||||
|
||||
nsIDOMStorage_Clear_customMethodCallCode = """
|
||||
|
Loading…
Reference in New Issue
Block a user