Changeset 202504 in webkit


Ignore:
Timestamp:
Jun 27, 2016 12:06:21 PM (8 years ago)
Author:
andersca@apple.com
Message:

Discounted items are displayed with positive values
https://bugs.webkit.org/show_bug.cgi?id=159160
rdar://problem/26980772

Reviewed by Dean Jackson.

  • UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:

(WebKit::toDecimalNumber):
Add new helper function. Correctly compute the mantissa.

(WebKit::toPKPaymentSummaryItem):
(WebKit::toPKShippingMethod):
Use toDecimalNumber.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r202484 r202504  
     12016-06-27  Anders Carlsson  <andersca@apple.com>
     2
     3        Discounted items are displayed with positive values
     4        https://bugs.webkit.org/show_bug.cgi?id=159160
     5        rdar://problem/26980772
     6
     7        Reviewed by Dean Jackson.
     8
     9        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
     10        (WebKit::toDecimalNumber):
     11        Add new helper function. Correctly compute the mantissa.
     12
     13        (WebKit::toPKPaymentSummaryItem):
     14        (WebKit::toPKShippingMethod):
     15        Use toDecimalNumber.
     16
    1172016-06-27  Miguel Gomez  <magomez@igalia.com>
    218
  • trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm

    r202432 r202504  
    258258}
    259259
     260static RetainPtr<NSDecimalNumber> toDecimalNumber(int64_t value)
     261{
     262    return adoptNS([[NSDecimalNumber alloc] initWithMantissa:llabs(value) exponent:-2 isNegative:value < 0]);
     263}
     264
    260265static RetainPtr<PKPaymentSummaryItem> toPKPaymentSummaryItem(const WebCore::PaymentRequest::LineItem& lineItem)
    261266{
    262     auto amount = adoptNS([[NSDecimalNumber alloc] initWithMantissa:lineItem.amount.valueOr(0) exponent:-2 isNegative:*lineItem.amount < 0]);
    263 
    264     return [getPKPaymentSummaryItemClass() summaryItemWithLabel:lineItem.label amount:amount.get() type:toPKPaymentSummaryItemType(lineItem.type)];
     267    return [getPKPaymentSummaryItemClass() summaryItemWithLabel:lineItem.label amount:toDecimalNumber(lineItem.amount.valueOr(0)).get() type:toPKPaymentSummaryItemType(lineItem.type)];
    265268}
    266269
     
    321324static RetainPtr<PKShippingMethod> toPKShippingMethod(const WebCore::PaymentRequest::ShippingMethod& shippingMethod)
    322325{
    323     auto amount = adoptNS([[NSDecimalNumber alloc] initWithMantissa:shippingMethod.amount exponent:-2 isNegative:NO]);
    324 
    325     RetainPtr<PKShippingMethod> result = [getPKShippingMethodClass() summaryItemWithLabel:shippingMethod.label amount:amount.get()];
     326    RetainPtr<PKShippingMethod> result = [getPKShippingMethodClass() summaryItemWithLabel:shippingMethod.label amount:toDecimalNumber(shippingMethod.amount).get()];
    326327    [result setIdentifier:shippingMethod.identifier];
    327328    [result setDetail:shippingMethod.detail];
Note: See TracChangeset for help on using the changeset viewer.