Title: [290813] trunk/Source
Revision
290813
Author
drou...@apple.com
Date
2022-03-03 20:08:26 -0800 (Thu, 03 Mar 2022)

Log Message

[GPU Process] dont load Apple Pay button/logo PDFs in the WebProcess
https://bugs.webkit.org/show_bug.cgi?id=237177

Reviewed by Simon Fraser.

Source/WebCore:

* platform/graphics/SystemImage.h: Added.
(WebCore::SystemImage::draw const):
(WebCore::SystemImage::SystemImage):
Introduce a new extendable class `SystemImage` that represents a collection of arguments
and methodology (that uses those arguments) to draw something from the system.
This patch introduces two concrete uses:
- `ApplePayButtonSystemImage` uses PassKit SPI to draw an Apple Pay button.
- `ApplePayLogoSystemImage` loads a PDF file of the Apple Pay logo from inside PassKit.
This architecture was chosen so that `GraphicsContext` doesn't have to know about Apple Pay
specific things, instead only dealing with a very generic interface (whos subclasses know
more specifically what to do with the data they're given).

* Modules/applepay/ApplePayButtonSystemImage.h: Added.
(WebCore::ApplePayButtonSystemImage::create):
(WebCore::ApplePayButtonSystemImage::ApplePayButtonSystemImage):
(WebCore::ApplePayButtonSystemImage::encode const):
(WebCore::ApplePayButtonSystemImage::decode):
(isType):
* Modules/applepay/ApplePayButtonSystemImage.mm: Added.
(WebCore::toPKPaymentButtonType):
(WebCore::toPKPaymentButtonStyle):
(WebCore::ApplePayButtonSystemImage::draw const):
* css/CSSPrimitiveValueMappings.h:
* rendering/style/RenderStyle.h:
* rendering/style/RenderStyleConstants.cpp:
* rendering/style/RenderStyleConstants.h:
Drive-by: Move `ApplePayButtonStyle` and `ApplePayButtonType` to `ApplePayButtonSystemImage.h`
so they can be used elsewhere (e.g. GPUProcess) without having to include everything else.

* Modules/applepay/ApplePayLogoSystemImage.h: Added.
(WebCore::ApplePayLogoSystemImage::create):
(WebCore::ApplePayLogoSystemImage::ApplePayLogoSystemImage):
(WebCore::ApplePayLogoSystemImage::encode const):
(WebCore::ApplePayLogoSystemImage::decode):
(isType):
* Modules/applepay/ApplePayLogoSystemImage.mm: Added.
(WebCore::passKitBundle):
(WebCore::loadPassKitPDFPage):
(WebCore::applePayLogoWhite):
(WebCore::applePayLogoBlack):
(WebCore::applePayLogoForStyle):
(WebCore::ApplePayLogoSystemImage::draw const):
Add a new `ApplePayLogoStyle` so that the WebProcess isn't able to provide an arbitrary PDF
to load when rendering `-webkit-named-image(apple-pay-logo-[white,black])`.

* platform/cocoa/ThemeCocoa.mm:
(WebCore::ThemeCocoa::drawNamedImage const):
(WebCore::fitContextToBox): Deleted.
(WebCore::passKitBundle): Deleted.
(WebCore::loadPassKitPDFPage): Deleted.
(WebCore::applePayButtonLogoBlack): Deleted.
(WebCore::applePayButtonLogoWhite): Deleted.
(WebCore::drawApplePayButton): Deleted.
* rendering/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::paintApplePayButton):
(WebCore::toPKPaymentButtonStyle): Deleted.
(WebCore::toPKPaymentButtonType): Deleted.
Move the logic that draws the Apple Pay button to a method on `GraphicsContext` so that it
can hook into the various GPUProcess flags/systems.

* platform/graphics/GraphicsContext.h:
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawSystemImage): Added.
* platform/graphics/BifurcatedGraphicsContext.h:
* platform/graphics/BifurcatedGraphicsContext.cpp:
(WebCore::BifurcatedGraphicsContext::drawSystemImage): Added.
* platform/graphics/NullGraphicsContext.h:
(WebCore::NullGraphicsContext::drawSystemImage): Added.
* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::append):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::apply):
(WebCore::DisplayList::ItemHandle::destroy):
(WebCore::DisplayList::ItemHandle::safeCopy const):
* platform/graphics/displaylists/DisplayListItemType.h:
* platform/graphics/displaylists/DisplayListItemType.cpp:
(WebCore::DisplayList::sizeOfItemInBytes):
(WebCore::DisplayList::isDrawingItem):
(WebCore::DisplayList::isInlineItem):
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::DrawSystemImage::DrawSystemImage): Added.
(WebCore::DisplayList::DrawSystemImage::systemImage const): Added.
(WebCore::DisplayList::DrawSystemImage::destination const): Added.
(WebCore::DisplayList::DrawSystemImage::globalBounds const): Added.
(WebCore::DisplayList::DrawSystemImage::localBounds const): Added.
(WebCore::DisplayList::DrawSystemImage::encode const): Added.
(WebCore::DisplayList::DrawSystemImage::decode): Added.
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::DrawSystemImage::apply const): Added.
(WebCore::DisplayList::operator<<):
* platform/graphics/displaylists/DisplayListRecorder.h:
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::drawSystemImage): Added.
* platform/graphics/displaylists/DisplayListRecorderImpl.h:
* platform/graphics/displaylists/DisplayListRecorderImpl.cpp:
(WebCore::DisplayList::RecorderImpl::recordDrawSystemImage): Added.
Add new `DrawSystemImage` display list item to handle GPUProcess drawing of `SystemImage`.

* Headers.cmake:
* Sources.txt:
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:

* Modules/model-element/scenekit/SceneKitModelLoaderUSD.mm:
Drive-by: Unified sources build fix.

Source/WebKit:

See `Source/WebCore/ChangeLog` for an explanation of `SystemImage`.

* Shared/WebCoreArgumentCoders.h:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<Ref<SystemImage>>::encode): Added.
(IPC::ArgumentCoder<Ref<SystemImage>>::decode): Added.
Support sending `SystemImage` (technically `Ref<SystemImage>`) across processes.

* GPUProcess/graphics/RemoteDisplayListRecorder.messages.in:
* GPUProcess/graphics/RemoteDisplayListRecorder.h:
* GPUProcess/graphics/RemoteDisplayListRecorder.cpp:
(WebKit::RemoteDisplayListRecorder::drawSystemImage): Added.
* WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:
* WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:
(WebKit::RemoteDisplayListRecorderProxy::recordDrawSystemImage): Addded.
Add new `DrawSystemImage` display list item.

* Scripts/webkit/messages.py:
(class_template_headers):
Add support for `Ref<T>` in IPC messages.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (290812 => 290813)


--- trunk/Source/WebCore/ChangeLog	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/ChangeLog	2022-03-04 04:08:26 UTC (rev 290813)
@@ -1,3 +1,116 @@
+2022-03-03  Devin Rousso  <drou...@apple.com>
+
+        [GPU Process] dont load Apple Pay button/logo PDFs in the WebProcess
+        https://bugs.webkit.org/show_bug.cgi?id=237177
+
+        Reviewed by Simon Fraser.
+
+        * platform/graphics/SystemImage.h: Added.
+        (WebCore::SystemImage::draw const):
+        (WebCore::SystemImage::SystemImage):
+        Introduce a new extendable class `SystemImage` that represents a collection of arguments
+        and methodology (that uses those arguments) to draw something from the system.
+        This patch introduces two concrete uses:
+        - `ApplePayButtonSystemImage` uses PassKit SPI to draw an Apple Pay button.
+        - `ApplePayLogoSystemImage` loads a PDF file of the Apple Pay logo from inside PassKit.
+        This architecture was chosen so that `GraphicsContext` doesn't have to know about Apple Pay
+        specific things, instead only dealing with a very generic interface (whos subclasses know
+        more specifically what to do with the data they're given).
+
+        * Modules/applepay/ApplePayButtonSystemImage.h: Added.
+        (WebCore::ApplePayButtonSystemImage::create):
+        (WebCore::ApplePayButtonSystemImage::ApplePayButtonSystemImage):
+        (WebCore::ApplePayButtonSystemImage::encode const):
+        (WebCore::ApplePayButtonSystemImage::decode):
+        (isType):
+        * Modules/applepay/ApplePayButtonSystemImage.mm: Added.
+        (WebCore::toPKPaymentButtonType):
+        (WebCore::toPKPaymentButtonStyle):
+        (WebCore::ApplePayButtonSystemImage::draw const):
+        * css/CSSPrimitiveValueMappings.h:
+        * rendering/style/RenderStyle.h:
+        * rendering/style/RenderStyleConstants.cpp:
+        * rendering/style/RenderStyleConstants.h:
+        Drive-by: Move `ApplePayButtonStyle` and `ApplePayButtonType` to `ApplePayButtonSystemImage.h`
+        so they can be used elsewhere (e.g. GPUProcess) without having to include everything else.
+
+        * Modules/applepay/ApplePayLogoSystemImage.h: Added.
+        (WebCore::ApplePayLogoSystemImage::create):
+        (WebCore::ApplePayLogoSystemImage::ApplePayLogoSystemImage):
+        (WebCore::ApplePayLogoSystemImage::encode const):
+        (WebCore::ApplePayLogoSystemImage::decode):
+        (isType):
+        * Modules/applepay/ApplePayLogoSystemImage.mm: Added.
+        (WebCore::passKitBundle):
+        (WebCore::loadPassKitPDFPage):
+        (WebCore::applePayLogoWhite):
+        (WebCore::applePayLogoBlack):
+        (WebCore::applePayLogoForStyle):
+        (WebCore::ApplePayLogoSystemImage::draw const):
+        Add a new `ApplePayLogoStyle` so that the WebProcess isn't able to provide an arbitrary PDF
+        to load when rendering `-webkit-named-image(apple-pay-logo-[white,black])`.
+
+        * platform/cocoa/ThemeCocoa.mm:
+        (WebCore::ThemeCocoa::drawNamedImage const):
+        (WebCore::fitContextToBox): Deleted.
+        (WebCore::passKitBundle): Deleted.
+        (WebCore::loadPassKitPDFPage): Deleted.
+        (WebCore::applePayButtonLogoBlack): Deleted.
+        (WebCore::applePayButtonLogoWhite): Deleted.
+        (WebCore::drawApplePayButton): Deleted.
+        * rendering/RenderThemeCocoa.mm:
+        (WebCore::RenderThemeCocoa::paintApplePayButton):
+        (WebCore::toPKPaymentButtonStyle): Deleted.
+        (WebCore::toPKPaymentButtonType): Deleted.
+        Move the logic that draws the Apple Pay button to a method on `GraphicsContext` so that it
+        can hook into the various GPUProcess flags/systems.
+
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::drawSystemImage): Added.
+        * platform/graphics/BifurcatedGraphicsContext.h:
+        * platform/graphics/BifurcatedGraphicsContext.cpp:
+        (WebCore::BifurcatedGraphicsContext::drawSystemImage): Added.
+        * platform/graphics/NullGraphicsContext.h:
+        (WebCore::NullGraphicsContext::drawSystemImage): Added.
+        * platform/graphics/displaylists/DisplayList.cpp:
+        (WebCore::DisplayList::DisplayList::append):
+        * platform/graphics/displaylists/DisplayListItemBuffer.cpp:
+        (WebCore::DisplayList::ItemHandle::apply):
+        (WebCore::DisplayList::ItemHandle::destroy):
+        (WebCore::DisplayList::ItemHandle::safeCopy const):
+        * platform/graphics/displaylists/DisplayListItemType.h:
+        * platform/graphics/displaylists/DisplayListItemType.cpp:
+        (WebCore::DisplayList::sizeOfItemInBytes):
+        (WebCore::DisplayList::isDrawingItem):
+        (WebCore::DisplayList::isInlineItem):
+        * platform/graphics/displaylists/DisplayListItems.h:
+        (WebCore::DisplayList::DrawSystemImage::DrawSystemImage): Added.
+        (WebCore::DisplayList::DrawSystemImage::systemImage const): Added.
+        (WebCore::DisplayList::DrawSystemImage::destination const): Added.
+        (WebCore::DisplayList::DrawSystemImage::globalBounds const): Added.
+        (WebCore::DisplayList::DrawSystemImage::localBounds const): Added.
+        (WebCore::DisplayList::DrawSystemImage::encode const): Added.
+        (WebCore::DisplayList::DrawSystemImage::decode): Added.
+        * platform/graphics/displaylists/DisplayListItems.cpp:
+        (WebCore::DisplayList::DrawSystemImage::apply const): Added.
+        (WebCore::DisplayList::operator<<):
+        * platform/graphics/displaylists/DisplayListRecorder.h:
+        * platform/graphics/displaylists/DisplayListRecorder.cpp:
+        (WebCore::DisplayList::Recorder::drawSystemImage): Added.
+        * platform/graphics/displaylists/DisplayListRecorderImpl.h:
+        * platform/graphics/displaylists/DisplayListRecorderImpl.cpp:
+        (WebCore::DisplayList::RecorderImpl::recordDrawSystemImage): Added.
+        Add new `DrawSystemImage` display list item to handle GPUProcess drawing of `SystemImage`.
+
+        * Headers.cmake:
+        * Sources.txt:
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * Modules/model-element/scenekit/SceneKitModelLoaderUSD.mm:
+        Drive-by: Unified sources build fix.
+
 2022-03-03  Simon Fraser  <simon.fra...@apple.com>
 
         Element with position: sticky after sticking, starts to move incorrectly when scrolling

Modified: trunk/Source/WebCore/Headers.cmake (290812 => 290813)


--- trunk/Source/WebCore/Headers.cmake	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/Headers.cmake	2022-03-04 04:08:26 UTC (rev 290813)
@@ -131,6 +131,8 @@
 
     Modules/airplay/PlaybackTargetClientContextIdentifier.h
 
+    Modules/applepay/ApplePayButtonSystemImage.h
+    Modules/applepay/ApplePayLogoSystemImage.h
     Modules/applepay/ApplePaySessionPaymentRequest.h
     Modules/applepay/Payment.h
     Modules/applepay/PaymentContact.h
@@ -1572,6 +1574,7 @@
     platform/graphics/SourceBufferPrivateClient.h
     platform/graphics/SourceImage.h
     platform/graphics/StringTruncator.h
+    platform/graphics/SystemImage.h
     platform/graphics/TabSize.h
     platform/graphics/TextRun.h
     platform/graphics/TextTrackRepresentation.h

Added: trunk/Source/WebCore/Modules/applepay/ApplePayButtonSystemImage.h (0 => 290813)


--- trunk/Source/WebCore/Modules/applepay/ApplePayButtonSystemImage.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayButtonSystemImage.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY)
+
+#include "SystemImage.h"
+#include <optional>
+#include <wtf/Forward.h>
+#include <wtf/Ref.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+enum class ApplePayButtonType : uint8_t {
+    Plain,
+    Buy,
+    SetUp,
+    Donate,
+    CheckOut,
+    Book,
+    Subscribe,
+#if ENABLE(APPLE_PAY_NEW_BUTTON_TYPES)
+    Reload,
+    AddMoney,
+    TopUp,
+    Order,
+    Rent,
+    Support,
+    Contribute,
+    Tip,
+#endif // ENABLE(APPLE_PAY_NEW_BUTTON_TYPES)
+};
+
+enum class ApplePayButtonStyle : uint8_t {
+    White,
+    WhiteOutline,
+    Black,
+};
+
+class WEBCORE_EXPORT ApplePayButtonSystemImage final : public SystemImage {
+public:
+    static Ref<ApplePayButtonSystemImage> create(ApplePayButtonType applePayButtonType, ApplePayButtonStyle applePayButtonStyle, const String& locale, float largestCornerRadius)
+    {
+        return adoptRef(*new ApplePayButtonSystemImage(applePayButtonType, applePayButtonStyle, locale, largestCornerRadius));
+    }
+
+    virtual ~ApplePayButtonSystemImage() = default;
+
+    void draw(GraphicsContext&, const FloatRect&) const final;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static std::optional<Ref<ApplePayButtonSystemImage>> decode(Decoder&);
+
+private:
+    ApplePayButtonSystemImage(ApplePayButtonType applePayButtonType, ApplePayButtonStyle applePayButtonStyle, const String& locale, float largestCornerRadius)
+        : SystemImage(SystemImageType::ApplePayButton)
+        , m_applePayButtonType(applePayButtonType)
+        , m_applePayButtonStyle(applePayButtonStyle)
+        , m_locale(locale)
+        , m_largestCornerRadius(largestCornerRadius)
+    {
+    }
+
+    ApplePayButtonType m_applePayButtonType;
+    ApplePayButtonStyle m_applePayButtonStyle;
+    String m_locale;
+    float m_largestCornerRadius;
+};
+
+template<class Encoder>
+void ApplePayButtonSystemImage::encode(Encoder& encoder) const
+{
+    encoder << m_applePayButtonType;
+    encoder << m_applePayButtonStyle;
+    encoder << m_locale;
+    encoder << m_largestCornerRadius;
+}
+
+template<class Decoder>
+std::optional<Ref<ApplePayButtonSystemImage>> ApplePayButtonSystemImage::decode(Decoder& decoder)
+{
+#define DECODE(name, type) \
+    std::optional<type> name; \
+    decoder >> name; \
+    if (!name) \
+        return std::nullopt; \
+
+    DECODE(applePayButtonType, ApplePayButtonType)
+    DECODE(applePayButtonStyle, ApplePayButtonStyle)
+    DECODE(locale, String)
+    DECODE(largestCornerRadius, float)
+
+#undef DECODE
+
+    return ApplePayButtonSystemImage::create(WTFMove(*applePayButtonType), WTFMove(*applePayButtonStyle), WTFMove(*locale), WTFMove(*largestCornerRadius));
+}
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ApplePayButtonSystemImage)
+    static bool isType(const WebCore::SystemImage& systemImage) { return systemImage.systemImageType() == WebCore::SystemImageType::ApplePayButton; }
+SPECIALIZE_TYPE_TRAITS_END()
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::ApplePayButtonType> {
+    using values = EnumValues<WebCore::ApplePayButtonType,
+        WebCore::ApplePayButtonType::Plain,
+        WebCore::ApplePayButtonType::Buy,
+        WebCore::ApplePayButtonType::SetUp,
+        WebCore::ApplePayButtonType::Donate,
+        WebCore::ApplePayButtonType::CheckOut,
+        WebCore::ApplePayButtonType::Book,
+        WebCore::ApplePayButtonType::Subscribe
+#if ENABLE(APPLE_PAY_NEW_BUTTON_TYPES)
+        , WebCore::ApplePayButtonType::Reload,
+        WebCore::ApplePayButtonType::AddMoney,
+        WebCore::ApplePayButtonType::TopUp,
+        WebCore::ApplePayButtonType::Order,
+        WebCore::ApplePayButtonType::Rent,
+        WebCore::ApplePayButtonType::Support,
+        WebCore::ApplePayButtonType::Contribute,
+        WebCore::ApplePayButtonType::Tip
+#endif // ENABLE(APPLE_PAY_NEW_BUTTON_TYPES)
+    >;
+};
+
+template<> struct EnumTraits<WebCore::ApplePayButtonStyle> {
+    using values = EnumValues<
+        WebCore::ApplePayButtonStyle,
+        WebCore::ApplePayButtonStyle::White,
+        WebCore::ApplePayButtonStyle::WhiteOutline,
+        WebCore::ApplePayButtonStyle::Black
+    >;
+};
+
+} // namespace WTF
+
+#endif // ENABLE(APPLE_PAY)

Added: trunk/Source/WebCore/Modules/applepay/ApplePayButtonSystemImage.mm (0 => 290813)


--- trunk/Source/WebCore/Modules/applepay/ApplePayButtonSystemImage.mm	                        (rev 0)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayButtonSystemImage.mm	2022-03-04 04:08:26 UTC (rev 290813)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#import "config.h"
+#import "ApplePayButtonSystemImage.h"
+
+#if ENABLE(APPLE_PAY)
+
+#import "FloatRect.h"
+#import "GraphicsContextCG.h"
+#import <pal/cocoa/PassKitSoftLink.h>
+
+namespace WebCore {
+
+static PKPaymentButtonType toPKPaymentButtonType(ApplePayButtonType type)
+{
+    switch (type) {
+    case ApplePayButtonType::Plain:
+        return PKPaymentButtonTypePlain;
+    case ApplePayButtonType::Buy:
+        return PKPaymentButtonTypeBuy;
+    case ApplePayButtonType::SetUp:
+        return PKPaymentButtonTypeSetUp;
+    case ApplePayButtonType::Donate:
+        return PKPaymentButtonTypeDonate;
+    case ApplePayButtonType::CheckOut:
+        return PKPaymentButtonTypeCheckout;
+    case ApplePayButtonType::Book:
+        return PKPaymentButtonTypeBook;
+    case ApplePayButtonType::Subscribe:
+        return PKPaymentButtonTypeSubscribe;
+#if HAVE(PASSKIT_NEW_BUTTON_TYPES)
+    case ApplePayButtonType::Reload:
+        return PKPaymentButtonTypeReload;
+    case ApplePayButtonType::AddMoney:
+        return PKPaymentButtonTypeAddMoney;
+    case ApplePayButtonType::TopUp:
+        return PKPaymentButtonTypeTopUp;
+    case ApplePayButtonType::Order:
+        return PKPaymentButtonTypeOrder;
+    case ApplePayButtonType::Rent:
+        return PKPaymentButtonTypeRent;
+    case ApplePayButtonType::Support:
+        return PKPaymentButtonTypeSupport;
+    case ApplePayButtonType::Contribute:
+        return PKPaymentButtonTypeContribute;
+    case ApplePayButtonType::Tip:
+        return PKPaymentButtonTypeTip;
+#endif // HAVE(PASSKIT_NEW_BUTTON_TYPES)
+    }
+}
+
+static PKPaymentButtonStyle toPKPaymentButtonStyle(ApplePayButtonStyle style)
+{
+    switch (style) {
+    case ApplePayButtonStyle::White:
+        return PKPaymentButtonStyleWhite;
+    case ApplePayButtonStyle::WhiteOutline:
+        return PKPaymentButtonStyleWhiteOutline;
+    case ApplePayButtonStyle::Black:
+        return PKPaymentButtonStyleBlack;
+    }
+}
+
+void ApplePayButtonSystemImage::draw(GraphicsContext& context, const FloatRect& destinationRect) const
+{
+    GraphicsContextStateSaver stateSaver(context);
+
+    context.setShouldSmoothFonts(true);
+    context.scale(FloatSize(1, -1));
+
+    PKDrawApplePayButtonWithCornerRadius(context.platformContext(), CGRectMake(destinationRect.x(), -destinationRect.maxY(), destinationRect.width(), destinationRect.height()), 1.0, m_largestCornerRadius, toPKPaymentButtonType(m_applePayButtonType), toPKPaymentButtonStyle(m_applePayButtonStyle), m_locale);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY)

Added: trunk/Source/WebCore/Modules/applepay/ApplePayLogoSystemImage.h (0 => 290813)


--- trunk/Source/WebCore/Modules/applepay/ApplePayLogoSystemImage.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayLogoSystemImage.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY)
+
+#include "SystemImage.h"
+#include <optional>
+#include <wtf/Forward.h>
+#include <wtf/Ref.h>
+
+namespace WebCore {
+
+enum class ApplePayLogoStyle : uint8_t {
+    White,
+    Black,
+};
+
+class WEBCORE_EXPORT ApplePayLogoSystemImage final : public SystemImage {
+public:
+    static Ref<ApplePayLogoSystemImage> create(ApplePayLogoStyle applePayLogoStyle)
+    {
+        return adoptRef(*new ApplePayLogoSystemImage(applePayLogoStyle));
+    }
+
+    virtual ~ApplePayLogoSystemImage() = default;
+
+    void draw(GraphicsContext&, const FloatRect&) const final;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static std::optional<Ref<ApplePayLogoSystemImage>> decode(Decoder&);
+
+private:
+    ApplePayLogoSystemImage(ApplePayLogoStyle applePayLogoStyle)
+        : SystemImage(SystemImageType::ApplePayLogo)
+        , m_applePayLogoStyle(applePayLogoStyle)
+    {
+    }
+
+    ApplePayLogoStyle m_applePayLogoStyle;
+};
+
+template<class Encoder>
+void ApplePayLogoSystemImage::encode(Encoder& encoder) const
+{
+    encoder << m_applePayLogoStyle;
+}
+
+template<class Decoder>
+std::optional<Ref<ApplePayLogoSystemImage>> ApplePayLogoSystemImage::decode(Decoder& decoder)
+{
+#define DECODE(name, type) \
+    std::optional<type> name; \
+    decoder >> name; \
+    if (!name) \
+        return std::nullopt; \
+
+    DECODE(applePayLogoStyle, ApplePayLogoStyle)
+
+#undef DECODE
+
+    return ApplePayLogoSystemImage::create(WTFMove(*applePayLogoStyle));
+}
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ApplePayLogoSystemImage)
+    static bool isType(const WebCore::SystemImage& systemImage) { return systemImage.systemImageType() == WebCore::SystemImageType::ApplePayLogo; }
+SPECIALIZE_TYPE_TRAITS_END()
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::ApplePayLogoStyle> {
+    using values = EnumValues<
+        WebCore::ApplePayLogoStyle,
+        WebCore::ApplePayLogoStyle::White,
+        WebCore::ApplePayLogoStyle::Black
+    >;
+};
+
+} // namespace WTF
+
+#endif // ENABLE(APPLE_PAY)

Added: trunk/Source/WebCore/Modules/applepay/ApplePayLogoSystemImage.mm (0 => 290813)


--- trunk/Source/WebCore/Modules/applepay/ApplePayLogoSystemImage.mm	                        (rev 0)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayLogoSystemImage.mm	2022-03-04 04:08:26 UTC (rev 290813)
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#import "config.h"
+#import "ApplePayLogoSystemImage.h"
+
+#if ENABLE(APPLE_PAY)
+
+#import "FloatRect.h"
+#import "GeometryUtilities.h"
+#import "GraphicsContext.h"
+#import <wtf/NeverDestroyed.h>
+#import <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+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" isDirectory:YES]];
+#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 RetainPtr<CGPDFPageRef> applePayLogoWhite()
+{
+    static NeverDestroyed<RetainPtr<CGPDFPageRef>> logoPage;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        logoPage.get() = loadPassKitPDFPage(@"PayButtonLogoWhite");
+    });
+    return logoPage;
+}
+
+static RetainPtr<CGPDFPageRef> applePayLogoBlack()
+{
+    static NeverDestroyed<RetainPtr<CGPDFPageRef>> logoPage;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        logoPage.get() = loadPassKitPDFPage(@"PayButtonLogoBlack");
+    });
+    return logoPage;
+}
+
+static RetainPtr<CGPDFPageRef> applePayLogoForStyle(ApplePayLogoStyle style)
+{
+    switch (style) {
+    case ApplePayLogoStyle::White:
+        return applePayLogoWhite();
+
+    case ApplePayLogoStyle::Black:
+        return applePayLogoBlack();
+    }
+
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
+void ApplePayLogoSystemImage::draw(GraphicsContext& context, const FloatRect& destinationRect) const
+{
+    auto page = applePayLogoForStyle(m_applePayLogoStyle);
+    if (!page)
+        return;
+
+    CGSize pdfSize = CGPDFPageGetBoxRect(page.get(), kCGPDFMediaBox).size;
+
+    auto largestRect = largestRectWithAspectRatioInsideRect(pdfSize.width / pdfSize.height, destinationRect);
+    context.translate(largestRect.x(), largestRect.y());
+    context.scale(largestRect.width() / pdfSize.width);
+
+    context.translate(0, pdfSize.height);
+    context.scale(FloatSize(1, -1));
+
+    CGContextDrawPDFPage(context.platformContext(), page.get());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY)

Modified: trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelLoaderUSD.mm (290812 => 290813)


--- trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelLoaderUSD.mm	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelLoaderUSD.mm	2022-03-04 04:08:26 UTC (rev 290813)
@@ -30,6 +30,7 @@
 #import "SceneKitModelLoaderUSD.h"
 
 #import "Model.h"
+#import "ResourceError.h"
 #import "SceneKitModel.h"
 #import "SceneKitModelLoader.h"
 #import "SceneKitModelLoaderClient.h"

Modified: trunk/Source/WebCore/SourcesCocoa.txt (290812 => 290813)


--- trunk/Source/WebCore/SourcesCocoa.txt	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2022-03-04 04:08:26 UTC (rev 290813)
@@ -71,9 +71,11 @@
 JSApplePayShippingMethodUpdate.cpp
 JSApplePayValidateMerchantEvent.cpp
 Modules/airplay/WebMediaSessionManager.cpp
+Modules/applepay/ApplePayButtonSystemImage.mm
 Modules/applepay/ApplePayCouponCodeChangedEvent.cpp
 Modules/applepay/ApplePayCancelEvent.cpp
 Modules/applepay/ApplePayContactField.cpp
+Modules/applepay/ApplePayLogoSystemImage.mm
 Modules/applepay/ApplePayMerchantCapability.cpp
 Modules/applepay/ApplePayPaymentAuthorizationResult.cpp
 Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (290812 => 290813)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-03-04 04:08:26 UTC (rev 290813)
@@ -3122,6 +3122,9 @@
 		95AA571025EEED32004E9283 /* InspectorCanvasCallTracer.h in Headers */ = {isa = PBXBuildFile; fileRef = 95AA570E25EEED31004E9283 /* InspectorCanvasCallTracer.h */; };
 		95BA4FAD26D981AA002A0E62 /* PlatformViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 95BA4FAB26D981AA002A0E62 /* PlatformViewController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		95DF9D25252BEDB2000D7F46 /* PointerCharacteristics.h in Headers */ = {isa = PBXBuildFile; fileRef = 95DF9D23252BED99000D7F46 /* PointerCharacteristics.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		95E9F44627C9A39C00945337 /* SystemImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 95E9F44427C9A39B00945337 /* SystemImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		95E9F44B27C9F66600945337 /* ApplePayButtonSystemImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 95E9F44927C9F66600945337 /* ApplePayButtonSystemImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		95E9F44F27C9F69C00945337 /* ApplePayLogoSystemImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 95E9F44D27C9F69B00945337 /* ApplePayLogoSystemImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		95EAD563266EF2DB004B9CF1 /* ApplePayCouponCodeChangedEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 95EAD55F266EF2DA004B9CF1 /* ApplePayCouponCodeChangedEvent.h */; };
 		95EAD56A266EF2FA004B9CF1 /* ApplePayDateComponentsRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 95EAD566266EF2F8004B9CF1 /* ApplePayDateComponentsRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		95EAD56D266EF2FA004B9CF1 /* ApplePayDateComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = 95EAD569266EF2F9004B9CF1 /* ApplePayDateComponents.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13089,6 +13092,11 @@
 		95AA570E25EEED31004E9283 /* InspectorCanvasCallTracer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasCallTracer.h; sourceTree = "<group>"; };
 		95BA4FAB26D981AA002A0E62 /* PlatformViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformViewController.h; sourceTree = "<group>"; };
 		95DF9D23252BED99000D7F46 /* PointerCharacteristics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PointerCharacteristics.h; sourceTree = "<group>"; };
+		95E9F44427C9A39B00945337 /* SystemImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemImage.h; sourceTree = "<group>"; };
+		95E9F44827C9F66500945337 /* ApplePayButtonSystemImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ApplePayButtonSystemImage.mm; sourceTree = "<group>"; };
+		95E9F44927C9F66600945337 /* ApplePayButtonSystemImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplePayButtonSystemImage.h; sourceTree = "<group>"; };
+		95E9F44C27C9F69B00945337 /* ApplePayLogoSystemImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ApplePayLogoSystemImage.mm; sourceTree = "<group>"; };
+		95E9F44D27C9F69B00945337 /* ApplePayLogoSystemImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplePayLogoSystemImage.h; sourceTree = "<group>"; };
 		95EAD55F266EF2DA004B9CF1 /* ApplePayCouponCodeChangedEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplePayCouponCodeChangedEvent.h; sourceTree = "<group>"; };
 		95EAD561266EF2DA004B9CF1 /* ApplePayCouponCodeChangedEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ApplePayCouponCodeChangedEvent.idl; sourceTree = "<group>"; };
 		95EAD562266EF2DB004B9CF1 /* ApplePayCouponCodeChangedEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplePayCouponCodeChangedEvent.cpp; sourceTree = "<group>"; };
@@ -19642,6 +19650,8 @@
 			children = (
 				1A58E8691D19D8C000C0EA73 /* cocoa */,
 				A1DF5A9F1F7EE0F10058A477 /* paymentrequest */,
+				95E9F44927C9F66600945337 /* ApplePayButtonSystemImage.h */,
+				95E9F44827C9F66500945337 /* ApplePayButtonSystemImage.mm */,
 				A113E02C2331A0E4009C33A0 /* ApplePayCancelEvent.cpp */,
 				A113E02B2331A0E4009C33A0 /* ApplePayCancelEvent.h */,
 				A1956F182331A4680057E9D2 /* ApplePayCancelEvent.idl */,
@@ -19679,6 +19689,8 @@
 				A13B61692475DFC500BBE6DE /* ApplePayInstallmentRetailChannel.idl */,
 				7C6579E21E00827000E3A27A /* ApplePayLineItem.h */,
 				7C6579E41E0082C800E3A27A /* ApplePayLineItem.idl */,
+				95E9F44D27C9F69B00945337 /* ApplePayLogoSystemImage.h */,
+				95E9F44C27C9F69B00945337 /* ApplePayLogoSystemImage.mm */,
 				A1DF5AA81F8070D40058A477 /* ApplePayMerchantCapability.cpp */,
 				A1DF5A831F7EBDF20058A477 /* ApplePayMerchantCapability.h */,
 				A1DF5A851F7EBDF20058A477 /* ApplePayMerchantCapability.idl */,
@@ -29164,6 +29176,7 @@
 				B23540F00D00782E002382FA /* StringTruncator.cpp */,
 				B23540F10D00782E002382FA /* StringTruncator.h */,
 				087558C413B4A57D00F49307 /* SurrogatePairAwareTextIterator.h */,
+				95E9F44427C9A39B00945337 /* SystemImage.h */,
 				3BB6B80F22A7D311003A2A69 /* TabSize.h */,
 				376DCCE013B4F966002EBEFC /* TextRun.cpp */,
 				A824B4640E2EF2EA0081A7B7 /* TextRun.h */,
@@ -33511,6 +33524,7 @@
 				4425070925829A2700C09368 /* AppHighlightStorage.h in Headers */,
 				95FB662526D7033C0068AC67 /* ApplePayAMSUIPaymentHandler.h in Headers */,
 				95FB662626D7033C0068AC67 /* ApplePayAMSUIRequest.h in Headers */,
+				95E9F44B27C9F66600945337 /* ApplePayButtonSystemImage.h in Headers */,
 				A113E02E2331A134009C33A0 /* ApplePayCancelEvent.h in Headers */,
 				A1DF5A941F7EC4320058A477 /* ApplePayContactField.h in Headers */,
 				95EAD563266EF2DB004B9CF1 /* ApplePayCouponCodeChangedEvent.h in Headers */,
@@ -33528,6 +33542,7 @@
 				A11750A1247468F700D4D26C /* ApplePayInstallmentItemType.h in Headers */,
 				A13B616B2475E04800BBE6DE /* ApplePayInstallmentRetailChannel.h in Headers */,
 				7C6579E31E00827000E3A27A /* ApplePayLineItem.h in Headers */,
+				95E9F44F27C9F69C00945337 /* ApplePayLogoSystemImage.h in Headers */,
 				A1DF5A861F7EBDF20058A477 /* ApplePayMerchantCapability.h in Headers */,
 				A1F6CFFF1FE096210018078C /* ApplePayModifier.h in Headers */,
 				7C6523011E00D03400677F22 /* ApplePayPayment.h in Headers */,
@@ -37743,6 +37758,7 @@
 				E180811716FCF9CB00B80D07 /* SynchronousLoaderClient.h in Headers */,
 				C1692DD523D23E08006E88F7 /* SystemBattery.h in Headers */,
 				E4E8B4EC216B79E500B8834D /* SystemFontDatabaseCoreText.h in Headers */,
+				95E9F44627C9A39C00945337 /* SystemImage.h in Headers */,
 				0F03C0741884695E00A5F8CA /* SystemMemory.h in Headers */,
 				E3C04138254CB30D0021D0E6 /* SystemSoundDelegate.h in Headers */,
 				E3C0412F254CA29B0021D0E6 /* SystemSoundManager.h in Headers */,

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (290812 => 290813)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -29,6 +29,7 @@
 
 #pragma once
 
+#include "ApplePayButtonSystemImage.h"
 #include "CSSCalcValue.h"
 #include "CSSFontFamily.h"
 #include "CSSPrimitiveValue.h"

Modified: trunk/Source/WebCore/platform/cocoa/ThemeCocoa.mm (290812 => 290813)


--- trunk/Source/WebCore/platform/cocoa/ThemeCocoa.mm	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/cocoa/ThemeCocoa.mm	2022-03-04 04:08:26 UTC (rev 290813)
@@ -26,7 +26,9 @@
 #import "config.h"
 #import "ThemeCocoa.h"
 
+#import "ApplePayLogoSystemImage.h"
 #import "FontCascade.h"
+#import "GeometryUtilities.h"
 #import "GraphicsContext.h"
 #import "ImageBuffer.h"
 #import <dlfcn.h>
@@ -33,101 +35,6 @@
 
 namespace WebCore {
 
-static void fitContextToBox(GraphicsContext& context, const FloatSize& srcImageSize, const FloatSize& dstSize)
-{
-    float srcRatio = srcImageSize.aspectRatio();
-    float dstRatio = dstSize.aspectRatio();
-
-    float scale;
-    float translationX = 0;
-    float translationY = 0;
-    if (srcRatio > dstRatio) {
-        scale = dstSize.width() / srcImageSize.width();
-        translationY = (dstSize.height() - scale * srcImageSize.height()) / 2;
-    } else {
-        scale = dstSize.height() / srcImageSize.height();
-        translationX = (dstSize.width() - scale * srcImageSize.width()) / 2;
-    }
-    context.translate(translationX, translationY);
-    context.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" isDirectory:YES]];
-#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 FloatSize& size)
-{
-    // Create a local ImageBuffer because decoding the PDF images has to happen in WebProcess.
-    auto imageBuffer = context.createAlignedImageBuffer(size, DestinationColorSpace::SRGB(), RenderingMethod::Local);
-    if (!imageBuffer)
-        return;
-
-    CGSize pdfSize = CGPDFPageGetBoxRect(page, kCGPDFMediaBox).size;
-
-    auto& imageContext = imageBuffer->context();
-    fitContextToBox(imageContext, FloatSize(pdfSize), size);
-    imageContext.translate(0, pdfSize.height);
-    imageContext.scale(FloatSize(1, -1));
-    CGContextDrawPDFPage(imageContext.platformContext(), page);
-
-    context.drawConsumingImageBuffer(WTFMove(imageBuffer), FloatRect(FloatPoint::zero(), size));
-};
-
-#endif
-
 void ThemeCocoa::drawNamedImage(const String& name, GraphicsContext& context, const FloatSize& size) const
 {
     if (name == "wireless-playback") {
@@ -135,7 +42,9 @@
         context.setFillColor(Color::black);
 
         FloatSize wirelessPlaybackSrcSize(32, 24.016);
-        fitContextToBox(context, wirelessPlaybackSrcSize, size);
+        auto largestRect = largestRectWithAspectRatioInsideRect(wirelessPlaybackSrcSize.aspectRatio(), FloatRect(FloatPoint::zero(), size));
+        context.translate(largestRect.x(), largestRect.y());
+        context.scale(largestRect.width() / wirelessPlaybackSrcSize.width());
 
         Path outline;
         outline.moveTo(FloatPoint(24.066, 18));
@@ -164,17 +73,13 @@
 
 #if ENABLE(APPLE_PAY)
     if (name == "apple-pay-logo-black") {
-        if (auto logo = applePayButtonLogoBlack()) {
-            drawApplePayButton(context, logo, size);
-            return;
-        }
+        context.drawSystemImage(ApplePayLogoSystemImage::create(ApplePayLogoStyle::Black), FloatRect(FloatPoint::zero(), size));
+        return;
     }
 
     if (name == "apple-pay-logo-white") {
-        if (auto logo = applePayButtonLogoWhite()) {
-            drawApplePayButton(context, logo, size);
-            return;
-        }
+        context.drawSystemImage(ApplePayLogoSystemImage::create(ApplePayLogoStyle::White), FloatRect(FloatPoint::zero(), size));
+        return;
     }
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -263,6 +263,12 @@
     m_secondaryContext.drawNativeImage(nativeImage, selfSize, destRect, srcRect, options);
 }
 
+void BifurcatedGraphicsContext::drawSystemImage(SystemImage& systemImage, const FloatRect& destinationRect)
+{
+    m_primaryContext.drawSystemImage(systemImage, destinationRect);
+    m_secondaryContext.drawSystemImage(systemImage, destinationRect);
+}
+
 void BifurcatedGraphicsContext::drawPattern(NativeImage& nativeImage, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
 {
     m_primaryContext.drawPattern(nativeImage, destRect, tileRect, patternTransform, phase, spacing, options);

Modified: trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -98,6 +98,7 @@
     void setMiterLimit(float) final;
 
     void drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }) final;
+    void drawSystemImage(SystemImage&, const FloatRect&) final;
     void drawPattern(NativeImage&, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }) final;
     ImageDrawResult drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { ImageOrientation::FromImage }) final;
     ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& = { }) final;

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -38,6 +38,7 @@
 #include "MediaPlayerPrivate.h"
 #include "NullGraphicsContext.h"
 #include "RoundedRect.h"
+#include "SystemImage.h"
 #include "TextRun.h"
 #include <wtf/text/TextStream.h>
 
@@ -638,6 +639,11 @@
     return createScaledImageBuffer(rect, scaleFactor(), colorSpace, renderingMode(), renderingMethod);
 }
 
+void GraphicsContext::drawSystemImage(SystemImage& systemImage, const FloatRect& destinationRect)
+{
+    systemImage.draw(*this, destinationRect);
+}
+
 ImageDrawResult GraphicsContext::drawImage(Image& image, const FloatPoint& destination, const ImagePaintingOptions& imagePaintingOptions)
 {
     return drawImage(image, FloatRect(destination, image.size()), FloatRect(FloatPoint(), image.size()), imagePaintingOptions);

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -87,6 +87,7 @@
 class RoundedRect;
 class GraphicsContextGL;
 class Path;
+class SystemImage;
 class TextRun;
 class TransformationMatrix;
 
@@ -428,6 +429,8 @@
 
     virtual void drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }) = 0;
 
+    virtual void drawSystemImage(SystemImage&, const FloatRect&);
+
     WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatPoint& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage });
     WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatRect& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage });
     WEBCORE_EXPORT virtual ImageDrawResult drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { ImageOrientation::FromImage });

Modified: trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -63,6 +63,8 @@
 
     void drawNativeImage(NativeImage&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) final { }
 
+    void drawSystemImage(SystemImage&, const FloatRect&) final { };
+
     void drawPattern(NativeImage&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, const ImagePaintingOptions&) final { }
 
     IntRect clipBounds() const final { return { }; }

Added: trunk/Source/WebCore/platform/graphics/SystemImage.h (0 => 290813)


--- trunk/Source/WebCore/platform/graphics/SystemImage.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/SystemImage.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#pragma once
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class FloatRect;
+class GraphicsContext;
+
+enum class SystemImageType : uint8_t {
+#if ENABLE(APPLE_PAY)
+    ApplePayButton,
+    ApplePayLogo,
+#endif
+};
+
+class WEBCORE_EXPORT SystemImage : public RefCounted<SystemImage> {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    virtual ~SystemImage() = default;
+
+    virtual void draw(GraphicsContext&, const FloatRect&) const { }
+
+    SystemImageType systemImageType() const { return m_systemImageType; }
+
+protected:
+    SystemImage(SystemImageType systemImageType)
+        : m_systemImageType(systemImageType)
+    {
+    }
+
+private:
+    SystemImageType m_systemImageType;
+};
+
+} // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::SystemImageType> {
+    using values = EnumValues<
+        WebCore::SystemImageType
+#if ENABLE(APPLE_PAY)
+        , WebCore::SystemImageType::ApplePayButton,
+        WebCore::SystemImageType::ApplePayLogo
+#endif
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -248,6 +248,8 @@
         return append<DrawImageBuffer>(item.get<DrawImageBuffer>());
     case ItemType::DrawNativeImage:
         return append<DrawNativeImage>(item.get<DrawNativeImage>());
+    case ItemType::DrawSystemImage:
+        return append<DrawSystemImage>(item.get<DrawSystemImage>());
     case ItemType::DrawPattern:
         return append<DrawPattern>(item.get<DrawPattern>());
     case ItemType::DrawRect:

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -121,6 +121,9 @@
     case ItemType::DrawNativeImage:
         get<DrawNativeImage>().apply(context);
         return;
+    case ItemType::DrawSystemImage:
+        get<DrawSystemImage>().apply(context);
+        return;
     case ItemType::DrawPattern:
         get<DrawPattern>().apply(context);
         return;
@@ -338,6 +341,9 @@
     case ItemType::DrawNativeImage:
         static_assert(std::is_trivially_destructible<DrawNativeImage>::value);
         return;
+    case ItemType::DrawSystemImage:
+        get<DrawSystemImage>().~DrawSystemImage();
+        return;
     case ItemType::DrawPattern:
         static_assert(std::is_trivially_destructible<DrawPattern>::value);
         return;
@@ -489,6 +495,8 @@
         return copyInto<DrawLinesForText>(itemOffset, *this);
     case ItemType::DrawNativeImage:
         return copyInto<DrawNativeImage>(itemOffset, *this);
+    case ItemType::DrawSystemImage:
+        return copyInto<DrawSystemImage>(itemOffset, *this);
     case ItemType::DrawPattern:
         return copyInto<DrawPattern>(itemOffset, *this);
     case ItemType::DrawPath:

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -84,6 +84,8 @@
         return sizeof(DrawImageBuffer);
     case ItemType::DrawNativeImage:
         return sizeof(DrawNativeImage);
+    case ItemType::DrawSystemImage:
+        return sizeof(DrawSystemImage);
     case ItemType::DrawPattern:
         return sizeof(DrawPattern);
     case ItemType::DrawRect:
@@ -215,6 +217,7 @@
     case ItemType::DrawLine:
     case ItemType::DrawLinesForText:
     case ItemType::DrawNativeImage:
+    case ItemType::DrawSystemImage:
     case ItemType::DrawPattern:
     case ItemType::DrawPath:
     case ItemType::DrawRect:
@@ -294,6 +297,7 @@
     case ItemType::SetLineDash:
     case ItemType::SetState:
     case ItemType::StrokePath:
+    case ItemType::DrawSystemImage:
         return false;
     case ItemType::ApplyDeviceScaleFactor:
 #if USE(CG)

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -54,6 +54,7 @@
     DrawGlyphs,
     DrawImageBuffer,
     DrawNativeImage,
+    DrawSystemImage,
     DrawPattern,
     DrawRect,
     DrawLine,

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -398,6 +398,18 @@
     return ts;
 }
 
+void DrawSystemImage::apply(GraphicsContext& context) const
+{
+    context.drawSystemImage(m_systemImage, m_destinationRect);
+}
+
+static TextStream& operator<<(TextStream& ts, const DrawSystemImage& item)
+{
+    // FIXME: dump more stuff.
+    ts.dumpProperty("destination", item.destinationRect());
+    return ts;
+}
+
 DrawPattern::DrawPattern(RenderingResourceIdentifier imageIdentifier, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
     : m_imageIdentifier(imageIdentifier)
     , m_destination(destRect)
@@ -1021,6 +1033,7 @@
     case ItemType::DrawGlyphs: ts << "draw-glyphs"; break;
     case ItemType::DrawImageBuffer: ts << "draw-image-buffer"; break;
     case ItemType::DrawNativeImage: ts << "draw-native-image"; break;
+    case ItemType::DrawSystemImage: ts << "draw-system-image"; break;
     case ItemType::DrawPattern: ts << "draw-pattern"; break;
     case ItemType::DrawRect: ts << "draw-rect"; break;
     case ItemType::DrawLine: ts << "draw-line"; break;
@@ -1141,6 +1154,9 @@
     case ItemType::DrawNativeImage:
         ts << item.get<DrawNativeImage>();
         break;
+    case ItemType::DrawSystemImage:
+        ts << item.get<DrawSystemImage>();
+        break;
     case ItemType::DrawPattern:
         ts << item.get<DrawPattern>();
         break;

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -40,6 +40,7 @@
 #include "PixelBuffer.h"
 #include "RenderingResourceIdentifier.h"
 #include "SharedBuffer.h"
+#include "SystemImage.h"
 #include <variant>
 #include <wtf/EnumTraits.h>
 #include <wtf/TypeCasts.h>
@@ -993,6 +994,61 @@
     ImagePaintingOptions m_options;
 };
 
+class DrawSystemImage {
+public:
+    static constexpr ItemType itemType = ItemType::DrawSystemImage;
+    static constexpr bool isInlineItem = false;
+    static constexpr bool isDrawingItem = true;
+
+    DrawSystemImage(SystemImage& systemImage, const FloatRect& destinationRect)
+        : m_systemImage(systemImage)
+        , m_destinationRect(destinationRect)
+    {
+    }
+
+    const Ref<SystemImage>& systemImage() const { return m_systemImage; }
+    const FloatRect& destinationRect() const { return m_destinationRect; }
+
+    WEBCORE_EXPORT void apply(GraphicsContext&) const;
+
+    std::optional<FloatRect> globalBounds() const { return std::nullopt; }
+    std::optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destinationRect; }
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static std::optional<DrawSystemImage> decode(Decoder&);
+
+private:
+    Ref<SystemImage> m_systemImage;
+    FloatRect m_destinationRect;
+};
+
+template<class Encoder>
+void DrawSystemImage::encode(Encoder& encoder) const
+{
+    encoder << m_systemImage;
+    encoder << m_destinationRect;
+}
+
+template<class Decoder>
+std::optional<DrawSystemImage> DrawSystemImage::decode(Decoder& decoder)
+{
+#define DECODE(name, type) \
+    std::optional<type> name; \
+    decoder >> name; \
+    if (!name) \
+        return std::nullopt; \
+
+    DECODE(systemImage, Ref<SystemImage>)
+    DECODE(destinationRect, FloatRect)
+
+#undef DECODE
+
+    return { {
+        WTFMove(*systemImage),
+        WTFMove(*destinationRect),
+    } };
+}
+
 class DrawPattern {
 public:
     static constexpr ItemType itemType = ItemType::DrawPattern;
@@ -2220,6 +2276,7 @@
     , DrawPath
     , DrawPattern
     , DrawRect
+    , DrawSystemImage
     , EndTransparencyLayer
     , FillCompositedRect
     , FillEllipse
@@ -2306,6 +2363,7 @@
     WebCore::DisplayList::ItemType::DrawGlyphs,
     WebCore::DisplayList::ItemType::DrawImageBuffer,
     WebCore::DisplayList::ItemType::DrawNativeImage,
+    WebCore::DisplayList::ItemType::DrawSystemImage,
     WebCore::DisplayList::ItemType::DrawPattern,
     WebCore::DisplayList::ItemType::DrawRect,
     WebCore::DisplayList::ItemType::DrawLine,

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -196,6 +196,11 @@
     recordDrawNativeImage(image.renderingResourceIdentifier(), imageSize, destRect, srcRect, options);
 }
 
+void Recorder::drawSystemImage(SystemImage& systemImage, const FloatRect& destinationRect)
+{
+    recordDrawSystemImage(systemImage, destinationRect);
+}
+
 void Recorder::drawPattern(NativeImage& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
 {
     appendStateChangeItemIfNecessary();

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -84,6 +84,7 @@
     virtual void recordDrawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode) = 0;
     virtual void recordDrawImageBuffer(ImageBuffer&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
     virtual void recordDrawNativeImage(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
+    virtual void recordDrawSystemImage(SystemImage&, const FloatRect&) = 0;
     virtual void recordDrawPattern(RenderingResourceIdentifier, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }) = 0;
     virtual void recordBeginTransparencyLayer(float) = 0;
     virtual void recordEndTransparencyLayer() = 0;
@@ -220,6 +221,7 @@
 
     WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) final;
     WEBCORE_EXPORT void drawNativeImage(NativeImage&, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) final;
+    WEBCORE_EXPORT void drawSystemImage(SystemImage&, const FloatRect&) final;
     WEBCORE_EXPORT void drawPattern(NativeImage&, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) final;
     WEBCORE_EXPORT void drawPattern(ImageBuffer&, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) final;
 

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -182,6 +182,11 @@
     append<DrawNativeImage>(imageIdentifier, imageSize, destRect, srcRect, options);
 }
 
+void RecorderImpl::recordDrawSystemImage(SystemImage& systemImage, const FloatRect& destinationRect)
+{
+    append<DrawSystemImage>(systemImage, destinationRect);
+}
+
 void RecorderImpl::recordDrawPattern(RenderingResourceIdentifier imageIdentifier, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
 {
     append<DrawPattern>(imageIdentifier, destRect, tileRect, transform, phase, spacing, options);

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h (290812 => 290813)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -70,6 +70,7 @@
     void recordDrawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode) final;
     void recordDrawImageBuffer(ImageBuffer&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) final;
     void recordDrawNativeImage(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) final;
+    void recordDrawSystemImage(SystemImage&, const FloatRect&) final;
     void recordDrawPattern(RenderingResourceIdentifier, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }) final;
     void recordBeginTransparencyLayer(float) final;
     void recordEndTransparencyLayer() final;

Modified: trunk/Source/WebCore/rendering/RenderThemeCocoa.mm (290812 => 290813)


--- trunk/Source/WebCore/rendering/RenderThemeCocoa.mm	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/rendering/RenderThemeCocoa.mm	2022-03-04 04:08:26 UTC (rev 290813)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "RenderThemeCocoa.h"
 
+#import "ApplePayLogoSystemImage.h"
 #import "GraphicsContextCG.h"
 #import "HTMLInputElement.h"
 #import "ImageBuffer.h"
@@ -100,64 +101,8 @@
     }
 }
 
-static PKPaymentButtonStyle toPKPaymentButtonStyle(ApplePayButtonStyle style)
-{
-    switch (style) {
-    case ApplePayButtonStyle::White:
-        return PKPaymentButtonStyleWhite;
-    case ApplePayButtonStyle::WhiteOutline:
-        return PKPaymentButtonStyleWhiteOutline;
-    case ApplePayButtonStyle::Black:
-        return PKPaymentButtonStyleBlack;
-    }
-}
-
-static PKPaymentButtonType toPKPaymentButtonType(ApplePayButtonType type)
-{
-    switch (type) {
-    case ApplePayButtonType::Plain:
-        return PKPaymentButtonTypePlain;
-    case ApplePayButtonType::Buy:
-        return PKPaymentButtonTypeBuy;
-    case ApplePayButtonType::SetUp:
-        return PKPaymentButtonTypeSetUp;
-    case ApplePayButtonType::Donate:
-        return PKPaymentButtonTypeDonate;
-    case ApplePayButtonType::CheckOut:
-        return PKPaymentButtonTypeCheckout;
-    case ApplePayButtonType::Book:
-        return PKPaymentButtonTypeBook;
-    case ApplePayButtonType::Subscribe:
-        return PKPaymentButtonTypeSubscribe;
-#if HAVE(PASSKIT_NEW_BUTTON_TYPES)
-    case ApplePayButtonType::Reload:
-        return PKPaymentButtonTypeReload;
-    case ApplePayButtonType::AddMoney:
-        return PKPaymentButtonTypeAddMoney;
-    case ApplePayButtonType::TopUp:
-        return PKPaymentButtonTypeTopUp;
-    case ApplePayButtonType::Order:
-        return PKPaymentButtonTypeOrder;
-    case ApplePayButtonType::Rent:
-        return PKPaymentButtonTypeRent;
-    case ApplePayButtonType::Support:
-        return PKPaymentButtonTypeSupport;
-    case ApplePayButtonType::Contribute:
-        return PKPaymentButtonTypeContribute;
-    case ApplePayButtonType::Tip:
-        return PKPaymentButtonTypeTip;
-#endif
-    }
-}
-
 bool RenderThemeCocoa::paintApplePayButton(const RenderObject& renderer, const PaintInfo& paintInfo, const IntRect& paintRect)
 {
-    auto& destinationContext = paintInfo.context();
-
-    auto imageBuffer = destinationContext.createAlignedImageBuffer(paintRect.size());
-    if (!imageBuffer)
-        return false;
-
     auto& style = renderer.style();
     auto largestCornerRadius = std::max<CGFloat>({
         floatValueForLength(style.borderTopLeftRadius().height, paintRect.height()),
@@ -169,14 +114,7 @@
         floatValueForLength(style.borderBottomRightRadius().height, paintRect.height()),
         floatValueForLength(style.borderBottomRightRadius().width, paintRect.width())
     });
-
-    auto& imageContext = imageBuffer->context();
-    imageContext.setShouldSmoothFonts(true);
-    imageContext.setShouldSubpixelQuantizeFonts(false);
-    imageContext.scale(FloatSize(1, -1));
-    PKDrawApplePayButtonWithCornerRadius(imageContext.platformContext(), CGRectMake(0, -paintRect.height(), paintRect.width(), paintRect.height()), 1.0, largestCornerRadius, toPKPaymentButtonType(style.applePayButtonType()), toPKPaymentButtonStyle(style.applePayButtonStyle()), style.computedLocale());
-
-    destinationContext.drawConsumingImageBuffer(WTFMove(imageBuffer), paintRect);
+    paintInfo.context().drawSystemImage(ApplePayButtonSystemImage::create(style.applePayButtonType(), style.applePayButtonStyle(), style.computedLocale(), largestCornerRadius), paintRect);
     return false;
 }
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (290812 => 290813)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -25,6 +25,7 @@
 #pragma once
 
 #include "AnimationList.h"
+#include "ApplePayButtonSystemImage.h"
 #include "BorderValue.h"
 #include "CSSLineBoxContainValue.h"
 #include "CSSPrimitiveValue.h"

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp (290812 => 290813)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -52,42 +52,6 @@
     return ts;
 }
 
-#if ENABLE(APPLE_PAY)
-TextStream& operator<<(TextStream& ts, ApplePayButtonStyle buttonStyle)
-{
-    switch (buttonStyle) {
-    case ApplePayButtonStyle::White: ts << "white"; break;
-    case ApplePayButtonStyle::WhiteOutline: ts << "white-outline"; break;
-    case ApplePayButtonStyle::Black: ts << "black"; break;
-    }
-    return ts;
-}
-
-TextStream& operator<<(TextStream& ts, ApplePayButtonType playState)
-{
-    switch (playState) {
-    case ApplePayButtonType::Plain: ts << "plain"; break;
-    case ApplePayButtonType::Buy: ts << "buy"; break;
-    case ApplePayButtonType::SetUp: ts << "setup"; break;
-    case ApplePayButtonType::Donate: ts << "donate"; break;
-    case ApplePayButtonType::CheckOut: ts << "checkout"; break;
-    case ApplePayButtonType::Book: ts << "book"; break;
-    case ApplePayButtonType::Subscribe: ts << "subscribe"; break;
-#if ENABLE(APPLE_PAY_NEW_BUTTON_TYPES)
-    case ApplePayButtonType::Reload: ts << "reload"; break;
-    case ApplePayButtonType::AddMoney: ts << "add-money"; break;
-    case ApplePayButtonType::TopUp: ts << "top-up"; break;
-    case ApplePayButtonType::Order: ts << "order"; break;
-    case ApplePayButtonType::Rent: ts << "rent"; break;
-    case ApplePayButtonType::Support: ts << "support"; break;
-    case ApplePayButtonType::Contribute: ts << "contribute"; break;
-    case ApplePayButtonType::Tip: ts << "tip"; break;
-#endif
-    }
-    return ts;
-}
-#endif
-
 TextStream& operator<<(TextStream& ts, AspectRatioType aspectRatioType)
 {
     switch (aspectRatioType) {

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (290812 => 290813)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -1161,34 +1161,6 @@
 };
 #endif
 
-#if ENABLE(APPLE_PAY)
-enum class ApplePayButtonStyle : uint8_t {
-    White,
-    WhiteOutline,
-    Black,
-};
-
-enum class ApplePayButtonType : uint8_t {
-    Plain,
-    Buy,
-    SetUp,
-    Donate,
-    CheckOut,
-    Book,
-    Subscribe,
-#if ENABLE(APPLE_PAY_NEW_BUTTON_TYPES)
-    Reload,
-    AddMoney,
-    TopUp,
-    Order,
-    Rent,
-    Support,
-    Contribute,
-    Tip,
-#endif
-};
-#endif
-
 // These are all minimized combinations of paint-order.
 enum class PaintOrder : uint8_t {
     Normal,
@@ -1244,10 +1216,6 @@
 
 WTF::TextStream& operator<<(WTF::TextStream&, AnimationFillMode);
 WTF::TextStream& operator<<(WTF::TextStream&, AnimationPlayState);
-#if ENABLE(APPLE_PAY)
-WTF::TextStream& operator<<(WTF::TextStream&, ApplePayButtonStyle);
-WTF::TextStream& operator<<(WTF::TextStream&, ApplePayButtonType);
-#endif
 WTF::TextStream& operator<<(WTF::TextStream&, AspectRatioType);
 WTF::TextStream& operator<<(WTF::TextStream&, AutoRepeatType);
 WTF::TextStream& operator<<(WTF::TextStream&, BackfaceVisibility);

Modified: trunk/Source/WebKit/ChangeLog (290812 => 290813)


--- trunk/Source/WebKit/ChangeLog	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/ChangeLog	2022-03-04 04:08:26 UTC (rev 290813)
@@ -1,3 +1,31 @@
+2022-03-03  Devin Rousso  <drou...@apple.com>
+
+        [GPU Process] dont load Apple Pay button/logo PDFs in the WebProcess
+        https://bugs.webkit.org/show_bug.cgi?id=237177
+
+        Reviewed by Simon Fraser.
+
+        See `Source/WebCore/ChangeLog` for an explanation of `SystemImage`.
+
+        * Shared/WebCoreArgumentCoders.h:
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<Ref<SystemImage>>::encode): Added.
+        (IPC::ArgumentCoder<Ref<SystemImage>>::decode): Added.
+        Support sending `SystemImage` (technically `Ref<SystemImage>`) across processes.
+
+        * GPUProcess/graphics/RemoteDisplayListRecorder.messages.in:
+        * GPUProcess/graphics/RemoteDisplayListRecorder.h:
+        * GPUProcess/graphics/RemoteDisplayListRecorder.cpp:
+        (WebKit::RemoteDisplayListRecorder::drawSystemImage): Added.
+        * WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:
+        * WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:
+        (WebKit::RemoteDisplayListRecorderProxy::recordDrawSystemImage): Addded.
+        Add new `DrawSystemImage` display list item.
+
+        * Scripts/webkit/messages.py:
+        (class_template_headers):
+        Add support for `Ref<T>` in IPC messages.
+
 2022-03-03  Michael Saboff  <msab...@apple.com>
 
         Copy WebKit frameworks and XPC processes to Secondary Path

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp (290812 => 290813)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -283,6 +283,11 @@
     handleItem(DisplayList::DrawNativeImage(imageIdentifier.object(), imageSize, destRect, srcRect, options), *image);
 }
 
+void RemoteDisplayListRecorder::drawSystemImage(SystemImage& systemImage, const FloatRect& destinationRect)
+{
+    handleItem(DisplayList::DrawSystemImage(systemImage, destinationRect));
+}
+
 void RemoteDisplayListRecorder::drawPattern(RenderingResourceIdentifier imageIdentifier, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
 {
     // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h (290812 => 290813)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -82,6 +82,7 @@
     void drawFilteredImageBuffer(std::optional<WebCore::RenderingResourceIdentifier> sourceImageIdentifier, const WebCore::FloatRect& sourceImageRect, IPC::FilterReference);
     void drawImageBuffer(WebCore::RenderingResourceIdentifier imageBufferIdentifier, const WebCore::FloatRect& destinationRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&);
     void drawNativeImage(WebCore::RenderingResourceIdentifier imageIdentifier, const WebCore::FloatSize& imageSize, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&);
+    void drawSystemImage(WebCore::SystemImage&, const WebCore::FloatRect&);
     void drawPattern(WebCore::RenderingResourceIdentifier imageIdentifier, const WebCore::FloatRect& destRect, const WebCore::FloatRect& tileRect, const WebCore::AffineTransform&, const WebCore::FloatPoint&, const WebCore::FloatSize& spacing, const WebCore::ImagePaintingOptions&);
     void beginTransparencyLayer(float opacity);
     void endTransparencyLayer();

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.messages.in (290812 => 290813)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.messages.in	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.messages.in	2022-03-04 04:08:26 UTC (rev 290813)
@@ -48,6 +48,7 @@
     DrawFilteredImageBuffer(std::optional<WebCore::RenderingResourceIdentifier> sourceImageIdentifier, WebCore::FloatRect sourceImageRect, IPC::FilterReference filter)
     DrawImageBuffer(WebCore::RenderingResourceIdentifier imageBufferIdentifier, WebCore::FloatRect destinationRect, WebCore::FloatRect srcRect, struct WebCore::ImagePaintingOptions options)
     DrawNativeImage(WebCore::RenderingResourceIdentifier imageIdentifier, WebCore::FloatSize imageSize, WebCore::FloatRect destRect, WebCore::FloatRect srcRect, struct WebCore::ImagePaintingOptions options)
+    DrawSystemImage(Ref<WebCore::SystemImage> systemImage, WebCore::FloatRect destinationRect)
     DrawPattern(WebCore::RenderingResourceIdentifier imageIdentifier, WebCore::FloatRect destRect, WebCore::FloatRect tileRect, WebCore::AffineTransform transform, WebCore::FloatPoint phase, WebCore::FloatSize spacing, struct WebCore::ImagePaintingOptions options)
     BeginTransparencyLayer(float opacity)
     EndTransparencyLayer()

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (290812 => 290813)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2022-03-04 04:08:26 UTC (rev 290813)
@@ -637,6 +637,7 @@
         'std::optional': {'headers': ['<optional>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
         'std::pair': {'headers': ['<utility>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
         'IPC::ArrayReference': {'headers': ['"ArrayReference.h"'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
+        'Ref': {'headers': ['<wtf/Ref.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
         'RefPtr': {'headers': ['<wtf/RefCounted.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
         'RetainPtr': {'headers': ['<wtf/RetainPtr.h>'], 'argument_coder_headers': ['"ArgumentCodersCF.h"']},
     }

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (290812 => 290813)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -31,7 +31,10 @@
 #include "StreamConnectionEncoder.h"
 #include <_javascript_Core/GenericTypedArrayViewInlines.h>
 #include <_javascript_Core/JSGenericTypedArrayViewInlines.h>
+#include <WebCore/ApplePayButtonSystemImage.h>
+#include <WebCore/ApplePayLogoSystemImage.h>
 #include <WebCore/AuthenticationChallenge.h>
+#include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/BlobPart.h>
 #include <WebCore/CacheQueryOptions.h>
 #include <WebCore/CacheStorageConnection.h>
@@ -84,6 +87,7 @@
 #include <WebCore/ServiceWorkerData.h>
 #include <WebCore/ShareData.h>
 #include <WebCore/SharedBuffer.h>
+#include <WebCore/SystemImage.h>
 #include <WebCore/TextCheckerClient.h>
 #include <WebCore/TextIndicator.h>
 #include <WebCore/TimingFunction.h>
@@ -3175,6 +3179,52 @@
     return WebCore::ScriptBuffer { WTFMove(buffer) };
 }
 
+template<typename Encoder>
+void ArgumentCoder<Ref<SystemImage>>::encode(Encoder& encoder, const Ref<SystemImage>& systemImage)
+{
+    encoder << systemImage->systemImageType();
+
+    switch (systemImage->systemImageType()) {
+#if ENABLE(APPLE_PAY)
+    case SystemImageType::ApplePayButton:
+        downcast<ApplePayButtonSystemImage>(systemImage.get()).encode(encoder);
+        return;
+
+    case SystemImageType::ApplePayLogo:
+        downcast<ApplePayLogoSystemImage>(systemImage.get()).encode(encoder);
+        return;
+#endif
+    }
+
+    ASSERT_NOT_REACHED();
+}
+
+template
+void ArgumentCoder<Ref<SystemImage>>::encode<Encoder>(Encoder&, const Ref<SystemImage>&);
+template
+void ArgumentCoder<Ref<SystemImage>>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, const Ref<SystemImage>&);
+
+std::optional<Ref<SystemImage>> ArgumentCoder<Ref<SystemImage>>::decode(Decoder& decoder)
+{
+    std::optional<SystemImageType> systemImageType;
+    decoder >> systemImageType;
+    if (!systemImageType)
+        return std::nullopt;
+
+    switch (*systemImageType) {
+#if ENABLE(APPLE_PAY)
+    case SystemImageType::ApplePayButton:
+        return ApplePayButtonSystemImage::decode(decoder);
+
+    case SystemImageType::ApplePayLogo:
+        return ApplePayLogoSystemImage::decode(decoder);
+#endif
+    }
+
+    ASSERT_NOT_REACHED();
+    return std::nullopt;
+}
+
 #if ENABLE(ENCRYPTED_MEDIA)
 void ArgumentCoder<WebCore::CDMInstanceSession::Message>::encode(Encoder& encoder, const WebCore::CDMInstanceSession::Message& message)
 {

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (290812 => 290813)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -144,6 +144,7 @@
 class SpringTimingFunction;
 class StepsTimingFunction;
 class StickyPositionViewportConstraints;
+class SystemImage;
 class TextCheckingRequestData;
 class TransformationMatrix;
 class UserStyleSheet;
@@ -772,6 +773,12 @@
     static std::optional<WebCore::ScriptBuffer> decode(Decoder&);
 };
 
+template<> struct ArgumentCoder<Ref<WebCore::SystemImage>> {
+    template<typename Encoder>
+    static void encode(Encoder&, const Ref<WebCore::SystemImage>&);
+    static std::optional<Ref<WebCore::SystemImage>> decode(Decoder&);
+};
+
 #if ENABLE(DATA_DETECTION)
 
 template<> struct ArgumentCoder<WebCore::DataDetectorElementInfo> {

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp (290812 => 290813)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp	2022-03-04 04:08:26 UTC (rev 290813)
@@ -195,6 +195,11 @@
     send(Messages::RemoteDisplayListRecorder::DrawNativeImage(imageIdentifier, imageSize, destRect, srcRect, options));
 }
 
+void RemoteDisplayListRecorderProxy::recordDrawSystemImage(SystemImage& systemImage, const FloatRect& destinationRect)
+{
+    send(Messages::RemoteDisplayListRecorder::DrawSystemImage(systemImage, destinationRect));
+}
+
 void RemoteDisplayListRecorderProxy::recordDrawPattern(RenderingResourceIdentifier imageIdentifier, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
 {
     send(Messages::RemoteDisplayListRecorder::DrawPattern(imageIdentifier, destRect, tileRect, transform, phase, spacing, options));

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h (290812 => 290813)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h	2022-03-04 02:54:00 UTC (rev 290812)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h	2022-03-04 04:08:26 UTC (rev 290813)
@@ -89,6 +89,7 @@
     void recordDrawGlyphs(const WebCore::Font&, const WebCore::GlyphBufferGlyph*, const WebCore::GlyphBufferAdvance*, unsigned count, const WebCore::FloatPoint& localAnchor, WebCore::FontSmoothingMode) final;
     void recordDrawImageBuffer(WebCore::ImageBuffer&, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&) final;
     void recordDrawNativeImage(WebCore::RenderingResourceIdentifier imageIdentifier, const WebCore::FloatSize& imageSize, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&) final;
+    void recordDrawSystemImage(WebCore::SystemImage&, const WebCore::FloatRect&);
     void recordDrawPattern(WebCore::RenderingResourceIdentifier, const WebCore::FloatRect& destRect, const WebCore::FloatRect& tileRect, const WebCore::AffineTransform&, const WebCore::FloatPoint& phase, const WebCore::FloatSize& spacing, const WebCore::ImagePaintingOptions& = { }) final;
     void recordBeginTransparencyLayer(float) final;
     void recordEndTransparencyLayer() final;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to