Bug 171251

Summary: Web Inspector: ObjC RWIProtocol codegen should better handle optional members
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, buildbot, commit-queue, inspector-bugzilla-changes, joepeck, keith_miller, mark.lam, msaboff, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix bburg: review+

Description Joseph Pecoraro 2017-04-24 14:50:32 PDT
ObjC RWIProtocol codegen should better handle optional members

For example, Highlight Config has optional color values:

    "id": "HighlightConfig",
    "type": "object",
    "properties": [
        { "name": "showInfo", "type": "boolean", "optional": true, "description": "Whether the node info tooltip should be shown (default: false)." },
        { "name": "contentColor", "$ref": "RGBAColor", "optional": true, "description": "The content box highlight fill color (default: transparent)." },
        { "name": "paddingColor", "$ref": "RGBAColor", "optional": true, "description": "The padding highlight fill color (default: transparent)." },
        { "name": "borderColor", "$ref": "RGBAColor", "optional": true, "description": "The border highlight fill color (default: transparent)." },
        { "name": "marginColor", "$ref": "RGBAColor", "optional": true, "description": "The margin highlight fill color (default: transparent)." }
    ],

However we return without checking if it was null or not:

    - (RWIProtocolDOMRGBAColor *)contentColor
    {
        return [[RWIProtocolDOMRGBAColor alloc] initWithInspectorObject:[[super objectForKey:@"contentColor"] toInspectorObject].get()];
    }

Should be something like:

    - (RWIProtocolDOMRGBAColor *)contentColor
    {
        RWIProtocolJSONObject *object = [[super objectForKey:@"contentColor"];
        if (!object)
            return nil;
        return [[RWIProtocolDOMRGBAColor alloc] initWithInspectorObject:[object toInspectorObject].get()];
    }
Comment 1 Joseph Pecoraro 2017-04-24 14:51:40 PDT
<rdar://problem/31697002>
Comment 2 Joseph Pecoraro 2017-04-24 14:52:53 PDT
Created attachment 308014 [details]
[PATCH] Proposed Fix
Comment 3 Build Bot 2017-04-24 14:54:11 PDT
This patch modifies the inspector protocol generator. Please ensure that you have rebaselined any generator test results (i.e., by running `Tools/Scripts/run-inspector-generator-tests --reset-results`)
Comment 4 Build Bot 2017-04-24 14:54:18 PDT
Attachment 308014 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py:449:  multiple statements on one line (semicolon)  [pep8/E702] [5]
ERROR: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:215:  trailing whitespace  [pep8/W291] [5]
Total errors found: 2 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 BJ Burg 2017-04-24 14:56:10 PDT
Comment on attachment 308014 [details]
[PATCH] Proposed Fix

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

r=me

> Source/JavaScriptCore/ChangeLog:18
> +        Rebaselined inspector generator tests.

Thanks!
Comment 6 Joseph Pecoraro 2017-04-24 15:02:40 PDT
<https://trac.webkit.org/changeset/215698/webkit>