OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/SourceLocation.h" | 5 #include "bindings/core/v8/SourceLocation.h" |
6 | 6 |
7 #include "bindings/core/v8/V8BindingMacros.h" | 7 #include "bindings/core/v8/V8BindingMacros.h" |
8 #include "bindings/core/v8/V8PerIsolateData.h" | 8 #include "bindings/core/v8/V8PerIsolateData.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 ScriptForbiddenScope::AllowUserAgentScript allowScripting; | 34 ScriptForbiddenScope::AllowUserAgentScript allowScripting; |
35 return data->threadDebugger()->debugger()->captureStackTrace(stackSize); | 35 return data->threadDebugger()->debugger()->captureStackTrace(stackSize); |
36 } | 36 } |
37 | 37 |
38 } | 38 } |
39 | 39 |
40 // static | 40 // static |
41 PassOwnPtr<SourceLocation> SourceLocation::capture(const String& url, unsigned l ineNumber, unsigned columnNumber) | 41 PassOwnPtr<SourceLocation> SourceLocation::capture(const String& url, unsigned l ineNumber, unsigned columnNumber) |
42 { | 42 { |
43 std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(); | 43 std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(); |
44 if (stackTrace && !stackTrace->isEmpty()) | 44 if (stackTrace && !stackTrace->isEmpty()) { |
45 return SourceLocation::create(stackTrace->topSourceURL(), stackTrace->to pLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0); | 45 const V8StackTrace* stackTracePtr = stackTrace.get(); |
Yuki
2016/05/26 06:55:50
I'm a bit uneasy to use a raw pointer here.
co
kinaba
2016/05/26 07:14:19
Makes sense. Done.
| |
46 return SourceLocation::create(stackTracePtr->topSourceURL(), stackTraceP tr->topLineNumber(), stackTracePtr->topColumnNumber(), std::move(stackTrace), 0) ; | |
47 } | |
46 return SourceLocation::create(url, lineNumber, columnNumber, std::move(stack Trace)); | 48 return SourceLocation::create(url, lineNumber, columnNumber, std::move(stack Trace)); |
47 } | 49 } |
48 | 50 |
49 // static | 51 // static |
50 PassOwnPtr<SourceLocation> SourceLocation::capture(ExecutionContext* executionCo ntext) | 52 PassOwnPtr<SourceLocation> SourceLocation::capture(ExecutionContext* executionCo ntext) |
51 { | 53 { |
52 std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(); | 54 std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(); |
53 if (stackTrace && !stackTrace->isEmpty()) | 55 if (stackTrace && !stackTrace->isEmpty()) { |
54 return SourceLocation::create(stackTrace->topSourceURL(), stackTrace->to pLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0); | 56 const V8StackTrace* stackTracePtr = stackTrace.get(); |
57 return SourceLocation::create(stackTracePtr->topSourceURL(), stackTraceP tr->topLineNumber(), stackTracePtr->topColumnNumber(), std::move(stackTrace), 0) ; | |
58 } | |
55 | 59 |
56 Document* document = executionContext && executionContext->isDocument() ? to Document(executionContext) : nullptr; | 60 Document* document = executionContext && executionContext->isDocument() ? to Document(executionContext) : nullptr; |
57 if (document) { | 61 if (document) { |
58 unsigned lineNumber = 0; | 62 unsigned lineNumber = 0; |
59 if (document->scriptableDocumentParser() && !document->isInDocumentWrite ()) { | 63 if (document->scriptableDocumentParser() && !document->isInDocumentWrite ()) { |
60 if (document->scriptableDocumentParser()->isParsingAtLineNumber()) | 64 if (document->scriptableDocumentParser()->isParsingAtLineNumber()) |
61 lineNumber = document->scriptableDocumentParser()->lineNumber(). oneBasedInt(); | 65 lineNumber = document->scriptableDocumentParser()->lineNumber(). oneBasedInt(); |
62 } | 66 } |
63 return SourceLocation::create(document->url().getString(), lineNumber, 0 , std::move(stackTrace)); | 67 return SourceLocation::create(document->url().getString(), lineNumber, 0 , std::move(stackTrace)); |
64 } | 68 } |
(...skipping 17 matching lines...) Expand all Loading... | |
82 scriptId = 0; | 86 scriptId = 0; |
83 } | 87 } |
84 | 88 |
85 int lineNumber = 0; | 89 int lineNumber = 0; |
86 int columnNumber = 0; | 90 int columnNumber = 0; |
87 if (v8Call(message->GetLineNumber(isolate->GetCurrentContext()), lineNumber) | 91 if (v8Call(message->GetLineNumber(isolate->GetCurrentContext()), lineNumber) |
88 && v8Call(message->GetStartColumn(isolate->GetCurrentContext()), columnN umber)) | 92 && v8Call(message->GetStartColumn(isolate->GetCurrentContext()), columnN umber)) |
89 ++columnNumber; | 93 ++columnNumber; |
90 | 94 |
91 if ((!scriptId || !lineNumber) && stackTrace && !stackTrace->isEmpty()) | 95 if ((!scriptId || !lineNumber) && stackTrace && !stackTrace->isEmpty()) |
92 return adoptPtr(new SourceLocation(stackTrace->topSourceURL(), stackTrac e->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0)); | 96 return adoptPtr(new SourceLocation(stackTrace->topSourceURL(), stackTrac e->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0)); |
Yuki
2016/05/26 07:05:36
This line also seems problematic.
kinaba
2016/05/26 07:14:19
Good catch!
| |
93 | 97 |
94 String url = toCoreStringWithUndefinedOrNullCheck(message->GetScriptOrigin() .ResourceName()); | 98 String url = toCoreStringWithUndefinedOrNullCheck(message->GetScriptOrigin() .ResourceName()); |
95 if (url.isNull()) | 99 if (url.isNull()) |
96 url = executionContext->url(); | 100 url = executionContext->url(); |
97 return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move( stackTrace), scriptId)); | 101 return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move( stackTrace), scriptId)); |
98 } | 102 } |
99 | 103 |
100 // static | 104 // static |
101 PassOwnPtr<SourceLocation> SourceLocation::create(const String& url, unsigned li neNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int s criptId) | 105 PassOwnPtr<SourceLocation> SourceLocation::create(const String& url, unsigned li neNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int s criptId) |
102 { | 106 { |
(...skipping 27 matching lines...) Expand all Loading... | |
130 value->endDictionary(); | 134 value->endDictionary(); |
131 value->endArray(); | 135 value->endArray(); |
132 } | 136 } |
133 | 137 |
134 PassOwnPtr<SourceLocation> SourceLocation::clone() const | 138 PassOwnPtr<SourceLocation> SourceLocation::clone() const |
135 { | 139 { |
136 return adoptPtr(new SourceLocation(m_url, m_lineNumber, m_columnNumber, m_st ackTrace ? m_stackTrace->clone() : nullptr, m_scriptId)); | 140 return adoptPtr(new SourceLocation(m_url, m_lineNumber, m_columnNumber, m_st ackTrace ? m_stackTrace->clone() : nullptr, m_scriptId)); |
137 } | 141 } |
138 | 142 |
139 } // namespace blink | 143 } // namespace blink |
OLD | NEW |