| 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 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentPa
rser(); | 252 ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentPa
rser(); |
| 253 if (parser) | 253 if (parser) |
| 254 return parser->textPosition(); | 254 return parser->textPosition(); |
| 255 return TextPosition::minimumPosition(); | 255 return TextPosition::minimumPosition(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 // Create a V8 object with an interceptor of NPObjectPropertyGetter. | 258 // Create a V8 object with an interceptor of NPObjectPropertyGetter. |
| 259 void ScriptController::bindToWindowObject(LocalFrame* frame, const String& key,
NPObject* object) | 259 void ScriptController::bindToWindowObject(LocalFrame* frame, const String& key,
NPObject* object) |
| 260 { | 260 { |
| 261 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 261 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 262 if (scriptState->contextIsEmpty()) | 262 if (scriptState->contextIsValid()) |
| 263 return; | 263 return; |
| 264 | 264 |
| 265 ScriptState::Scope scope(scriptState); | 265 ScriptState::Scope scope(scriptState); |
| 266 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0, m_isolat
e); | 266 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0, m_isolat
e); |
| 267 | 267 |
| 268 // Attach to the global object. | 268 // Attach to the global object. |
| 269 scriptState->context()->Global()->Set(v8String(m_isolate, key), value); | 269 scriptState->context()->Global()->Set(v8String(m_isolate, key), value); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void ScriptController::enableEval() | 272 void ScriptController::enableEval() |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 static NPObject* createNoScriptObject() | 362 static NPObject* createNoScriptObject() |
| 363 { | 363 { |
| 364 notImplemented(); | 364 notImplemented(); |
| 365 return 0; | 365 return 0; |
| 366 } | 366 } |
| 367 | 367 |
| 368 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) | 368 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) |
| 369 { | 369 { |
| 370 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 370 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 371 if (scriptState->contextIsEmpty()) | 371 if (scriptState->contextIsValid()) |
| 372 return createNoScriptObject(); | 372 return createNoScriptObject(); |
| 373 | 373 |
| 374 ScriptState::Scope scope(scriptState); | 374 ScriptState::Scope scope(scriptState); |
| 375 LocalDOMWindow* window = frame->domWindow(); | 375 LocalDOMWindow* window = frame->domWindow(); |
| 376 v8::Handle<v8::Value> global = toV8(window, scriptState->context()->Global()
, scriptState->isolate()); | 376 v8::Handle<v8::Value> global = toV8(window, scriptState->context()->Global()
, scriptState->isolate()); |
| 377 ASSERT(global->IsObject()); | 377 ASSERT(global->IsObject()); |
| 378 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo
w, isolate); | 378 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo
w, isolate); |
| 379 } | 379 } |
| 380 | 380 |
| 381 NPObject* ScriptController::windowScriptNPObject() | 381 NPObject* ScriptController::windowScriptNPObject() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 397 return m_windowScriptNPObject; | 397 return m_windowScriptNPObject; |
| 398 } | 398 } |
| 399 | 399 |
| 400 NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
* plugin) | 400 NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
* plugin) |
| 401 { | 401 { |
| 402 // Can't create NPObjects when JavaScript is disabled. | 402 // Can't create NPObjects when JavaScript is disabled. |
| 403 if (!canExecuteScripts(NotAboutToExecuteScript)) | 403 if (!canExecuteScripts(NotAboutToExecuteScript)) |
| 404 return createNoScriptObject(); | 404 return createNoScriptObject(); |
| 405 | 405 |
| 406 ScriptState* scriptState = ScriptState::forMainWorld(m_frame); | 406 ScriptState* scriptState = ScriptState::forMainWorld(m_frame); |
| 407 if (scriptState->contextIsEmpty()) | 407 if (scriptState->contextIsValid()) |
| 408 return createNoScriptObject(); | 408 return createNoScriptObject(); |
| 409 | 409 |
| 410 ScriptState::Scope scope(scriptState); | 410 ScriptState::Scope scope(scriptState); |
| 411 LocalDOMWindow* window = m_frame->domWindow(); | 411 LocalDOMWindow* window = m_frame->domWindow(); |
| 412 v8::Handle<v8::Value> v8plugin = toV8(plugin, scriptState->context()->Global
(), scriptState->isolate()); | 412 v8::Handle<v8::Value> v8plugin = toV8(plugin, scriptState->context()->Global
(), scriptState->isolate()); |
| 413 if (!v8plugin->IsObject()) | 413 if (!v8plugin->IsObject()) |
| 414 return createNoScriptObject(); | 414 return createNoScriptObject(); |
| 415 | 415 |
| 416 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win
dow, scriptState->isolate()); | 416 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win
dow, scriptState->isolate()); |
| 417 } | 417 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 resultArray->Set(i, evaluationResult); | 633 resultArray->Set(i, evaluationResult); |
| 634 } | 634 } |
| 635 | 635 |
| 636 if (results) { | 636 if (results) { |
| 637 for (size_t i = 0; i < resultArray->Length(); ++i) | 637 for (size_t i = 0; i < resultArray->Length(); ++i) |
| 638 results->append(handleScope.Escape(resultArray->Get(i))); | 638 results->append(handleScope.Escape(resultArray->Get(i))); |
| 639 } | 639 } |
| 640 } | 640 } |
| 641 | 641 |
| 642 } // namespace blink | 642 } // namespace blink |
| OLD | NEW |