mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1257919 part 8. Make the line/column number getters on JSStackFrame take an explicit JSContext. r=khuey
This commit is contained in:
parent
cc563df19f
commit
5df498fbd2
@ -1042,13 +1042,13 @@ StackFrameToStackEntry(JSContext* aCx, nsIStackFrame* aStackFrame,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
int32_t lineNumber;
|
||||
rv = aStackFrame->GetLineNumber(&lineNumber);
|
||||
rv = aStackFrame->GetLineNumber(aCx, &lineNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aStackEntry.mLineNumber = lineNumber;
|
||||
|
||||
int32_t columnNumber;
|
||||
rv = aStackFrame->GetColumnNumber(&columnNumber);
|
||||
rv = aStackFrame->GetColumnNumber(aCx, &columnNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aStackEntry.mColumnNumber = columnNumber;
|
||||
|
@ -321,14 +321,14 @@ Exception::GetFilename(JSContext* aCx, nsAString& aFilename)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Exception::GetLineNumber(uint32_t *aLineNumber)
|
||||
Exception::GetLineNumber(JSContext* aCx, uint32_t *aLineNumber)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLineNumber);
|
||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (mLocation) {
|
||||
int32_t lineno;
|
||||
nsresult rv = mLocation->GetLineNumber(&lineno);
|
||||
nsresult rv = mLocation->GetLineNumber(aCx, &lineno);
|
||||
*aLineNumber = lineno;
|
||||
return rv;
|
||||
}
|
||||
@ -474,11 +474,11 @@ Exception::GetName(nsString& retval)
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Exception::LineNumber() const
|
||||
Exception::LineNumber(JSContext* aCx) const
|
||||
{
|
||||
if (mLocation) {
|
||||
int32_t lineno;
|
||||
if (NS_SUCCEEDED(mLocation->GetLineNumber(&lineno))) {
|
||||
if (NS_SUCCEEDED(mLocation->GetLineNumber(aCx, &lineno))) {
|
||||
return lineno;
|
||||
}
|
||||
return 0;
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
// The XPCOM GetFilename does the right thing. It might throw, but we want to
|
||||
// return an empty filename in that case anyway, instead of throwing.
|
||||
|
||||
uint32_t LineNumber() const;
|
||||
uint32_t LineNumber(JSContext* aCx) const;
|
||||
|
||||
uint32_t ColumnNumber() const;
|
||||
|
||||
|
@ -221,7 +221,7 @@ class BlobURLsReporter final : public nsIMemoryReporter
|
||||
int32_t lineNumber = 0;
|
||||
|
||||
frame->GetFilename(cx, fileNameUTF16);
|
||||
frame->GetLineNumber(&lineNumber);
|
||||
frame->GetLineNumber(cx, &lineNumber);
|
||||
|
||||
if (!fileNameUTF16.IsEmpty()) {
|
||||
NS_ConvertUTF16toUTF8 fileName(fileNameUTF16);
|
||||
|
@ -409,7 +409,7 @@ DOMInterfaces = {
|
||||
'binaryNames': {
|
||||
'message': 'messageMoz',
|
||||
},
|
||||
'implicitJSContext': [ 'filename' ],
|
||||
'implicitJSContext': [ 'filename', 'lineNumber' ],
|
||||
},
|
||||
|
||||
'DOMMatrixReadOnly': {
|
||||
@ -479,7 +479,7 @@ DOMInterfaces = {
|
||||
'binaryNames': {
|
||||
'message': 'messageMoz',
|
||||
},
|
||||
'implicitJSContext': [ '__stringifier', 'filename' ],
|
||||
'implicitJSContext': [ '__stringifier', 'filename', 'lineNumber' ],
|
||||
},
|
||||
|
||||
'ExtendableEvent': {
|
||||
|
@ -212,9 +212,9 @@ public:
|
||||
explicit JSStackFrame(JS::Handle<JSObject*> aStack);
|
||||
|
||||
protected:
|
||||
int32_t GetLineno();
|
||||
int32_t GetLineno(JSContext* aCx);
|
||||
|
||||
int32_t GetColNo();
|
||||
int32_t GetColNo(JSContext* aCx);
|
||||
|
||||
private:
|
||||
virtual ~JSStackFrame();
|
||||
@ -408,16 +408,15 @@ NS_IMETHODIMP JSStackFrame::GetName(JSContext* aCx, nsAString& aFunction)
|
||||
}
|
||||
|
||||
int32_t
|
||||
JSStackFrame::GetLineno()
|
||||
JSStackFrame::GetLineno(JSContext* aCx)
|
||||
{
|
||||
if (!mStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
uint32_t line;
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameLine, mLinenoInitialized,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameLine, mLinenoInitialized,
|
||||
&canCache, &useCachedValue, &line);
|
||||
|
||||
if (useCachedValue) {
|
||||
@ -432,23 +431,22 @@ JSStackFrame::GetLineno()
|
||||
return line;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetLineNumber(int32_t* aLineNumber)
|
||||
NS_IMETHODIMP JSStackFrame::GetLineNumber(JSContext* aCx, int32_t* aLineNumber)
|
||||
{
|
||||
*aLineNumber = GetLineno();
|
||||
*aLineNumber = GetLineno(aCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t
|
||||
JSStackFrame::GetColNo()
|
||||
JSStackFrame::GetColNo(JSContext* aCx)
|
||||
{
|
||||
if (!mStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
uint32_t col;
|
||||
bool canCache = false, useCachedValue = false;
|
||||
GetValueIfNotCached(cx, mStack, JS::GetSavedFrameColumn, mColNoInitialized,
|
||||
GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameColumn, mColNoInitialized,
|
||||
&canCache, &useCachedValue, &col);
|
||||
|
||||
if (useCachedValue) {
|
||||
@ -463,9 +461,10 @@ JSStackFrame::GetColNo()
|
||||
return col;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetColumnNumber(int32_t* aColumnNumber)
|
||||
NS_IMETHODIMP JSStackFrame::GetColumnNumber(JSContext* aCx,
|
||||
int32_t* aColumnNumber)
|
||||
{
|
||||
*aColumnNumber = GetColNo();
|
||||
*aColumnNumber = GetColNo(aCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -650,7 +649,7 @@ NS_IMETHODIMP JSStackFrame::ToString(JSContext* aCx, nsACString& _retval)
|
||||
funname.AssignLiteral("<TOP_LEVEL>");
|
||||
}
|
||||
|
||||
int32_t lineno = GetLineno();
|
||||
int32_t lineno = GetLineno(aCx);
|
||||
|
||||
static const char format[] = "JS frame :: %s :: %s :: line %d";
|
||||
_retval.AppendPrintf(format,
|
||||
|
@ -431,7 +431,7 @@ ExtractErrorValues(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
||||
domException->GetFilename(aCx, filename);
|
||||
if (!filename.IsEmpty()) {
|
||||
CopyUTF16toUTF8(filename, aSourceSpecOut);
|
||||
*aLineOut = domException->LineNumber();
|
||||
*aLineOut = domException->LineNumber(aCx);
|
||||
*aColumnOut = domException->ColumnNumber();
|
||||
}
|
||||
|
||||
|
@ -1580,7 +1580,7 @@ AssembleSandboxMemoryReporterName(JSContext* cx, nsCString& sandboxName)
|
||||
nsString location;
|
||||
int32_t lineNumber = 0;
|
||||
frame->GetFilename(cx, location);
|
||||
frame->GetLineNumber(&lineNumber);
|
||||
frame->GetLineNumber(cx, &lineNumber);
|
||||
|
||||
sandboxName.AppendLiteral(" (from: ");
|
||||
sandboxName.Append(NS_ConvertUTF16toUTF8(location));
|
||||
|
@ -2323,7 +2323,7 @@ nsXPCComponents_Utils::ReportError(HandleValue error, JSContext* cx)
|
||||
nsCOMPtr<nsIStackFrame> frame = dom::GetCurrentJSStack();
|
||||
if (frame) {
|
||||
frame->GetFilename(cx, fileName);
|
||||
frame->GetLineNumber(&lineNo);
|
||||
frame->GetLineNumber(cx, &lineNo);
|
||||
JS::Rooted<JS::Value> stack(cx);
|
||||
nsresult rv = frame->GetNativeSavedFrame(&stack);
|
||||
if (NS_SUCCEEDED(rv) && stack.isObject()) {
|
||||
@ -2431,7 +2431,7 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
|
||||
nsString frameFile;
|
||||
frame->GetFilename(cx, frameFile);
|
||||
CopyUTF16toUTF8(frameFile, filename);
|
||||
frame->GetLineNumber(&lineNo);
|
||||
frame->GetLineNumber(cx, &lineNo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -917,7 +917,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
||||
GetLocation(getter_AddRefs(location));
|
||||
if (location) {
|
||||
// Get line number w/o checking; 0 is ok.
|
||||
location->GetLineNumber(&lineNumber);
|
||||
location->GetLineNumber(cx, &lineNumber);
|
||||
|
||||
// get a filename.
|
||||
rv = location->GetFilename(cx, sourceName);
|
||||
|
@ -57,7 +57,7 @@ SandboxLogJSStack(void)
|
||||
fileName.SetIsVoid(true);
|
||||
Unused << frame->GetFilename(cx, fileName);
|
||||
lineNumber = 0;
|
||||
Unused << frame->GetLineNumber(&lineNumber);
|
||||
Unused << frame->GetLineNumber(cx, &lineNumber);
|
||||
funName.SetIsVoid(true);
|
||||
Unused << frame->GetName(cx, funName);
|
||||
|
||||
|
@ -21,7 +21,9 @@ interface nsIStackFrame : nsISupports
|
||||
[implicit_jscontext]
|
||||
readonly attribute AString name;
|
||||
// Valid line numbers begin at '1'. '0' indicates unknown.
|
||||
[implicit_jscontext]
|
||||
readonly attribute int32_t lineNumber;
|
||||
[implicit_jscontext]
|
||||
readonly attribute int32_t columnNumber;
|
||||
readonly attribute AUTF8String sourceLine;
|
||||
readonly attribute AString asyncCause;
|
||||
@ -62,6 +64,7 @@ interface nsIException : nsISupports
|
||||
[implicit_jscontext]
|
||||
readonly attribute AString filename;
|
||||
// Valid line numbers begin at '1'. '0' indicates unknown.
|
||||
[implicit_jscontext]
|
||||
readonly attribute uint32_t lineNumber;
|
||||
// Valid column numbers begin at 0.
|
||||
// We don't have an unambiguous indicator for unknown.
|
||||
|
Loading…
Reference in New Issue
Block a user