2011-03-21 Sam Weinig <sam@webkit.org>
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Mar 2011 18:33:58 +0000 (18:33 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Mar 2011 18:33:58 +0000 (18:33 +0000)
        Reviewed by Anders Carlsson.

        Need WebKit2 API for creating a page with a specific main frame name
        https://bugs.webkit.org/show_bug.cgi?id=56759

        * Shared/WebPageCreationParameters.cpp:
        (WebKit::WebPageCreationParameters::encode):
        (WebKit::WebPageCreationParameters::decode):
        * Shared/WebPageCreationParameters.h:
        Add mainFrameName to creation parameters.

        * UIProcess/API/mac/WKView.h:
        * UIProcess/API/mac/WKView.mm:
        (-[WKView initWithFrame:]):
        (-[WKView initWithFrame:contextRef:]):
        (-[WKView initWithFrame:contextRef:pageGroupRef:]):
        (-[WKView initWithFrame:contextRef:pageGroupRef:mainFrameName:]):
        Add new initializer which takes a main frame name.

        * UIProcess/WebPageProxy.cpp:
        (WebKit::WebPageProxy::setMainFrameName):
        (WebKit::WebPageProxy::creationParameters):
        * UIProcess/WebPageProxy.h:
        Store the main frame name for initialization/re-initialization.

        * WebProcess/WebPage/WebFrame.cpp:
        (WebKit::WebFrame::createMainFrame):
        * WebProcess/WebPage/WebFrame.h:
        * WebProcess/WebPage/WebPage.cpp:
        (WebKit::WebPage::WebPage):
        Pass the name to main frame creation.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/API/mac/WKView.h
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index b5e960df8cf0959c19f5959308fc9918317bcfbe..ffaada496ea8cdf319545e8ff489c0c6d972552c 100644 (file)
@@ -1,3 +1,37 @@
+2011-03-21  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Need WebKit2 API for creating a page with a specific main frame name
+        https://bugs.webkit.org/show_bug.cgi?id=56759
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        Add mainFrameName to creation parameters.
+
+        * UIProcess/API/mac/WKView.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView initWithFrame:]):
+        (-[WKView initWithFrame:contextRef:]):
+        (-[WKView initWithFrame:contextRef:pageGroupRef:]):
+        (-[WKView initWithFrame:contextRef:pageGroupRef:mainFrameName:]):
+        Add new initializer which takes a main frame name.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setMainFrameName):
+        (WebKit::WebPageProxy::creationParameters):
+        * UIProcess/WebPageProxy.h:
+        Store the main frame name for initialization/re-initialization.
+
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::createMainFrame):
+        * WebProcess/WebPage/WebFrame.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        Pass the name to main frame creation.
+
 2011-03-20  Bill Budge  <bbudge@chromium.org>
 
         Reviewed by Adam Barth.
index 33b53e31d9e1e6f3ba8bf8e7b6e762f21ac2b05d..eb52f106e63944c493a2eafbba4103d138578556 100644 (file)
@@ -47,6 +47,7 @@ void WebPageCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(useFixedLayout);
     encoder->encode(fixedLayoutSize);
     encoder->encode(userAgent);
+    encoder->encode(mainFrameName);
     encoder->encode(sessionState);
     encoder->encode(highestUsedBackForwardItemID);
     encoder->encode(canRunBeforeUnloadConfirmPanel);
@@ -91,6 +92,8 @@ bool WebPageCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebPag
         return false;
     if (!decoder->decode(parameters.userAgent))
         return false;
+    if (!decoder->decode(parameters.mainFrameName))
+        return false;
     if (!decoder->decode(parameters.sessionState))
         return false;
     if (!decoder->decode(parameters.highestUsedBackForwardItemID))
index 31759e14f32f271475d8d90eace79e35e9b0341d..fbc1953730191c9c4ee814b0d86c195cc0b057bb 100644 (file)
@@ -64,6 +64,7 @@ struct WebPageCreationParameters {
     WebCore::IntSize fixedLayoutSize;
 
     String userAgent;
+    String mainFrameName;
 
     SessionState sessionState;
     uint64_t highestUsedBackForwardItemID;
index 8c1826c6a8384b9d80ecb4474b6d4d19832a12ef..e230f83809be473915a1b8ce41458b7ee0aee81e 100644 (file)
@@ -36,6 +36,7 @@ WK_EXPORT
 
 - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef;
 - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef;
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef mainFrameName:(NSString *)mainFrameName;
 
 - (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef;
 - (BOOL)canChangeFrameLayout:(WKFrameRef)frameRef;
index 4acf7719516247c0a4e1032d9642a5f38adb0efb..93ad42a785939e6a904938903a2460e2505db31f 100644 (file)
@@ -172,16 +172,6 @@ static bool useNewDrawingArea()
     return true;
 }
 
-- (id)initWithFrame:(NSRect)frame
-{
-    return [self initWithFrame:frame contextRef:toAPI(WebContext::sharedProcessContext())];
-}
-
-- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef
-{   
-    return [self initWithFrame:frame contextRef:contextRef pageGroupRef:nil];
-}
-
 - (void)_registerDraggedTypes
 {
     NSMutableSet *types = [[NSMutableSet alloc] initWithArray:PasteboardTypes::forEditing()];
@@ -208,7 +198,22 @@ static bool useNewDrawingArea()
 #endif
 }
 
+- (id)initWithFrame:(NSRect)frame
+{
+    return [self initWithFrame:frame contextRef:toAPI(WebContext::sharedProcessContext())];
+}
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef
+{   
+    return [self initWithFrame:frame contextRef:contextRef pageGroupRef:nil];
+}
+
 - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef
+{
+    return [self initWithFrame:frame contextRef:contextRef pageGroupRef:pageGroupRef mainFrameName:nil];
+}
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef mainFrameName:(NSString *)mainFrameName
 {
     self = [super initWithFrame:frame];
     if (!self)
@@ -230,7 +235,9 @@ static bool useNewDrawingArea()
 
     _data->_pageClient = PageClientImpl::create(self);
     _data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef));
+    _data->_page->setMainFrameName(mainFrameName);
     _data->_page->initializeWebPage();
+
 #if ENABLE(FULLSCREEN_API)
     _data->_page->fullScreenManager()->setWebView(self);
 #endif
index daa26c15d0c3641a92f7591a8de2f6fd40694fa9..29e8e8a20e3b4e2e1f784b25da437dab1761023d 100644 (file)
@@ -935,6 +935,11 @@ void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
     process()->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
 }
 
+void WebPageProxy::setMainFrameName(const String& mainFrameName)
+{
+    m_mainFrameName = mainFrameName;
+}
+
 void WebPageProxy::terminateProcess()
 {
     if (!isValid())
@@ -2573,6 +2578,7 @@ WebPageCreationParameters WebPageProxy::creationParameters() const
     parameters.useFixedLayout = m_useFixedLayout;
     parameters.fixedLayoutSize = m_fixedLayoutSize;
     parameters.userAgent = userAgent();
+    parameters.mainFrameName = m_mainFrameName;
     parameters.sessionState = SessionState(m_backForwardList->entries(), m_backForwardList->currentIndex());
     parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID();
     parameters.canRunBeforeUnloadConfirmPanel = m_uiClient.canRunBeforeUnloadConfirmPanel();
index 85400f5a4bbcc6334398b1a17973956339655496..5e82c2d9e072cb187c29607405b4e5dd0b4c92d9 100644 (file)
@@ -291,6 +291,8 @@ public:
     void setCustomTextEncodingName(const String&);
     String customTextEncodingName() const { return m_customTextEncodingName; }
 
+    void setMainFrameName(const String&);
+
     double estimatedProgress() const;
 
     void terminateProcess();
@@ -661,6 +663,7 @@ private:
     String m_applicationNameForUserAgent;
     String m_customUserAgent;
     String m_customTextEncodingName;
+    String m_mainFrameName;
 
 #if ENABLE(INSPECTOR)
     RefPtr<WebInspectorProxy> m_inspector;
index 574634f0c9663269c1a9529d3c0e70990c56ca4d..dad54b440b46703e8a11cff614231cd84a1340e4 100644 (file)
@@ -80,13 +80,13 @@ static uint64_t generateListenerID()
     return uniqueListenerID++;
 }
 
-PassRefPtr<WebFrame> WebFrame::createMainFrame(WebPage* page)
+PassRefPtr<WebFrame> WebFrame::createMainFrame(WebPage* page, const String& frameName)
 {
     RefPtr<WebFrame> frame = create();
 
     page->send(Messages::WebPageProxy::DidCreateMainFrame(frame->frameID()));
 
-    frame->init(page, String(), 0);
+    frame->init(page, frameName, 0);
 
     return frame.release();
 }
index 3c63cf3ad8dc2203de44550963a7db1bf1a72d2d..6699318ad5b8c594958c8e235b0210535fd840bc 100644 (file)
@@ -54,7 +54,7 @@ class WebFrame : public APIObject {
 public:
     static const Type APIType = TypeBundleFrame;
 
-    static PassRefPtr<WebFrame> createMainFrame(WebPage*);
+    static PassRefPtr<WebFrame> createMainFrame(WebPage*, const String& frameName);
     static PassRefPtr<WebFrame> createSubframe(WebPage*, const String& frameName, WebCore::HTMLFrameOwnerElement*);
     ~WebFrame();
 
index 036f6d1b9314e66da6ac3d0227c0c7e5a3dd4836..5f6a59edcd49237c2e013177a0bfa949fe452e57 100644 (file)
@@ -196,7 +196,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     Settings::setDefaultMinDOMTimerInterval(0.004);
 
     m_drawingArea = DrawingArea::create(this, parameters);
-    m_mainFrame = WebFrame::createMainFrame(this);
+    m_mainFrame = WebFrame::createMainFrame(this, parameters.mainFrameName);
 
     setDrawsBackground(parameters.drawsBackground);
     setDrawsTransparentBackground(parameters.drawsTransparentBackground);