WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
80890
Web Inspector: Introduce SnippetsScriptMapping.
https://bugs.webkit.org/show_bug.cgi?id=80890
Summary
Web Inspector: Introduce SnippetsScriptMapping.
Vsevolod Vlasov
Reported
2012-03-12 14:30:30 PDT
Patch to follow. Tests for this mapping will be added once snippet could be evaluated.
Attachments
Patch
(10.85 KB, patch)
2012-03-12 14:54 PDT
,
Vsevolod Vlasov
no flags
Details
Formatted Diff
Diff
Patch
(12.42 KB, patch)
2012-03-13 08:05 PDT
,
Vsevolod Vlasov
no flags
Details
Formatted Diff
Diff
Patch
(12.92 KB, patch)
2012-03-13 10:56 PDT
,
Vsevolod Vlasov
no flags
Details
Formatted Diff
Diff
Patch
(12.97 KB, patch)
2012-03-13 11:51 PDT
,
Vsevolod Vlasov
no flags
Details
Formatted Diff
Diff
Patch
(13.21 KB, patch)
2012-03-14 02:04 PDT
,
Vsevolod Vlasov
pfeldman
: review+
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Vsevolod Vlasov
Comment 1
2012-03-12 14:54:20 PDT
Created
attachment 131421
[details]
Patch
Pavel Podivilov
Comment 2
2012-03-13 03:34:51 PDT
Comment on
attachment 131421
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=131421&action=review
> Source/WebCore/inspector/front-end/SnippetsModel.js:227 > + WebInspector.snippetsModel.addEventListener(WebInspector.SnippetsModel.EventTypes.SnippetDeleted, this._snippetDeleted.bind(this));
SnippetRemoved would be more consistent with other code.
> Source/WebCore/inspector/front-end/SnippetsModel.js:237 > + var snippet = this._snippetForScriptId[rawLocation.scriptId];
Could you only store the last script in _snippetForScriptId and delete stale scripts (_snippetForLastScriptId)? There should be no need to access snippet for stale scripts.
> Source/WebCore/inspector/front-end/SnippetsModel.js:242 > + if (!uiSourceCode)
It's guaranteed that addScript was already called for this script, so uiSourceCode should always exist here.
> Source/WebCore/inspector/front-end/SnippetsModel.js:261 > + if (!lastScript)
There's no script for this UISourceCode. How could there be a lastScript for the snippet?
> Source/WebCore/inspector/front-end/SnippetsModel.js:262 > + return null;
Please make sure all clients will check for null.
> Source/WebCore/inspector/front-end/SnippetsModel.js:274 > + result.push(snippet.uiSourceCode);
Wouldn't there be duplicates?
> Source/WebCore/inspector/front-end/SnippetsModel.js:289 > + var uiSourceCode = new WebInspector.UISourceCode(script.sourceURL, script.sourceURL, new WebInspector.ScriptContentProvider(script));
You should probably bind this script to existing snippet.uiSourceCode instead of creating a new one.
> Source/WebCore/inspector/front-end/SnippetsModel.js:294 > + if (!snippet)
Is it possible? Maybe preventing the snippet from being deleted while it's evaluated would make the code easier to understand.
> Source/WebCore/inspector/front-end/SnippetsModel.js:310 > + uiSourceCode.isSnippet = true;
uiSourceCode.isEditable = true?
> Source/WebCore/inspector/front-end/SnippetsModel.js:350 > + this._lastScriptForSnippet = new Map();
Clear other maps as well?
Vsevolod Vlasov
Comment 3
2012-03-13 08:01:23 PDT
Comment on
attachment 131421
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=131421&action=review
>> Source/WebCore/inspector/front-end/SnippetsModel.js:227 >> + WebInspector.snippetsModel.addEventListener(WebInspector.SnippetsModel.EventTypes.SnippetDeleted, this._snippetDeleted.bind(this)); > > SnippetRemoved would be more consistent with other code.
Done.
>> Source/WebCore/inspector/front-end/SnippetsModel.js:237 >> + var snippet = this._snippetForScriptId[rawLocation.scriptId]; > > Could you only store the last script in _snippetForScriptId and delete stale scripts (_snippetForLastScriptId)? There should be no need to access snippet for stale scripts.
Done.
>> Source/WebCore/inspector/front-end/SnippetsModel.js:242 >> + if (!uiSourceCode) > > It's guaranteed that addScript was already called for this script, so uiSourceCode should always exist here.
Done.
>> Source/WebCore/inspector/front-end/SnippetsModel.js:261 >> + if (!lastScript) > > There's no script for this UISourceCode. How could there be a lastScript for the snippet?
I have removed _lastScriptForSnippet map at all and rewritten this piece of code as we discussed offline.
>> Source/WebCore/inspector/front-end/SnippetsModel.js:289 >> + var uiSourceCode = new WebInspector.UISourceCode(script.sourceURL, script.sourceURL, new WebInspector.ScriptContentProvider(script)); > > You should probably bind this script to existing snippet.uiSourceCode instead of creating a new one.
Done.
>> Source/WebCore/inspector/front-end/SnippetsModel.js:310 >> + uiSourceCode.isSnippet = true; > > uiSourceCode.isEditable = true?
Done.
>> Source/WebCore/inspector/front-end/SnippetsModel.js:350 >> + this._lastScriptForSnippet = new Map(); > > Clear other maps as well?
No need to clear snippet<->uiSourceCode maps, since snippet are not removed upon navigation.
Vsevolod Vlasov
Comment 4
2012-03-13 08:05:36 PDT
Created
attachment 131614
[details]
Patch
Vsevolod Vlasov
Comment 5
2012-03-13 10:56:51 PDT
Created
attachment 131669
[details]
Patch
Vsevolod Vlasov
Comment 6
2012-03-13 11:51:20 PDT
Created
attachment 131686
[details]
Patch
Pavel Podivilov
Comment 7
2012-03-14 01:44:20 PDT
Comment on
attachment 131614
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=131614&action=review
looks good!
> Source/WebCore/inspector/front-end/ScriptMapping.js:178 > + if (WebInspector.snippetsModel.snippetForSourceURL(script.sourceURL))
There could be no snippet at this moment. Please check that script.sourceURL starts with "snippet://" instead.
> Source/WebCore/inspector/front-end/SnippetsModel.js:391 > + this._uiSourceCodeForScriptId = {};
Do you need to dispatch removed events here?
Pavel Podivilov
Comment 8
2012-03-14 01:47:39 PDT
Comment on
attachment 131686
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=131686&action=review
> Source/WebCore/inspector/front-end/SnippetsModel.js:307 > + _uiSourceCodesForScripts: function()
Not uiSourceCodesForScripts actually, maybe releasedUISourceCodes?
Vsevolod Vlasov
Comment 9
2012-03-14 02:04:28 PDT
Created
attachment 131808
[details]
Patch
Vsevolod Vlasov
Comment 10
2012-03-14 03:00:09 PDT
Committed
r110681
: <
http://trac.webkit.org/changeset/110681
>
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