Bug 163188

Summary: Update generated bindings code so that dictionary structures no longer need explicit constructors
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: BindingsAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, darin, sam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 163624    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2016-10-09 16:53:32 PDT
Update generated bindings code so that dictionary structures no longer need constructors.
Comment 1 Chris Dumez 2016-10-09 17:15:09 PDT
Created attachment 291054 [details]
Patch
Comment 2 Darin Adler 2016-10-09 17:39:24 PDT
Comment on attachment 291054 [details]
Patch

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

Now that I see your change written out, I don’t see any downside to this.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1144
> +    $result .= "    return result;\n";

We want WTFMove(result) here, otherwise we end up copying the result to make the Optional<> version. Saves work and reference count churn when there are data members that have non-trivial constructors.

> Source/WebCore/dom/ClipboardEvent.h:37
>      struct Init : public EventInit {

No need for the "public" here.

> Source/WebCore/dom/CustomEvent.h:44
>      struct Init : public EventInit {

No need for the "public" here.

> Source/WebCore/dom/EventModifierInit.h:32
>  struct EventModifierInit : public UIEventInit {

No need for the "public" here.

> Source/WebCore/editing/Editor.cpp:884
>      RefPtr<DataTransfer> dataTransfer = DataTransfer::createForCopyAndPaste(policy);

This should be auto.

> Source/WebCore/editing/Editor.cpp:889
> +    init.clipboardData = dataTransfer.get();

This should just be standard assignment. I don’t think a call to .get() would be needed here; RefPtr = RefPtr should compile and RefPtr = Ref should also compile with no get call.
Comment 3 Chris Dumez 2016-10-09 17:44:10 PDT
(In reply to comment #2)
> Comment on attachment 291054 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=291054&action=review
> 
> Now that I see your change written out, I don’t see any downside to this.

Well, the downside is that we'll have to pass non-nullable wrapper type as raw pointers for now. Thankfully, this is not common in dictionaries (only 1 instance in WebKit).
Comment 4 Chris Dumez 2016-10-09 17:46:52 PDT
Created attachment 291055 [details]
Patch
Comment 5 Chris Dumez 2016-10-09 18:18:40 PDT
Comment on attachment 291055 [details]
Patch

Clearing flags on attachment: 291055

Committed r206974: <http://trac.webkit.org/changeset/206974>
Comment 6 Chris Dumez 2016-10-09 18:18:45 PDT
All reviewed patches have been landed.  Closing bug.