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 27 matching lines...) Expand all Loading... |
38 #include "bindings/core/v8/ScriptSourceCode.h" | 38 #include "bindings/core/v8/ScriptSourceCode.h" |
39 #include "bindings/core/v8/ScriptValue.h" | 39 #include "bindings/core/v8/ScriptValue.h" |
40 #include "bindings/core/v8/V8Binding.h" | 40 #include "bindings/core/v8/V8Binding.h" |
41 #include "bindings/core/v8/V8Event.h" | 41 #include "bindings/core/v8/V8Event.h" |
42 #include "bindings/core/v8/V8GCController.h" | 42 #include "bindings/core/v8/V8GCController.h" |
43 #include "bindings/core/v8/V8HTMLElement.h" | 43 #include "bindings/core/v8/V8HTMLElement.h" |
44 #include "bindings/core/v8/V8PerContextData.h" | 44 #include "bindings/core/v8/V8PerContextData.h" |
45 #include "bindings/core/v8/V8ScriptRunner.h" | 45 #include "bindings/core/v8/V8ScriptRunner.h" |
46 #include "bindings/core/v8/V8Window.h" | 46 #include "bindings/core/v8/V8Window.h" |
47 #include "bindings/core/v8/WindowProxy.h" | 47 #include "bindings/core/v8/WindowProxy.h" |
| 48 #include "core/app/Module.h" |
48 #include "core/dom/Document.h" | 49 #include "core/dom/Document.h" |
49 #include "core/dom/Node.h" | 50 #include "core/dom/Node.h" |
50 #include "core/events/Event.h" | 51 #include "core/events/Event.h" |
51 #include "core/events/EventListener.h" | 52 #include "core/events/EventListener.h" |
52 #include "core/frame/LocalDOMWindow.h" | 53 #include "core/frame/LocalDOMWindow.h" |
53 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
54 #include "core/frame/Settings.h" | 55 #include "core/frame/Settings.h" |
55 #include "core/frame/UseCounter.h" | 56 #include "core/frame/UseCounter.h" |
56 #include "core/html/imports/HTMLImportChild.h" | 57 #include "core/html/imports/HTMLImportChild.h" |
57 #include "core/html/imports/HTMLImportLoader.h" | 58 #include "core/html/imports/HTMLImportLoader.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 evaluationResult = v8::Local<v8::Value>::New(m_isolate, v8::Undefine
d(m_isolate)); | 322 evaluationResult = v8::Local<v8::Value>::New(m_isolate, v8::Undefine
d(m_isolate)); |
322 resultArray->Set(i, evaluationResult); | 323 resultArray->Set(i, evaluationResult); |
323 } | 324 } |
324 | 325 |
325 if (results) { | 326 if (results) { |
326 for (size_t i = 0; i < resultArray->Length(); ++i) | 327 for (size_t i = 0; i < resultArray->Length(); ++i) |
327 results->append(handleScope.Escape(resultArray->Get(i))); | 328 results->append(handleScope.Escape(resultArray->Get(i))); |
328 } | 329 } |
329 } | 330 } |
330 | 331 |
331 void ScriptController::executeModuleScript(Document& document, const String& sou
rce, const TextPosition& textPosition) | 332 void ScriptController::executeModuleScript(AbstractModule* module, const String&
source, const TextPosition& textPosition) |
332 { | 333 { |
333 v8::HandleScope handleScope(m_isolate); | 334 v8::HandleScope handleScope(m_isolate); |
334 v8::Handle<v8::Context> context = toV8Context(m_frame, DOMWrapperWorld::main
World()); | 335 v8::Handle<v8::Context> context = toV8Context(m_frame, DOMWrapperWorld::main
World()); |
335 if (context.IsEmpty()) | 336 if (context.IsEmpty()) |
336 return; | 337 return; |
337 | 338 |
338 ScriptState* scriptState = ScriptState::from(context); | 339 ScriptState* scriptState = ScriptState::from(context); |
339 ScriptState::Scope scope(scriptState); | 340 ScriptState::Scope scope(scriptState); |
340 | 341 |
341 RefPtr<LocalFrame> protect(m_frame); | 342 RefPtr<LocalFrame> protect(m_frame); |
342 | 343 |
343 v8::TryCatch tryCatch; | 344 v8::TryCatch tryCatch; |
344 tryCatch.SetVerbose(true); | 345 tryCatch.SetVerbose(true); |
345 | 346 |
346 V8ScriptModule module; | 347 V8ScriptModule scriptModule; |
347 module.resourceName = document.url().string(); | 348 scriptModule.resourceName = module->url(); |
348 module.textPosition = textPosition; | 349 scriptModule.textPosition = textPosition; |
349 // FIXME: This should be the actual module object instead of the document. | 350 scriptModule.moduleObject = toV8(module, context->Global(), m_isolate); |
350 module.moduleObject = toV8(&document, context->Global(), m_isolate); | 351 scriptModule.source = source; |
351 module.source = source; | |
352 | 352 |
353 if (HTMLImport* parent = document.import()) { | 353 if (HTMLImport* parent = module->document()->import()) { |
354 for (HTMLImport* child = parent->firstChild(); child; child = child->nex
t()) { | 354 for (HTMLImportChild* child = static_cast<HTMLImportChild*>(parent->firs
tChild()); |
355 if (Element* link = static_cast<HTMLImportChild*>(child)->link()) { | 355 child; child = static_cast<HTMLImportChild*>(child->next())) { |
| 356 if (Element* link = child->link()) { |
356 String name = link->getAttribute(HTMLNames::asAttr); | 357 String name = link->getAttribute(HTMLNames::asAttr); |
357 if (!name.isEmpty()) { | 358 if (!name.isEmpty()) { |
358 module.formalDependencies.append(name); | 359 scriptModule.formalDependencies.append(name); |
359 v8::Handle<v8::Value> actual; | 360 v8::Handle<v8::Value> actual; |
360 if (child->document()) | 361 if (Module* childModule = child->module()) |
361 actual = child->document()->exports().v8Value(); | 362 actual = childModule->exports().v8Value(); |
362 if (actual.IsEmpty()) | 363 if (actual.IsEmpty()) |
363 actual = v8::Undefined(m_isolate); | 364 actual = v8::Undefined(m_isolate); |
364 module.resolvedDependencies.append(actual); | 365 scriptModule.resolvedDependencies.append(actual); |
365 } | 366 } |
366 } | 367 } |
367 } | 368 } |
368 } | 369 } |
369 | 370 |
370 V8ScriptRunner::runModule(m_isolate, m_frame->document(), module); | 371 V8ScriptRunner::runModule(m_isolate, m_frame->document(), scriptModule); |
371 } | 372 } |
372 | 373 |
373 } // namespace blink | 374 } // namespace blink |
OLD | NEW |