Title: [206668] branches/safari-602-branch/Source/WebCore
Revision
206668
Author
bshaf...@apple.com
Date
2016-09-30 14:19:31 -0700 (Fri, 30 Sep 2016)

Log Message

Merge r205980. rdar://problem/28567557

Modified Paths

Added Paths

Diff

Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/ChangeLog	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog	2016-09-30 21:19:31 UTC (rev 206668)
@@ -1,3 +1,102 @@
+2016-09-30  Babak Shafiei  <bshaf...@apple.com>
+
+        Merge r205980. rdar://problem/28567557
+
+    2016-09-14  Anders Carlsson  <ander...@apple.com>
+
+            Add CSS -webkit-appearance property for Apple Pay buttons
+            https://bugs.webkit.org/show_bug.cgi?id=161986
+
+            Reviewed by Dean Jackson.
+
+            Add a new -webkit-appearance property, "-apple-pay-button".
+            Also, add two properties, "-apple-pay-button-type" and "-apple-pay-button-style".
+
+            * WebCore.xcodeproj/project.pbxproj:
+            Add RenderThemeCocoa.h and RenderThemeCocoa.mm.
+
+            * css/CSSComputedStyleDeclaration.cpp:
+            (WebCore::ComputedStyleExtractor::propertyValue):
+            Handle CSSPropertyApplePayButtonStyle and CSSPropertyApplePayButtonType.
+
+            * css/CSSPrimitiveValueMappings.h:
+            (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+            (WebCore::CSSPrimitiveValue::operator ApplePayButtonStyle):
+            (WebCore::CSSPrimitiveValue::operator ApplePayButtonType):
+            Add ApplePayButtonStyle and ApplePayButtonType conversion routines.
+
+            * css/CSSPropertyNames.in:
+            Add -apple-pay-button-style and -apple-pay-button-type.
+
+            * css/CSSValueKeywords.in:
+            Add CSS values.
+
+            * css/parser/CSSParser.cpp:
+            (WebCore::isValidKeywordPropertyAndValue):
+            Handle CSSPropertyApplePayButtonStyle and CSSPropertyApplePayButtonType.
+
+            * css/parser/CSSParserFastPaths.cpp:
+            (WebCore::CSSParserFastPaths::isKeywordPropertyID):
+            Handle CSSPropertyApplePayButtonStyle and CSSPropertyApplePayButtonType.
+
+            (WebCore::isAppleLegacyCSSPropertyKeyword):
+            New function that returns whether the CSS property should be rewritten to -webkit-.
+            We want to rewrite -apple- but not -apple-pay-.
+
+            (WebCore::cssPropertyID):
+            Use the newly added isAppleLegacyCSSPropertyKeyword.
+
+            (WebCore::isAppleLegacyCSSValueKeyword):
+            Check for "-apple-pay-" in addition to "-apple-system-".
+
+            * platform/ThemeTypes.h:
+            Add ApplePayButtonPart.
+
+            * platform/spi/cocoa/PassKitSPI.h:
+            Add PKDrawApplePayButton declaration.
+
+            * rendering/RenderTheme.cpp:
+            (WebCore::RenderTheme::adjustStyle):
+            Handle ApplePayButtonPart.
+
+            (WebCore::RenderTheme::paint):
+            Handle ApplePayButtonPart.
+
+            * rendering/RenderTheme.h:
+            (WebCore::RenderTheme::adjustApplePayButtonStyle):
+            (WebCore::RenderTheme::paintApplePayButton):
+            Add new functions.
+
+            * rendering/RenderThemeCocoa.h: Added.
+            * rendering/RenderThemeCocoa.mm: Added.
+            (WebCore::RenderThemeCocoa::adjustApplePayButtonStyle):
+            Adjust the minimum width and minimum height accordingly.
+
+            (WebCore::toPKPaymentButtonStyle):
+            (WebCore::toPKPaymentButtonType):
+            Helper functions that convert our WebCore types to PK types.
+
+            (WebCore::RenderThemeCocoa::paintApplePayButton):
+            Call PKDrawApplePayButton.
+
+            * rendering/RenderThemeIOS.h:
+            * rendering/RenderThemeMac.h:
+            Inherit from RenderThemeCocoa.
+
+            * rendering/style/RenderStyle.h:
+            (WebCore::RenderStyle::applePayButtonStyle):
+            (WebCore::RenderStyle::applePayButtonType):
+            (WebCore::RenderStyle::setApplePayButtonStyle):
+            (WebCore::RenderStyle::setApplePayButtonType):
+            (WebCore::RenderStyle::initialApplePayButtonStyle):
+            (WebCore::RenderStyle::initialApplePayButtonType):
+            * rendering/style/RenderStyleConstants.h:
+            * rendering/style/StyleRareInheritedData.cpp:
+            (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+            (WebCore::StyleRareInheritedData::operator==):
+            * rendering/style/StyleRareInheritedData.h:
+            Add new style members for the button style and button type properties.
+
 2016-09-29  Babak Shafiei  <bshaf...@apple.com>
 
         Merge r206556. rdar://problem/28524440

Modified: branches/safari-602-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-09-30 21:19:31 UTC (rev 206668)
@@ -697,6 +697,8 @@
 		1A22464E0CC98DDB00C05240 /* SQLiteTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2246480CC98DDB00C05240 /* SQLiteTransaction.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A24844D1D1A272A00F56BA7 /* PaymentHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24844C1D1A270100F56BA7 /* PaymentHeaders.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A250E0D1CDD632000D0BE63 /* LinkIconType.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A250E0C1CDD632000D0BE63 /* LinkIconType.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1A299FE71D7F5FA600A60093 /* RenderThemeCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A299FE51D7F5FA600A60093 /* RenderThemeCocoa.mm */; };
+		1A299FE81D7F5FA600A60093 /* RenderThemeCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A299FE61D7F5FA600A60093 /* RenderThemeCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A2A68230B5BEDE70002A480 /* ProgressTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A68210B5BEDE70002A480 /* ProgressTracker.cpp */; };
 		1A2A68240B5BEDE70002A480 /* ProgressTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2A68220B5BEDE70002A480 /* ProgressTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A2AAC580DC2A3B100A20D9A /* ApplicationCacheStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2AAC560DC2A3B100A20D9A /* ApplicationCacheStorage.cpp */; };
@@ -8208,6 +8210,8 @@
 		1A2246480CC98DDB00C05240 /* SQLiteTransaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLiteTransaction.h; sourceTree = "<group>"; };
 		1A24844C1D1A270100F56BA7 /* PaymentHeaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PaymentHeaders.h; sourceTree = "<group>"; };
 		1A250E0C1CDD632000D0BE63 /* LinkIconType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkIconType.h; sourceTree = "<group>"; };
+		1A299FE51D7F5FA600A60093 /* RenderThemeCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderThemeCocoa.mm; sourceTree = "<group>"; };
+		1A299FE61D7F5FA600A60093 /* RenderThemeCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderThemeCocoa.h; sourceTree = "<group>"; };
 		1A2A68210B5BEDE70002A480 /* ProgressTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ProgressTracker.cpp; sourceTree = "<group>"; };
 		1A2A68220B5BEDE70002A480 /* ProgressTracker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ProgressTracker.h; sourceTree = "<group>"; };
 		1A2AAC560DC2A3B100A20D9A /* ApplicationCacheStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheStorage.cpp; sourceTree = "<group>"; };
@@ -24404,6 +24408,8 @@
 				E4C91A15180999F100A17F6D /* RenderTextLineBoxes.h */,
 				BCEA484A097D93020094C9E4 /* RenderTheme.cpp */,
 				BCEA484B097D93020094C9E4 /* RenderTheme.h */,
+				1A299FE61D7F5FA600A60093 /* RenderThemeCocoa.h */,
+				1A299FE51D7F5FA600A60093 /* RenderThemeCocoa.mm */,
 				FED13D500CEA949700D89466 /* RenderThemeIOS.h */,
 				C55C7BA01718AFBA001327E4 /* RenderThemeIOS.mm */,
 				BCEA4848097D93020094C9E4 /* RenderThemeMac.h */,
@@ -26939,6 +26945,7 @@
 				BC926F810C0552470082776B /* JSHTMLFrameSetElement.h in Headers */,
 				A80E7B150A19D606007FB8C5 /* JSHTMLHeadElement.h in Headers */,
 				1AE2AA2F0A1CDAB400B42B25 /* JSHTMLHeadingElement.h in Headers */,
+				1A299FE81D7F5FA600A60093 /* RenderThemeCocoa.h in Headers */,
 				1AE2AA310A1CDAB400B42B25 /* JSHTMLHRElement.h in Headers */,
 				1A85B1900A1B18A200D8C87C /* JSHTMLHtmlElement.h in Headers */,
 				BC4918C90BFEA050009D6316 /* JSHTMLIFrameElement.h in Headers */,
@@ -29430,6 +29437,7 @@
 				F45C231D1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp in Sources */,
 				37F57ACF1A5072DD00876F98 /* AXObjectCache.cpp in Sources */,
 				AAA728F916D1D8BC00D3BBC6 /* AXObjectCacheIOS.mm in Sources */,
+				1A299FE71D7F5FA600A60093 /* RenderThemeCocoa.mm in Sources */,
 				29A8124B0FBB9CA900510293 /* AXObjectCacheMac.mm in Sources */,
 				BCA8C81F11E3D36900812FB7 /* BackForwardController.cpp in Sources */,
 				BCA8CA5F11E4E6D100812FB7 /* BackForwardList.cpp in Sources */,

Modified: branches/safari-602-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2016-09-30 21:19:31 UTC (rev 206668)
@@ -3765,6 +3765,13 @@
             return cssValuePool.createValue(style->trailingWord());
 #endif
 
+#if ENABLE(APPLE_PAY)
+        case CSSPropertyApplePayButtonStyle:
+            return cssValuePool.createValue(style->applePayButtonStyle());
+        case CSSPropertyApplePayButtonType:
+            return cssValuePool.createValue(style->applePayButtonType());
+#endif
+
         /* Individual properties not part of the spec */
         case CSSPropertyBackgroundRepeatX:
         case CSSPropertyBackgroundRepeatY:

Modified: branches/safari-602-branch/Source/WebCore/css/CSSParser.cpp (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/css/CSSParser.cpp	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/css/CSSParser.cpp	2016-09-30 21:19:31 UTC (rev 206668)
@@ -984,6 +984,16 @@
             return true;
         break;
 #endif
+#if ENABLE(APPLE_PAY)
+    case CSSPropertyApplePayButtonStyle: // white | white-outline | black
+        if (valueID == CSSValueWhite || valueID == CSSValueWhiteOutline || valueID == CSSValueBlack)
+            return true;
+        break;
+    case CSSPropertyApplePayButtonType: // plain | buy | set-up | in-store
+        if (valueID == CSSValuePlain || valueID == CSSValueBuy || valueID == CSSValueSetUp || valueID == CSSValueInStore)
+            return true;
+        break;
+#endif
     case CSSPropertyFontVariantPosition: // normal | sub | super
         if (valueID == CSSValueNormal || valueID == CSSValueSub || valueID == CSSValueSuper)
             return true;
@@ -13552,6 +13562,17 @@
 }
 #endif
 
+#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES)
+static bool isAppleLegacyCSSPropertyKeyword(const char* propertyKeyword, unsigned length)
+{
+    static const char applePrefix[] = "-apple-";
+    static const char applePayPrefix[] = "-apple-pay-";
+
+    return hasPrefix(propertyKeyword, length, applePrefix)
+        && !hasPrefix(propertyKeyword, length, applePayPrefix);
+}
+#endif
+
 template <typename CharacterType>
 static CSSPropertyID cssPropertyID(const CharacterType* propertyName, unsigned length)
 {
@@ -13571,7 +13592,7 @@
         // If the prefix is -apple- or -khtml-, change it to -webkit-.
         // This makes the string one character longer.
         if (RuntimeEnabledFeatures::sharedFeatures().legacyCSSVendorPrefixesEnabled()
-            && (hasPrefix(buffer, length, "-apple-") || hasPrefix(buffer, length, "-khtml-"))) {
+            && (isAppleLegacyCSSPropertyKeyword(buffer, length) || hasPrefix(buffer, length, "-khtml-"))) {
             memmove(buffer + 7, buffer + 6, length + 1 - 6);
             memcpy(buffer, "-webkit", 7);
             ++length;
@@ -13622,14 +13643,16 @@
 }
 #endif
 
-static bool isAppleLegacyCssValueKeyword(const char* valueKeyword, unsigned length)
+static bool isAppleLegacyCSSValueKeyword(const char* valueKeyword, unsigned length)
 {
     static const char applePrefix[] = "-apple-";
-    static const char appleSystemPrefix[] = "-apple-system";
+    static const char appleSystemPrefix[] = "-apple-system-";
+    static const char applePayPrefix[] = "-apple-pay-";
     static const char* appleWirelessPlaybackTargetActive = getValueName(CSSValueAppleWirelessPlaybackTargetActive);
 
     return hasPrefix(valueKeyword, length, applePrefix)
         && !hasPrefix(valueKeyword, length, appleSystemPrefix)
+        && !hasPrefix(valueKeyword, length, applePayPrefix)
         && !WTF::equal(reinterpret_cast<const LChar*>(valueKeyword), reinterpret_cast<const LChar*>(appleWirelessPlaybackTargetActive), length);
 }
 
@@ -13651,7 +13674,7 @@
         // This makes the string one character longer.
         // On iOS we don't want to change values starting with -apple-system to -webkit-system.
         // FIXME: Remove this mangling without breaking the web.
-        if (isAppleLegacyCssValueKeyword(buffer, length) || hasPrefix(buffer, length, "-khtml-")) {
+        if (isAppleLegacyCSSValueKeyword(buffer, length) || hasPrefix(buffer, length, "-khtml-")) {
             memmove(buffer + 7, buffer + 6, length + 1 - 6);
             memcpy(buffer, "-webkit", 7);
             ++length;

Modified: branches/safari-602-branch/Source/WebCore/css/CSSPrimitiveValueMappings.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/css/CSSPrimitiveValueMappings.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/css/CSSPrimitiveValueMappings.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -616,6 +616,11 @@
         m_value.valueID = CSSValueImageControlsButton;
         break;
 #endif
+#if ENABLE(APPLE_PAY)
+    case ApplePayButtonPart:
+        m_value.valueID = CSSValueApplePayButton;
+        break;
+#endif
     }
 }
 
@@ -5473,6 +5478,87 @@
 }
 #endif
 
+#if ENABLE(APPLE_PAY)
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ApplePayButtonStyle e)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_VALUE_ID;
+    switch (e) {
+    case ApplePayButtonStyle::White:
+        m_value.valueID = CSSValueWhite;
+        break;
+    case ApplePayButtonStyle::WhiteOutline:
+        m_value.valueID = CSSValueWhiteOutline;
+        break;
+    case ApplePayButtonStyle::Black:
+        m_value.valueID = CSSValueBlack;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ApplePayButtonStyle() const
+{
+    ASSERT(isValueID());
+    switch (m_value.valueID) {
+    case CSSValueWhite:
+        return ApplePayButtonStyle::White;
+    case CSSValueWhiteOutline:
+        return ApplePayButtonStyle::WhiteOutline;
+    case CSSValueBlack:
+        return ApplePayButtonStyle::Black;
+    default:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return ApplePayButtonStyle::Black;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ApplePayButtonType e)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_VALUE_ID;
+    switch (e) {
+    case ApplePayButtonType::Plain:
+        m_value.valueID = CSSValuePlain;
+        break;
+    case ApplePayButtonType::Buy:
+        m_value.valueID = CSSValueBuy;
+        break;
+    case ApplePayButtonType::SetUp:
+        m_value.valueID = CSSValueSetUp;
+        break;
+    case ApplePayButtonType::InStore:
+        m_value.valueID = CSSValueInStore;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ApplePayButtonType() const
+{
+    ASSERT(isValueID());
+    switch (m_value.valueID) {
+    case CSSValuePlain:
+        return ApplePayButtonType::Plain;
+    case CSSValueBuy:
+        return ApplePayButtonType::Buy;
+    case CSSValueSetUp:
+        return ApplePayButtonType::SetUp;
+    case CSSValueInStore:
+        return ApplePayButtonType::InStore;
+    default:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return ApplePayButtonType::Plain;
+}
+#endif
+
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontVariantPosition position)
     : CSSValue(PrimitiveClass)
 {

Modified: branches/safari-602-branch/Source/WebCore/css/CSSPropertyNames.in (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/css/CSSPropertyNames.in	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/css/CSSPropertyNames.in	2016-09-30 21:19:31 UTC (rev 206668)
@@ -681,3 +681,8 @@
 #if defined(ENABLE_CSS_TRAILING_WORD) && ENABLE_CSS_TRAILING_WORD
 -apple-trailing-word [Inherited, NameForMethods=TrailingWord]
 #endif
+
+#if defined(ENABLE_APPLE_PAY) && ENABLE_APPLE_PAY
+-apple-pay-button-style
+-apple-pay-button-type
+#endif

Modified: branches/safari-602-branch/Source/WebCore/css/CSSValueKeywords.in (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/css/CSSValueKeywords.in	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/css/CSSValueKeywords.in	2016-09-30 21:19:31 UTC (rev 206668)
@@ -806,6 +806,9 @@
 #if defined(ENABLE_SERVICE_CONTROLS) && ENABLE_SERVICE_CONTROLS
 image-controls-button
 #endif
+#if defined(ENABLE_APPLE_PAY) && ENABLE_APPLE_PAY
+-apple-pay-button
+#endif
 textarea
 #if defined(ENABLE_ATTACHMENT_ELEMENT) && ENABLE_ATTACHMENT_ELEMENT
 attachment
@@ -1179,6 +1182,17 @@
 -webkit-partially-balanced
 #endif
 
+#if defined(ENABLE_APPLE_PAY) && ENABLE_APPLE_PAY
+// -apple-pay-button-style
+white-outline
+
+// -apple-pay-button-type
+plain
+buy
+set-up
+in-store
+#endif
+
 // font-synthesis
 weight
 style

Modified: branches/safari-602-branch/Source/WebCore/platform/ThemeTypes.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/platform/ThemeTypes.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/platform/ThemeTypes.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef ThemeTypes_h
-#define ThemeTypes_h
+#pragma once
 
 namespace WebCore {
 
@@ -49,6 +48,9 @@
 #if ENABLE(SERVICE_CONTROLS)
     ImageControlsButtonPart,
 #endif
+#if ENABLE(APPLE_PAY)
+    ApplePayButtonPart,
+#endif
     TextAreaPart,
 #if ENABLE(ATTACHMENT_ELEMENT)
     AttachmentPart,
@@ -73,4 +75,3 @@
 };
 
 }
-#endif

Modified: branches/safari-602-branch/Source/WebCore/platform/spi/cocoa/PassKitSPI.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/platform/spi/cocoa/PassKitSPI.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/platform/spi/cocoa/PassKitSPI.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -222,3 +222,6 @@
 @end
 
 NS_ASSUME_NONNULL_END
+
+extern "C"
+void PKDrawApplePayButton(_Nonnull CGContextRef, CGRect drawRect, CGFloat scale, PKPaymentButtonType, PKPaymentButtonStyle, NSString * _Nullable languageCode);

Modified: branches/safari-602-branch/Source/WebCore/rendering/RenderTheme.cpp (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/RenderTheme.cpp	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/rendering/RenderTheme.cpp	2016-09-30 21:19:31 UTC (rev 206668)
@@ -253,6 +253,10 @@
 #endif
     case CapsLockIndicatorPart:
         return adjustCapsLockIndicatorStyle(styleResolver, style, element);
+#if ENABLE(APPLE_PAY)
+    case ApplePayButtonPart:
+        return adjustApplePayButtonStyle(styleResolver, style, element);
+#endif
 #if ENABLE(ATTACHMENT_ELEMENT)
     case AttachmentPart:
         return adjustAttachmentStyle(styleResolver, style, element);
@@ -401,6 +405,10 @@
 #endif
     case CapsLockIndicatorPart:
         return paintCapsLockIndicator(box, paintInfo, integralSnappedRect);
+#if ENABLE(APPLE_PAY)
+    case ApplePayButtonPart:
+        return paintApplePayButton(box, paintInfo, integralSnappedRect);
+#endif
 #if ENABLE(ATTACHMENT_ELEMENT)
     case AttachmentPart:
         return paintAttachment(box, paintInfo, integralSnappedRect);

Modified: branches/safari-602-branch/Source/WebCore/rendering/RenderTheme.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/RenderTheme.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/rendering/RenderTheme.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -325,6 +325,11 @@
     virtual void adjustCapsLockIndicatorStyle(StyleResolver&, RenderStyle&, const Element*) const;
     virtual bool paintCapsLockIndicator(const RenderObject&, const PaintInfo&, const IntRect&);
 
+#if ENABLE(APPLE_PAY)
+    virtual void adjustApplePayButtonStyle(StyleResolver&, RenderStyle&, const Element*) const { }
+    virtual bool paintApplePayButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
+#endif
+
 #if ENABLE(ATTACHMENT_ELEMENT)
     virtual void adjustAttachmentStyle(StyleResolver&, RenderStyle&, const Element*) const;
     virtual bool paintAttachment(const RenderObject&, const PaintInfo&, const IntRect&);

Added: branches/safari-602-branch/Source/WebCore/rendering/RenderThemeCocoa.h (0 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/RenderThemeCocoa.h	                        (rev 0)
+++ branches/safari-602-branch/Source/WebCore/rendering/RenderThemeCocoa.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 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 "RenderTheme.h"
+
+namespace WebCore {
+
+class RenderThemeCocoa : public RenderTheme {
+private:
+#if ENABLE(APPLE_PAY)
+    void adjustApplePayButtonStyle(StyleResolver&, RenderStyle&, const Element*) const override;
+    bool paintApplePayButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
+#endif
+};
+
+}

Added: branches/safari-602-branch/Source/WebCore/rendering/RenderThemeCocoa.mm (0 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/RenderThemeCocoa.mm	                        (rev 0)
+++ branches/safari-602-branch/Source/WebCore/rendering/RenderThemeCocoa.mm	2016-09-30 21:19:31 UTC (rev 206668)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RenderThemeCocoa.h"
+
+#if ENABLE(APPLE_PAY)
+
+#include "PassKitSPI.h"
+#include "RenderElement.h"
+#include "RenderStyle.h"
+#include "SoftLinking.h"
+#include "TranslateTransformOperation.h"
+
+#if PLATFORM(MAC)
+SOFT_LINK_PRIVATE_FRAMEWORK(PassKit);
+#else
+SOFT_LINK_FRAMEWORK(PassKit);
+#endif
+
+SOFT_LINK_MAY_FAIL(PassKit, PKDrawApplePayButton, void, (CGContextRef context, CGRect drawRect, CGFloat scale, PKPaymentButtonType type, PKPaymentButtonStyle style, NSString *languageCode), (context, drawRect, scale, type, style, languageCode));
+
+namespace WebCore {
+
+static const auto applePayButtonMinimumWidth = 140;
+static const auto applePayButtonPlainMinimumWidth = 100;
+static const auto applePayButtonMinimumHeight = 30;
+
+void RenderThemeCocoa::adjustApplePayButtonStyle(StyleResolver&, RenderStyle& style, const Element*) const
+{
+    if (style.applePayButtonType() == ApplePayButtonType::Plain)
+        style.setMinWidth(Length(applePayButtonPlainMinimumWidth, Fixed));
+    else
+        style.setMinWidth(Length(applePayButtonMinimumWidth, Fixed));
+    style.setMinHeight(Length(applePayButtonMinimumHeight, Fixed));
+}
+
+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::InStore:
+        return PKPaymentButtonTypeInStore;
+    }
+}
+
+bool RenderThemeCocoa::paintApplePayButton(const RenderObject& renderer, const PaintInfo& paintInfo, const IntRect& paintRect)
+{
+    if (!canLoadPKDrawApplePayButton())
+        return false;
+
+    GraphicsContextStateSaver stateSaver(paintInfo.context());
+
+    paintInfo.context().setShouldSmoothFonts(true);
+    paintInfo.context().scale(FloatSize(1, -1));
+
+    PKDrawApplePayButton(paintInfo.context().platformContext(), CGRectMake(paintRect.x(), -paintRect.maxY(), paintRect.width(), paintRect.height()), 1.0, toPKPaymentButtonType(renderer.style().applePayButtonType()), toPKPaymentButtonStyle(renderer.style().applePayButtonStyle()), renderer.style().locale());
+
+    return false;
+}
+
+}
+
+#endif

Modified: branches/safari-602-branch/Source/WebCore/rendering/RenderThemeIOS.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/RenderThemeIOS.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/rendering/RenderThemeIOS.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -23,12 +23,11 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef RenderThemeIOS_h
-#define RenderThemeIOS_h
+#pragma once
 
 #if PLATFORM(IOS)
 
-#include "RenderTheme.h"
+#include "RenderThemeCocoa.h"
 
 namespace WebCore {
     
@@ -36,7 +35,7 @@
 class GraphicsContext;
 struct AttachmentLayout;
 
-class RenderThemeIOS final : public RenderTheme {
+class RenderThemeIOS final : public RenderThemeCocoa {
 public:
     static Ref<RenderTheme> create();
 
@@ -135,4 +134,3 @@
 }
 
 #endif // PLATFORM(IOS)
-#endif // RenderThemeIOS_h

Modified: branches/safari-602-branch/Source/WebCore/rendering/RenderThemeMac.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/RenderThemeMac.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/rendering/RenderThemeMac.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -19,12 +19,12 @@
  * Boston, MA 02110-1301, USA.
  *
  */
-#if !PLATFORM(IOS)
 
-#ifndef RenderThemeMac_h
-#define RenderThemeMac_h
+#pragma once
 
-#import "RenderTheme.h"
+#if PLATFORM(MAC)
+
+#import "RenderThemeCocoa.h"
 #import <wtf/RetainPtr.h>
 #import <wtf/HashMap.h>
 
@@ -40,7 +40,7 @@
 class RenderStyle;
 struct AttachmentLayout;
 
-class RenderThemeMac final : public RenderTheme {
+class RenderThemeMac final : public RenderThemeCocoa {
 public:
     static Ref<RenderTheme> create();
 
@@ -250,6 +250,4 @@
 
 } // namespace WebCore
 
-#endif // RenderThemeMac_h
-
-#endif // !PLATFORM(IOS)
+#endif // PLATFORM(MAC)

Modified: branches/safari-602-branch/Source/WebCore/rendering/style/RenderStyle.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/style/RenderStyle.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/rendering/style/RenderStyle.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -1219,7 +1219,12 @@
 #if ENABLE(CSS_TRAILING_WORD)
     TrailingWord trailingWord() const { return static_cast<TrailingWord>(rareInheritedData->trailingWord); }
 #endif
-    
+
+#if ENABLE(APPLE_PAY)
+    ApplePayButtonStyle applePayButtonStyle() const { return static_cast<ApplePayButtonStyle>(rareNonInheritedData->m_applePayButtonStyle); }
+    ApplePayButtonType applePayButtonType() const { return static_cast<ApplePayButtonType>(rareNonInheritedData->m_applePayButtonType); }
+#endif
+
     void checkVariablesInCustomProperties();
 
 // attribute setter methods
@@ -1736,6 +1741,11 @@
     void setTrailingWord(TrailingWord v) { SET_VAR(rareInheritedData, trailingWord, static_cast<unsigned>(v)); }
 #endif
 
+#if ENABLE(APPLE_PAY)
+    void setApplePayButtonStyle(ApplePayButtonStyle v) { SET_VAR(rareNonInheritedData, m_applePayButtonStyle, static_cast<unsigned>(v)); }
+    void setApplePayButtonType(ApplePayButtonType v) { SET_VAR(rareNonInheritedData, m_applePayButtonType, static_cast<unsigned>(v)); }
+#endif
+
     const SVGRenderStyle& svgStyle() const { return *m_svgStyle; }
     SVGRenderStyle& accessSVGStyle() { return *m_svgStyle.access(); }
 
@@ -2085,6 +2095,11 @@
     static TrailingWord initialTrailingWord() { return TrailingWord::Auto; }
 #endif
 
+#if ENABLE(APPLE_PAY)
+    static ApplePayButtonStyle initialApplePayButtonStyle() { return ApplePayButtonStyle::Black; }
+    static ApplePayButtonType initialApplePayButtonType() { return ApplePayButtonType::Plain; }
+#endif
+
 #if ENABLE(CSS_GRID_LAYOUT)
     // The initial value is 'none' for grid tracks.
     static Vector<GridTrackSize> initialGridColumns() { return Vector<GridTrackSize>(); }

Modified: branches/safari-602-branch/Source/WebCore/rendering/style/RenderStyleConstants.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/style/RenderStyleConstants.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/rendering/style/RenderStyleConstants.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -696,6 +696,21 @@
 };
 #endif
 
+#if ENABLE(APPLE_PAY)
+enum class ApplePayButtonStyle {
+    White,
+    WhiteOutline,
+    Black,
+};
+
+enum class ApplePayButtonType {
+    Plain,
+    Buy,
+    SetUp,
+    InStore,
+};
+#endif
+
 TextStream& operator<<(TextStream&, EFillSizeType);
 TextStream& operator<<(TextStream&, EFillAttachment);
 TextStream& operator<<(TextStream&, EFillBox);

Modified: branches/safari-602-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2016-09-30 21:19:31 UTC (rev 206668)
@@ -104,6 +104,10 @@
     , m_effectiveBlendMode(RenderStyle::initialBlendMode())
     , m_isolation(RenderStyle::initialIsolation())
 #endif
+#if ENABLE(APPLE_PAY)
+    , m_applePayButtonStyle(static_cast<unsigned>(RenderStyle::initialApplePayButtonStyle()))
+    , m_applePayButtonType(static_cast<unsigned>(RenderStyle::initialApplePayButtonType()))
+#endif
     , m_objectFit(RenderStyle::initialObjectFit())
     , m_breakBefore(RenderStyle::initialBreakBetween())
     , m_breakAfter(RenderStyle::initialBreakBetween())
@@ -200,6 +204,10 @@
     , m_effectiveBlendMode(o.m_effectiveBlendMode)
     , m_isolation(o.m_isolation)
 #endif
+#if ENABLE(APPLE_PAY)
+    , m_applePayButtonStyle(o.m_applePayButtonStyle)
+    , m_applePayButtonType(o.m_applePayButtonType)
+#endif
     , m_objectFit(o.m_objectFit)
     , m_breakBefore(o.m_breakBefore)
     , m_breakAfter(o.m_breakAfter)
@@ -306,6 +314,10 @@
         && m_effectiveBlendMode == o.m_effectiveBlendMode
         && m_isolation == o.m_isolation
 #endif
+#if ENABLE(APPLE_PAY)
+        && m_applePayButtonStyle == o.m_applePayButtonStyle
+        && m_applePayButtonType == o.m_applePayButtonType
+#endif
         && m_aspectRatioType == o.m_aspectRatioType
         && m_objectFit == o.m_objectFit
         && m_breakAfter == o.m_breakAfter

Modified: branches/safari-602-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (206667 => 206668)


--- branches/safari-602-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2016-09-30 21:18:41 UTC (rev 206667)
+++ branches/safari-602-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2016-09-30 21:19:31 UTC (rev 206668)
@@ -22,8 +22,7 @@
  *
  */
 
-#ifndef StyleRareNonInheritedData_h
-#define StyleRareNonInheritedData_h
+#pragma once
 
 #include "BasicShapes.h"
 #include "CSSPropertyNames.h"
@@ -220,6 +219,11 @@
     unsigned m_isolation : 1; // Isolation
 #endif
 
+#if ENABLE(APPLE_PAY)
+    unsigned m_applePayButtonStyle : 2;
+    unsigned m_applePayButtonType : 3;
+#endif
+
     unsigned m_objectFit : 3; // ObjectFit
     
     unsigned m_breakBefore : 4; // BreakBetween
@@ -237,5 +241,3 @@
 };
 
 } // namespace WebCore
-
-#endif // StyleRareNonInheritedData_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to