Bug 142890 - Web Inspector: Adopt ES6 Class Syntax for all Controller Objects
Summary: Web Inspector: Adopt ES6 Class Syntax for all Controller Objects
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Matt Baker
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-03-19 18:31 PDT by Matt Baker
Modified: 2015-03-22 22:03 PDT (History)
9 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (244.02 KB, patch)
2015-03-20 17:19 PDT, Matt Baker
no flags Details | Formatted Diff | Diff
[PATCH] Proposed Fix (243.82 KB, patch)
2015-03-20 18:53 PDT, Matt Baker
no flags Details | Formatted Diff | Diff
[PATCH] Proposed Fix (243.67 KB, patch)
2015-03-22 18:26 PDT, Matt Baker
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Baker 2015-03-19 18:31:43 PDT
* SUMMARY
Adopt ES6 Class Syntax for all Controller Objects.

* NOTES
The const keyword isn't allowed in strict mode, and ES6 class method scope uses strict mode implicitly. Instances of const will need to be replaced with var.
Comment 1 Radar WebKit Bug Importer 2015-03-19 18:32:13 PDT
<rdar://problem/20233853>
Comment 2 Matt Baker 2015-03-20 17:19:26 PDT
Created attachment 249152 [details]
[PATCH] Proposed Fix
Comment 3 Ryosuke Niwa 2015-03-20 17:21:49 PDT
Comment on attachment 249152 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=249152&action=review

> Source/WebInspectorUI/UserInterface/Controllers/BasicBlockAnnotator.js:31
> +        super(this, sourceCodeTextEditor);

This will throw a ReferenceError since it'll access "this" before calling super()
Comment 4 Ryosuke Niwa 2015-03-20 17:26:22 PDT
Comment on attachment 249152 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=249152&action=review

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorGradientEditingController.js:30
> +        super(this, codeMirror, marker);

Ditto.

> Source/WebInspectorUI/UserInterface/Controllers/TypeTokenAnnotator.js:30
> +        super(this, sourceCodeTextEditor);

Ditto.
Comment 5 Joseph Pecoraro 2015-03-20 17:54:54 PDT
Comment on attachment 249152 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=249152&action=review

Must fix those super calls.

>> Source/WebInspectorUI/UserInterface/Controllers/BasicBlockAnnotator.js:31
>> +        super(this, sourceCodeTextEditor);
> 
> This will throw a ReferenceError since it'll access "this" before calling super()

Yes, this is replacing:

    WebInspector.Annotator.call(this, sourceCodeTextEditor);

So the "this" is not needed. This should just be:

    super(sourceCodeTextEditor);

You can test this at runtime by using the Type Profiler.

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorColorEditingController.js:30
> +        super(this, codeMirror, marker);

Same.

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorDragToAdjustNumberController.js:26
> -WebInspector.CodeMirrorDragToAdjustNumberController = function(codeMirror)
> +WebInspector.CodeMirrorDragToAdjustNumberController = class CodeMirrorDragToAdjustNumberController

Weird that some of our WebInspector.CodeMirrorFoo classes extend WebInspector.Object and others don't. Maybe they all should.

> Source/WebInspectorUI/UserInterface/Controllers/FormatterSourceMap.js:35
> +    } 

Trailing whitespace!

> Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:28
> -    get: function()
> +    get()

Very interesting. I wonder if we should avoid this change. For now, I'd prefer this to be "get: function()" as thinking about it at a high level, this is a get property that is a function, not a method. I think it makes more sense to use the old syntax here.
Comment 6 Matt Baker 2015-03-20 18:53:01 PDT
Created attachment 249155 [details]
[PATCH] Proposed Fix
Comment 7 Matt Baker 2015-03-22 18:26:15 PDT
Created attachment 249211 [details]
[PATCH] Proposed Fix

To appease the bots.
Comment 8 Joseph Pecoraro 2015-03-22 21:16:58 PDT
Comment on attachment 249211 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=249211&action=review

> Source/WebInspectorUI/ChangeLog:6
> +        Reviewed by Joseph Pecoraro.

Since this is already reviewed, you can just set the cq+ flag to get it landed.
Comment 9 WebKit Commit Bot 2015-03-22 22:03:10 PDT
Comment on attachment 249211 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 249211

Committed r181844: <http://trac.webkit.org/changeset/181844>
Comment 10 WebKit Commit Bot 2015-03-22 22:03:15 PDT
All reviewed patches have been landed.  Closing bug.