RESOLVED FIXED Bug 39156
FrameLoader: refactor FrameLoader::createWindow() to be a non-member, non-friend function
https://bugs.webkit.org/show_bug.cgi?id=39156
Summary FrameLoader: refactor FrameLoader::createWindow() to be a non-member, non-fri...
Chris Jerdonek
Reported 2010-05-15 04:31:10 PDT
The FrameLoader class shouldn't be responsible for creating windows. Moving createWindow() out of the FrameLoader class is a good first step. This will also increase encapsulation by reducing the number of public functions with access to FrameLoader's private data.
Attachments
Proposed patch (9.57 KB, patch)
2010-05-16 03:26 PDT, Chris Jerdonek
no flags
Proposed patch (re-attaching newest) (10.56 KB, patch)
2010-05-16 03:31 PDT, Chris Jerdonek
darin: review-
Proposed patch 2 (10.71 KB, patch)
2010-05-18 17:08 PDT, Chris Jerdonek
no flags
Proposed patch 3 (10.71 KB, patch)
2010-05-18 22:50 PDT, Chris Jerdonek
no flags
Chris Jerdonek
Comment 1 2010-05-16 03:26:52 PDT
Created attachment 56183 [details] Proposed patch Note that this will probably not build/apply until the patch for bug 39157 lands.
Chris Jerdonek
Comment 2 2010-05-16 03:31:08 PDT
Created attachment 56184 [details] Proposed patch (re-attaching newest) As before, this will not apply.
Adam Barth
Comment 3 2010-05-16 18:13:31 PDT
Comment on attachment 56184 [details] Proposed patch (re-attaching newest) WebCore/loader/FrameLoader.cpp:3966 + Frame* createWindowFromFrameLoader(FrameLoader* sourceFrameLoader, FrameLoader* frameLoaderForFrameLookup, const FrameLoadRequest& request, const WindowFeatures& features, bool& created) I think sourceFrameLoader should be openerFrameLoader because that's the Frame that ends up being the opener. It might make more sense to pass in the Frame as "opener" and then get the outgoing referrer, etc, from opener->loader()->... The reason for do that is the Frame is the root object of a who constellation of objects, one of which is the FrameLoader. We usually use the Frame as object to keep track of the context, not the FrameLoader. createWindowFromFrameLoader also isn't a great name. Maybe createWindow? I'm not sure this should be a free function. It feels like it should be a member of something...
Darin Adler
Comment 4 2010-05-16 21:10:11 PDT
Comment on attachment 56184 [details] Proposed patch (re-attaching newest) I don't think the name createWindowFromFrameLoader is good. These names that mention the arguments don't usually work well in C++. Further, we almost always pass Frame* rather than FrameLoader* to functions, as a part of the general pattern of the Frame family of classes, so I suggest that first two arguments both be Frame*, not FrameLoader*. The name createWindow seems OK to me, except for the fact that the non-web-browser meaning of window in computer operating systems competes a little bit with the misguided use of window to mean the per-frame global controller object, "window". I also wonder if FrameLoader.h/cpp is the right place for this. I think I'd say review+ if this was named createWindow and took two Frame*. It's OK that the function in JSDOMWindowCustom is also called createWindow because the arguments are different. review- mainly because of the use of FrameLoader* as the argument type.
Darin Adler
Comment 5 2010-05-16 21:11:24 PDT
Looks like Adam and I made quite similar comments. I think it would make sense for this to be the member of something, maybe a static member, that should be responsible for creating windows. But I think it's OK as a free function too.
Chris Jerdonek
Comment 6 2010-05-16 23:40:07 PDT
(In reply to comment #3) > (From update of attachment 56184 [details]) > WebCore/loader/FrameLoader.cpp:3966 > + Frame* createWindowFromFrameLoader(FrameLoader* sourceFrameLoader, FrameLoader* > ... > I'm not sure this should be a free function. It feels like it should be a member of something... (In reply to comment #4) > I also wonder if FrameLoader.h/cpp is the right place for this. (In reply to comment #5) > Looks like Adam and I made quite similar comments. I think it would make sense for this to be the member of something, maybe a static member, that should be responsible for creating windows. But I think it's OK as a free function too. Thanks, guys, for the helpful comments. With respect to making FrameLoader::createWindow() a free function, the intent was not for it to stay that way. The intent was to be incremental and first separate the function from the class. As we continue refactoring and grow to see the right abstractions, we can later move this to an appropriate class/location. In the meantime, hopefully separating it out will make it slightly easier to think about FrameLoader.
Chris Jerdonek
Comment 7 2010-05-18 17:08:39 PDT
Created attachment 56426 [details] Proposed patch 2 Addressing your comments. (In reply to comment #3) > I'm not sure this should be a free function. It feels like it should be a member of something... (In reply to comment #4) > I also wonder if FrameLoader.h/cpp is the right place for this. (In reply to comment #5) > I think it would make sense for this to be the member of something, maybe a static member, that should be responsible for creating windows. But I think it's OK as a free function too. I also added a FIXME to move this to a more appropriate location/class per my comment 6.
WebKit Review Bot
Comment 8 2010-05-18 17:40:35 PDT
Chris Jerdonek
Comment 9 2010-05-18 22:50:29 PDT
Created attachment 56455 [details] Proposed patch 3 Qualified the call to createWindow() in BindingDOMWindow.h. The compiler was interpreting the call to createWindow() in BindingDOMWindow.h as a dependent name because it has the same name as BindingDOMWindow<Binding>::createWindow() -- even though the signature is different.
Chris Jerdonek
Comment 10 2010-05-24 13:59:29 PDT
Darin or Adam, can one of you review the newest patch that addresses both or your comments? Adam, if createWindow() being a free function is a blocking issue for you, can you confirm that you thought the Page class is an appropriate location? I've added a FIXME to move it, so we can always do that later.
Adam Barth
Comment 11 2010-06-18 15:50:09 PDT
Comment on attachment 56455 [details] Proposed patch 3 WebCore/bindings/generic/BindingDOMWindow.h:93 + Frame* newFrame = WebCore::createWindow(callingFrame, openerFrame, frameRequest, windowFeatures, created); Do we need the WebCore:: prefix here?
Adam Barth
Comment 12 2010-08-11 10:13:51 PDT
Comment on attachment 56455 [details] Proposed patch 3 Turns out we do because otherwise we'll call the member function.
WebKit Commit Bot
Comment 13 2010-08-11 10:40:49 PDT
Comment on attachment 56455 [details] Proposed patch 3 Clearing flags on attachment: 56455 Committed r65164: <http://trac.webkit.org/changeset/65164>
WebKit Commit Bot
Comment 14 2010-08-11 10:40:54 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.