Bug 173273 - Modernize UserScript.h
Summary: Modernize UserScript.h
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-12 14:00 PDT by Alex Christensen
Modified: 2017-06-14 11:13 PDT (History)
2 users (show)

See Also:


Attachments
Patch (13.85 KB, patch)
2017-06-12 14:04 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (13.87 KB, patch)
2017-06-12 14:30 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (13.83 KB, patch)
2017-06-12 15:19 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2017-06-12 14:00:55 PDT
Modernize UserScript.h
Comment 1 Alex Christensen 2017-06-12 14:04:36 PDT
Created attachment 312692 [details]
Patch
Comment 2 Alex Christensen 2017-06-12 14:30:07 PDT
Created attachment 312696 [details]
Patch
Comment 3 Alex Christensen 2017-06-12 15:19:34 PDT
Created attachment 312708 [details]
Patch
Comment 4 Alex Christensen 2017-06-12 15:38:21 PDT
https://trac.webkit.org/r218146
Comment 5 Darin Adler 2017-06-14 07:35:08 PDT
Comment on attachment 312708 [details]
Patch

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

> Source/WebCore/page/UserScript.h:35
>  class UserScript {

This seems like a struct, not a class. All it has is the constructor and getter functions for all data members. That’s exactly what a const struct is like.

> Source/WebCore/page/UserScript.h:38
> +    UserScript() { }

We could write this instead, which I prefer.

    UserScript() = default;

> Source/WebCore/page/UserScript.h:39
> +    ~UserScript() { }

This should be omitted. This is what the compiler will do if you don’t define a destructor.

> Source/WebCore/page/UserScript.h:59
> +    template<class Encoder> void encode(Encoder&) const;
> +    template<class Decoder> static bool decode(Decoder&, UserScript&);

We normally prefer typename rather than class for the type arguments.

Why do these functions need to be members? They can be written entirely using public interface.
Comment 6 Alex Christensen 2017-06-14 11:13:42 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 312708 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=312708&action=review
> 
> > Source/WebCore/page/UserScript.h:35
> >  class UserScript {
> 
> This seems like a struct, not a class. All it has is the constructor and
> getter functions for all data members. That’s exactly what a const struct is
> like.
> 
Yep, could be done.

> > Source/WebCore/page/UserScript.h:38
> > +    UserScript() { }
> 
> We could write this instead, which I prefer.
> 
>     UserScript() = default;
> 
> > Source/WebCore/page/UserScript.h:39
> > +    ~UserScript() { }
> 
> This should be omitted. This is what the compiler will do if you don’t
> define a destructor.
> 
I agree with these pieces of feedback, and I did them in earlier patches, but EWS/El Capitan's compilers failed to link WebKit2 for some reason.

> > Source/WebCore/page/UserScript.h:59
> > +    template<class Encoder> void encode(Encoder&) const;
> > +    template<class Decoder> static bool decode(Decoder&, UserScript&);
> 
> We normally prefer typename rather than class for the type arguments.
> 
> Why do these functions need to be members? They can be written entirely
> using public interface.
> 
Indeed