Bug 1200484 (part 12) - Use JS column numbers in nsJSTimeoutHandler. r=peterv.

This commit is contained in:
Nicholas Nethercote 2015-09-03 16:03:19 -07:00
parent 47c345ebaa
commit f4a1d433ff
3 changed files with 23 additions and 14 deletions

View File

@ -12644,8 +12644,8 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
NS_ASSERTION(script, "timeout has no script nor handler text!");
const char* filename = nullptr;
uint32_t lineNo = 0;
handler->GetLocation(&filename, &lineNo);
uint32_t lineNo = 0, dummyColumn = 0;
handler->GetLocation(&filename, &lineNo, &dummyColumn);
// New script entry point required, due to the "Create a script" sub-step of
// http://www.whatwg.org/specs/web-apps/current-work/#timer-initialisation-steps

View File

@ -39,7 +39,8 @@ public:
// Get the location of the script.
// Note: The memory pointed to by aFileName is owned by the
// nsIScriptTimeoutHandler and should not be freed by the caller.
virtual void GetLocation(const char **aFileName, uint32_t *aLineNo) = 0;
virtual void GetLocation(const char **aFileName, uint32_t *aLineNo,
uint32_t *aColumn) = 0;
// If we have a Function, get the arguments for passing to it.
virtual const nsTArray<JS::Value>& GetArgs() = 0;

View File

@ -48,10 +48,12 @@ public:
{
return mFunction;
}
virtual void GetLocation(const char** aFileName, uint32_t* aLineNo) override
virtual void GetLocation(const char** aFileName, uint32_t* aLineNo,
uint32_t* aColumn) override
{
*aFileName = mFileName.get();
*aLineNo = mLineNo;
*aColumn = mColumn;
}
virtual const nsTArray<JS::Value>& GetArgs() override
@ -68,6 +70,7 @@ private:
// caller of setTimeout()
nsCString mFileName;
uint32_t mLineNo;
uint32_t mColumn;
nsTArray<JS::Heap<JS::Value> > mArgs;
// The expression to evaluate or function to call. If mFunction is non-null
@ -107,6 +110,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSScriptTimeoutHandler)
name.Append(tmp->mFileName);
name.Append(':');
name.AppendInt(tmp->mLineNo);
name.Append(':');
name.AppendInt(tmp->mColumn);
name.Append(']');
}
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name.get());
@ -184,8 +189,9 @@ CheckCSPForEval(JSContext* aCx, nsGlobalWindow* aWindow, ErrorResult& aError)
return allowsEval;
}
nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler() :
mLineNo(0)
nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler()
: mLineNo(0)
, mColumn(0)
{
}
@ -193,9 +199,10 @@ nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
nsGlobalWindow *aWindow,
Function& aFunction,
FallibleTArray<JS::Heap<JS::Value> >& aArguments,
ErrorResult& aError) :
mLineNo(0),
mFunction(&aFunction)
ErrorResult& aError)
: mLineNo(0)
, mColumn(0)
, mFunction(&aFunction)
{
if (!aWindow->GetContextInternal() || !aWindow->FastGetGlobalJSObject()) {
// This window was already closed, or never properly initialized,
@ -208,16 +215,17 @@ nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
mArgs.SwapElements(aArguments);
// Get the calling location.
nsJSUtils::GetCallingLocation(aCx, mFileName, &mLineNo);
nsJSUtils::GetCallingLocation(aCx, mFileName, &mLineNo, &mColumn);
}
nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
nsGlobalWindow *aWindow,
const nsAString& aExpression,
bool* aAllowEval,
ErrorResult& aError) :
mLineNo(0),
mExpr(aExpression)
ErrorResult& aError)
: mLineNo(0)
, mColumn(0)
, mExpr(aExpression)
{
if (!aWindow->GetContextInternal() || !aWindow->FastGetGlobalJSObject()) {
// This window was already closed, or never properly initialized,
@ -232,7 +240,7 @@ nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
}
// Get the calling location.
nsJSUtils::GetCallingLocation(aCx, mFileName, &mLineNo);
nsJSUtils::GetCallingLocation(aCx, mFileName, &mLineNo, &mColumn);
}
nsJSScriptTimeoutHandler::~nsJSScriptTimeoutHandler()