Bug 38827

Summary: FrameLoader: refactor changeLocation() and urlSelected() to share more code
Product: WebKit Reporter: Chris Jerdonek <cjerdonek>
Component: WebCore Misc.Assignee: Chris Jerdonek <cjerdonek>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, cjerdonek, eric, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Proposed patch
abarth: review-
Proposed patch 2 abarth: review+, abarth: commit-queue-

Description Chris Jerdonek 2010-05-09 18:00:34 PDT
The following call appears twice:

m_frame->script()->executeIfJavaScriptURL()

Also, when changeLocation() is called, the function unnecessarily gets called twice.
Comment 1 Chris Jerdonek 2010-05-13 01:01:35 PDT
Created attachment 55954 [details]
Proposed patch
Comment 2 Adam Barth 2010-05-16 06:53:06 PDT
Comment on attachment 55954 [details]
Proposed patch

For parameters like shouldReplaceDocumentIfJavascriptURL, we like to use enums with two values so you can read at the call site what the parameter does (instead of just "true" or "false").  For example, we'd add ReplaceDocumentIfJavaScritptURL or DoNotReplaceDocumentIfJavaScritptURL as the argument.
Comment 3 Chris Jerdonek 2010-05-16 14:09:46 PDT
Created attachment 56193 [details]
Proposed patch 2
Comment 4 Adam Barth 2010-05-16 17:41:55 PDT
Comment on attachment 56193 [details]
Proposed patch 2

LGTM.  Please consider these small tweaks below before landing.

WebCore/loader/FrameLoader.cpp:340
 +      bool lockHistory, bool lockBackForwardList, bool userGesture, ReferrerPolicy referrerPolicy)
We usually don't add line breaks for function declarations, even when they're ridiculously long like this one.

WebCore/loader/FrameLoader.cpp:352
 +      if (m_frame->script()->executeIfJavaScriptURL(request.url(), userGesture, shouldReplaceDocumentIfJavaScriptURL == ReplaceDocumentIfJavaScriptURL))
You might consider propagating the enum down into executeIfJavaScriptURL so we don't have to convert here and other callers (if there are any) will look prettier.
Comment 5 Chris Jerdonek 2010-05-17 00:35:56 PDT
Committed r59596: <http://trac.webkit.org/changeset/59596>
Comment 6 Chris Jerdonek 2010-05-17 01:17:24 PDT
(In reply to comment #4)
> (From update of attachment 56193 [details])
> LGTM.  Please consider these small tweaks below before landing.
> 
> WebCore/loader/FrameLoader.cpp:340
>  +      bool lockHistory, bool lockBackForwardList, bool userGesture, ReferrerPolicy referrerPolicy)
> We usually don't add line breaks for function declarations, even when they're ridiculously long like this one.
> 
> WebCore/loader/FrameLoader.cpp:352
>  +      if (m_frame->script()->executeIfJavaScriptURL(request.url(), userGesture, shouldReplaceDocumentIfJavaScriptURL == ReplaceDocumentIfJavaScriptURL))
> You might consider propagating the enum down into executeIfJavaScriptURL so we don't have to convert here and other callers (if there are any) will look prettier.

FYI, I incorporated both of these suggestions in the final commit.  Thanks for your review and helpful comments.
Comment 7 WebKit Review Bot 2010-05-17 03:26:49 PDT
http://trac.webkit.org/changeset/59596 might have broken GTK Linux 32-bit Debug
Comment 8 Chris Jerdonek 2010-05-17 05:52:29 PDT
(In reply to comment #7)
> http://trac.webkit.org/changeset/59596 might have broken GTK Linux 32-bit Debug

The three test cases that failed here also failed in a previous revision (r59591), so it doesn't look like the revision for this report caused the breakage.