Bug 142891

Summary: Web Inspector: Adopt ES6 Class Syntax for all View Objects.
Product: WebKit Reporter: Matt Baker <mattbaker>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, graouts, joepeck, jonowells, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 143106, 143107, 143108, 143111, 143127, 143128, 147439, 147534, 147658    
Bug Blocks: 147409    
Attachments:
Description Flags
WIP
none
WIP (Ignore Space)
none
WIP none

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.