| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 v8::HandleScope scope(isolate); | 76 v8::HandleScope scope(isolate); |
| 77 v8::Local<v8::Context> context = state->context(); | 77 v8::Local<v8::Context> context = state->context(); |
| 78 v8::Context::Scope contextScope(context); | 78 v8::Context::Scope contextScope(context); |
| 79 | 79 |
| 80 ExceptionState es(isolate); | 80 ExceptionState es(isolate); |
| 81 if (!BindingSecurity::shouldAllowAccessToNode(node, es)) | 81 if (!BindingSecurity::shouldAllowAccessToNode(node, es)) |
| 82 return ScriptValue(v8::Null(isolate), isolate); | 82 return ScriptValue(v8::Null(isolate), isolate); |
| 83 return ScriptValue(toV8(node, v8::Handle<v8::Object>(), isolate), isolate); | 83 return ScriptValue(toV8(node, v8::Handle<v8::Object>(), isolate), isolate); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void V8InjectedScriptHost::inspectedObjectMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 86 void V8InjectedScriptHost::inspectedObjectMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
| 87 { | 87 { |
| 88 if (args.Length() < 1) | 88 if (info.Length() < 1) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 if (!args[0]->IsInt32()) { | 91 if (!info[0]->IsInt32()) { |
| 92 throwTypeError("argument has to be an integer", args.GetIsolate()); | 92 throwTypeError("argument has to be an integer", info.GetIsolate()); |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 | 95 |
| 96 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 96 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 97 InjectedScriptHost::InspectableObject* object = host->inspectedObject(args[0
]->ToInt32()->Value()); | 97 InjectedScriptHost::InspectableObject* object = host->inspectedObject(info[0
]->ToInt32()->Value()); |
| 98 v8SetReturnValue(args, object->get(ScriptState::current()).v8Value()); | 98 v8SetReturnValue(info, object->get(ScriptState::current()).v8Value()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void V8InjectedScriptHost::internalConstructorNameMethodCustom(const v8::Functio
nCallbackInfo<v8::Value>& args) | 101 void V8InjectedScriptHost::internalConstructorNameMethodCustom(const v8::Functio
nCallbackInfo<v8::Value>& info) |
| 102 { | 102 { |
| 103 if (args.Length() < 1) | 103 if (info.Length() < 1) |
| 104 return; | 104 return; |
| 105 | 105 |
| 106 if (!args[0]->IsObject()) | 106 if (!info[0]->IsObject()) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 v8SetReturnValue(args, args[0]->ToObject()->GetConstructorName()); | 109 v8SetReturnValue(info, info[0]->ToObject()->GetConstructorName()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void V8InjectedScriptHost::isHTMLAllCollectionMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) | 112 void V8InjectedScriptHost::isHTMLAllCollectionMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
| 113 { | 113 { |
| 114 if (args.Length() < 1) | 114 if (info.Length() < 1) |
| 115 return; | 115 return; |
| 116 | 116 |
| 117 if (!args[0]->IsObject()) { | 117 if (!info[0]->IsObject()) { |
| 118 v8SetReturnValue(args, false); | 118 v8SetReturnValue(info, false); |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 | 121 |
| 122 v8SetReturnValue(args, V8HTMLAllCollection::HasInstance(args[0], args.GetIso
late(), worldType(args.GetIsolate()))); | 122 v8SetReturnValue(info, V8HTMLAllCollection::HasInstance(info[0], info.GetIso
late(), worldType(info.GetIsolate()))); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void V8InjectedScriptHost::typeMethodCustom(const v8::FunctionCallbackInfo<v8::V
alue>& args) | 125 void V8InjectedScriptHost::typeMethodCustom(const v8::FunctionCallbackInfo<v8::V
alue>& info) |
| 126 { | 126 { |
| 127 if (args.Length() < 1) | 127 if (info.Length() < 1) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 v8::Handle<v8::Value> value = args[0]; | 130 v8::Handle<v8::Value> value = info[0]; |
| 131 if (value->IsString()) { | 131 if (value->IsString()) { |
| 132 v8SetReturnValue(args, v8::String::NewSymbol("string")); | 132 v8SetReturnValue(info, v8::String::NewSymbol("string")); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 if (value->IsArray()) { | 135 if (value->IsArray()) { |
| 136 v8SetReturnValue(args, v8::String::NewSymbol("array")); | 136 v8SetReturnValue(info, v8::String::NewSymbol("array")); |
| 137 return; | 137 return; |
| 138 } | 138 } |
| 139 if (value->IsBoolean()) { | 139 if (value->IsBoolean()) { |
| 140 v8SetReturnValue(args, v8::String::NewSymbol("boolean")); | 140 v8SetReturnValue(info, v8::String::NewSymbol("boolean")); |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 if (value->IsNumber()) { | 143 if (value->IsNumber()) { |
| 144 v8SetReturnValue(args, v8::String::NewSymbol("number")); | 144 v8SetReturnValue(info, v8::String::NewSymbol("number")); |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 if (value->IsDate()) { | 147 if (value->IsDate()) { |
| 148 v8SetReturnValue(args, v8::String::NewSymbol("date")); | 148 v8SetReturnValue(info, v8::String::NewSymbol("date")); |
| 149 return; | 149 return; |
| 150 } | 150 } |
| 151 if (value->IsRegExp()) { | 151 if (value->IsRegExp()) { |
| 152 v8SetReturnValue(args, v8::String::NewSymbol("regexp")); | 152 v8SetReturnValue(info, v8::String::NewSymbol("regexp")); |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 WrapperWorldType currentWorldType = worldType(args.GetIsolate()); | 155 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
| 156 if (V8Node::HasInstance(value, args.GetIsolate(), currentWorldType)) { | 156 if (V8Node::HasInstance(value, info.GetIsolate(), currentWorldType)) { |
| 157 v8SetReturnValue(args, v8::String::NewSymbol("node")); | 157 v8SetReturnValue(info, v8::String::NewSymbol("node")); |
| 158 return; | 158 return; |
| 159 } | 159 } |
| 160 if (V8NodeList::HasInstance(value, args.GetIsolate(), currentWorldType)) { | 160 if (V8NodeList::HasInstance(value, info.GetIsolate(), currentWorldType)) { |
| 161 v8SetReturnValue(args, v8::String::NewSymbol("array")); | 161 v8SetReturnValue(info, v8::String::NewSymbol("array")); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 if (V8HTMLCollection::HasInstance(value, args.GetIsolate(), currentWorldType
)) { | 164 if (V8HTMLCollection::HasInstance(value, info.GetIsolate(), currentWorldType
)) { |
| 165 v8SetReturnValue(args, v8::String::NewSymbol("array")); | 165 v8SetReturnValue(info, v8::String::NewSymbol("array")); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 if (V8Int8Array::HasInstance(value, args.GetIsolate(), currentWorldType) ||
V8Int16Array::HasInstance(value, args.GetIsolate(), currentWorldType) || V8Int32
Array::HasInstance(value, args.GetIsolate(), currentWorldType)) { | 168 if (V8Int8Array::HasInstance(value, info.GetIsolate(), currentWorldType) ||
V8Int16Array::HasInstance(value, info.GetIsolate(), currentWorldType) || V8Int32
Array::HasInstance(value, info.GetIsolate(), currentWorldType)) { |
| 169 v8SetReturnValue(args, v8::String::NewSymbol("array")); | 169 v8SetReturnValue(info, v8::String::NewSymbol("array")); |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 if (V8Uint8Array::HasInstance(value, args.GetIsolate(), currentWorldType) ||
V8Uint16Array::HasInstance(value, args.GetIsolate(), currentWorldType) || V8Uin
t32Array::HasInstance(value, args.GetIsolate(), currentWorldType)) { | 172 if (V8Uint8Array::HasInstance(value, info.GetIsolate(), currentWorldType) ||
V8Uint16Array::HasInstance(value, info.GetIsolate(), currentWorldType) || V8Uin
t32Array::HasInstance(value, info.GetIsolate(), currentWorldType)) { |
| 173 v8SetReturnValue(args, v8::String::NewSymbol("array")); | 173 v8SetReturnValue(info, v8::String::NewSymbol("array")); |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 if (V8Float32Array::HasInstance(value, args.GetIsolate(), currentWorldType)
|| V8Float64Array::HasInstance(value, args.GetIsolate(), currentWorldType)) { | 176 if (V8Float32Array::HasInstance(value, info.GetIsolate(), currentWorldType)
|| V8Float64Array::HasInstance(value, info.GetIsolate(), currentWorldType)) { |
| 177 v8SetReturnValue(args, v8::String::NewSymbol("array")); | 177 v8SetReturnValue(info, v8::String::NewSymbol("array")); |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 if (V8Uint8ClampedArray::HasInstance(value, args.GetIsolate(), currentWorldT
ype)) { | 180 if (V8Uint8ClampedArray::HasInstance(value, info.GetIsolate(), currentWorldT
ype)) { |
| 181 v8SetReturnValue(args, v8::String::NewSymbol("array")); | 181 v8SetReturnValue(info, v8::String::NewSymbol("array")); |
| 182 return; | 182 return; |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void V8InjectedScriptHost::functionDetailsMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 186 void V8InjectedScriptHost::functionDetailsMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
| 187 { | 187 { |
| 188 if (args.Length() < 1) | 188 if (info.Length() < 1) |
| 189 return; | 189 return; |
| 190 | 190 |
| 191 v8::Handle<v8::Value> value = args[0]; | 191 v8::Handle<v8::Value> value = info[0]; |
| 192 if (!value->IsFunction()) | 192 if (!value->IsFunction()) |
| 193 return; | 193 return; |
| 194 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value); | 194 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value); |
| 195 int lineNumber = function->GetScriptLineNumber(); | 195 int lineNumber = function->GetScriptLineNumber(); |
| 196 int columnNumber = function->GetScriptColumnNumber(); | 196 int columnNumber = function->GetScriptColumnNumber(); |
| 197 | 197 |
| 198 v8::Local<v8::Object> location = v8::Object::New(); | 198 v8::Local<v8::Object> location = v8::Object::New(); |
| 199 location->Set(v8::String::NewSymbol("lineNumber"), v8::Integer::New(lineNumb
er, args.GetIsolate())); | 199 location->Set(v8::String::NewSymbol("lineNumber"), v8::Integer::New(lineNumb
er, info.GetIsolate())); |
| 200 location->Set(v8::String::NewSymbol("columnNumber"), v8::Integer::New(column
Number, args.GetIsolate())); | 200 location->Set(v8::String::NewSymbol("columnNumber"), v8::Integer::New(column
Number, info.GetIsolate())); |
| 201 location->Set(v8::String::NewSymbol("scriptId"), function->GetScriptId()->To
String()); | 201 location->Set(v8::String::NewSymbol("scriptId"), function->GetScriptId()->To
String()); |
| 202 | 202 |
| 203 v8::Local<v8::Object> result = v8::Object::New(); | 203 v8::Local<v8::Object> result = v8::Object::New(); |
| 204 result->Set(v8::String::NewSymbol("location"), location); | 204 result->Set(v8::String::NewSymbol("location"), location); |
| 205 | 205 |
| 206 v8::Handle<v8::Value> name = function->GetName(); | 206 v8::Handle<v8::Value> name = function->GetName(); |
| 207 if (name->IsString() && v8::Handle<v8::String>::Cast(name)->Length()) | 207 if (name->IsString() && v8::Handle<v8::String>::Cast(name)->Length()) |
| 208 result->Set(v8::String::NewSymbol("name"), name); | 208 result->Set(v8::String::NewSymbol("name"), name); |
| 209 | 209 |
| 210 v8::Handle<v8::Value> inferredName = function->GetInferredName(); | 210 v8::Handle<v8::Value> inferredName = function->GetInferredName(); |
| 211 if (inferredName->IsString() && v8::Handle<v8::String>::Cast(inferredName)->
Length()) | 211 if (inferredName->IsString() && v8::Handle<v8::String>::Cast(inferredName)->
Length()) |
| 212 result->Set(v8::String::NewSymbol("inferredName"), inferredName); | 212 result->Set(v8::String::NewSymbol("inferredName"), inferredName); |
| 213 | 213 |
| 214 // FIXME: pass function displayName from V8 (crbug.com/17356). | 214 // FIXME: pass function displayName from V8 (crbug.com/17356). |
| 215 | 215 |
| 216 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 216 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 217 ScriptDebugServer& debugServer = host->scriptDebugServer(); | 217 ScriptDebugServer& debugServer = host->scriptDebugServer(); |
| 218 v8::Handle<v8::Value> scopes = debugServer.functionScopes(function); | 218 v8::Handle<v8::Value> scopes = debugServer.functionScopes(function); |
| 219 if (!scopes.IsEmpty() && scopes->IsArray()) | 219 if (!scopes.IsEmpty() && scopes->IsArray()) |
| 220 result->Set(v8::String::NewSymbol("rawScopes"), scopes); | 220 result->Set(v8::String::NewSymbol("rawScopes"), scopes); |
| 221 | 221 |
| 222 v8SetReturnValue(args, result); | 222 v8SetReturnValue(info, result); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void V8InjectedScriptHost::getInternalPropertiesMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& args) | 225 void V8InjectedScriptHost::getInternalPropertiesMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) |
| 226 { | 226 { |
| 227 if (args.Length() < 1) | 227 if (info.Length() < 1) |
| 228 return; | 228 return; |
| 229 | 229 |
| 230 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(args[0]); | 230 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(info[0]); |
| 231 | 231 |
| 232 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 232 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 233 ScriptDebugServer& debugServer = host->scriptDebugServer(); | 233 ScriptDebugServer& debugServer = host->scriptDebugServer(); |
| 234 v8SetReturnValue(args, debugServer.getInternalProperties(object)); | 234 v8SetReturnValue(info, debugServer.getInternalProperties(object)); |
| 235 } | 235 } |
| 236 | 236 |
| 237 static v8::Handle<v8::Array> getJSListenerFunctions(Document* document, const Ev
entListenerInfo& listenerInfo) | 237 static v8::Handle<v8::Array> getJSListenerFunctions(Document* document, const Ev
entListenerInfo& listenerInfo) |
| 238 { | 238 { |
| 239 v8::Local<v8::Array> result = v8::Array::New(); | 239 v8::Local<v8::Array> result = v8::Array::New(); |
| 240 size_t handlersCount = listenerInfo.eventListenerVector.size(); | 240 size_t handlersCount = listenerInfo.eventListenerVector.size(); |
| 241 for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) { | 241 for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) { |
| 242 RefPtr<EventListener> listener = listenerInfo.eventListenerVector[i].lis
tener; | 242 RefPtr<EventListener> listener = listenerInfo.eventListenerVector[i].lis
tener; |
| 243 if (listener->type() != EventListener::JSEventListenerType) { | 243 if (listener->type() != EventListener::JSEventListenerType) { |
| 244 ASSERT_NOT_REACHED(); | 244 ASSERT_NOT_REACHED(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 259 } | 259 } |
| 260 ASSERT(!function.IsEmpty()); | 260 ASSERT(!function.IsEmpty()); |
| 261 v8::Local<v8::Object> listenerEntry = v8::Object::New(); | 261 v8::Local<v8::Object> listenerEntry = v8::Object::New(); |
| 262 listenerEntry->Set(v8::String::NewSymbol("listener"), function); | 262 listenerEntry->Set(v8::String::NewSymbol("listener"), function); |
| 263 listenerEntry->Set(v8::String::NewSymbol("useCapture"), v8::Boolean::New
(listenerInfo.eventListenerVector[i].useCapture)); | 263 listenerEntry->Set(v8::String::NewSymbol("useCapture"), v8::Boolean::New
(listenerInfo.eventListenerVector[i].useCapture)); |
| 264 result->Set(v8::Number::New(v8Listener->isolate(), outputIndex++), liste
nerEntry); | 264 result->Set(v8::Number::New(v8Listener->isolate(), outputIndex++), liste
nerEntry); |
| 265 } | 265 } |
| 266 return result; | 266 return result; |
| 267 } | 267 } |
| 268 | 268 |
| 269 void V8InjectedScriptHost::getEventListenersMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) | 269 void V8InjectedScriptHost::getEventListenersMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& info) |
| 270 { | 270 { |
| 271 if (args.Length() < 1) | 271 if (info.Length() < 1) |
| 272 return; | 272 return; |
| 273 | 273 |
| 274 v8::Local<v8::Value> value = args[0]; | 274 v8::Local<v8::Value> value = info[0]; |
| 275 if (!V8Node::HasInstance(value, args.GetIsolate(), worldType(args.GetIsolate
()))) | 275 if (!V8Node::HasInstance(value, info.GetIsolate(), worldType(info.GetIsolate
()))) |
| 276 return; | 276 return; |
| 277 Node* node = V8Node::toNative(value->ToObject()); | 277 Node* node = V8Node::toNative(value->ToObject()); |
| 278 if (!node) | 278 if (!node) |
| 279 return; | 279 return; |
| 280 | 280 |
| 281 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 281 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 282 Vector<EventListenerInfo> listenersArray; | 282 Vector<EventListenerInfo> listenersArray; |
| 283 host->getEventListenersImpl(node, listenersArray); | 283 host->getEventListenersImpl(node, listenersArray); |
| 284 | 284 |
| 285 v8::Local<v8::Object> result = v8::Object::New(); | 285 v8::Local<v8::Object> result = v8::Object::New(); |
| 286 for (size_t i = 0; i < listenersArray.size(); ++i) { | 286 for (size_t i = 0; i < listenersArray.size(); ++i) { |
| 287 v8::Handle<v8::Array> listeners = getJSListenerFunctions(&node->document
(), listenersArray[i]); | 287 v8::Handle<v8::Array> listeners = getJSListenerFunctions(&node->document
(), listenersArray[i]); |
| 288 if (!listeners->Length()) | 288 if (!listeners->Length()) |
| 289 continue; | 289 continue; |
| 290 AtomicString eventType = listenersArray[i].eventType; | 290 AtomicString eventType = listenersArray[i].eventType; |
| 291 result->Set(v8String(eventType, args.GetIsolate()), listeners); | 291 result->Set(v8String(eventType, info.GetIsolate()), listeners); |
| 292 } | 292 } |
| 293 | 293 |
| 294 v8SetReturnValue(args, result); | 294 v8SetReturnValue(info, result); |
| 295 } | 295 } |
| 296 | 296 |
| 297 void V8InjectedScriptHost::inspectMethodCustom(const v8::FunctionCallbackInfo<v8
::Value>& args) | 297 void V8InjectedScriptHost::inspectMethodCustom(const v8::FunctionCallbackInfo<v8
::Value>& info) |
| 298 { | 298 { |
| 299 if (args.Length() < 2) | 299 if (info.Length() < 2) |
| 300 return; | 300 return; |
| 301 | 301 |
| 302 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 302 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 303 ScriptValue object(args[0], args.GetIsolate()); | 303 ScriptValue object(info[0], info.GetIsolate()); |
| 304 ScriptValue hints(args[1], args.GetIsolate()); | 304 ScriptValue hints(info[1], info.GetIsolate()); |
| 305 host->inspectImpl(object.toJSONValue(ScriptState::current()), hints.toJSONVa
lue(ScriptState::current())); | 305 host->inspectImpl(object.toJSONValue(ScriptState::current()), hints.toJSONVa
lue(ScriptState::current())); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void V8InjectedScriptHost::databaseIdMethodCustom(const v8::FunctionCallbackInfo
<v8::Value>& args) | 308 void V8InjectedScriptHost::databaseIdMethodCustom(const v8::FunctionCallbackInfo
<v8::Value>& info) |
| 309 { | 309 { |
| 310 if (args.Length() > 0 && V8Database::HasInstance(args[0], args.GetIsolate(),
worldType(args.GetIsolate()))) { | 310 if (info.Length() > 0 && V8Database::HasInstance(info[0], info.GetIsolate(),
worldType(info.GetIsolate()))) { |
| 311 Database* database = V8Database::toNative(v8::Handle<v8::Object>::Cast(a
rgs[0])); | 311 Database* database = V8Database::toNative(v8::Handle<v8::Object>::Cast(i
nfo[0])); |
| 312 if (database) { | 312 if (database) { |
| 313 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holde
r()); { | 313 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holde
r()); { |
| 314 v8SetReturnValueStringOrUndefined(args, host->databaseIdImpl(dat
abase), args.GetIsolate()); | 314 v8SetReturnValueStringOrUndefined(info, host->databaseIdImpl(dat
abase), info.GetIsolate()); |
| 315 return; | 315 return; |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 | 320 |
| 321 void V8InjectedScriptHost::storageIdMethodCustom(const v8::FunctionCallbackInfo<
v8::Value>& args) | 321 void V8InjectedScriptHost::storageIdMethodCustom(const v8::FunctionCallbackInfo<
v8::Value>& info) |
| 322 { | 322 { |
| 323 if (args.Length() > 0 && V8Storage::HasInstance(args[0], args.GetIsolate(),
worldType(args.GetIsolate()))) { | 323 if (info.Length() > 0 && V8Storage::HasInstance(info[0], info.GetIsolate(),
worldType(info.GetIsolate()))) { |
| 324 Storage* storage = V8Storage::toNative(v8::Handle<v8::Object>::Cast(args
[0])); | 324 Storage* storage = V8Storage::toNative(v8::Handle<v8::Object>::Cast(info
[0])); |
| 325 if (storage) { | 325 if (storage) { |
| 326 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holde
r()); | 326 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holde
r()); |
| 327 v8SetReturnValueStringOrUndefined(args, host->storageIdImpl(storage)
, args.GetIsolate()); | 327 v8SetReturnValueStringOrUndefined(info, host->storageIdImpl(storage)
, info.GetIsolate()); |
| 328 return; | 328 return; |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 void V8InjectedScriptHost::evaluateMethodCustom(const v8::FunctionCallbackInfo<v
8::Value>& args) | 333 void V8InjectedScriptHost::evaluateMethodCustom(const v8::FunctionCallbackInfo<v
8::Value>& info) |
| 334 { | 334 { |
| 335 if (args.Length() < 1) { | 335 if (info.Length() < 1) { |
| 336 v8::ThrowException(v8::Exception::Error(v8::String::New("One argument ex
pected."))); | 336 v8::ThrowException(v8::Exception::Error(v8::String::New("One argument ex
pected."))); |
| 337 return; | 337 return; |
| 338 } | 338 } |
| 339 | 339 |
| 340 v8::Handle<v8::String> expression = args[0]->ToString(); | 340 v8::Handle<v8::String> expression = info[0]->ToString(); |
| 341 if (expression.IsEmpty()) { | 341 if (expression.IsEmpty()) { |
| 342 v8::ThrowException(v8::Exception::Error(v8::String::New("The argument mu
st be a string."))); | 342 v8::ThrowException(v8::Exception::Error(v8::String::New("The argument mu
st be a string."))); |
| 343 return; | 343 return; |
| 344 } | 344 } |
| 345 | 345 |
| 346 ASSERT(!v8::Context::GetCurrent().IsEmpty()); | 346 ASSERT(!v8::Context::GetCurrent().IsEmpty()); |
| 347 v8::TryCatch tryCatch; | 347 v8::TryCatch tryCatch; |
| 348 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e
xpression, args.GetIsolate()); | 348 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e
xpression, info.GetIsolate()); |
| 349 if (tryCatch.HasCaught()) { | 349 if (tryCatch.HasCaught()) { |
| 350 v8SetReturnValue(args, tryCatch.ReThrow()); | 350 v8SetReturnValue(info, tryCatch.ReThrow()); |
| 351 return; | 351 return; |
| 352 } | 352 } |
| 353 v8SetReturnValue(args, result); | 353 v8SetReturnValue(info, result); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi
onCallbackInfo<v8::Value>& args) | 356 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi
onCallbackInfo<v8::Value>& info) |
| 357 { | 357 { |
| 358 v8::Handle<v8::Value> functionValue = args[0]; | 358 v8::Handle<v8::Value> functionValue = info[0]; |
| 359 int scopeIndex = args[1]->Int32Value(); | 359 int scopeIndex = info[1]->Int32Value(); |
| 360 String variableName = toWebCoreStringWithUndefinedOrNullCheck(args[2]); | 360 String variableName = toWebCoreStringWithUndefinedOrNullCheck(info[2]); |
| 361 v8::Handle<v8::Value> newValue = args[3]; | 361 v8::Handle<v8::Value> newValue = info[3]; |
| 362 | 362 |
| 363 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 363 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 364 ScriptDebugServer& debugServer = host->scriptDebugServer(); | 364 ScriptDebugServer& debugServer = host->scriptDebugServer(); |
| 365 v8SetReturnValue(args, debugServer.setFunctionVariableValue(functionValue, s
copeIndex, variableName, newValue)); | 365 v8SetReturnValue(info, debugServer.setFunctionVariableValue(functionValue, s
copeIndex, variableName, newValue)); |
| 366 } | 366 } |
| 367 | 367 |
| 368 static bool getFunctionLocation(const v8::FunctionCallbackInfo<v8::Value>& args,
String* scriptId, int* lineNumber, int* columnNumber) | 368 static bool getFunctionLocation(const v8::FunctionCallbackInfo<v8::Value>& info,
String* scriptId, int* lineNumber, int* columnNumber) |
| 369 { | 369 { |
| 370 if (args.Length() < 1) | 370 if (info.Length() < 1) |
| 371 return false; | 371 return false; |
| 372 v8::Handle<v8::Value> fn = args[0]; | 372 v8::Handle<v8::Value> fn = info[0]; |
| 373 if (!fn->IsFunction()) | 373 if (!fn->IsFunction()) |
| 374 return false; | 374 return false; |
| 375 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(fn); | 375 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(fn); |
| 376 *lineNumber = function->GetScriptLineNumber(); | 376 *lineNumber = function->GetScriptLineNumber(); |
| 377 *columnNumber = function->GetScriptColumnNumber(); | 377 *columnNumber = function->GetScriptColumnNumber(); |
| 378 if (*lineNumber == v8::Function::kLineOffsetNotFound || *columnNumber == v8:
:Function::kLineOffsetNotFound) | 378 if (*lineNumber == v8::Function::kLineOffsetNotFound || *columnNumber == v8:
:Function::kLineOffsetNotFound) |
| 379 return false; | 379 return false; |
| 380 *scriptId = toWebCoreStringWithUndefinedOrNullCheck(function->GetScriptId())
; | 380 *scriptId = toWebCoreStringWithUndefinedOrNullCheck(function->GetScriptId())
; |
| 381 return true; | 381 return true; |
| 382 } | 382 } |
| 383 | 383 |
| 384 void V8InjectedScriptHost::debugFunctionMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 384 void V8InjectedScriptHost::debugFunctionMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 385 { | 385 { |
| 386 String scriptId; | 386 String scriptId; |
| 387 int lineNumber; | 387 int lineNumber; |
| 388 int columnNumber; | 388 int columnNumber; |
| 389 if (!getFunctionLocation(args, &scriptId, &lineNumber, &columnNumber)) | 389 if (!getFunctionLocation(info, &scriptId, &lineNumber, &columnNumber)) |
| 390 return; | 390 return; |
| 391 | 391 |
| 392 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 392 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 393 host->debugFunction(scriptId, lineNumber, columnNumber); | 393 host->debugFunction(scriptId, lineNumber, columnNumber); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void V8InjectedScriptHost::undebugFunctionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 396 void V8InjectedScriptHost::undebugFunctionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
| 397 { | 397 { |
| 398 String scriptId; | 398 String scriptId; |
| 399 int lineNumber; | 399 int lineNumber; |
| 400 int columnNumber; | 400 int columnNumber; |
| 401 if (!getFunctionLocation(args, &scriptId, &lineNumber, &columnNumber)) | 401 if (!getFunctionLocation(info, &scriptId, &lineNumber, &columnNumber)) |
| 402 return; | 402 return; |
| 403 | 403 |
| 404 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 404 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 405 host->undebugFunction(scriptId, lineNumber, columnNumber); | 405 host->undebugFunction(scriptId, lineNumber, columnNumber); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void V8InjectedScriptHost::monitorFunctionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 408 void V8InjectedScriptHost::monitorFunctionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
| 409 { | 409 { |
| 410 String scriptId; | 410 String scriptId; |
| 411 int lineNumber; | 411 int lineNumber; |
| 412 int columnNumber; | 412 int columnNumber; |
| 413 if (!getFunctionLocation(args, &scriptId, &lineNumber, &columnNumber)) | 413 if (!getFunctionLocation(info, &scriptId, &lineNumber, &columnNumber)) |
| 414 return; | 414 return; |
| 415 | 415 |
| 416 v8::Handle<v8::Value> name; | 416 v8::Handle<v8::Value> name; |
| 417 if (args.Length() > 0 && args[0]->IsFunction()) { | 417 if (info.Length() > 0 && info[0]->IsFunction()) { |
| 418 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(args[
0]); | 418 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(info[
0]); |
| 419 name = function->GetName(); | 419 name = function->GetName(); |
| 420 if (!name->IsString() || !v8::Handle<v8::String>::Cast(name)->Length()) | 420 if (!name->IsString() || !v8::Handle<v8::String>::Cast(name)->Length()) |
| 421 name = function->GetInferredName(); | 421 name = function->GetInferredName(); |
| 422 } | 422 } |
| 423 | 423 |
| 424 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 424 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 425 host->monitorFunction(scriptId, lineNumber, columnNumber, toWebCoreStringWit
hUndefinedOrNullCheck(name)); | 425 host->monitorFunction(scriptId, lineNumber, columnNumber, toWebCoreStringWit
hUndefinedOrNullCheck(name)); |
| 426 } | 426 } |
| 427 | 427 |
| 428 void V8InjectedScriptHost::unmonitorFunctionMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) | 428 void V8InjectedScriptHost::unmonitorFunctionMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& info) |
| 429 { | 429 { |
| 430 String scriptId; | 430 String scriptId; |
| 431 int lineNumber; | 431 int lineNumber; |
| 432 int columnNumber; | 432 int columnNumber; |
| 433 if (!getFunctionLocation(args, &scriptId, &lineNumber, &columnNumber)) | 433 if (!getFunctionLocation(info, &scriptId, &lineNumber, &columnNumber)) |
| 434 return; | 434 return; |
| 435 | 435 |
| 436 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); | 436 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 437 host->unmonitorFunction(scriptId, lineNumber, columnNumber); | 437 host->unmonitorFunction(scriptId, lineNumber, columnNumber); |
| 438 } | 438 } |
| 439 | 439 |
| 440 } // namespace WebCore | 440 } // namespace WebCore |
| OLD | NEW |