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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentPa
rser(); | 256 ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentPa
rser(); |
257 if (parser) | 257 if (parser) |
258 return parser->textPosition(); | 258 return parser->textPosition(); |
259 return TextPosition::minimumPosition(); | 259 return TextPosition::minimumPosition(); |
260 } | 260 } |
261 | 261 |
262 // Create a V8 object with an interceptor of NPObjectPropertyGetter. | 262 // Create a V8 object with an interceptor of NPObjectPropertyGetter. |
263 void ScriptController::bindToWindowObject(LocalFrame* frame, const String& key,
NPObject* object) | 263 void ScriptController::bindToWindowObject(LocalFrame* frame, const String& key,
NPObject* object) |
264 { | 264 { |
265 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 265 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
266 if (scriptState->contextIsValid()) | 266 if (!scriptState->contextIsValid()) |
267 return; | 267 return; |
268 | 268 |
269 ScriptState::Scope scope(scriptState); | 269 ScriptState::Scope scope(scriptState); |
270 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0, m_isolat
e); | 270 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0, m_isolat
e); |
271 | 271 |
272 // Attach to the global object. | 272 // Attach to the global object. |
273 scriptState->context()->Global()->Set(v8String(m_isolate, key), value); | 273 scriptState->context()->Global()->Set(v8String(m_isolate, key), value); |
274 } | 274 } |
275 | 275 |
276 void ScriptController::enableEval() | 276 void ScriptController::enableEval() |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 365 |
366 static NPObject* createNoScriptObject() | 366 static NPObject* createNoScriptObject() |
367 { | 367 { |
368 notImplemented(); | 368 notImplemented(); |
369 return 0; | 369 return 0; |
370 } | 370 } |
371 | 371 |
372 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) | 372 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) |
373 { | 373 { |
374 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 374 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
375 if (scriptState->contextIsValid()) | 375 if (!scriptState->contextIsValid()) |
376 return createNoScriptObject(); | 376 return createNoScriptObject(); |
377 | 377 |
378 ScriptState::Scope scope(scriptState); | 378 ScriptState::Scope scope(scriptState); |
379 LocalDOMWindow* window = frame->domWindow(); | 379 LocalDOMWindow* window = frame->domWindow(); |
380 v8::Handle<v8::Value> global = toV8(window, scriptState->context()->Global()
, scriptState->isolate()); | 380 v8::Handle<v8::Value> global = toV8(window, scriptState->context()->Global()
, scriptState->isolate()); |
381 ASSERT(global->IsObject()); | 381 ASSERT(global->IsObject()); |
382 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo
w, isolate); | 382 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo
w, isolate); |
383 } | 383 } |
384 | 384 |
385 NPObject* ScriptController::windowScriptNPObject() | 385 NPObject* ScriptController::windowScriptNPObject() |
(...skipping 15 matching lines...) Expand all Loading... |
401 return m_windowScriptNPObject; | 401 return m_windowScriptNPObject; |
402 } | 402 } |
403 | 403 |
404 NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
* plugin) | 404 NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
* plugin) |
405 { | 405 { |
406 // Can't create NPObjects when JavaScript is disabled. | 406 // Can't create NPObjects when JavaScript is disabled. |
407 if (!canExecuteScripts(NotAboutToExecuteScript)) | 407 if (!canExecuteScripts(NotAboutToExecuteScript)) |
408 return createNoScriptObject(); | 408 return createNoScriptObject(); |
409 | 409 |
410 ScriptState* scriptState = ScriptState::forMainWorld(m_frame); | 410 ScriptState* scriptState = ScriptState::forMainWorld(m_frame); |
411 if (scriptState->contextIsValid()) | 411 if (!scriptState->contextIsValid()) |
412 return createNoScriptObject(); | 412 return createNoScriptObject(); |
413 | 413 |
414 ScriptState::Scope scope(scriptState); | 414 ScriptState::Scope scope(scriptState); |
415 LocalDOMWindow* window = m_frame->domWindow(); | 415 LocalDOMWindow* window = m_frame->domWindow(); |
416 v8::Handle<v8::Value> v8plugin = toV8(plugin, scriptState->context()->Global
(), scriptState->isolate()); | 416 v8::Handle<v8::Value> v8plugin = toV8(plugin, scriptState->context()->Global
(), scriptState->isolate()); |
417 if (!v8plugin->IsObject()) | 417 if (!v8plugin->IsObject()) |
418 return createNoScriptObject(); | 418 return createNoScriptObject(); |
419 | 419 |
420 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win
dow, scriptState->isolate()); | 420 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win
dow, scriptState->isolate()); |
421 } | 421 } |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 resultArray->Set(i, evaluationResult); | 637 resultArray->Set(i, evaluationResult); |
638 } | 638 } |
639 | 639 |
640 if (results) { | 640 if (results) { |
641 for (size_t i = 0; i < resultArray->Length(); ++i) | 641 for (size_t i = 0; i < resultArray->Length(); ++i) |
642 results->append(handleScope.Escape(resultArray->Get(i))); | 642 results->append(handleScope.Escape(resultArray->Get(i))); |
643 } | 643 } |
644 } | 644 } |
645 | 645 |
646 } // namespace blink | 646 } // namespace blink |
OLD | NEW |