Bug 142891 - Web Inspector: Adopt ES6 Class Syntax for all View Objects.
Summary: Web Inspector: Adopt ES6 Class Syntax for all View 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: Nobody
URL:
Keywords: InRadar
Depends on: 143106 143107 143108 143111 143127 143128 147439 147534 147658
Blocks: InspectorAdoptES6
  Show dependency treegraph
 
Reported: 2015-03-19 18:40 PDT by Matt Baker
Modified: 2015-08-05 11:31 PDT (History)
8 users (show)

See Also:


Attachments
WIP (1.41 MB, patch)
2015-03-25 17:10 PDT, Timothy Hatcher
no flags Details | Formatted Diff | Diff
WIP (Ignore Space) (1.03 MB, patch)
2015-03-25 17:13 PDT, Timothy Hatcher
no flags Details | Formatted Diff | Diff
WIP (586.21 KB, patch)
2015-03-27 00:46 PDT, Timothy Hatcher
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:40:54 PDT
* SUMMARY
Adopt ES6 Class Syntax for all View Objects. Some view constructors (I'm looking at you, ContentView) follow an implicit factory pattern whereby the base class constructor returns a concrete type based on the represented object. We should make the factory pattern explicit using a static class method:

class ContentView {
    static create(representedObject) {
        if (typeof representedObject === "string" || representedObject instanceof String)
            return new WebInspector.TextContentView(representedObject);

        // And so on...

        console.assert(!WebInspector.ContentView.isViewable(representedObject));
        throw "Can't make a ContentView for an unknown representedObject.";
    }
}

* 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:41:22 PDT
<rdar://problem/20233935>
Comment 2 Timothy Hatcher 2015-03-25 17:10:56 PDT
Created attachment 249448 [details]
WIP
Comment 3 Timothy Hatcher 2015-03-25 17:13:17 PDT
Created attachment 249449 [details]
WIP (Ignore Space)
Comment 4 Timothy Hatcher 2015-03-27 00:46:04 PDT
Created attachment 249557 [details]
WIP

Latest WIP after landing some of the working classes.