Ignore:
Timestamp:
Jan 2, 2019, 9:59:08 AM (6 years ago)
Author:
[email protected]
Message:

SourceProviders should use an actual URL instead of a string
https://bugs.webkit.org/show_bug.cgi?id=192734

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

This will be useful for the Module loader API in the future where
by default it will use the relative path from the referring module
to resolve dependencies.

I didn't change the JSC shell's urls to be absolute paths as it
caused problems with the stack traces in our Chakra tests. Since
the absolute paths included system directories the diff would
appear incorrect.
See: https://bugs.webkit.org/show_bug.cgi?id=193077

  • API/JSBase.cpp:

(JSEvaluateScript):
(JSCheckScriptSyntax):

  • API/JSScriptRef.cpp:

(OpaqueJSScript::create):
(OpaqueJSScript::OpaqueJSScript):

  • API/glib/JSCContext.cpp:

(jsc_context_check_syntax):

  • jsc.cpp:

(jscSource):
(GlobalObject::moduleLoaderFetch):
(functionCheckModuleSyntax):
(runWithOptions):

  • parser/SourceCode.h:

(JSC::makeSource):

  • parser/SourceProvider.cpp:

(JSC::SourceProvider::SourceProvider):

  • parser/SourceProvider.h:

(JSC::SourceProvider::url const):
(JSC::StringSourceProvider::create):
(JSC::StringSourceProvider::StringSourceProvider):
(JSC::WebAssemblySourceProvider::create):
(JSC::WebAssemblySourceProvider::WebAssemblySourceProvider):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunctionSkippingEvalEnabledCheck):

  • tools/CodeProfile.h:

(JSC::CodeProfile::CodeProfile):

  • tools/FunctionOverrides.cpp:

(JSC::initializeOverrideInfo):

Source/WebCore:

Remove ScriptSourceCode's URL member and make the url() method
reference the URL on the SourceProvider. Also, avoid some
ref count churn.

Additionally, this patch fixes an existing bug in
WorkletGlobalScope() that would use a ScriptSourceCode after
WTFMoving it.

  • bindings/js/CachedScriptSourceProvider.h:

(WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):

  • bindings/js/ScheduledAction.cpp:

(WebCore::ScheduledAction::execute):

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::executeScriptInWorld):
(WebCore::ScriptController::executeScript):

  • bindings/js/ScriptSourceCode.h:

(WebCore::ScriptSourceCode::ScriptSourceCode):
(WebCore::ScriptSourceCode::m_code):
(WebCore::ScriptSourceCode::url const):
(WebCore::ScriptSourceCode::m_url): Deleted.

  • dom/ScriptElement.cpp:

(WebCore::ScriptElement::prepareScript):
(WebCore::ScriptElement::requestModuleScript):
(WebCore::ScriptElement::executePendingScript):

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript):

  • page/Frame.cpp:

(WebCore::Frame::injectUserScriptImmediately):

  • workers/WorkerGlobalScope.cpp:

(WebCore::WorkerGlobalScope::importScripts):

  • workers/WorkerThread.cpp:

(WebCore::WorkerThread::workerThread):

  • worklets/WorkletGlobalScope.cpp:

(WebCore::WorkletGlobalScope::WorkletGlobalScope):

  • xml/parser/XMLDocumentParserLibxml2.cpp:

(WebCore::XMLDocumentParser::endElementNs):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSBase.cpp

    r237266 r239569  
    6565    JSGlobalObject* globalObject = vm.vmEntryGlobalObject(exec);
    6666    auto sourceURLString = sourceURL ? sourceURL->string() : String();
    67     SourceCode source = makeSource(script->string(), SourceOrigin { sourceURLString }, sourceURLString, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
     67    SourceCode source = makeSource(script->string(), SourceOrigin { sourceURLString }, URL({ }, sourceURLString), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
    6868
    6969    NakedPtr<Exception> evaluationException;
     
    104104
    105105    auto sourceURLString = sourceURL ? sourceURL->string() : String();
    106     SourceCode source = makeSource(script->string(), SourceOrigin { sourceURLString }, sourceURLString, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
     106    SourceCode source = makeSource(script->string(), SourceOrigin { sourceURLString }, URL({ }, sourceURLString), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
    107107   
    108108    JSValue syntaxException;
Note: See TracChangeset for help on using the changeset viewer.