Ignore:
Timestamp:
Sep 15, 2016, 10:45:56 AM (9 years ago)
Author:
andersca@apple.com
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r201498 r205980  
    615615    case ImageControlsButtonPart:
    616616        m_value.valueID = CSSValueImageControlsButton;
     617        break;
     618#endif
     619#if ENABLE(APPLE_PAY)
     620    case ApplePayButtonPart:
     621        m_value.valueID = CSSValueApplePayButton;
    617622        break;
    618623#endif
     
    54745479#endif
    54755480
     5481#if ENABLE(APPLE_PAY)
     5482template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ApplePayButtonStyle e)
     5483    : CSSValue(PrimitiveClass)
     5484{
     5485    m_primitiveUnitType = CSS_VALUE_ID;
     5486    switch (e) {
     5487    case ApplePayButtonStyle::White:
     5488        m_value.valueID = CSSValueWhite;
     5489        break;
     5490    case ApplePayButtonStyle::WhiteOutline:
     5491        m_value.valueID = CSSValueWhiteOutline;
     5492        break;
     5493    case ApplePayButtonStyle::Black:
     5494        m_value.valueID = CSSValueBlack;
     5495        break;
     5496    default:
     5497        ASSERT_NOT_REACHED();
     5498        break;
     5499    }
     5500}
     5501
     5502template<> inline CSSPrimitiveValue::operator ApplePayButtonStyle() const
     5503{
     5504    ASSERT(isValueID());
     5505    switch (m_value.valueID) {
     5506    case CSSValueWhite:
     5507        return ApplePayButtonStyle::White;
     5508    case CSSValueWhiteOutline:
     5509        return ApplePayButtonStyle::WhiteOutline;
     5510    case CSSValueBlack:
     5511        return ApplePayButtonStyle::Black;
     5512    default:
     5513        break;
     5514    }
     5515    ASSERT_NOT_REACHED();
     5516    return ApplePayButtonStyle::Black;
     5517}
     5518
     5519template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ApplePayButtonType e)
     5520    : CSSValue(PrimitiveClass)
     5521{
     5522    m_primitiveUnitType = CSS_VALUE_ID;
     5523    switch (e) {
     5524    case ApplePayButtonType::Plain:
     5525        m_value.valueID = CSSValuePlain;
     5526        break;
     5527    case ApplePayButtonType::Buy:
     5528        m_value.valueID = CSSValueBuy;
     5529        break;
     5530    case ApplePayButtonType::SetUp:
     5531        m_value.valueID = CSSValueSetUp;
     5532        break;
     5533    case ApplePayButtonType::InStore:
     5534        m_value.valueID = CSSValueInStore;
     5535        break;
     5536    default:
     5537        ASSERT_NOT_REACHED();
     5538        break;
     5539    }
     5540}
     5541
     5542template<> inline CSSPrimitiveValue::operator ApplePayButtonType() const
     5543{
     5544    ASSERT(isValueID());
     5545    switch (m_value.valueID) {
     5546    case CSSValuePlain:
     5547        return ApplePayButtonType::Plain;
     5548    case CSSValueBuy:
     5549        return ApplePayButtonType::Buy;
     5550    case CSSValueSetUp:
     5551        return ApplePayButtonType::SetUp;
     5552    case CSSValueInStore:
     5553        return ApplePayButtonType::InStore;
     5554    default:
     5555        break;
     5556    }
     5557    ASSERT_NOT_REACHED();
     5558    return ApplePayButtonType::Plain;
     5559}
     5560#endif
     5561
    54765562template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontVariantPosition position)
    54775563    : CSSValue(PrimitiveClass)
Note: See TracChangeset for help on using the changeset viewer.