| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (parser) | 247 if (parser) |
| 248 return parser->textPosition(); | 248 return parser->textPosition(); |
| 249 return TextPosition::minimumPosition(); | 249 return TextPosition::minimumPosition(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 // Create a V8 object with an interceptor of NPObjectPropertyGetter. | 252 // Create a V8 object with an interceptor of NPObjectPropertyGetter. |
| 253 void ScriptController::bindToWindowObject(LocalFrame* frame, const String& key,
NPObject* object) | 253 void ScriptController::bindToWindowObject(LocalFrame* frame, const String& key,
NPObject* object) |
| 254 { | 254 { |
| 255 v8::HandleScope handleScope(m_isolate); | 255 v8::HandleScope handleScope(m_isolate); |
| 256 | 256 |
| 257 v8::Handle<v8::Context> v8Context = toV8Context(m_isolate, frame, DOMWrapper
World::mainWorld()); | 257 v8::Handle<v8::Context> v8Context = toV8Context(frame, DOMWrapperWorld::main
World()); |
| 258 if (v8Context.IsEmpty()) | 258 if (v8Context.IsEmpty()) |
| 259 return; | 259 return; |
| 260 | 260 |
| 261 v8::Context::Scope scope(v8Context); | 261 v8::Context::Scope scope(v8Context); |
| 262 | 262 |
| 263 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0, m_isolat
e); | 263 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0, m_isolat
e); |
| 264 | 264 |
| 265 // Attach to the global object. | 265 // Attach to the global object. |
| 266 v8::Handle<v8::Object> global = v8Context->Global(); | 266 v8::Handle<v8::Object> global = v8Context->Global(); |
| 267 global->Set(v8String(m_isolate, key), value); | 267 global->Set(v8String(m_isolate, key), value); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 357 |
| 358 static NPObject* createNoScriptObject() | 358 static NPObject* createNoScriptObject() |
| 359 { | 359 { |
| 360 notImplemented(); | 360 notImplemented(); |
| 361 return 0; | 361 return 0; |
| 362 } | 362 } |
| 363 | 363 |
| 364 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) | 364 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) |
| 365 { | 365 { |
| 366 v8::HandleScope handleScope(isolate); | 366 v8::HandleScope handleScope(isolate); |
| 367 v8::Handle<v8::Context> v8Context = toV8Context(isolate, frame, DOMWrapperWo
rld::mainWorld()); | 367 v8::Handle<v8::Context> v8Context = toV8Context(frame, DOMWrapperWorld::main
World()); |
| 368 if (v8Context.IsEmpty()) | 368 if (v8Context.IsEmpty()) |
| 369 return createNoScriptObject(); | 369 return createNoScriptObject(); |
| 370 | 370 |
| 371 v8::Context::Scope scope(v8Context); | 371 v8::Context::Scope scope(v8Context); |
| 372 DOMWindow* window = frame->domWindow(); | 372 DOMWindow* window = frame->domWindow(); |
| 373 v8::Handle<v8::Value> global = toV8(window, v8Context->Global(), v8Context->
GetIsolate()); | 373 v8::Handle<v8::Value> global = toV8(window, v8Context->Global(), v8Context->
GetIsolate()); |
| 374 ASSERT(global->IsObject()); | 374 ASSERT(global->IsObject()); |
| 375 | 375 |
| 376 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo
w, isolate); | 376 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo
w, isolate); |
| 377 } | 377 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 395 return m_windowScriptNPObject; | 395 return m_windowScriptNPObject; |
| 396 } | 396 } |
| 397 | 397 |
| 398 NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
* plugin) | 398 NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
* plugin) |
| 399 { | 399 { |
| 400 // Can't create NPObjects when JavaScript is disabled. | 400 // Can't create NPObjects when JavaScript is disabled. |
| 401 if (!canExecuteScripts(NotAboutToExecuteScript)) | 401 if (!canExecuteScripts(NotAboutToExecuteScript)) |
| 402 return createNoScriptObject(); | 402 return createNoScriptObject(); |
| 403 | 403 |
| 404 v8::HandleScope handleScope(m_isolate); | 404 v8::HandleScope handleScope(m_isolate); |
| 405 v8::Handle<v8::Context> v8Context = toV8Context(m_isolate, m_frame, DOMWrapp
erWorld::mainWorld()); | 405 v8::Handle<v8::Context> v8Context = toV8Context(m_frame, DOMWrapperWorld::ma
inWorld()); |
| 406 if (v8Context.IsEmpty()) | 406 if (v8Context.IsEmpty()) |
| 407 return createNoScriptObject(); | 407 return createNoScriptObject(); |
| 408 v8::Context::Scope scope(v8Context); | 408 v8::Context::Scope scope(v8Context); |
| 409 | 409 |
| 410 DOMWindow* window = m_frame->domWindow(); | 410 DOMWindow* window = m_frame->domWindow(); |
| 411 v8::Handle<v8::Value> v8plugin = toV8(plugin, v8Context->Global(), v8Context
->GetIsolate()); | 411 v8::Handle<v8::Value> v8plugin = toV8(plugin, v8Context->Global(), v8Context
->GetIsolate()); |
| 412 if (!v8plugin->IsObject()) | 412 if (!v8plugin->IsObject()) |
| 413 return createNoScriptObject(); | 413 return createNoScriptObject(); |
| 414 | 414 |
| 415 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win
dow, v8Context->GetIsolate()); | 415 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win
dow, v8Context->GetIsolate()); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 ScriptValue ScriptController::evaluateScriptInMainWorld(const ScriptSourceCode&
sourceCode, AccessControlStatus corsStatus, ExecuteScriptPolicy policy) | 567 ScriptValue ScriptController::evaluateScriptInMainWorld(const ScriptSourceCode&
sourceCode, AccessControlStatus corsStatus, ExecuteScriptPolicy policy) |
| 568 { | 568 { |
| 569 if (policy == DoNotExecuteScriptWhenScriptsDisabled && !canExecuteScripts(Ab
outToExecuteScript)) | 569 if (policy == DoNotExecuteScriptWhenScriptsDisabled && !canExecuteScripts(Ab
outToExecuteScript)) |
| 570 return ScriptValue(); | 570 return ScriptValue(); |
| 571 | 571 |
| 572 String sourceURL = sourceCode.url(); | 572 String sourceURL = sourceCode.url(); |
| 573 const String* savedSourceURL = m_sourceURL; | 573 const String* savedSourceURL = m_sourceURL; |
| 574 m_sourceURL = &sourceURL; | 574 m_sourceURL = &sourceURL; |
| 575 | 575 |
| 576 v8::HandleScope handleScope(m_isolate); | 576 v8::HandleScope handleScope(m_isolate); |
| 577 v8::Handle<v8::Context> v8Context = toV8Context(m_isolate, m_frame, DOMWrapp
erWorld::mainWorld()); | 577 v8::Handle<v8::Context> v8Context = toV8Context(m_frame, DOMWrapperWorld::ma
inWorld()); |
| 578 if (v8Context.IsEmpty()) | 578 if (v8Context.IsEmpty()) |
| 579 return ScriptValue(); | 579 return ScriptValue(); |
| 580 v8::Context::Scope scope(v8Context); | 580 v8::Context::Scope scope(v8Context); |
| 581 | 581 |
| 582 RefPtr<LocalFrame> protect(m_frame); | 582 RefPtr<LocalFrame> protect(m_frame); |
| 583 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 583 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
| 584 m_frame->loader().didAccessInitialDocument(); | 584 m_frame->loader().didAccessInitialDocument(); |
| 585 | 585 |
| 586 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio
n::preprocess(m_frame, sourceCode); | 586 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio
n::preprocess(m_frame, sourceCode); |
| 587 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma
ybeProcessedSourceCode : sourceCode; | 587 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma
ybeProcessedSourceCode : sourceCode; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 616 resultArray->Set(i, evaluationResult); | 616 resultArray->Set(i, evaluationResult); |
| 617 } | 617 } |
| 618 | 618 |
| 619 if (results) { | 619 if (results) { |
| 620 for (size_t i = 0; i < resultArray->Length(); ++i) | 620 for (size_t i = 0; i < resultArray->Length(); ++i) |
| 621 results->append(ScriptValue(ScriptState::from(context), resultArray-
>Get(i))); | 621 results->append(ScriptValue(ScriptState::from(context), resultArray-
>Get(i))); |
| 622 } | 622 } |
| 623 } | 623 } |
| 624 | 624 |
| 625 } // namespace WebCore | 625 } // namespace WebCore |
| OLD | NEW |