Title: [210140] trunk/Source/WebCore
Revision
210140
Author
[email protected]
Date
2016-12-23 14:01:12 -0800 (Fri, 23 Dec 2016)

Log Message

Add missing std::optional to ApplePayPaymentRequest.lineItems
https://bugs.webkit.org/show_bug.cgi?id=166468

Patch by Sam Weinig <[email protected]> on 2016-12-23
Reviewed by Alexey Proskuryakov.

No functional change, but is more consistent.

* Modules/applepay/ApplePayPaymentRequest.h:
Remove unnecessary #include of <heap/Strong.h>, add std::optional to lineItems.

* Modules/applepay/ApplePaySession.cpp:
(WebCore::convertAndValidate):
Update to deal with optional line items, remove unnecessary comment.

* Modules/applepay/ApplePaySession.h:
Remove unneeded forward declarations.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (210139 => 210140)


--- trunk/Source/WebCore/ChangeLog	2016-12-23 19:45:46 UTC (rev 210139)
+++ trunk/Source/WebCore/ChangeLog	2016-12-23 22:01:12 UTC (rev 210140)
@@ -1,3 +1,22 @@
+2016-12-23  Sam Weinig  <[email protected]>
+
+        Add missing std::optional to ApplePayPaymentRequest.lineItems
+        https://bugs.webkit.org/show_bug.cgi?id=166468
+
+        Reviewed by Alexey Proskuryakov.
+
+        No functional change, but is more consistent.
+
+        * Modules/applepay/ApplePayPaymentRequest.h:
+        Remove unnecessary #include of <heap/Strong.h>, add std::optional to lineItems.
+
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::convertAndValidate):
+        Update to deal with optional line items, remove unnecessary comment.
+
+        * Modules/applepay/ApplePaySession.h:
+        Remove unneeded forward declarations.
+
 2016-12-22  Sam Weinig  <[email protected]>
 
         [WebIDL] Remove custom bindings for WebSQL code

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h (210139 => 210140)


--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h	2016-12-23 19:45:46 UTC (rev 210139)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h	2016-12-23 22:01:12 UTC (rev 210140)
@@ -31,7 +31,6 @@
 #include "ApplePayPaymentContact.h"
 #include "ApplePayShippingMethod.h"
 #include "PaymentRequest.h"
-#include <heap/Strong.h>
 
 namespace WebCore {
 
@@ -56,7 +55,7 @@
     std::optional<Vector<ApplePayShippingMethod>> shippingMethods;
 
     ApplePayLineItem total;
-    Vector<ApplePayLineItem> lineItems;
+    std::optional<Vector<ApplePayLineItem>> lineItems;
 
     String applicationData;
 };

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (210139 => 210140)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2016-12-23 19:45:46 UTC (rev 210139)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2016-12-23 22:01:12 UTC (rev 210140)
@@ -176,12 +176,15 @@
     return WTFMove(result);
 }
 
-static ExceptionOr<Vector<PaymentRequest::LineItem>> convertAndValidate(Vector<ApplePayLineItem>&& lineItems)
+static ExceptionOr<Vector<PaymentRequest::LineItem>> convertAndValidate(std::optional<Vector<ApplePayLineItem>>&& lineItems)
 {
     Vector<PaymentRequest::LineItem> result;
-    result.reserveInitialCapacity(lineItems.size());
+    if (!lineItems)
+        return WTFMove(result);
+
+    result.reserveInitialCapacity(lineItems->size());
     
-    for (auto lineItem : lineItems) {
+    for (auto lineItem : lineItems.value()) {
         auto convertedLineItem = convertAndValidate(WTFMove(lineItem));
         if (convertedLineItem.hasException())
             return convertedLineItem.releaseException();
@@ -300,7 +303,6 @@
         return total.releaseException();
     result.setTotal(total.releaseReturnValue());
 
-    // FIXME: Should this swallow exceptions like the old code seemed to do?
     auto lineItems = convertAndValidate(WTFMove(paymentRequest.lineItems));
     if (lineItems.hasException())
         return lineItems.releaseException();

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.h (210139 => 210140)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.h	2016-12-23 19:45:46 UTC (rev 210139)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.h	2016-12-23 22:01:12 UTC (rev 210140)
@@ -34,6 +34,11 @@
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 
+namespace JSC {
+class ExecState;
+class JSValue;
+}
+
 namespace WebCore {
 
 class DeferredPromise;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to