Changeset 190272 in webkit
- Timestamp:
- Sep 27, 2015, 3:24:18 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r190255 r190272 1178 1178 bindings/js/JSMessageEventCustom.cpp 1179 1179 bindings/js/JSMessagePortCustom.cpp 1180 bindings/js/JSModuleLoader.cpp 1180 1181 bindings/js/JSMutationCallback.cpp 1181 1182 bindings/js/JSMutationObserverCustom.cpp -
trunk/Source/WebCore/ChangeLog
r190271 r190272 1 2015-09-27 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [ES6] Implement ES6 Module loader hook stubs in WebCore 4 https://bugs.webkit.org/show_bug.cgi?id=149574 5 6 Reviewed by Ryosuke Niwa. 7 8 In this patch, we implement the loader hooks in the WebCore side. 9 Since the fetcher and actual evaluation code are separated from 10 this patch, they become empty. 11 12 Here, WebCore implements 3 loader hooks. 13 14 1. resolve hook 15 16 Takes the module name and resolve it to the unique module key. 17 In WebCore, we use URL as a module key. 18 And for the inlined module tag (e.g. <script type="module">import ...</script>), 19 we use the ES6 symbol as a module key. 20 In WebCore, we take the module name like "./hello.js" and resolve it by using 21 the URL of the importer module. 22 This functionality is implemented in this patch. 23 24 2. fetch hook 25 26 Fetches the resource specified by the module key. In WebCore, the module key is 27 URL. We use CachedResource loading system to load the resource of the modules. 28 The actual code of the fetch hook will be implemented in the subsequent patch. 29 30 3. evaluate hook 31 32 This is additional hook to instrument the module's execution for the inspector. 33 The actual code of the evaluate hook will be implemented in the subsequent patch. 34 35 In addition to that, we added required JSC forward headers for the module loader 36 implementation. 37 38 * CMakeLists.txt: 39 * ForwardingHeaders/runtime/JSInternalPromise.h: Added. 40 * ForwardingHeaders/runtime/JSInternalPromiseDeferred.h: Added. 41 * ForwardingHeaders/runtime/JSModuleRecord.h: Added. 42 * ForwardingHeaders/runtime/Symbol.h: Added. 43 * WebCore.vcxproj/WebCore.vcxproj: 44 * WebCore.vcxproj/WebCore.vcxproj.filters: 45 * WebCore.xcodeproj/project.pbxproj: 46 * bindings/js/JSBindingsAllInOne.cpp: 47 * bindings/js/JSDOMWindowBase.cpp: 48 (WebCore::JSDOMWindowBase::moduleLoaderResolve): 49 (WebCore::JSDOMWindowBase::moduleLoaderFetch): 50 (WebCore::JSDOMWindowBase::moduleLoaderEvaluate): 51 * bindings/js/JSDOMWindowBase.h: 52 * bindings/js/JSModuleLoader.cpp: Added. 53 (WebCore::JSModuleLoader::JSModuleLoader): 54 (WebCore::JSModuleLoader::resolve): 55 (WebCore::JSModuleLoader::fetch): 56 (WebCore::JSModuleLoader::evaluate): 57 * bindings/js/JSModuleLoader.h: Added. 58 (WebCore::JSModuleLoader::document): 59 * dom/Document.cpp: 60 (WebCore::Document::Document): 61 (WebCore::Document::~Document): 62 * dom/Document.h: 63 (WebCore::Document::moduleLoader): 64 1 65 2015-09-26 Hunseop Jeong <hs85.jeong@samsung.com> 2 66 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r190239 r190272 18415 18415 </ClCompile> 18416 18416 <ClCompile Include="..\bindings\js\JSMessagePortCustom.cpp"> 18417 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> 18418 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> 18419 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild> 18420 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild> 18421 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild> 18422 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild> 18423 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> 18424 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> 18425 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild> 18426 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild> 18427 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild> 18428 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild> 18429 </ClCompile> 18430 <ClCompile Include="..\bindings\js\JSModuleLoader.cpp"> 18417 18431 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> 18418 18432 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> … … 22479 22493 <ClInclude Include="..\bindings\js\JSMainThreadExecState.h" /> 22480 22494 <ClInclude Include="..\bindings\js\JSMessagePortCustom.h" /> 22495 <ClInclude Include="..\bindings\js\JSModuleLoader.h" /> 22481 22496 <ClInclude Include="..\bindings\js\JSMutationCallback.h" /> 22482 22497 <ClInclude Include="..\bindings\js\JSNodeCustom.h" /> … … 22723 22738 <ClInclude Include="..\ForwardingHeaders\runtime\ArgList.h" /> 22724 22739 <ClInclude Include="..\ForwardingHeaders\runtime\Identifier.h" /> 22740 <ClInclude Include="..\ForwardingHeaders\runtime\JSInternalPromise.h" /> 22741 <ClInclude Include="..\ForwardingHeaders\runtime\JSInternalPromiseDeferred.h" /> 22725 22742 <ClInclude Include="..\ForwardingHeaders\runtime\JSLock.h" /> 22726 22743 <ClInclude Include="..\ForwardingHeaders\runtime\JSObject.h" /> 22727 22744 <ClInclude Include="..\ForwardingHeaders\runtime\JSString.h" /> 22745 <ClInclude Include="..\ForwardingHeaders\runtime\JSModuleRecord.h" /> 22728 22746 <ClInclude Include="..\ForwardingHeaders\runtime\Lookup.h" /> 22729 22747 <ClInclude Include="..\ForwardingHeaders\runtime\Operations.h" /> 22730 22748 <ClInclude Include="..\ForwardingHeaders\runtime\Protect.h" /> 22731 22749 <ClInclude Include="..\ForwardingHeaders\runtime\StringObject.h" /> 22750 <ClInclude Include="..\ForwardingHeaders\runtime\Symbol.h" /> 22732 22751 <ClInclude Include="..\ForwardingHeaders\yarr\RegularExpression.h" /> 22733 22752 <ClInclude Include="..\ForwardingHeaders\yarr\Yarr.h" /> -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
r190198 r190272 4381 4381 <Filter>bindings\js</Filter> 4382 4382 </ClCompile> 4383 <ClCompile Include="..\bindings\js\JSModuleLoader.cpp"> 4384 <Filter>bindings\js</Filter> 4385 </ClCompile> 4383 4386 <ClCompile Include="..\bindings\js\JSMutationCallback.cpp"> 4384 4387 <Filter>bindings\js</Filter> … … 11475 11478 <Filter>bindings\js</Filter> 11476 11479 </ClInclude> 11480 <ClInclude Include="..\bindings\js\JSModuleLoader.h"> 11481 <Filter>bindings\js</Filter> 11482 </ClInclude> 11477 11483 <ClInclude Include="..\bindings\js\JSMutationCallback.h"> 11478 11484 <Filter>bindings\js</Filter> … … 11655 11661 <Filter>ForwardingHeaders\runtime</Filter> 11656 11662 </ClInclude> 11663 <ClInclude Include="..\ForwardingHeaders\runtime\JSInternalPromise.h"> 11664 <Filter>ForwardingHeaders\runtime</Filter> 11665 </ClInclude> 11666 <ClInclude Include="..\ForwardingHeaders\runtime\JSInternalPromiseDeferred.h"> 11667 <Filter>ForwardingHeaders\runtime</Filter> 11668 </ClInclude> 11657 11669 <ClInclude Include="..\ForwardingHeaders\runtime\JSLock.h"> 11658 11670 <Filter>ForwardingHeaders\runtime</Filter> … … 11661 11673 <Filter>ForwardingHeaders\runtime</Filter> 11662 11674 </ClInclude> 11675 <ClInclude Include="..\ForwardingHeaders\runtime\JSModuleRecord.h"> 11676 <Filter>ForwardingHeaders\runtime</Filter> 11677 </ClInclude> 11663 11678 <ClInclude Include="..\ForwardingHeaders\runtime\JSString.h"> 11664 11679 <Filter>ForwardingHeaders\runtime</Filter> … … 11677 11692 </ClInclude> 11678 11693 <ClInclude Include="..\ForwardingHeaders\runtime\StringObject.h"> 11694 <Filter>ForwardingHeaders\runtime</Filter> 11695 </ClInclude> 11696 <ClInclude Include="..\ForwardingHeaders\runtime\Symbol.h"> 11679 11697 <Filter>ForwardingHeaders\runtime</Filter> 11680 11698 </ClInclude> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r190239 r190272 6325 6325 E1FF8F6C180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */; }; 6326 6326 E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */; }; 6327 E38838981BAD145F00D62EE3 /* JSModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */; settings = {ASSET_TAGS = (); }; }; 6328 E38838991BAD145F00D62EE3 /* JSModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E38838951BAD145F00D62EE3 /* JSModuleLoader.h */; settings = {ASSET_TAGS = (); }; }; 6327 6329 E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6328 6330 E424A39E1330DF0100CF6DC9 /* LegacyTileGridTile.h in Headers */ = {isa = PBXBuildFile; fileRef = E424A39D1330DF0100CF6DC9 /* LegacyTileGridTile.h */; }; … … 14086 14088 E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRegistry.cpp; sourceTree = "<group>"; }; 14087 14089 E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRegistry.h; sourceTree = "<group>"; }; 14090 E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSModuleLoader.cpp; sourceTree = "<group>"; }; 14091 E38838951BAD145F00D62EE3 /* JSModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSModuleLoader.h; sourceTree = "<group>"; }; 14088 14092 E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = "<group>"; }; 14089 14093 E406F3FB1198307D009D59D6 /* ColorData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorData.cpp; sourceTree = "<group>"; }; … … 21538 21542 E1C36D320EB0A094007410BC /* JSWorkerGlobalScopeBase.cpp */, 21539 21543 E1C36D330EB0A094007410BC /* JSWorkerGlobalScopeBase.h */, 21544 E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */, 21545 E38838951BAD145F00D62EE3 /* JSModuleLoader.h */, 21540 21546 4198BDEE1A81123600B22FB5 /* ReadableJSStream.cpp */, 21541 21547 4198BDEF1A81123600B22FB5 /* ReadableJSStream.h */, … … 26208 26214 52E2CAFC19FF0207001EEB4F /* MediaProducer.h in Headers */, 26209 26215 4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */, 26216 E38838991BAD145F00D62EE3 /* JSModuleLoader.h in Headers */, 26210 26217 4E19592C0A39DACC00220FE5 /* MediaQueryEvaluator.h in Headers */, 26211 26218 4E19592E0A39DACC00220FE5 /* MediaQueryExp.h in Headers */, … … 28574 28581 498391510F1E76B400C23782 /* DOMWebKitCSSMatrix.mm in Sources */, 28575 28582 8AD0A59714C88358000D83C5 /* DOMWebKitCSSRegionRule.mm in Sources */, 28583 E38838981BAD145F00D62EE3 /* JSModuleLoader.cpp in Sources */, 28576 28584 31611E620E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.mm in Sources */, 28577 28585 3F2B33EC165AF15600E3987C /* DOMWebKitCSSViewportRule.mm in Sources */, -
trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
r190198 r190272 107 107 #include "JSMessageEventCustom.cpp" 108 108 #include "JSMessagePortCustom.cpp" 109 #include "JSModuleLoader.cpp" 109 110 #include "JSMutationCallback.cpp" 110 111 #include "JSMutationObserverCustom.cpp" -
trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
r190129 r190272 30 30 #include "JSDOMGlobalObjectTask.h" 31 31 #include "JSDOMWindowCustom.h" 32 #include "JSModuleLoader.h" 32 33 #include "JSNode.h" 33 34 #include "Logging.h" … … 37 38 #include "Settings.h" 38 39 #include "WebCoreJSClientData.h" 40 #include <runtime/JSInternalPromiseDeferred.h> 39 41 #include <runtime/Microtask.h> 40 42 #include <wtf/MainThread.h> … … 57 59 const ClassInfo JSDOMWindowBase::s_info = { "Window", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSDOMWindowBase) }; 58 60 59 const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr};61 const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, &moduleLoaderEvaluate }; 60 62 61 63 JSDOMWindowBase::JSDOMWindowBase(VM& vm, Structure* structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell) … … 277 279 } 278 280 281 282 JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSValue moduleName, JSC::JSValue importerModuleKey) 283 { 284 JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject); 285 if (RefPtr<Document> document = thisObject->impl().document()) 286 return document->moduleLoader()->resolve(globalObject, exec, moduleName, importerModuleKey); 287 JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject); 288 return deferred->reject(exec, jsUndefined()); 289 } 290 291 JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSValue moduleKey) 292 { 293 JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject); 294 if (RefPtr<Document> document = thisObject->impl().document()) 295 return document->moduleLoader()->fetch(globalObject, exec, moduleKey); 296 JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject); 297 return deferred->reject(exec, jsUndefined()); 298 } 299 300 JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSValue moduleKey, JSC::JSValue moduleRecord) 301 { 302 JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject); 303 if (RefPtr<Document> document = thisObject->impl().document()) 304 return document->moduleLoader()->evaluate(globalObject, exec, moduleKey, moduleRecord); 305 return JSC::jsUndefined(); 306 } 307 279 308 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h
r180653 r190272 79 79 80 80 private: 81 static JSC::JSInternalPromise* moduleLoaderResolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue, JSC::JSValue); 82 static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue); 83 static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue, JSC::JSValue); 84 81 85 RefPtr<DOMWindow> m_impl; 82 86 JSDOMWindowShell* m_shell; -
trunk/Source/WebCore/dom/Document.cpp
r190210 r190272 97 97 #include "InspectorInstrumentation.h" 98 98 #include "JSLazyEventListener.h" 99 #include "JSModuleLoader.h" 99 100 #include "Language.h" 100 101 #include "LoaderStrategy.h" … … 465 466 , m_overMinimumLayoutThreshold(false) 466 467 , m_scriptRunner(std::make_unique<ScriptRunner>(*this)) 468 , m_moduleLoader(std::make_unique<JSModuleLoader>(*this)) 467 469 , m_xmlVersion(ASCIILiteral("1.0")) 468 470 , m_xmlStandalone(StandaloneUnspecified) … … 606 608 607 609 m_scriptRunner = nullptr; 610 m_moduleLoader = nullptr; 608 611 609 612 removeAllEventListeners(); -
trunk/Source/WebCore/dom/Document.h
r190169 r190272 123 123 class LayoutRect; 124 124 class LiveNodeList; 125 class JSModuleLoader; 125 126 class JSNode; 126 127 class Locale; … … 935 936 936 937 ScriptRunner* scriptRunner() { return m_scriptRunner.get(); } 938 JSModuleLoader* moduleLoader() { return m_moduleLoader.get(); } 937 939 938 940 HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : 0; } … … 1519 1521 1520 1522 std::unique_ptr<ScriptRunner> m_scriptRunner; 1523 std::unique_ptr<JSModuleLoader> m_moduleLoader; 1521 1524 1522 1525 Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;
Note:
See TracChangeset
for help on using the changeset viewer.