WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 166925
Implement InlineClassicScript
https://bugs.webkit.org/show_bug.cgi?id=166925
Summary
Implement InlineClassicScript
Yusuke Suzuki
Reported
2017-01-11 06:48:58 PST
Implement InlineClassicScript
Attachments
Patch
(42.88 KB, patch)
2017-01-11 06:54 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(52.11 KB, patch)
2017-01-11 07:13 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(49.86 KB, patch)
2017-01-11 07:13 PST
,
Yusuke Suzuki
rniwa
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2017-01-11 06:54:37 PST
Created
attachment 298578
[details]
Patch
Yusuke Suzuki
Comment 2
2017-01-11 07:13:03 PST
Created
attachment 298580
[details]
Patch
Yusuke Suzuki
Comment 3
2017-01-11 07:13:56 PST
Created
attachment 298581
[details]
Patch
Ryosuke Niwa
Comment 4
2017-01-12 00:15:23 PST
Comment on
attachment 298581
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=298581&action=review
> Source/WebCore/ChangeLog:9 > + This patch is further clean up. We introduce InlineClassicScript, which is
Nit: *a* further *cleanup*.
> Source/WebCore/ChangeLog:17 > + It is important for dynamic-import. When dynamic-import operator is called, > + we need to get the ScriptFetcher for the caller script SourceOrigin.
This sentence is a bit wordy. Also, why do we need to the ScriptFetcher for the caller script SourceOrigin? It’s not clear to me how ScriptFetcher is used in dynamic-import operator by just reading this description.
> Source/JavaScriptCore/runtime/SourceOrigin.h:35 > - explicit SourceOrigin(const String& string) > + explicit SourceOrigin(const String& string, ScriptFetcher* fetcher = nullptr)
Instead of adding an extra argument to this constructor, why don’t we add an overloading constructor that takes Ref<ScriptFetcher>&& instead so that we can avoid ref churn?
> Source/WebCore/bindings/js/CachedScriptFetcher.h:52 > + void notifyClientFinished();
Where is this defined? I don’t think CachedScriptFetcher is used a CachedResourceClient.
> Source/WebCore/bindings/js/CachedScriptSourceProvider.h:52 > - CachedScriptSourceProvider(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType) > - : SourceProvider(JSC::SourceOrigin { cachedScript->response().url() }, cachedScript->response().url(), TextPosition(), sourceType) > + CachedScriptSourceProvider(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType, CachedScriptFetcher* scriptFetcher) > + : SourceProvider(JSC::SourceOrigin { cachedScript->response().url(), scriptFetcher }, cachedScript->response().url(), TextPosition(), sourceType)
Ditto about adding an overloading constructor avoid ref churn.
> Source/WebCore/dom/InlineClassicScript.cpp:37 > + scriptElement.element().attributeWithoutSynchronization(HTMLNames::nonceAttr),
Please store Element& in a local variable instead of calling four times.
> Source/WebCore/dom/ScriptElement.cpp:279 > - executeClassicScript(ScriptSourceCode(scriptContent(), document.url(), position, JSC::SourceProviderSourceType::Program)); > + executeClassicScript(ScriptSourceCode(scriptContent(), document.url(), position, JSC::SourceProviderSourceType::Program, InlineClassicScript::create(*this).ptr()));
This is will result in two calls to ref(). Once in here and again inside SourceOrigin::SourceOrigin. Why don’t we make SourceOrigin and ScriptSourceCode take Ref<CachedScriptFetcher>&& to avoid this?
Yusuke Suzuki
Comment 5
2017-01-12 00:58:51 PST
Comment on
attachment 298581
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=298581&action=review
Thanks!
>> Source/WebCore/ChangeLog:9 >> + This patch is further clean up. We introduce InlineClassicScript, which is > > Nit: *a* further *cleanup*.
Fixed.
>> Source/WebCore/ChangeLog:17 >> + we need to get the ScriptFetcher for the caller script SourceOrigin. > > This sentence is a bit wordy. Also, why do we need to the ScriptFetcher for the caller script SourceOrigin? > It’s not clear to me how ScriptFetcher is used in dynamic-import operator by just reading this description.
Subsequent module loading requests need the metadata, like `crossorigin` attribute information, `nonce` information etc. They are delivered by ScriptFetcher.
>> Source/JavaScriptCore/runtime/SourceOrigin.h:35 >> + explicit SourceOrigin(const String& string, ScriptFetcher* fetcher = nullptr) > > Instead of adding an extra argument to this constructor, why don’t we add an overloading constructor > that takes Ref<ScriptFetcher>&& instead so that we can avoid ref churn?
Nice. Added new overloaded constructor.
>> Source/WebCore/bindings/js/CachedScriptFetcher.h:52 >> + void notifyClientFinished(); > > Where is this defined? I don’t think CachedScriptFetcher is used a CachedResourceClient.
Yeah, it accidentally remains. It should be dropped.
>> Source/WebCore/bindings/js/CachedScriptSourceProvider.h:52 >> + : SourceProvider(JSC::SourceOrigin { cachedScript->response().url(), scriptFetcher }, cachedScript->response().url(), TextPosition(), sourceType) > > Ditto about adding an overloading constructor avoid ref churn.
For CachedScriptSourceProvider case, we always have CachedScriptFetcher. So We can just convert this constructor to take Ref<CachedScriptFetcher>&&.
>> Source/WebCore/dom/InlineClassicScript.cpp:37 >> + scriptElement.element().attributeWithoutSynchronization(HTMLNames::nonceAttr), > > Please store Element& in a local variable instead of calling four times.
Fixed.
>> Source/WebCore/dom/ScriptElement.cpp:279 >> + executeClassicScript(ScriptSourceCode(scriptContent(), document.url(), position, JSC::SourceProviderSourceType::Program, InlineClassicScript::create(*this).ptr())); > > This is will result in two calls to ref(). Once in here and again inside SourceOrigin::SourceOrigin. > Why don’t we make SourceOrigin and ScriptSourceCode take Ref<CachedScriptFetcher>&& to avoid this?
We changed to do that by overloading the constructor with Ref<CachedScriptFetcher>&& parameter.
Yusuke Suzuki
Comment 6
2017-01-12 01:02:49 PST
Committed
r210627
: <
http://trac.webkit.org/changeset/210627
>
Csaba Osztrogonác
Comment 7
2017-01-12 03:47:13 PST
(In reply to
comment #6
)
> Committed
r210627
: <
http://trac.webkit.org/changeset/210627
>
It broke the Apple Mac build everywhere, see build.webkit.org for details.
Yusuke Suzuki
Comment 8
2017-01-12 03:50:15 PST
Committed
r210630
: <
http://trac.webkit.org/changeset/210630
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug