Bug 173564 - Cleanup FrameLoadRequest
Summary: Cleanup FrameLoadRequest
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on: 173614
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-19 14:28 PDT by Daniel Bates
Modified: 2017-06-21 14:19 PDT (History)
9 users (show)

See Also:


Attachments
Patch (62.72 KB, patch)
2017-06-19 15:27 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (64.75 KB, patch)
2017-06-19 16:08 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-elcapitan (2.48 MB, application/zip)
2017-06-19 16:47 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews115 for mac-elcapitan (2.52 MB, application/zip)
2017-06-19 17:00 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (2.54 MB, application/zip)
2017-06-19 17:12 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews121 for ios-simulator-wk2 (71.76 MB, application/zip)
2017-06-19 18:08 PDT, Build Bot
no flags Details
Patch (45.31 KB, patch)
2017-06-20 15:36 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (45.44 KB, patch)
2017-06-20 15:52 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (46.54 KB, patch)
2017-06-21 11:33 PDT, Daniel Bates
bfulgham: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2017-06-19 14:28:00 PDT
FrameLoadRequest has too many constructors. FrameLoadRequest should hold a Ref<SecurityOrigin> instead of a RefPtr<SecurityOrigin> as it is never passed a non-null SecurityOrigin object. We should also pass a Frame& instead of Frame* to the FrameLoadRequest constructor that take a frame as it expects the specified frame is non-null to be able to retrieve the SecurityOrigin of the document in the specified frame.
Comment 1 Daniel Bates 2017-06-19 15:27:56 PDT
Created attachment 313336 [details]
Patch
Comment 2 Build Bot 2017-06-19 15:29:37 PDT
Attachment 313336 [details] did not pass style-queue:


ERROR: Source/WebCore/loader/FrameLoadRequest.cpp:41:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Total errors found: 1 in 23 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Daniel Bates 2017-06-19 16:08:35 PDT
Created attachment 313339 [details]
Patch
Comment 4 Build Bot 2017-06-19 16:12:50 PDT Comment hidden (obsolete)
Comment 5 Build Bot 2017-06-19 16:47:44 PDT Comment hidden (obsolete)
Comment 6 Build Bot 2017-06-19 16:47:46 PDT Comment hidden (obsolete)
Comment 7 Build Bot 2017-06-19 17:00:56 PDT Comment hidden (obsolete)
Comment 8 Build Bot 2017-06-19 17:00:58 PDT Comment hidden (obsolete)
Comment 9 Build Bot 2017-06-19 17:12:44 PDT Comment hidden (obsolete)
Comment 10 Build Bot 2017-06-19 17:12:46 PDT Comment hidden (obsolete)
Comment 11 Build Bot 2017-06-19 18:08:04 PDT Comment hidden (obsolete)
Comment 12 Build Bot 2017-06-19 18:08:08 PDT Comment hidden (obsolete)
Comment 13 Brent Fulgham 2017-06-20 14:59:09 PDT
Comment on attachment 313339 [details]
Patch

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

> Source/WebCore/ChangeLog:4
> +        https://bugs.webkit.org/show_bug.cgi?id=173564

Please import to Radar so we can track this if any regressions are found.

> Source/WebCore/ChangeLog:15
> +        the target frame name as we do not have one. Use C++11 brace initialization syntax. Rename

Do we have a new style guideline to use the brace syntax? Does it impart some benefit over the traditional parenthetical version?
Comment 14 Darin Adler 2017-06-20 15:15:29 PDT
Comment on attachment 313339 [details]
Patch

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

>> Source/WebCore/ChangeLog:15
>> +        the target frame name as we do not have one. Use C++11 brace initialization syntax. Rename
> 
> Do we have a new style guideline to use the brace syntax? Does it impart some benefit over the traditional parenthetical version?

We do not have a formal style guideline, but it’s definitely a trend in style, started by Anders Carlsson.

The benefit I am aware of: The braces syntax is stricter. Some type conversions that are done silently in the parentheses syntax are treated as errors if the braces syntax is used.
Comment 15 Brent Fulgham 2017-06-20 15:17:29 PDT
Dan: This patch seems to be introducing regressions. Can you please review the errors to see why were are getting behavior changes?
Comment 16 Brent Fulgham 2017-06-20 15:20:57 PDT
Comment on attachment 313339 [details]
Patch

While I like the direction of this patch, the test failures make me concerned that you have introduced changes in behavior, perhaps by unexpected changes in how these objects are being initialized. I don't feel comfortable approving the change with these failing tests.
Comment 17 Daniel Bates 2017-06-20 15:36:28 PDT
Created attachment 313444 [details]
Patch
Comment 18 Daniel Bates 2017-06-20 15:52:19 PDT
Created attachment 313446 [details]
Patch
Comment 19 Daniel Bates 2017-06-21 11:33:23 PDT
Created attachment 313535 [details]
Patch
Comment 20 Daniel Bates 2017-06-21 11:55:27 PDT
<rdar://problem/32903570>
Comment 21 Brent Fulgham 2017-06-21 13:01:40 PDT
Comment on attachment 313535 [details]
Patch

Very nice! r=me.
Comment 22 Darin Adler 2017-06-21 13:48:34 PDT
Comment on attachment 313535 [details]
Patch

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

> Source/WebCore/loader/FrameLoadRequest.h:69
> +    FrameLoadRequest(const FrameLoadRequest& other)
> +        : m_requester { other.m_requester.copyRef() }
> +        , m_resourceRequest { other.m_resourceRequest }
> +        , m_frameName { other.m_frameName }
> +        , m_substituteData { other.m_substituteData }
> +        , m_shouldCheckNewWindowPolicy { other.m_shouldCheckNewWindowPolicy }
> +        , m_lockHistory { other.m_lockHistory }
> +        , m_lockBackForwardList { other.m_lockBackForwardList }
> +        , m_shouldSendReferrer { other.m_shouldSendReferrer }
> +        , m_allowNavigationToInvalidURL { other.m_allowNavigationToInvalidURL }
> +        , m_newFrameOpenerPolicy { other.m_newFrameOpenerPolicy }
> +        , m_shouldReplaceDocumentIfJavaScriptURL { other.m_shouldReplaceDocumentIfJavaScriptURL }
> +        , m_shouldOpenExternalURLsPolicy { other.m_shouldOpenExternalURLsPolicy }
> +        , m_downloadAttribute { other.m_downloadAttribute }
>      {
>      }

Irritating that we have to write this long function because Ref can’t be copied; it would be so easy to make the mistake of leaving one of these data members out and cause a bug that way. Also annoying that we ever have to copy a FrameLoadRequest. Maybe we can change at least some call sites so we move instead?
Comment 23 Daniel Bates 2017-06-21 14:10:30 PDT
(In reply to Darin Adler from comment #22)
> Comment on attachment 313535 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=313535&action=review
> 
> > Source/WebCore/loader/FrameLoadRequest.h:69
> > +    FrameLoadRequest(const FrameLoadRequest& other)
> > +        : m_requester { other.m_requester.copyRef() }
> > +        , m_resourceRequest { other.m_resourceRequest }
> > +        , m_frameName { other.m_frameName }
> > +        , m_substituteData { other.m_substituteData }
> > +        , m_shouldCheckNewWindowPolicy { other.m_shouldCheckNewWindowPolicy }
> > +        , m_lockHistory { other.m_lockHistory }
> > +        , m_lockBackForwardList { other.m_lockBackForwardList }
> > +        , m_shouldSendReferrer { other.m_shouldSendReferrer }
> > +        , m_allowNavigationToInvalidURL { other.m_allowNavigationToInvalidURL }
> > +        , m_newFrameOpenerPolicy { other.m_newFrameOpenerPolicy }
> > +        , m_shouldReplaceDocumentIfJavaScriptURL { other.m_shouldReplaceDocumentIfJavaScriptURL }
> > +        , m_shouldOpenExternalURLsPolicy { other.m_shouldOpenExternalURLsPolicy }
> > +        , m_downloadAttribute { other.m_downloadAttribute }
> >      {
> >      }
> 
> Irritating that we have to write this long function because Ref can’t be
> copied; it would be so easy to make the mistake of leaving one of these data
> members out and cause a bug that way. Also annoying that we ever have to
> copy a FrameLoadRequest. Maybe we can change at least some call sites so we
> move instead?

When I was writing this patch I thought about making FrameLoadRequest a move-only type. I thought to do this in a separate bug/patch as this patch was already sufficiently large.
Comment 24 Daniel Bates 2017-06-21 14:19:16 PDT
Committed r218649: <http://trac.webkit.org/changeset/218649>