| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // Compile the script. | 265 // Compile the script. |
| 266 v8::Handle<v8::String> code = v8String(source.source(), m_isolate); | 266 v8::Handle<v8::String> code = v8String(source.source(), m_isolate); |
| 267 TRACE_EVENT_BEGIN0("v8", "v8.compile"); | 267 TRACE_EVENT_BEGIN0("v8", "v8.compile"); |
| 268 OwnPtr<v8::ScriptData> scriptData = ScriptSourceCode::precompileScript(c
ode, source.cachedScript()); | 268 OwnPtr<v8::ScriptData> scriptData = ScriptSourceCode::precompileScript(c
ode, source.cachedScript()); |
| 269 | 269 |
| 270 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts
at | 270 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts
at |
| 271 // 1, whereas v8 starts at 0. | 271 // 1, whereas v8 starts at 0. |
| 272 v8::Handle<v8::Script> script = ScriptSourceCode::compileScript(code, so
urce.url(), source.startPosition(), scriptData.get(), m_isolate); | 272 v8::Handle<v8::Script> script = ScriptSourceCode::compileScript(code, so
urce.url(), source.startPosition(), scriptData.get(), m_isolate); |
| 273 TRACE_EVENT_END0("v8", "v8.compile"); | 273 TRACE_EVENT_END0("v8", "v8.compile"); |
| 274 TRACE_EVENT0("v8", "v8.run"); | 274 TRACE_EVENT0("v8", "v8.run"); |
| 275 | 275 |
| 276 // Keep Frame (and therefore ScriptController) alive. | 276 // Keep Frame (and therefore ScriptController) alive. |
| 277 RefPtr<Frame> protect(m_frame); | 277 RefPtr<Frame> protect(m_frame); |
| 278 result = ScriptRunner::runCompiledScript(script, m_frame->document()); | 278 result = ScriptRunner::runCompiledScript(script, m_frame->document()); |
| 279 ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); | 279 ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); |
| 280 } | 280 } |
| 281 | 281 |
| 282 InspectorInstrumentation::didEvaluateScript(cookie); | 282 InspectorInstrumentation::didEvaluateScript(cookie); |
| 283 | 283 |
| 284 return result; | 284 return result; |
| 285 } | 285 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 | 673 |
| 674 bool ScriptController::setContextDebugId(int debugId) | 674 bool ScriptController::setContextDebugId(int debugId) |
| 675 { | 675 { |
| 676 ASSERT(debugId > 0); | 676 ASSERT(debugId > 0); |
| 677 if (!m_windowShell->isContextInitialized()) | 677 if (!m_windowShell->isContextInitialized()) |
| 678 return false; | 678 return false; |
| 679 v8::HandleScope scope; | 679 v8::HandleScope scope; |
| 680 v8::Handle<v8::Context> context = m_windowShell->context(); | 680 v8::Handle<v8::Context> context = m_windowShell->context(); |
| 681 return V8PerContextDebugData::setContextDebugData(context, "page", debugId); | 681 V8PerContextDebugData::setDebugDataForPage(context, debugId); |
| 682 return true; |
| 682 } | 683 } |
| 683 | 684 |
| 684 int ScriptController::contextDebugId(v8::Handle<v8::Context> context) | 685 int ScriptController::contextDebugId(v8::Handle<v8::Context> context) |
| 685 { | 686 { |
| 686 return V8PerContextDebugData::contextDebugId(context); | 687 return V8PerContextDebugData::debugId(context); |
| 687 } | 688 } |
| 688 | 689 |
| 689 void ScriptController::updateDocument() | 690 void ScriptController::updateDocument() |
| 690 { | 691 { |
| 691 // For an uninitialized main window shell, do not incur the cost of context
initialization during FrameLoader::init(). | 692 // For an uninitialized main window shell, do not incur the cost of context
initialization during FrameLoader::init(). |
| 692 if ((!m_windowShell->isContextInitialized() || !m_windowShell->isGlobalIniti
alized()) && m_frame->loader()->stateMachine()->creatingInitialEmptyDocument()) | 693 if ((!m_windowShell->isContextInitialized() || !m_windowShell->isGlobalIniti
alized()) && m_frame->loader()->stateMachine()->creatingInitialEmptyDocument()) |
| 693 return; | 694 return; |
| 694 | 695 |
| 695 if (!initializeMainWorld()) | 696 if (!initializeMainWorld()) |
| 696 windowShell(mainThreadNormalWorld())->updateDocument(); | 697 windowShell(mainThreadNormalWorld())->updateDocument(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 | 781 |
| 781 // DocumentWriter::replaceDocument can cause the DocumentLoader to get d
eref'ed and possible destroyed, | 782 // DocumentWriter::replaceDocument can cause the DocumentLoader to get d
eref'ed and possible destroyed, |
| 782 // so protect it with a RefPtr. | 783 // so protect it with a RefPtr. |
| 783 if (RefPtr<DocumentLoader> loader = m_frame->document()->loader()) | 784 if (RefPtr<DocumentLoader> loader = m_frame->document()->loader()) |
| 784 loader->writer()->replaceDocument(scriptResult, ownerDocument.get())
; | 785 loader->writer()->replaceDocument(scriptResult, ownerDocument.get())
; |
| 785 } | 786 } |
| 786 return true; | 787 return true; |
| 787 } | 788 } |
| 788 | 789 |
| 789 } // namespace WebCore | 790 } // namespace WebCore |
| OLD | NEW |