Bug 670896 - Add inner window ID and timestamp to nsIScriptError2; r=bzbarsky

This commit is contained in:
Mihai Sucan 2011-08-24 23:44:35 +03:00
Родитель 211ac44bb7
Коммит 47eca82a8c
35 изменённых файлов: 171 добавлений и 106 удалений

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

@ -280,7 +280,7 @@ var Scratchpad = {
scriptError.initWithWindowID(ex.message + "\n" + ex.stack, ex.fileName,
"", ex.lineNumber, 0, scriptError.errorFlag,
"content javascript",
this.getWindowId(contentWindow));
this.getInnerWindowId(contentWindow));
Services.console.logMessage(scriptError);
}
@ -633,16 +633,16 @@ var Scratchpad = {
},
/**
* Gets the ID of the outer window of the given DOM window object.
* Gets the ID of the inner window of the given DOM window object.
*
* @param nsIDOMWindow aWindow
* @return integer
* the outer window ID
* the inner window ID
*/
getWindowId: function SP_getWindowId(aWindow)
getInnerWindowId: function SP_getInnerWindowId(aWindow)
{
return aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
},
/**

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

@ -743,8 +743,8 @@ public:
* @param aColumnNumber Column number within resource containing error.
* @param aErrorFlags See nsIScriptError.
* @param aCategory Name of module reporting error.
* @param [aWindowId=0] (Optional) The window ID of the outer window the
* message originates from.
* @param [aInnerWindowId=0] (Optional) The window ID of the inner window
* the message originates from.
*/
enum PropertiesFile {
eCSS_PROPERTIES,
@ -769,7 +769,7 @@ public:
PRUint32 aColumnNumber,
PRUint32 aErrorFlags,
const char *aCategory,
PRUint64 aWindowId = 0);
PRUint64 aInnerWindowId = 0);
/**
* Report a localized error message to the error console.

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

@ -720,6 +720,15 @@ public:
return window ? window->WindowID() : 0;
}
/**
* Return the inner window ID.
*/
PRUint64 InnerWindowID()
{
nsPIDOMWindow *window = GetInnerWindow();
return window ? window->WindowID() : 0;
}
/**
* Get the script loader for this document
*/

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

@ -2734,7 +2734,7 @@ nsContentUtils::ReportToConsole(PropertiesFile aFile,
PRUint32 aColumnNumber,
PRUint32 aErrorFlags,
const char *aCategory,
PRUint64 aWindowId)
PRUint64 aInnerWindowId)
{
NS_ASSERTION((aParams && aParamsLength) || (!aParams && !aParamsLength),
"Supply either both parameters and their number or no"
@ -2768,7 +2768,8 @@ nsContentUtils::ReportToConsole(PropertiesFile aFile,
NS_ConvertUTF8toUTF16(spec).get(), // file name
aSourceLine.get(),
aLineNumber, aColumnNumber,
aErrorFlags, aCategory, aWindowId);
aErrorFlags, aCategory,
aInnerWindowId);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIScriptError> logError = do_QueryInterface(errorObject);
@ -2789,17 +2790,17 @@ nsContentUtils::ReportToConsole(PropertiesFile aFile,
nsIDocument* aDocument)
{
nsIURI* uri = aURI;
PRUint64 windowID = 0;
PRUint64 innerWindowID = 0;
if (aDocument) {
if (!uri) {
uri = aDocument->GetDocumentURI();
}
windowID = aDocument->OuterWindowID();
innerWindowID = aDocument->InnerWindowID();
}
return ReportToConsole(aFile, aMessageName, aParams, aParamsLength, uri,
aSourceLine, aLineNumber, aColumnNumber, aErrorFlags,
aCategory, windowID);
aCategory, innerWindowID);
}
PRBool

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

@ -85,7 +85,7 @@ nsEventSource::nsEventSource() :
mLastConvertionResult(NS_OK),
mReadyState(nsIEventSource::CONNECTING),
mScriptLine(0),
mWindowID(0)
mInnerWindowID(0)
{
}
@ -253,7 +253,7 @@ nsEventSource::Init(nsIPrincipal* aPrincipal,
mScriptFile.AssignASCII(filename);
}
mWindowID = nsJSUtils::GetCurrentlyRunningCodeWindowID(cx);
mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx);
}
// Get the load group for the page. When requesting we'll add ourselves to it.
@ -1072,7 +1072,7 @@ nsEventSource::PrintErrorOnConsole(const char *aBundleURI,
nsnull,
mScriptLine, 0,
nsIScriptError::errorFlag,
"Event Source", mWindowID);
"Event Source", mInnerWindowID);
// print the error message directly to the JS console
nsCOMPtr<nsIScriptError> logError = do_QueryInterface(errObj);

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

@ -252,12 +252,12 @@ protected:
// Event Source owner information:
// - the script file name
// - source code line number where the Event Source object was constructed.
// - the window ID of the outer window where the script lives. Note that this
// may not be the same as the Event Source owner window.
// - the ID of the inner window where the script lives. Note that this may not
// be the same as the Event Source owner window.
// These attributes are used for error reporting.
nsString mScriptFile;
PRUint32 mScriptLine;
PRUint64 mWindowID;
PRUint64 mInnerWindowID;
private:
nsEventSource(const nsEventSource& x); // prevent bad usage

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

@ -357,7 +357,7 @@ nsWebSocketEstablishedConnection::PrintErrorOnConsole(const char *aBundleURI,
NS_ConvertUTF8toUTF16(mOwner->GetScriptFile()).get(),
nsnull,
mOwner->GetScriptLine(), 0, nsIScriptError::errorFlag,
"Web Socket", mOwner->WindowID()
"Web Socket", mOwner->InnerWindowID()
);
// print the error message directly to the JS console
@ -631,7 +631,7 @@ nsWebSocket::nsWebSocket() : mKeepingAlive(PR_FALSE),
mReadyState(nsIMozWebSocket::CONNECTING),
mOutgoingBufferedAmount(0),
mScriptLine(0),
mWindowID(0)
mInnerWindowID(0)
{
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
}
@ -1428,7 +1428,7 @@ nsWebSocket::Init(nsIPrincipal* aPrincipal,
}
}
mWindowID = nsJSUtils::GetCurrentlyRunningCodeWindowID(cx);
mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx);
}
// parses the url

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

@ -99,7 +99,7 @@ public:
// Determine if preferences allow WebSocket
static PRBool PrefEnabled();
const PRUint64 WindowID() const { return mWindowID; }
const PRUint64 InnerWindowID() const { return mInnerWindowID; }
const nsCString& GetScriptFile() const { return mScriptFile; }
const PRUint32 GetScriptLine() const { return mScriptLine; }
@ -164,12 +164,12 @@ protected:
// Web Socket owner information:
// - the script file name, UTF8 encoded.
// - source code line number where the Web Socket object was constructed.
// - the window ID of the outer window where the script lives. Note that this
// may not be the same as the Web Socket owner window.
// - the ID of the inner window where the script lives. Note that this may not
// be the same as the Web Socket owner window.
// These attributes are used for error reporting.
nsCString mScriptFile;
PRUint32 mScriptLine;
PRUint64 mWindowID;
PRUint64 mInnerWindowID;
private:
nsWebSocket(const nsWebSocket& x); // prevent bad usage

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

@ -382,8 +382,8 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
nsnull, 0, 0, nsIScriptError::warningFlag,
"DOM",
callingDoc ?
callingDoc->OuterWindowID() :
this->OuterWindowID());
callingDoc->InnerWindowID() :
this->InnerWindowID());
NS_ENSURE_SUCCESS(rv, rv);

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

@ -1707,7 +1707,7 @@ PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
0, // column for error is not available
nsIScriptError::warningFlag,
"DOM:HTML",
nsJSUtils::GetCurrentlyRunningCodeWindowID(cx));
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx));
if (NS_SUCCEEDED(rv)){
nsCOMPtr<nsIScriptError> logError = do_QueryInterface(scriptError);

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

@ -540,6 +540,11 @@ public:
return outerWindow && !outerWindow->IsInnerWindow() ? outerWindow : nsnull;
}
static nsGlobalWindow* GetInnerWindowWithId(PRUint64 aInnerWindowID) {
nsGlobalWindow* innerWindow = sWindowsById->Get(aInnerWindowID);
return innerWindow && innerWindow->IsInnerWindow() ? innerWindow : nsnull;
}
static bool HasIndexedDBSupport();
static bool HasPerformanceSupport();

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

@ -267,11 +267,11 @@ public:
const nsAString& aFileName,
const nsAString& aSourceLine,
PRBool aDispatchEvent,
PRUint64 aWindowID)
PRUint64 aInnerWindowID)
: mScriptGlobal(aScriptGlobal), mLineNr(aLineNr), mColumn(aColumn),
mFlags(aFlags), mErrorMsg(aErrorMsg), mFileName(aFileName),
mSourceLine(aSourceLine), mDispatchEvent(aDispatchEvent),
mWindowID(aWindowID)
mInnerWindowID(aInnerWindowID)
{}
NS_IMETHOD Run()
@ -364,7 +364,7 @@ public:
rv = error2->InitWithWindowID(mErrorMsg.get(), mFileName.get(),
mSourceLine.get(),
mLineNr, mColumn, mFlags,
category, mWindowID);
category, mInnerWindowID);
} else {
rv = errorObject->Init(mErrorMsg.get(), mFileName.get(),
mSourceLine.get(),
@ -393,7 +393,7 @@ public:
nsString mFileName;
nsString mSourceLine;
PRBool mDispatchEvent;
PRUint64 mWindowID;
PRUint64 mInnerWindowID;
static PRBool sHandlingScriptError;
};
@ -474,13 +474,19 @@ NS_ScriptErrorReporter(JSContext *cx,
nsAutoString sourceLine;
sourceLine.Assign(reinterpret_cast<const PRUnichar*>(report->uclinebuf));
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(globalObject);
PRUint64 windowID = win ? win->WindowID() : 0;
PRUint64 innerWindowID = 0;
if (win) {
nsCOMPtr<nsPIDOMWindow> innerWin = win->GetCurrentInnerWindow();
if (innerWin) {
innerWindowID = innerWin->WindowID();
}
}
nsContentUtils::AddScriptRunner(
new ScriptErrorEvent(globalObject, report->lineno,
report->uctokenptr - report->uclinebuf,
report->flags, msg, fileName, sourceLine,
report->errorNumber != JSMSG_OUT_OF_MEMORY,
windowID));
innerWindowID));
}
}

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

@ -163,12 +163,12 @@ nsJSUtils::GetDynamicScriptContext(JSContext *aContext)
}
PRUint64
nsJSUtils::GetCurrentlyRunningCodeWindowID(JSContext *aContext)
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext)
{
if (!aContext)
return 0;
PRUint64 windowID = 0;
PRUint64 innerWindowID = 0;
JSObject *jsGlobal = JS_GetGlobalForScopeChain(aContext);
if (jsGlobal) {
@ -177,10 +177,10 @@ nsJSUtils::GetCurrentlyRunningCodeWindowID(JSContext *aContext)
if (scriptGlobal) {
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(scriptGlobal);
if (win)
windowID = win->GetOuterWindow()->WindowID();
innerWindowID = win->WindowID();
}
}
return windowID;
return innerWindowID;
}

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

@ -71,14 +71,14 @@ public:
static nsIScriptContext *GetDynamicScriptContext(JSContext *aContext);
/**
* Retrieve the outer window ID based on the given JSContext.
* Retrieve the inner window ID based on the given JSContext.
*
* @param JSContext aContext
* The JSContext from which you want to find the outer window ID.
* The JSContext from which you want to find the inner window ID.
*
* @returns PRUint64 the outer window ID.
* @returns PRUint64 the inner window ID.
*/
static PRUint64 GetCurrentlyRunningCodeWindowID(JSContext *aContext);
static PRUint64 GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext);
};

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

@ -895,11 +895,11 @@ public:
aWorkerPrivate->AssertInnerWindowIsCorrect();
}
PRUint64 windowId;
PRUint64 innerWindowId;
WorkerPrivate* parent = aWorkerPrivate->GetParent();
if (parent) {
windowId = 0;
innerWindowId = 0;
}
else {
AssertIsOnMainThread();
@ -909,13 +909,13 @@ public:
return true;
}
windowId = aWorkerPrivate->GetOuterWindowId();
innerWindowId = aWorkerPrivate->GetInnerWindowId();
}
return ReportErrorRunnable::ReportError(aCx, parent, true, target, mMessage,
mFilename, mLine, mLineNumber,
mColumnNumber, mFlags,
mErrorNumber, windowId);
mErrorNumber, innerWindowId);
}
static bool
@ -923,7 +923,7 @@ public:
bool aFireAtScope, JSObject* aTarget, const nsString& aMessage,
const nsString& aFilename, const nsString& aLine,
PRUint32 aLineNumber, PRUint32 aColumnNumber, PRUint32 aFlags,
PRUint32 aErrorNumber, PRUint64 aWindowId)
PRUint32 aErrorNumber, PRUint64 aInnerWindowId)
{
if (aWorkerPrivate) {
aWorkerPrivate->AssertIsOnWorkerThread();
@ -1030,7 +1030,7 @@ public:
aLine.get(), aLineNumber,
aColumnNumber, aFlags,
"Web Worker",
aWindowId))) {
aInnerWindowId))) {
consoleMessage = do_QueryInterface(scriptError);
NS_ASSERTION(consoleMessage, "This should never fail!");
}
@ -1932,10 +1932,10 @@ WorkerPrivateParent<Derived>::PostMessage(JSContext* aCx, jsval aMessage)
template <class Derived>
PRUint64
WorkerPrivateParent<Derived>::GetOuterWindowId()
WorkerPrivateParent<Derived>::GetInnerWindowId()
{
AssertIsOnMainThread();
return mDocument->OuterWindowID();
return mDocument->InnerWindowID();
}
template <class Derived>

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

@ -299,7 +299,7 @@ public:
PostMessage(JSContext* aCx, jsval aMessage);
PRUint64
GetOuterWindowId();
GetInnerWindowId();
void
UpdateJSContextOptions(JSContext* aCx, PRUint32 aOptions);

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

@ -96,15 +96,23 @@ interface nsIScriptError : nsIConsoleMessage
* An interface that nsIScriptError objects can implement to allow
* them to be initialized with a window id.
*/
[scriptable, uuid(35cd0f6a-f5bb-497a-ba83-9c8d089b52cd)]
[scriptable, uuid(4472646b-c928-4d76-9e7c-6b91da7f24cc)]
interface nsIScriptError2 : nsISupports {
/* Get the window id this was initialized with. Zero will be
returned if init() was used instead of initWithWindowId(). */
returned if init() was used instead of initWithWindowID(). */
readonly attribute unsigned long long outerWindowID;
/* Get the inner window id this was initialized with. Zero will be
returned if init() was used instead of initWithWindowID(). */
readonly attribute unsigned long long innerWindowID;
/* Elapsed time, in milliseconds, from a platform-specific zero time to the
time the message was created. */
readonly attribute long long timeStamp;
/* This should be called instead of nsIScriptError.init to
initialize with a window id. The window id should be for the
outer window associated with this error. */
inner window associated with this error. */
void initWithWindowID(in wstring message,
in wstring sourceName,
in wstring sourceLine,
@ -112,7 +120,7 @@ interface nsIScriptError2 : nsISupports {
in PRUint32 columnNumber,
in PRUint32 flags,
in string category,
in unsigned long long windowID);
in unsigned long long innerWindowID);
};
%{ C++

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

@ -43,6 +43,8 @@
*/
#include "xpcprivate.h"
#include "nsGlobalWindow.h"
#include "nsPIDOMWindow.h"
NS_IMPL_THREADSAFE_ISUPPORTS3(nsScriptError, nsIConsoleMessage, nsIScriptError,
nsIScriptError2)
@ -55,7 +57,9 @@ nsScriptError::nsScriptError()
mColumnNumber(0),
mFlags(0),
mCategory(),
mWindowID(0)
mOuterWindowID(0),
mInnerWindowID(0),
mTimeStamp(0)
{
}
@ -142,7 +146,7 @@ nsScriptError::InitWithWindowID(const PRUnichar *message,
PRUint32 columnNumber,
PRUint32 flags,
const char *category,
PRUint64 aWindowID)
PRUint64 aInnerWindowID)
{
mMessage.Assign(message);
mSourceName.Assign(sourceName);
@ -151,7 +155,18 @@ nsScriptError::InitWithWindowID(const PRUnichar *message,
mColumnNumber = columnNumber;
mFlags = flags;
mCategory.Assign(category);
mWindowID = aWindowID;
mTimeStamp = PR_Now() / 1000;
mInnerWindowID = aInnerWindowID;
if(aInnerWindowID) {
nsGlobalWindow* window =
nsGlobalWindow::GetInnerWindowWithId(aInnerWindowID);
if(window) {
nsPIDOMWindow* outer = window->GetOuterWindow();
if(outer)
mOuterWindowID = outer->WindowID();
}
}
return NS_OK;
}
@ -218,8 +233,22 @@ nsScriptError::ToString(nsACString& /*UTF8*/ aResult)
}
NS_IMETHODIMP
nsScriptError::GetOuterWindowID(PRUint64 *aWindowID)
nsScriptError::GetOuterWindowID(PRUint64 *aOuterWindowID)
{
*aWindowID = mWindowID;
*aOuterWindowID = mOuterWindowID;
return NS_OK;
}
NS_IMETHODIMP
nsScriptError::GetInnerWindowID(PRUint64 *aInnerWindowID)
{
*aInnerWindowID = mInnerWindowID;
return NS_OK;
}
NS_IMETHODIMP
nsScriptError::GetTimeStamp(PRInt64 *aTimeStamp)
{
*aTimeStamp = mTimeStamp;
return NS_OK;
}

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

@ -2880,7 +2880,7 @@ nsXPCComponents_Utils::ReportError()
if(NS_FAILED(rv) || !argv)
return NS_OK;
const PRUint64 windowID = nsJSUtils::GetCurrentlyRunningCodeWindowID(cx);
const PRUint64 innerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx);
JSErrorReport* err = JS_ErrorFromException(cx, argv[0]);
if(err)
@ -2899,7 +2899,7 @@ nsXPCComponents_Utils::ReportError()
err->lineno,
column,
err->flags,
"XPConnect JavaScript", windowID);
"XPConnect JavaScript", innerWindowID);
if(NS_FAILED(rv))
return NS_OK;
@ -2935,8 +2935,8 @@ nsXPCComponents_Utils::ReportError()
rv = scripterr->InitWithWindowID(reinterpret_cast<const PRUnichar *>(msgchars),
NS_ConvertUTF8toUTF16(fileName).get(),
nsnull,
lineNo, 0,
0, "XPConnect JavaScript", windowID);
lineNo, 0, 0,
"XPConnect JavaScript", innerWindowID);
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIScriptError> logError = do_QueryInterface(scripterr);

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

@ -1827,7 +1827,7 @@ XPCConvert::JSErrorToXPCException(XPCCallContext& ccx,
(const PRUnichar *)report->uclinebuf, report->lineno,
report->uctokenptr - report->uclinebuf, report->flags,
"XPConnect JavaScript",
nsJSUtils::GetCurrentlyRunningCodeWindowID(ccx.GetJSContext()));
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(ccx.GetJSContext()));
}
if(data)

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

@ -3885,7 +3885,9 @@ private:
PRUint32 mColumnNumber;
PRUint32 mFlags;
nsCString mCategory;
PRUint64 mWindowID;
PRUint64 mOuterWindowID;
PRUint64 mInnerWindowID;
PRUint64 mTimeStamp;
};
/***************************************************************************/

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

@ -1218,7 +1218,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
nsnull,
lineNumber, 0, 0,
"XPConnect JavaScript",
nsJSUtils::GetCurrentlyRunningCodeWindowID(cx));
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx));
if(NS_FAILED(rv))
scriptError = nsnull;
}

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

@ -285,7 +285,7 @@ nsCSSScanner::nsCSSScanner()
, mSVGMode(PR_FALSE)
#ifdef CSS_REPORT_PARSE_ERRORS
, mError(mErrorBuf, NS_ARRAY_LENGTH(mErrorBuf), 0)
, mWindowID(0)
, mInnerWindowID(0)
, mWindowIDCached(PR_FALSE)
, mSheet(nsnull)
, mLoader(nsnull)
@ -449,12 +449,12 @@ nsCSSScanner::OutputError()
if (InitGlobals() && gReportErrors) {
if (!mWindowIDCached) {
if (mSheet) {
mWindowID = mSheet->FindOwningWindowID();
mInnerWindowID = mSheet->FindOwningWindowInnerID();
}
if (mWindowID == 0 && mLoader) {
if (mInnerWindowID == 0 && mLoader) {
nsIDocument* doc = mLoader->GetDocument();
if (doc) {
mWindowID = doc->OuterWindowID();
mInnerWindowID = doc->InnerWindowID();
}
}
mWindowIDCached = PR_TRUE;
@ -471,7 +471,8 @@ nsCSSScanner::OutputError()
mErrorLineNumber,
mErrorColNumber,
nsIScriptError::warningFlag,
"CSS Parser", mWindowID);
"CSS Parser",
mInnerWindowID);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIScriptError> logError = do_QueryInterface(errorObject);
gConsoleService->LogMessage(logError);
@ -622,7 +623,7 @@ nsCSSScanner::Close()
mFileName.Truncate();
mURI = nsnull;
mError.Truncate();
mWindowID = 0;
mInnerWindowID = 0;
mWindowIDCached = PR_FALSE;
mSheet = nsnull;
mLoader = nsnull;

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

@ -248,7 +248,7 @@ protected:
PRUint32 mErrorLineNumber, mColNumber, mErrorColNumber;
nsFixedString mError;
PRUnichar mErrorBuf[200];
PRUint64 mWindowID;
PRUint64 mInnerWindowID;
PRBool mWindowIDCached;
nsCSSStyleSheet* mSheet;
mozilla::css::Loader* mLoader;

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

@ -1252,12 +1252,12 @@ nsCSSStyleSheet::SetOwningDocument(nsIDocument* aDocument)
}
}
/* virtual */ PRUint64
nsCSSStyleSheet::FindOwningWindowID() const
PRUint64
nsCSSStyleSheet::FindOwningWindowInnerID() const
{
PRUint64 windowID = 0;
if (mDocument) {
windowID = mDocument->OuterWindowID();
windowID = mDocument->InnerWindowID();
}
if (windowID == 0 && mOwningNode) {
@ -1265,7 +1265,7 @@ nsCSSStyleSheet::FindOwningWindowID() const
if (node) {
nsIDocument* doc = node->GetOwnerDoc();
if (doc) {
windowID = doc->OuterWindowID();
windowID = doc->InnerWindowID();
}
}
}
@ -1275,13 +1275,13 @@ nsCSSStyleSheet::FindOwningWindowID() const
if (sheet) {
nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(sheet);
if (cssSheet) {
windowID = cssSheet->FindOwningWindowID();
windowID = cssSheet->FindOwningWindowInnerID();
}
}
}
if (windowID == 0 && mParent) {
windowID = mParent->FindOwningWindowID();
windowID = mParent->FindOwningWindowInnerID();
}
return windowID;

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

@ -155,8 +155,8 @@ public:
virtual nsIDocument* GetOwningDocument() const; // may be null
virtual void SetOwningDocument(nsIDocument* aDocument);
// Find the ID of the owner outer window.
virtual PRUint64 FindOwningWindowID() const;
// Find the ID of the owner inner window.
PRUint64 FindOwningWindowInnerID() const;
#ifdef DEBUG
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
#endif

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

@ -798,14 +798,14 @@ nsUserFontSet::LogMessage(gfxProxyFontEntry *aProxy,
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
PRUint64 windowID = GetPresContext()->Document()->OuterWindowID();
PRUint64 innerWindowID = GetPresContext()->Document()->InnerWindowID();
rv = scriptError->InitWithWindowID(NS_ConvertUTF8toUTF16(msg).get(),
href.get(), // file
text.get(), // src line
0, 0, // line & column number
aFlags, // flags
"CSS Loader", // category (make separate?)
windowID);
innerWindowID);
if (NS_SUCCEEDED(rv)){
nsCOMPtr<nsIScriptError> logError = do_QueryInterface(scriptError);
if (logError) {

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

@ -133,7 +133,7 @@ Decoder::Finish()
NS_ConvertUTF8toUTF16(mImage->GetURIString()).get(),
nsnull,
0, 0, nsIScriptError::errorFlag,
"Image", mImage->WindowID()
"Image", mImage->InnerWindowID()
);
nsCOMPtr<nsIScriptError> error = do_QueryInterface(errorObject);

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

@ -42,7 +42,7 @@ namespace imagelib {
// Constructor
Image::Image(imgStatusTracker* aStatusTracker) :
mWindowId(0),
mInnerWindowId(0),
mAnimationConsumers(0),
mAnimationMode(kNormalAnimMode),
mInitialized(PR_FALSE),

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

@ -125,10 +125,10 @@ public:
PRUint32 GetAnimationConsumers() { return mAnimationConsumers; }
#endif
void SetWindowID(PRUint64 aWindowId) {
mWindowId = aWindowId;
void SetInnerWindowID(PRUint64 aInnerWindowId) {
mInnerWindowId = aInnerWindowId;
}
PRUint64 WindowID() const { return mWindowId; }
PRUint64 InnerWindowID() const { return mInnerWindowId; }
PRBool HasError() { return mError; }
@ -144,7 +144,7 @@ protected:
virtual nsresult StartAnimation() = 0;
virtual nsresult StopAnimation() = 0;
PRUint64 mWindowId;
PRUint64 mInnerWindowId;
// Member data shared by all implementations of this abstract class
nsAutoPtr<imgStatusTracker> mStatusTracker;

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

@ -1709,10 +1709,10 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
request->Init(aURI, aURI, loadGroup, newChannel, entry, cacheId, aCX,
aLoadingPrincipal, corsmode);
// Pass the windowID of the loading document, if possible.
// Pass the inner window ID of the loading document, if possible.
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aCX);
if (doc) {
request->SetWindowID(doc->OuterWindowID());
request->SetInnerWindowID(doc->InnerWindowID());
}
// create the proxy listener

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

@ -184,8 +184,9 @@ NS_IMPL_ISUPPORTS8(imgRequest,
imgRequest::imgRequest() :
mCacheId(0), mValidator(nsnull), mImageSniffers("image-sniffing-services"),
mWindowId(0), mCORSMode(imgIRequest::CORS_NONE), mDecodeRequested(PR_FALSE),
mIsMultiPartChannel(PR_FALSE), mGotData(PR_FALSE), mIsInCache(PR_FALSE)
mInnerWindowId(0), mCORSMode(imgIRequest::CORS_NONE),
mDecodeRequested(PR_FALSE), mIsMultiPartChannel(PR_FALSE), mGotData(PR_FALSE),
mIsInCache(PR_FALSE)
{}
imgRequest::~imgRequest()
@ -1035,7 +1036,7 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
} else {
mImage = new RasterImage(mStatusTracker.forget());
}
mImage->SetWindowID(mWindowId);
mImage->SetInnerWindowID(mInnerWindowId);
imageType = mImage->GetType();
// Notify any imgRequestProxys that are observing us that we have an Image.

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

@ -123,12 +123,12 @@ public:
nsresult UnlockImage();
nsresult RequestDecode();
inline void SetWindowID(PRUint64 aWindowId) {
mWindowId = aWindowId;
inline void SetInnerWindowID(PRUint64 aInnerWindowId) {
mInnerWindowId = aInnerWindowId;
}
inline PRUint64 WindowID() const {
return mWindowId;
inline PRUint64 InnerWindowID() const {
return mInnerWindowId;
}
// Set the cache validation information (expiry time, whether we must
@ -257,8 +257,8 @@ private:
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
nsCOMPtr<nsIChannel> mNewRedirectChannel;
// Originating outer window ID. Used for error reporting.
PRUint64 mWindowId;
// The ID of the inner window origin, used for error reporting.
PRUint64 mInnerWindowId;
// The CORS mode (defined in imgIRequest) this image was loaded with. By
// default, imgIRequest::CORS_NONE.

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

@ -376,7 +376,7 @@ nsExpatDriver::nsExpatDriver()
mInternalState(NS_OK),
mExpatBuffered(0),
mCatalogData(nsnull),
mWindowID(0)
mInnerWindowID(0)
{
}
@ -953,7 +953,7 @@ nsExpatDriver::HandleError()
mLastLine.get(),
lineNumber, colNumber,
nsIScriptError::errorFlag, "malformed-xml",
mWindowID);
mInnerWindowID);
}
// If it didn't initialize, we can't do any logging.
@ -1250,8 +1250,11 @@ nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
win = do_QueryInterface(global);
}
}
if (win && !win->IsInnerWindow()) {
win = win->GetCurrentInnerWindow();
}
if (win) {
mWindowID = win->GetOuterWindow()->WindowID();
mInnerWindowID = win->WindowID();
}
}

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

@ -169,7 +169,7 @@ private:
nsString mURISpec;
// Used for error reporting.
PRUint64 mWindowID;
PRUint64 mInnerWindowID;
};
#endif