Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.cpp

Issue 1653053002: Devtools: parse variables scopes and sourcemap them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/v8_inspector/V8JavaScriptCallFrame.h" 5 #include "platform/v8_inspector/V8JavaScriptCallFrame.h"
6 6
7 #include "platform/v8_inspector/InspectorWrapper.h" 7 #include "platform/v8_inspector/InspectorWrapper.h"
8 #include "platform/v8_inspector/JavaScriptCallFrame.h" 8 #include "platform/v8_inspector/JavaScriptCallFrame.h"
9 #include "platform/v8_inspector/V8StringUtil.h" 9 #include "platform/v8_inspector/V8StringUtil.h"
10 #include "wtf/RefPtr.h" 10 #include "wtf/RefPtr.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 void scopeNameMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 136 void scopeNameMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
137 { 137 {
138 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder()); 138 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
139 v8::Maybe<int32_t> maybeScopeIndex = info[0]->Int32Value(info.GetIsolate()-> GetCurrentContext()); 139 v8::Maybe<int32_t> maybeScopeIndex = info[0]->Int32Value(info.GetIsolate()-> GetCurrentContext());
140 if (maybeScopeIndex.IsNothing()) 140 if (maybeScopeIndex.IsNothing())
141 return; 141 return;
142 int scopeIndex = maybeScopeIndex.FromJust(); 142 int scopeIndex = maybeScopeIndex.FromJust();
143 info.GetReturnValue().Set(impl->scopeName(scopeIndex)); 143 info.GetReturnValue().Set(impl->scopeName(scopeIndex));
144 } 144 }
145 145
146 void scopeStartLocationMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
147 {
148 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
149 v8::Maybe<int32_t> maybeScopeIndex = info[0]->Int32Value(info.GetIsolate()-> GetCurrentContext());
150 if (maybeScopeIndex.IsNothing())
151 return;
152 int scopeIndex = maybeScopeIndex.FromJust();
153 info.GetReturnValue().Set(impl->scopeStartLocation(scopeIndex));
154 }
155
156 void scopeEndLocationMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& i nfo)
157 {
158 JavaScriptCallFrame* impl = V8JavaScriptCallFrame::unwrap(info.GetIsolate()- >GetCurrentContext(), info.Holder());
159 v8::Maybe<int32_t> maybeScopeIndex = info[0]->Int32Value(info.GetIsolate()-> GetCurrentContext());
160 if (maybeScopeIndex.IsNothing())
161 return;
162 int scopeIndex = maybeScopeIndex.FromJust();
163 info.GetReturnValue().Set(impl->scopeEndLocation(scopeIndex));
164 }
165
146 char hiddenPropertyName[] = "v8inspector::JavaScriptCallFrame"; 166 char hiddenPropertyName[] = "v8inspector::JavaScriptCallFrame";
147 char className[] = "V8JavaScriptCallFrame"; 167 char className[] = "V8JavaScriptCallFrame";
148 using JavaScriptCallFrameWrapper = InspectorWrapper<JavaScriptCallFrame, hiddenP ropertyName, className>; 168 using JavaScriptCallFrameWrapper = InspectorWrapper<JavaScriptCallFrame, hiddenP ropertyName, className>;
149 169
150 const JavaScriptCallFrameWrapper::V8AttributeConfiguration V8JavaScriptCallFrame Attributes[] = { 170 const JavaScriptCallFrameWrapper::V8AttributeConfiguration V8JavaScriptCallFrame Attributes[] = {
151 {"scopeChain", scopeChainAttributeGetterCallback}, 171 {"scopeChain", scopeChainAttributeGetterCallback},
152 {"thisObject", thisObjectAttributeGetterCallback}, 172 {"thisObject", thisObjectAttributeGetterCallback},
153 {"returnValue", returnValueAttributeGetterCallback}, 173 {"returnValue", returnValueAttributeGetterCallback},
154 174
155 {"caller", callerAttributeGetterCallback}, 175 {"caller", callerAttributeGetterCallback},
156 {"sourceID", sourceIDAttributeGetterCallback}, 176 {"sourceID", sourceIDAttributeGetterCallback},
157 {"line", lineAttributeGetterCallback}, 177 {"line", lineAttributeGetterCallback},
158 {"column", columnAttributeGetterCallback}, 178 {"column", columnAttributeGetterCallback},
159 {"stepInPositions", stepInPositionsAttributeGetterCallback}, 179 {"stepInPositions", stepInPositionsAttributeGetterCallback},
160 {"functionName", functionNameAttributeGetterCallback}, 180 {"functionName", functionNameAttributeGetterCallback},
161 {"functionLine", functionLineAttributeGetterCallback}, 181 {"functionLine", functionLineAttributeGetterCallback},
162 {"functionColumn", functionColumnAttributeGetterCallback}, 182 {"functionColumn", functionColumnAttributeGetterCallback},
163 {"isAtReturn", isAtReturnAttributeGetterCallback}, 183 {"isAtReturn", isAtReturnAttributeGetterCallback},
164 }; 184 };
165 185
166 const JavaScriptCallFrameWrapper::V8MethodConfiguration V8JavaScriptCallFrameMet hods[] = { 186 const JavaScriptCallFrameWrapper::V8MethodConfiguration V8JavaScriptCallFrameMet hods[] = {
167 {"evaluateWithExceptionDetails", evaluateWithExceptionDetailsMethodCallback} , 187 {"evaluateWithExceptionDetails", evaluateWithExceptionDetailsMethodCallback} ,
168 {"restart", restartMethodCallback}, 188 {"restart", restartMethodCallback},
169 {"setVariableValue", setVariableValueMethodCallback}, 189 {"setVariableValue", setVariableValueMethodCallback},
170 {"scopeType", scopeTypeMethodCallback}, 190 {"scopeType", scopeTypeMethodCallback},
171 {"scopeName", scopeNameMethodCallback} 191 {"scopeName", scopeNameMethodCallback},
192 {"scopeStartLocation", scopeStartLocationMethodCallback},
193 {"scopeEndLocation", scopeEndLocationMethodCallback},
172 }; 194 };
173 195
174 } // namespace 196 } // namespace
175 197
176 v8::Local<v8::FunctionTemplate> V8JavaScriptCallFrame::createWrapperTemplate(v8: :Isolate* isolate) 198 v8::Local<v8::FunctionTemplate> V8JavaScriptCallFrame::createWrapperTemplate(v8: :Isolate* isolate)
177 { 199 {
178 Vector<InspectorWrapperBase::V8MethodConfiguration> methods(WTF_ARRAY_LENGTH (V8JavaScriptCallFrameMethods)); 200 Vector<InspectorWrapperBase::V8MethodConfiguration> methods(WTF_ARRAY_LENGTH (V8JavaScriptCallFrameMethods));
179 std::copy(V8JavaScriptCallFrameMethods, V8JavaScriptCallFrameMethods + WTF_A RRAY_LENGTH(V8JavaScriptCallFrameMethods), methods.begin()); 201 std::copy(V8JavaScriptCallFrameMethods, V8JavaScriptCallFrameMethods + WTF_A RRAY_LENGTH(V8JavaScriptCallFrameMethods), methods.begin());
180 Vector<InspectorWrapperBase::V8AttributeConfiguration> attributes(WTF_ARRAY_ LENGTH(V8JavaScriptCallFrameAttributes)); 202 Vector<InspectorWrapperBase::V8AttributeConfiguration> attributes(WTF_ARRAY_ LENGTH(V8JavaScriptCallFrameAttributes));
181 std::copy(V8JavaScriptCallFrameAttributes, V8JavaScriptCallFrameAttributes + WTF_ARRAY_LENGTH(V8JavaScriptCallFrameAttributes), attributes.begin()); 203 std::copy(V8JavaScriptCallFrameAttributes, V8JavaScriptCallFrameAttributes + WTF_ARRAY_LENGTH(V8JavaScriptCallFrameAttributes), attributes.begin());
182 return JavaScriptCallFrameWrapper::createWrapperTemplate(isolate, methods, a ttributes); 204 return JavaScriptCallFrameWrapper::createWrapperTemplate(isolate, methods, a ttributes);
183 } 205 }
184 206
185 v8::Local<v8::Object> V8JavaScriptCallFrame::wrap(V8DebuggerClient* client, v8:: Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, PassRefPtr<JavaScriptCallFrame> frame) 207 v8::Local<v8::Object> V8JavaScriptCallFrame::wrap(V8DebuggerClient* client, v8:: Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, PassRefPtr<JavaScriptCallFrame> frame)
186 { 208 {
187 // Store template for .caller callback 209 // Store template for .caller callback
188 frame->setWrapperTemplate(constructorTemplate, context->GetIsolate()); 210 frame->setWrapperTemplate(constructorTemplate, context->GetIsolate());
189 return JavaScriptCallFrameWrapper::wrap(client, constructorTemplate, context , frame); 211 return JavaScriptCallFrameWrapper::wrap(client, constructorTemplate, context , frame);
190 } 212 }
191 213
192 JavaScriptCallFrame* V8JavaScriptCallFrame::unwrap(v8::Local<v8::Context> contex t, v8::Local<v8::Object> object) 214 JavaScriptCallFrame* V8JavaScriptCallFrame::unwrap(v8::Local<v8::Context> contex t, v8::Local<v8::Object> object)
193 { 215 {
194 return JavaScriptCallFrameWrapper::unwrap(context, object); 216 return JavaScriptCallFrameWrapper::unwrap(context, object);
195 } 217 }
196 218
197 } // namespace blink 219 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698