Title: [202345] trunk/Source/WebCore
Revision
202345
Author
[email protected]
Date
2016-06-22 13:00:03 -0700 (Wed, 22 Jun 2016)

Log Message

Inline the last of the Apple Pay WebCore code
https://bugs.webkit.org/show_bug.cgi?id=159032

Reviewed by Tim Horton.

* loader/EmptyClients.cpp:
(WebCore::fillWithEmptyClients):
* page/MainFrame.cpp:
(WebCore::MainFrame::MainFrame):
* page/MainFrame.h:
* page/PageConfiguration.h:
* platform/cocoa/ThemeCocoa.mm:
(WebCore::passKitBundle):
(WebCore::loadPassKitPDFPage):
(WebCore::applePayButtonLogoBlack):
(WebCore::applePayButtonLogoWhite):
(WebCore::drawApplePayButton):
(WebCore::ThemeCocoa::drawNamedImage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (202344 => 202345)


--- trunk/Source/WebCore/CMakeLists.txt	2016-06-22 19:36:35 UTC (rev 202344)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-06-22 20:00:03 UTC (rev 202345)
@@ -5,6 +5,7 @@
 set(WebCore_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}"
     "${WEBCORE_DIR}/Modules/airplay"
+    "${WEBCORE_DIR}/Modules/applepay"
     "${WEBCORE_DIR}/Modules/battery"
     "${WEBCORE_DIR}/Modules/encryptedmedia"
     "${WEBCORE_DIR}/Modules/fetch"

Modified: trunk/Source/WebCore/ChangeLog (202344 => 202345)


--- trunk/Source/WebCore/ChangeLog	2016-06-22 19:36:35 UTC (rev 202344)
+++ trunk/Source/WebCore/ChangeLog	2016-06-22 20:00:03 UTC (rev 202345)
@@ -1,5 +1,26 @@
 2016-06-22  Anders Carlsson  <[email protected]>
 
+        Inline the last of the Apple Pay WebCore code
+        https://bugs.webkit.org/show_bug.cgi?id=159032
+
+        Reviewed by Tim Horton.
+
+        * loader/EmptyClients.cpp:
+        (WebCore::fillWithEmptyClients):
+        * page/MainFrame.cpp:
+        (WebCore::MainFrame::MainFrame):
+        * page/MainFrame.h:
+        * page/PageConfiguration.h:
+        * platform/cocoa/ThemeCocoa.mm:
+        (WebCore::passKitBundle):
+        (WebCore::loadPassKitPDFPage):
+        (WebCore::applePayButtonLogoBlack):
+        (WebCore::applePayButtonLogoWhite):
+        (WebCore::drawApplePayButton):
+        (WebCore::ThemeCocoa::drawNamedImage):
+
+2016-06-22  Anders Carlsson  <[email protected]>
+
         Exception is not thrown when shipping method is an invalid amount
         https://bugs.webkit.org/show_bug.cgi?id=159030
         rdar://problem/26700413

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (202344 => 202345)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2016-06-22 19:36:35 UTC (rev 202344)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2016-06-22 20:00:03 UTC (rev 202345)
@@ -41,6 +41,7 @@
 #include "InProcessIDBServer.h"
 #include "Page.h"
 #include "PageConfiguration.h"
+#include "PaymentCoordinatorClient.h"
 #include "StorageArea.h"
 #include "StorageNamespace.h"
 #include "StorageNamespaceProvider.h"
@@ -47,12 +48,25 @@
 #include "UserContentProvider.h"
 #include <wtf/NeverDestroyed.h>
 
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/EmptyClientsIncludes.h>
+namespace WebCore {
+
+#if ENABLE(APPLE_PAY)
+class EmptyPaymentCoordinatorClient final : public PaymentCoordinatorClient {
+    bool supportsVersion(unsigned) override { return false; }
+    bool canMakePayments() override { return false; }
+    void canMakePaymentsWithActiveCard(const String&, const String&, std::function<void (bool)> completionHandler) override { callOnMainThread([completionHandler] { completionHandler(false); }); }
+    void showPaymentUI(const URL&, const Vector<URL>&, const PaymentRequest&) override { }
+    void completeMerchantValidation(const PaymentMerchantSession&) override { }
+
+    void completeShippingMethodSelection(PaymentAuthorizationStatus, Optional<PaymentRequest::TotalAndLineItems>) override { }
+    void completeShippingContactSelection(PaymentAuthorizationStatus, const Vector<PaymentRequest::ShippingMethod>&, Optional<PaymentRequest::TotalAndLineItems>) override { }
+    void completePaymentMethodSelection(Optional<WebCore::PaymentRequest::TotalAndLineItems>) override { }
+    void completePaymentSession(PaymentAuthorizationStatus) override { }
+    void abortPaymentSession() override { }
+    void mainFrameDestroyed() override { }
+};
 #endif
 
-namespace WebCore {
-
 class EmptyDatabaseProvider final : public DatabaseProvider {
 #if ENABLE(INDEXED_DATABASE)
     virtual IDBClient::IDBConnectionToServer& idbConnectionToServerForSession(const SessionID&)
@@ -120,6 +134,11 @@
     static NeverDestroyed<EmptyChromeClient> dummyChromeClient;
     pageConfiguration.chromeClient = &dummyChromeClient.get();
 
+#if ENABLE(APPLE_PAY)
+    static NeverDestroyed<EmptyPaymentCoordinatorClient> dummyPaymentCoordinatorClient;
+    pageConfiguration.paymentCoordinatorClient = &dummyPaymentCoordinatorClient.get();
+#endif
+
 #if ENABLE(CONTEXT_MENUS)
     static NeverDestroyed<EmptyContextMenuClient> dummyContextMenuClient;
     pageConfiguration.contextMenuClient = &dummyContextMenuClient.get();
@@ -146,10 +165,6 @@
     pageConfiguration.storageNamespaceProvider = adoptRef(new EmptyStorageNamespaceProvider);
     pageConfiguration.userContentProvider = adoptRef(new EmptyUserContentProvider);
     pageConfiguration.visitedLinkStore = adoptRef(new EmptyVisitedLinkStore);
-
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/EmptyClientsFill.cpp>
-#endif
 }
 
 class EmptyPopupMenu : public PopupMenu {

Modified: trunk/Source/WebCore/page/MainFrame.cpp (202344 => 202345)


--- trunk/Source/WebCore/page/MainFrame.cpp	2016-06-22 19:36:35 UTC (rev 202344)
+++ trunk/Source/WebCore/page/MainFrame.cpp	2016-06-22 20:00:03 UTC (rev 202345)
@@ -30,6 +30,7 @@
 #include "EmptyClients.h"
 #include "PageConfiguration.h"
 #include "PageOverlayController.h"
+#include "PaymentCoordinator.h"
 #include "ScrollLatchingState.h"
 #include "Settings.h"
 #include "WheelEventDeltaFilter.h"
@@ -37,10 +38,6 @@
 
 #if PLATFORM(MAC)
 #include "ServicesOverlayController.h"
-#endif /* PLATFORM(MAC) */
-
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/MainFrameIncludes.h>
 #endif
 
 namespace WebCore {
@@ -48,17 +45,15 @@
 inline MainFrame::MainFrame(Page& page, PageConfiguration& configuration)
     : Frame(page, nullptr, *configuration.loaderClientForMainFrame)
     , m_selfOnlyRefCount(0)
-#if PLATFORM(MAC)
-#if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
+#if PLATFORM(MAC) && (ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION))
     , m_servicesOverlayController(std::make_unique<ServicesOverlayController>(*this))
 #endif
-#endif
     , m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create())
     , m_pageOverlayController(std::make_unique<PageOverlayController>(*this))
+#if ENABLE(APPLE_PAY)
+    , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*configuration.paymentCoordinatorClient))
+#endif
 {
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/MainFrameInitialization.cpp>
-#endif
 }
 
 MainFrame::~MainFrame()

Modified: trunk/Source/WebCore/page/MainFrame.h (202344 => 202345)


--- trunk/Source/WebCore/page/MainFrame.h	2016-06-22 19:36:35 UTC (rev 202344)
+++ trunk/Source/WebCore/page/MainFrame.h	2016-06-22 20:00:03 UTC (rev 202345)
@@ -63,8 +63,8 @@
     void removeLatchingStateForTarget(Element&);
 #endif // PLATFORM(MAC)
 
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/MainFrameMembers.h>
+#if ENABLE(APPLE_PAY)
+    PaymentCoordinator& paymentCoordinator() const { return *m_paymentCoordinator; }
 #endif
 
 private:
@@ -83,6 +83,10 @@
 
     std::unique_ptr<WheelEventDeltaFilter> m_recentWheelEventDeltaFilter;
     std::unique_ptr<PageOverlayController> m_pageOverlayController;
+
+#if ENABLE(APPLE_PAY)
+    std::unique_ptr<PaymentCoordinator> m_paymentCoordinator;
+#endif
 };
 
 inline bool Frame::isMainFrame() const

Modified: trunk/Source/WebCore/page/PageConfiguration.h (202344 => 202345)


--- trunk/Source/WebCore/page/PageConfiguration.h	2016-06-22 19:36:35 UTC (rev 202344)
+++ trunk/Source/WebCore/page/PageConfiguration.h	2016-06-22 20:00:03 UTC (rev 202345)
@@ -29,10 +29,6 @@
 #include <wtf/RefPtr.h>
 #include <wtf/UniqueRef.h>
 
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/PageConfigurationIncludes.h>
-#endif
-
 namespace WebCore {
 
 class AlternativeTextClient;
@@ -45,6 +41,7 @@
 class EditorClient;
 class FrameLoaderClient;
 class InspectorClient;
+class PaymentCoordinatorClient;
 class PlugInClient;
 class ProgressTrackerClient;
 class SocketProvider;
@@ -72,6 +69,10 @@
     UniqueRef<SocketProvider> socketProvider;
     DragClient* dragClient { nullptr };
     InspectorClient* inspectorClient { nullptr };
+#if ENABLE(APPLE_PAY)
+    PaymentCoordinatorClient* paymentCoordinatorClient { nullptr };
+#endif
+
     PlugInClient* plugInClient { nullptr };
     ProgressTrackerClient* progressTrackerClient { nullptr };
     RefPtr<BackForwardClient> backForwardClient;
@@ -79,10 +80,6 @@
     FrameLoaderClient* loaderClientForMainFrame { nullptr };
     std::unique_ptr<DiagnosticLoggingClient> diagnosticLoggingClient { nullptr };
 
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/PageConfigurationMembers.h>
-#endif
-
     RefPtr<ApplicationCacheStorage> applicationCacheStorage;
     RefPtr<DatabaseProvider> databaseProvider;
     RefPtr<StorageNamespaceProvider> storageNamespaceProvider;

Modified: trunk/Source/WebCore/platform/cocoa/ThemeCocoa.mm (202344 => 202345)


--- trunk/Source/WebCore/platform/cocoa/ThemeCocoa.mm	2016-06-22 19:36:35 UTC (rev 202344)
+++ trunk/Source/WebCore/platform/cocoa/ThemeCocoa.mm	2016-06-22 20:00:03 UTC (rev 202345)
@@ -53,9 +53,77 @@
     context.scale(FloatSize(scale, scale));
 }
 
+#if ENABLE(APPLE_PAY)
+static NSBundle *passKitBundle()
+{
+    static NSBundle *passKitBundle;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+#if PLATFORM(MAC)
+        passKitBundle = [NSBundle bundleWithURL:[NSURL fileURLWithPath:@"/System/Library/PrivateFrameworks/PassKit.framework"]];
+#else
+        dlopen("/System/Library/Frameworks/PassKit.framework/PassKit", RTLD_NOW);
+        passKitBundle = [NSBundle bundleForClass:NSClassFromString(@"PKPaymentAuthorizationViewController")];
+#endif
+    });
+
+    return passKitBundle;
+}
+
+static RetainPtr<CGPDFPageRef> loadPassKitPDFPage(NSString *imageName)
+{
+    NSURL *url = "" URLForResource:imageName withExtension:@"pdf"];
+    if (!url)
+        return nullptr;
+
+    auto document = adoptCF(CGPDFDocumentCreateWithURL((CFURLRef)url));
+    if (!document)
+        return nullptr;
+
+    if (!CGPDFDocumentGetNumberOfPages(document.get()))
+        return nullptr;
+
+    return CGPDFDocumentGetPage(document.get(), 1);
+};
+
+static CGPDFPageRef applePayButtonLogoBlack()
+{
+    static CGPDFPageRef logoPage;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        logoPage = loadPassKitPDFPage(@"PayButtonLogoBlack").leakRef();
+    });
+
+    return logoPage;
+};
+
+static CGPDFPageRef applePayButtonLogoWhite()
+{
+    static CGPDFPageRef logoPage;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        logoPage = loadPassKitPDFPage(@"PayButtonLogoWhite").leakRef();
+    });
+
+    return logoPage;
+};
+
+static void drawApplePayButton(GraphicsContext& context, CGPDFPageRef page, const FloatRect& rect)
+{
+    CGSize pdfSize = CGPDFPageGetBoxRect(page, kCGPDFMediaBox).size;
+    GraphicsContextStateSaver stateSaver(context);
+    fitContextToBox(context, FloatSize(pdfSize), rect.size());
+
+    CGContextTranslateCTM(context.platformContext(), 0, pdfSize.height);
+    CGContextScaleCTM(context.platformContext(), 1, -1);
+
+    CGContextDrawPDFPage(context.platformContext(), page);
+};
+
+#endif
+
 void ThemeCocoa::drawNamedImage(const String& name, GraphicsContext& context, const FloatRect& rect) const
 {
-    // We only handle one icon at the moment.
     if (name == "wireless-playback") {
         GraphicsContextStateSaver stateSaver(context);
         context.setFillColor(Color::black);
@@ -88,8 +156,20 @@
         return;
     }
 
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/ThemeCocoaDrawNamedImage.mm>
+#if ENABLE(APPLE_PAY)
+    if (name == "apple-pay-logo-black") {
+        if (auto logo = applePayButtonLogoBlack()) {
+            drawApplePayButton(context, logo, rect);
+            return;
+        }
+    }
+
+    if (name == "apple-pay-logo-white") {
+        if (auto logo = applePayButtonLogoWhite()) {
+            drawApplePayButton(context, logo, rect);
+            return;
+        }
+    }
 #endif
 
     Theme::drawNamedImage(name, context, rect);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to