| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 bool ScriptController::processingUserGesture() | 150 bool ScriptController::processingUserGesture() |
| 151 { | 151 { |
| 152 return UserGestureIndicator::processingUserGesture(); | 152 return UserGestureIndicator::processingUserGesture(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> fun
ction, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]) | 155 v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> fun
ction, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]) |
| 156 { | 156 { |
| 157 // Keep Frame (and therefore ScriptController) alive. | 157 // Keep Frame (and therefore ScriptController) alive. |
| 158 RefPtr<Frame> protect(m_frame); | 158 RefPtr<Frame> protect(m_frame); |
| 159 return ScriptController::callFunctionWithInstrumentation(m_frame ? m_frame->
document() : 0, function, receiver, argc, args); | 159 return ScriptController::callFunctionWithInstrumentation(m_frame ? m_frame->
document() : 0, function, receiver, argc, args, m_isolate); |
| 160 } | 160 } |
| 161 | 161 |
| 162 ScriptValue ScriptController::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Fu
nction> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Valu
e> argv[]) | 162 ScriptValue ScriptController::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Fu
nction> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Valu
e> argv[]) |
| 163 { | 163 { |
| 164 // FIXME: This should probably perform the same isPaused check that happens
in ScriptController::executeScript. | 164 // FIXME: This should probably perform the same isPaused check that happens
in ScriptController::executeScript. |
| 165 return ScriptValue(callFunction(function, receiver, argc, argv)); | 165 return ScriptValue(callFunction(function, receiver, argc, argv)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 static void resourceInfo(const v8::Handle<v8::Function> function, String& resour
ceName, int& lineNumber) | 168 static void resourceInfo(const v8::Handle<v8::Function> function, String& resour
ceName, int& lineNumber) |
| 169 { | 169 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 183 int lineNumber; | 183 int lineNumber; |
| 184 resourceInfo(function, resourceName, lineNumber); | 184 resourceInfo(function, resourceName, lineNumber); |
| 185 | 185 |
| 186 StringBuilder builder; | 186 StringBuilder builder; |
| 187 builder.append(resourceName); | 187 builder.append(resourceName); |
| 188 builder.append(':'); | 188 builder.append(':'); |
| 189 builder.appendNumber(lineNumber); | 189 builder.appendNumber(lineNumber); |
| 190 return builder.toString(); | 190 return builder.toString(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 v8::Local<v8::Value> ScriptController::callFunctionWithInstrumentation(ScriptExe
cutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object
> receiver, int argc, v8::Handle<v8::Value> args[]) | 193 v8::Local<v8::Value> ScriptController::callFunctionWithInstrumentation(ScriptExe
cutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object
> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate) |
| 194 { | 194 { |
| 195 InspectorInstrumentationCookie cookie; | 195 InspectorInstrumentationCookie cookie; |
| 196 if (InspectorInstrumentation::timelineAgentEnabled(context)) { | 196 if (InspectorInstrumentation::timelineAgentEnabled(context)) { |
| 197 String resourceName; | 197 String resourceName; |
| 198 int lineNumber; | 198 int lineNumber; |
| 199 resourceInfo(function, resourceName, lineNumber); | 199 resourceInfo(function, resourceName, lineNumber); |
| 200 cookie = InspectorInstrumentation::willCallFunction(context, resourceNam
e, lineNumber); | 200 cookie = InspectorInstrumentation::willCallFunction(context, resourceNam
e, lineNumber); |
| 201 } | 201 } |
| 202 | 202 |
| 203 v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, context
, receiver, argc, args); | 203 v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, context
, receiver, argc, args, isolate); |
| 204 | 204 |
| 205 InspectorInstrumentation::didCallFunction(cookie); | 205 InspectorInstrumentation::didCallFunction(cookie); |
| 206 return result; | 206 return result; |
| 207 } | 207 } |
| 208 | 208 |
| 209 v8::Local<v8::Value> ScriptController::compileAndRunScript(const ScriptSourceCod
e& source, AccessControlStatus corsStatus) | 209 v8::Local<v8::Value> ScriptController::compileAndRunScript(const ScriptSourceCod
e& source, AccessControlStatus corsStatus) |
| 210 { | 210 { |
| 211 ASSERT(v8::Context::InContext()); | 211 ASSERT(v8::Context::InContext()); |
| 212 | 212 |
| 213 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvalua
teScript(m_frame, source.url().isNull() ? String() : source.url().string(), sour
ce.startLine()); | 213 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvalua
teScript(m_frame, source.url().isNull() ? String() : source.url().string(), sour
ce.startLine()); |
| 214 | 214 |
| 215 v8::Local<v8::Value> result; | 215 v8::Local<v8::Value> result; |
| 216 { | 216 { |
| 217 // Isolate exceptions that occur when compiling and executing | 217 // Isolate exceptions that occur when compiling and executing |
| 218 // the code. These exceptions should not interfere with | 218 // the code. These exceptions should not interfere with |
| 219 // javascript code we might evaluate from C++ when returning | 219 // javascript code we might evaluate from C++ when returning |
| 220 // from here. | 220 // from here. |
| 221 v8::TryCatch tryCatch; | 221 v8::TryCatch tryCatch; |
| 222 tryCatch.SetVerbose(true); | 222 tryCatch.SetVerbose(true); |
| 223 | 223 |
| 224 v8::Handle<v8::String> code = v8String(source.source(), m_isolate); | 224 v8::Handle<v8::String> code = v8String(source.source(), m_isolate); |
| 225 OwnPtr<v8::ScriptData> scriptData = V8ScriptRunner::precompileScript(cod
e, source.resource()); | 225 OwnPtr<v8::ScriptData> scriptData = V8ScriptRunner::precompileScript(cod
e, source.resource()); |
| 226 | 226 |
| 227 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts
at | 227 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts
at |
| 228 // 1, whereas v8 starts at 0. | 228 // 1, whereas v8 starts at 0. |
| 229 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(code, sour
ce.url(), source.startPosition(), scriptData.get(), m_isolate, corsStatus); | 229 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(code, sour
ce.url(), source.startPosition(), scriptData.get(), m_isolate, corsStatus); |
| 230 | 230 |
| 231 // Keep Frame (and therefore ScriptController) alive. | 231 // Keep Frame (and therefore ScriptController) alive. |
| 232 RefPtr<Frame> protect(m_frame); | 232 RefPtr<Frame> protect(m_frame); |
| 233 result = V8ScriptRunner::runCompiledScript(script, m_frame->document()); | 233 result = V8ScriptRunner::runCompiledScript(script, m_frame->document(),
m_isolate); |
| 234 ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); | 234 ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 InspectorInstrumentation::didEvaluateScript(cookie); | 237 InspectorInstrumentation::didEvaluateScript(cookie); |
| 238 | 238 |
| 239 return result; | 239 return result; |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool ScriptController::initializeMainWorld() | 242 bool ScriptController::initializeMainWorld() |
| 243 { | 243 { |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 v8Results = evaluateHandleScope.Close(resultArray); | 714 v8Results = evaluateHandleScope.Close(resultArray); |
| 715 } | 715 } |
| 716 | 716 |
| 717 if (results && !v8Results.IsEmpty()) { | 717 if (results && !v8Results.IsEmpty()) { |
| 718 for (size_t i = 0; i < v8Results->Length(); ++i) | 718 for (size_t i = 0; i < v8Results->Length(); ++i) |
| 719 results->append(ScriptValue(v8Results->Get(i))); | 719 results->append(ScriptValue(v8Results->Get(i))); |
| 720 } | 720 } |
| 721 } | 721 } |
| 722 | 722 |
| 723 } // namespace WebCore | 723 } // namespace WebCore |
| OLD | NEW |