| Index: third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
|
| index e821aa35329654789104ee6d79b5e3ef3e1d255b..f7e4197f4b94008753555589c481ea87de5ecacc 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "bindings/core/v8/SourceLocation.h"
|
|
|
| +#include "bindings/core/v8/V8BindingMacros.h"
|
| #include "bindings/core/v8/V8PerIsolateData.h"
|
| #include "core/dom/Document.h"
|
| #include "core/dom/ExecutionContext.h"
|
| @@ -66,6 +67,37 @@ PassOwnPtr<SourceLocation> SourceLocation::capture(ExecutionContext* executionCo
|
| }
|
|
|
| // static
|
| +PassOwnPtr<SourceLocation> SourceLocation::fromMessage(v8::Isolate* isolate, v8::Local<v8::Message> message, ExecutionContext* executionContext)
|
| +{
|
| + v8::Local<v8::StackTrace> stack = message->GetStackTrace();
|
| + std::unique_ptr<V8StackTrace> stackTrace = nullptr;
|
| + V8PerIsolateData* data = V8PerIsolateData::from(isolate);
|
| + if (data && data->threadDebugger())
|
| + stackTrace = data->threadDebugger()->debugger()->createStackTrace(stack);
|
| +
|
| + int scriptId = message->GetScriptOrigin().ScriptID()->Value();
|
| + if (!stack.IsEmpty() && stack->GetFrameCount() > 0) {
|
| + int topScriptId = stack->GetFrame(0)->GetScriptId();
|
| + if (topScriptId == scriptId)
|
| + scriptId = 0;
|
| + }
|
| +
|
| + int lineNumber = 0;
|
| + int columnNumber = 0;
|
| + if (v8Call(message->GetLineNumber(isolate->GetCurrentContext()), lineNumber)
|
| + && v8Call(message->GetStartColumn(isolate->GetCurrentContext()), columnNumber))
|
| + ++columnNumber;
|
| +
|
| + if ((!scriptId || !lineNumber) && stackTrace && !stackTrace->isEmpty())
|
| + return adoptPtr(new SourceLocation(stackTrace->topSourceURL(), stackTrace->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0));
|
| +
|
| + String url = toCoreStringWithUndefinedOrNullCheck(message->GetScriptOrigin().ResourceName());
|
| + if (url.isNull())
|
| + url = executionContext->url();
|
| + return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId));
|
| +}
|
| +
|
| +// static
|
| PassOwnPtr<SourceLocation> SourceLocation::create(const String& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int scriptId)
|
| {
|
| return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId));
|
|
|