Skip to content
Permalink
Browse files
Add WKWindowFeaturesRef and a new modern createNewPage UI client call…
…back

https://bugs.webkit.org/show_bug.cgi?id=147989

Reviewed by Tim Horton.

* Platform/IPC/mac/ConnectionMac.mm:
* Shared/API/APIObject.h:
* Shared/API/c/WKBase.h:
* UIProcess/API/APIWindowFeatures.cpp: Added.
* UIProcess/API/APIWindowFeatures.h: Added.
* UIProcess/API/C/WKAPICast.h:
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
* UIProcess/API/C/WKPageUIClient.h:
* UIProcess/API/C/WKWindowFeaturesRef.cpp: Added.
(WKWindowFeaturesGetTypeID):
* UIProcess/API/C/WKWindowFeaturesRef.h: Added.
* UIProcess/API/Cocoa/WKWindowFeatures.mm:
(-[WKWindowFeatures dealloc]):
(-[WKWindowFeatures menuBarVisibility]):
(-[WKWindowFeatures statusBarVisibility]):
(-[WKWindowFeatures toolbarsVisibility]):
(-[WKWindowFeatures allowsResizing]):
(-[WKWindowFeatures x]):
(-[WKWindowFeatures y]):
(-[WKWindowFeatures width]):
(-[WKWindowFeatures height]):
(-[WKWindowFeatures _apiObject]):
(-[WKWindowFeatures _initWithWindowFeatures:]): Deleted.
* UIProcess/API/Cocoa/WKWindowFeaturesInternal.h:
(WebKit::wrapper):
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::createNewPage):
* WebKit2.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/166098@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188404 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Aug 13, 2015
1 parent 134aafc commit 0199a33a84c8e198f6ebb5eeb4b2614895fcd138
Showing 14 changed files with 409 additions and 83 deletions.
@@ -1,3 +1,40 @@
2015-08-13 Anders Carlsson <andersca@apple.com>

Add WKWindowFeaturesRef and a new modern createNewPage UI client callback
https://bugs.webkit.org/show_bug.cgi?id=147989

Reviewed by Tim Horton.

* Platform/IPC/mac/ConnectionMac.mm:
* Shared/API/APIObject.h:
* Shared/API/c/WKBase.h:
* UIProcess/API/APIWindowFeatures.cpp: Added.
* UIProcess/API/APIWindowFeatures.h: Added.
* UIProcess/API/C/WKAPICast.h:
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
* UIProcess/API/C/WKPageUIClient.h:
* UIProcess/API/C/WKWindowFeaturesRef.cpp: Added.
(WKWindowFeaturesGetTypeID):
* UIProcess/API/C/WKWindowFeaturesRef.h: Added.
* UIProcess/API/Cocoa/WKWindowFeatures.mm:
(-[WKWindowFeatures dealloc]):
(-[WKWindowFeatures menuBarVisibility]):
(-[WKWindowFeatures statusBarVisibility]):
(-[WKWindowFeatures toolbarsVisibility]):
(-[WKWindowFeatures allowsResizing]):
(-[WKWindowFeatures x]):
(-[WKWindowFeatures y]):
(-[WKWindowFeatures width]):
(-[WKWindowFeatures height]):
(-[WKWindowFeatures _apiObject]):
(-[WKWindowFeatures _initWithWindowFeatures:]): Deleted.
* UIProcess/API/Cocoa/WKWindowFeaturesInternal.h:
(WebKit::wrapper):
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::createNewPage):
* WebKit2.xcodeproj/project.pbxproj:

2015-08-13 Simon Fraser <simon.fraser@apple.com>

FilterOperation.h should not include FilterEffect.h
@@ -148,6 +148,7 @@ class Object
VisitedLinkProvider,
WebsiteDataRecord,
WebsiteDataStore,
WindowFeatures,

#if ENABLE(MEDIA_SESSION)
MediaSessionFocusManager,
@@ -142,6 +142,7 @@ typedef const struct OpaqueWKUserScript* WKUserScriptRef;
typedef const struct OpaqueWKVibration* WKVibrationRef;
typedef const struct OpaqueWKViewportAttributes* WKViewportAttributesRef;
typedef const struct OpaqueWKWebsiteDataStore* WKWebsiteDataStoreRef;
typedef const struct OpaqueWKWindowFeatures* WKWindowFeaturesRef;

/* WebKit2 Bundle types */

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "APIWindowFeatures.h"

namespace API {

Ref<WindowFeatures> WindowFeatures::create(const WebCore::WindowFeatures& windowFeatures)
{
return adoptRef(*new WindowFeatures(windowFeatures));
}

WindowFeatures::WindowFeatures(const WebCore::WindowFeatures& windowFeatures)
: m_windowFeatures(windowFeatures)
{
}

WindowFeatures::~WindowFeatures()
{
}

}
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef APIWindowFeatures_h
#define APIWindowFeatures_h

#include "APIObject.h"
#include <WebCore/WindowFeatures.h>

namespace API {

class WindowFeatures final : public ObjectImpl<Object::Type::WindowFeatures> {
public:
static Ref<WindowFeatures> create(const WebCore::WindowFeatures&);
virtual ~WindowFeatures();

const WebCore::WindowFeatures& windowFeatures() const { return m_windowFeatures; }

private:
explicit WindowFeatures(const WebCore::WindowFeatures&);

const WebCore::WindowFeatures m_windowFeatures;
};

}

#endif // APIWindowFeatures_h
@@ -64,6 +64,7 @@ class UserContentExtension;
class UserContentExtensionStore;
class UserScript;
class WebsiteDataStore;
class WindowFeatures;
}

namespace WebKit {
@@ -166,6 +167,7 @@ WK_ADD_API_MAPPING(WKUserScriptRef, API::UserScript)
WK_ADD_API_MAPPING(WKVibrationRef, WebVibrationProxy)
WK_ADD_API_MAPPING(WKViewportAttributesRef, WebViewportAttributes)
WK_ADD_API_MAPPING(WKWebsiteDataStoreRef, API::WebsiteDataStore)
WK_ADD_API_MAPPING(WKWindowFeaturesRef, API::WindowFeatures)

/* Enum conversions */

@@ -41,6 +41,7 @@
#include "APIPolicyClient.h"
#include "APISessionState.h"
#include "APIUIClient.h"
#include "APIWindowFeatures.h"
#include "AuthenticationChallengeProxy.h"
#include "LegacySessionStateCoding.h"
#include "Logging.h"
@@ -102,7 +103,7 @@ template<> struct ClientTraits<WKPagePolicyClientBase> {
};

template<> struct ClientTraits<WKPageUIClientBase> {
typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5> Versions;
typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6> Versions;
};

#if ENABLE(CONTEXT_MENUS)
@@ -1341,38 +1342,55 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient
}

private:
virtual PassRefPtr<WebPageProxy> createNewPage(WebPageProxy* page, WebFrameProxy*, const SecurityOriginData&, const ResourceRequest& resourceRequest, const WindowFeatures& windowFeatures, const NavigationActionData& navigationActionData) override
{
if (!m_client.base.version && !m_client.createNewPage_deprecatedForUseWithV0)
return 0;
virtual PassRefPtr<WebPageProxy> createNewPage(WebPageProxy* page, WebFrameProxy* initiatingFrame, const SecurityOriginData& securityOriginData, const ResourceRequest& resourceRequest, const WindowFeatures& windowFeatures, const NavigationActionData& navigationActionData) override
{
if (m_client.base.version < 6) {
if (!m_client.base.version && !m_client.createNewPage_deprecatedForUseWithV0)
return nullptr;

if (!m_client.createNewPage_deprecatedForUseWithV1)
return nullptr;

API::Dictionary::MapType map;
if (windowFeatures.x)
map.set("x", API::Double::create(*windowFeatures.x));
if (windowFeatures.y)
map.set("y", API::Double::create(*windowFeatures.y));
if (windowFeatures.width)
map.set("width", API::Double::create(*windowFeatures.width));
if (windowFeatures.height)
map.set("height", API::Double::create(*windowFeatures.height));
map.set("menuBarVisible", API::Boolean::create(windowFeatures.menuBarVisible));
map.set("statusBarVisible", API::Boolean::create(windowFeatures.statusBarVisible));
map.set("toolBarVisible", API::Boolean::create(windowFeatures.toolBarVisible));
map.set("locationBarVisible", API::Boolean::create(windowFeatures.locationBarVisible));
map.set("scrollbarsVisible", API::Boolean::create(windowFeatures.scrollbarsVisible));
map.set("resizable", API::Boolean::create(windowFeatures.resizable));
map.set("fullscreen", API::Boolean::create(windowFeatures.fullscreen));
map.set("dialog", API::Boolean::create(windowFeatures.dialog));
Ref<API::Dictionary> featuresMap = API::Dictionary::create(WTF::move(map));

if (!m_client.base.version)
return adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV0(toAPI(page), toAPI(featuresMap.ptr()), toAPI(navigationActionData.modifiers), toAPI(navigationActionData.mouseButton), m_client.base.clientInfo)));

Ref<API::URLRequest> request = API::URLRequest::create(resourceRequest);
return adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV1(toAPI(page), toAPI(request.ptr()), toAPI(featuresMap.ptr()), toAPI(navigationActionData.modifiers), toAPI(navigationActionData.mouseButton), m_client.base.clientInfo)));
}

if (m_client.base.version > 0 && !m_client.createNewPage)
return 0;
if (!m_client.createNewPage)
return nullptr;

API::Dictionary::MapType map;
if (windowFeatures.x)
map.set("x", API::Double::create(*windowFeatures.x));
if (windowFeatures.y)
map.set("y", API::Double::create(*windowFeatures.y));
if (windowFeatures.width)
map.set("width", API::Double::create(*windowFeatures.width));
if (windowFeatures.height)
map.set("height", API::Double::create(*windowFeatures.height));
map.set("menuBarVisible", API::Boolean::create(windowFeatures.menuBarVisible));
map.set("statusBarVisible", API::Boolean::create(windowFeatures.statusBarVisible));
map.set("toolBarVisible", API::Boolean::create(windowFeatures.toolBarVisible));
map.set("locationBarVisible", API::Boolean::create(windowFeatures.locationBarVisible));
map.set("scrollbarsVisible", API::Boolean::create(windowFeatures.scrollbarsVisible));
map.set("resizable", API::Boolean::create(windowFeatures.resizable));
map.set("fullscreen", API::Boolean::create(windowFeatures.fullscreen));
map.set("dialog", API::Boolean::create(windowFeatures.dialog));
Ref<API::Dictionary> featuresMap = API::Dictionary::create(WTF::move(map));

if (!m_client.base.version)
return adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV0(toAPI(page), toAPI(featuresMap.ptr()), toAPI(navigationActionData.modifiers), toAPI(navigationActionData.mouseButton), m_client.base.clientInfo)));
auto configuration = page->configuration().copy();
configuration->setRelatedPage(page);

Ref<API::URLRequest> request = API::URLRequest::create(resourceRequest);
return adoptRef(toImpl(m_client.createNewPage(toAPI(page), toAPI(request.ptr()), toAPI(featuresMap.ptr()), toAPI(navigationActionData.modifiers), toAPI(navigationActionData.mouseButton), m_client.base.clientInfo)));
auto sourceFrameInfo = API::FrameInfo::create(*initiatingFrame, securityOriginData.securityOrigin());

bool shouldOpenAppLinks = !protocolHostAndPortAreEqual(WebCore::URL(WebCore::ParsedURLString, initiatingFrame->url()), resourceRequest.url());
auto apiNavigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.ptr(), nullptr, resourceRequest, WebCore::URL(), shouldOpenAppLinks);

auto apiWindowFeatures = API::WindowFeatures::create(windowFeatures);

return adoptRef(toImpl(m_client.createNewPage(toAPI(page), toAPI(configuration.ptr()), toAPI(apiNavigationAction.ptr()), toAPI(apiWindowFeatures.ptr()), m_client.base.clientInfo)));
}

virtual void showPage(WebPageProxy* page) override

0 comments on commit 0199a33

Please sign in to comment.