window.open should prepare for seamless navigation by using findFrameForNavigation
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2012 00:42:37 +0000 (00:42 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2012 00:42:37 +0000 (00:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83835

Reviewed by Ryosuke Niwa.

Before this patch, window.open called FrameTree::find and
Document::canNavigate separately.  This patch refactors the code to
call FrameLoader::findFrameForNavigation, which does both.  This
refactoring prepares window.open to understand seamless navigation,
which will happen in findFrameForNavigation.

This patch should have no behavior change today, but once we merge the
seamless branch, this change will be tested by
https://github.com/eseidel/webkit/blob/seamless/LayoutTests/fast/frames/seamless/seamless-window-open.html

See https://github.com/eseidel/webkit/commit/a0d8b7defbb63047912aefbc8e22bca4f0638c37 for context.

* WebCore.exp.in:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::findFrameForNavigation):
(WebCore::createWindow):
* loader/FrameLoader.h:
(FrameLoader):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114057 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h

index 18926ca..d84c2d3 100644 (file)
@@ -1,3 +1,29 @@
+2012-04-12  Adam Barth  <abarth@webkit.org>
+
+        window.open should prepare for seamless navigation by using findFrameForNavigation
+        https://bugs.webkit.org/show_bug.cgi?id=83835
+
+        Reviewed by Ryosuke Niwa.
+
+        Before this patch, window.open called FrameTree::find and
+        Document::canNavigate separately.  This patch refactors the code to
+        call FrameLoader::findFrameForNavigation, which does both.  This
+        refactoring prepares window.open to understand seamless navigation,
+        which will happen in findFrameForNavigation.
+
+        This patch should have no behavior change today, but once we merge the
+        seamless branch, this change will be tested by
+        https://github.com/eseidel/webkit/blob/seamless/LayoutTests/fast/frames/seamless/seamless-window-open.html
+
+        See https://github.com/eseidel/webkit/commit/a0d8b7defbb63047912aefbc8e22bca4f0638c37 for context.
+
+        * WebCore.exp.in:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::findFrameForNavigation):
+        (WebCore::createWindow):
+        * loader/FrameLoader.h:
+        (FrameLoader):
+
 2012-04-12  Andy Estes  <aestes@apple.com>
 
         REGRESSION (r102262): iAd Producer relies on CSSStyleDeclaration property setters respecting '!important'
index b8d8d8e..54051f8 100644 (file)
@@ -177,7 +177,7 @@ __ZN7WebCore11FrameLoader16detachFromParentEv
 __ZN7WebCore11FrameLoader16loadFrameRequestERKNS_16FrameLoadRequestEbbN3WTF10PassRefPtrINS_5EventEEENS5_INS_9FormStateEEENS_18ShouldSendReferrerE
 __ZN7WebCore11FrameLoader17stopForUserCancelEb
 __ZN7WebCore11FrameLoader21loadURLIntoChildFrameERKNS_4KURLERKN3WTF6StringEPNS_5FrameE
-__ZN7WebCore11FrameLoader22findFrameForNavigationERKN3WTF12AtomicStringE
+__ZN7WebCore11FrameLoader22findFrameForNavigationERKN3WTF12AtomicStringEPNS_8DocumentE
 __ZN7WebCore11FrameLoader23timeOfLastCompletedLoadEv    
 __ZN7WebCore11FrameLoader26reloadWithOverrideEncodingERKN3WTF6StringE
 __ZN7WebCore11FrameLoader32setOriginalURLForDownloadRequestERNS_15ResourceRequestE
index 516cc73..fb80ef3 100644 (file)
@@ -2935,14 +2935,20 @@ void FrameLoader::checkDidPerformFirstNavigation()
     }
 }
 
-Frame* FrameLoader::findFrameForNavigation(const AtomicString& name)
+Frame* FrameLoader::findFrameForNavigation(const AtomicString& name, Document* activeDocument)
 {
     Frame* frame = m_frame->tree()->find(name);
-    // FIXME: We calling canNavigate on the Document that's requesting the
-    // navigation, not based on the document that happens to be displayed in
-    // this Frame.
-    if (!m_frame->document()->canNavigate(frame))
-        return 0;
+
+    if (activeDocument) {
+        if (!activeDocument->canNavigate(frame))
+            return 0;
+    } else {
+        // FIXME: Eventually all callers should supply the actual activeDocument
+        // so we can call canNavigate with the right document.
+        if (!m_frame->document()->canNavigate(frame))
+            return 0;
+    }
+
     return frame;
 }
 
@@ -3194,8 +3200,7 @@ Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLoadReque
     ASSERT(!features.dialog || request.frameName().isEmpty());
 
     if (!request.frameName().isEmpty() && request.frameName() != "_blank") {
-        Frame* frame = lookupFrame->tree()->find(request.frameName());
-        if (frame && openerFrame->document()->canNavigate(frame)) {
+        if (Frame* frame = lookupFrame->loader()->findFrameForNavigation(request.frameName(), openerFrame->document())) {
             if (Page* page = frame->page())
                 page->chrome()->focus();
             created = false;
index ed378ae..291a6ad 100644 (file)
@@ -245,7 +245,7 @@ public:
 
     FrameLoaderStateMachine* stateMachine() const { return &m_stateMachine; }
 
-    Frame* findFrameForNavigation(const AtomicString& name);
+    Frame* findFrameForNavigation(const AtomicString& name, Document* activeDocument = 0);
 
     void applyUserAgent(ResourceRequest&);