WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
175755
[Payment Request] Implement the PaymentRequest constructor
https://bugs.webkit.org/show_bug.cgi?id=175755
Summary
[Payment Request] Implement the PaymentRequest constructor
Andy Estes
Reported
2017-08-20 01:49:52 PDT
[Payment Request] Implement the PaymentRequest constructor
Attachments
Patch
(122.49 KB, patch)
2017-08-20 03:37 PDT
,
Andy Estes
no flags
Details
Formatted Diff
Diff
Patch
(115.46 KB, patch)
2017-08-20 20:36 PDT
,
Andy Estes
no flags
Details
Formatted Diff
Diff
Patch
(115.49 KB, patch)
2017-08-20 20:37 PDT
,
Andy Estes
no flags
Details
Formatted Diff
Diff
Patch
(115.53 KB, patch)
2017-08-21 09:58 PDT
,
Andy Estes
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Andy Estes
Comment 1
2017-08-20 03:37:04 PDT
Comment hidden (obsolete)
Created
attachment 318601
[details]
Patch
Build Bot
Comment 2
2017-08-20 03:39:57 PDT
Comment hidden (obsolete)
Attachment 318601
[details]
did not pass style-queue: ERROR: Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:123: Code inside a namespace should not be indented. [whitespace/indent] [4] Total errors found: 1 in 14 files If any of these errors are false positives, please file a bug against check-webkit-style.
Sam Weinig
Comment 3
2017-08-20 12:20:16 PDT
Comment on
attachment 318601
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=318601&action=review
> Source/WebCore/Modules/paymentrequest/PaymentCurrencyAmount.cpp:33 > +static bool isValidCurrency(const String& currency)
I think adding a comment indicating this is the IsWellFormedCurrencyCode operation (and a link) would be helpful). Also, given that is an ECMA script concept, does an implementation of this concept exist in JSC already?
> Source/WebCore/Modules/paymentrequest/PaymentCurrencyAmount.cpp:47 > +static bool isValidDecimalMonetaryValue(const String& value)
Again, annotating what part of the spec this is implementing would be helpful. (Same for other functions below).
> Source/WebCore/Modules/paymentrequest/PaymentCurrencyAmount.h:40 > + ExceptionOr<void> validate();
I've been trying to keep these structs that map to dictionaries as pure data types, but I am not sure I have great reason why. In cases like this, I made the function global, and took the dictionary as a parameter. If this is only used from PaymentRequest.cpp, I might even just make this a static in there.
> Source/WebCore/Modules/paymentrequest/PaymentDetailsModifier.idl:32 > + JSON data;
I think it would be worth noting that the spec has the an object. I'm not sure if this change is exactly right, with respect to exceptions. The JSON type will throw on dictionary conversion if the type cannot be converted or otherwise. That is probably not the correct time to throw.
> Source/WebCore/Modules/paymentrequest/PaymentMethodData.idl:30 > - object data; > + JSON data;
Same comment as in PaymentDetailsModifier.idl.
> Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:67 > + // FIXME: Rethrow any exceptions that occurred while stringifying paymentMethod.data.
I am not sure you will have made it here if stringifying paymentMethod.data threw an exception.
> Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:99 > + modifierData.reserveCapacity(paymentDetails.modifiers.size());
You can use reserveInitialCapacity here.
> Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:113 > + // FIXME: Rethrow any exceptions that occurred while stringifying paymentMethod.data.
I am not sure you will have made it here if stringifying paymentMethod.data threw an exception.
Andy Estes
Comment 4
2017-08-20 15:54:53 PDT
(In reply to Sam Weinig from
comment #3
)
> Comment on
attachment 318601
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=318601&action=review
> > > Source/WebCore/Modules/paymentrequest/PaymentDetailsModifier.idl:32 > > + JSON data; > > I'm not sure if this change is exactly right, with respect to exceptions. > The JSON type will throw on dictionary conversion if the type cannot be > converted or otherwise. That is probably not the correct time to throw.
I think you're right. I was under the impression that the bindings for JSON wouldn't throw on errors but would just give a null String instead. I'm probably wrong about that. I'll take another pass and try to get the JSON stringification correct. I'll also address your other comments. Thanks for taking a look!
Andy Estes
Comment 5
2017-08-20 19:44:13 PDT
(In reply to Sam Weinig from
comment #3
)
> Comment on
attachment 318601
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=318601&action=review
> > > Source/WebCore/Modules/paymentrequest/PaymentCurrencyAmount.cpp:33 > > +static bool isValidCurrency(const String& currency) > > Also, given that is an ECMA script concept, does an implementation of this concept exist in JSC already?
There is an implementation in IntlNumberFormat, but I couldn't see how to easily reuse it. It's a simple algorithm, so I didn't feel too bad about duplicating it.
Andy Estes
Comment 6
2017-08-20 20:36:59 PDT
Comment hidden (obsolete)
Created
attachment 318611
[details]
Patch
Andy Estes
Comment 7
2017-08-20 20:37:56 PDT
Comment hidden (obsolete)
Created
attachment 318612
[details]
Patch
Build Bot
Comment 8
2017-08-20 20:39:10 PDT
Comment hidden (obsolete)
Attachment 318612
[details]
did not pass style-queue: ERROR: Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:246: Code inside a namespace should not be indented. [whitespace/indent] [4] Total errors found: 1 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 9
2017-08-21 09:04:07 PDT
Comment on
attachment 318612
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=318612&action=review
> Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:55 > +static bool isValidDecimalMonetaryValue(const String& value)
Should take a StringView.
> Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:66 > + for (unsigned i = 0; i < value.length(); ++i) {
Should use a modern for loop since StringView offers that: for (auto character : value.codeUnits()) {
Andy Estes
Comment 10
2017-08-21 09:58:04 PDT
Comment hidden (obsolete)
Created
attachment 318640
[details]
Patch
Build Bot
Comment 11
2017-08-21 10:00:19 PDT
Comment hidden (obsolete)
Attachment 318640
[details]
did not pass style-queue: ERROR: Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:245: Code inside a namespace should not be indented. [whitespace/indent] [4] Total errors found: 1 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 12
2017-08-21 10:41:08 PDT
Comment on
attachment 318640
[details]
Patch Clearing flags on attachment: 318640 Committed
r220971
: <
http://trac.webkit.org/changeset/220971
>
WebKit Commit Bot
Comment 13
2017-08-21 10:41:10 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 14
2017-08-21 10:42:00 PDT
<
rdar://problem/33994157
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug