Bug 157459 - Change EventSource constructor to take an IDL dictionary instead of a WebCore::Dictionary
Summary: Change EventSource constructor to take an IDL dictionary instead of a WebCore...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on: 157463
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-07 23:19 PDT by Darin Adler
Modified: 2016-05-08 11:46 PDT (History)
11 users (show)

See Also:


Attachments
Patch (7.79 KB, patch)
2016-05-07 23:27 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (33.14 KB, patch)
2016-05-08 10:22 PDT, Darin Adler
cdumez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2016-05-07 23:19:19 PDT
Change EventSource constructor to take an IDL dictionary instead of a WebCore::Dictionary
Comment 1 Darin Adler 2016-05-07 23:27:30 PDT
Created attachment 278355 [details]
Patch
Comment 2 Chris Dumez 2016-05-07 23:34:30 PDT
Comment on attachment 278355 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278355&action=review

> Source/WebCore/page/EventSource.cpp:60
> +inline EventSource::EventSource(ScriptExecutionContext& context, const URL& url, const Optional<Init>& eventSourceInit)

This is probably my bug but I don't think we should use Optional<> for dictionaries. Web IDL says:
"""
If the type of an argument is a dictionary type or a union type that has a dictionary type as one of its flattened member types, and that dictionary type and its ancestors have no required members, and the argument is either the final argument or is followed only by optional arguments, then the argument must be specified as optional. Such arguments are always considered to have a default value of an empty dictionary, unless otherwise specified.
"""
Comment 3 Darin Adler 2016-05-08 00:14:26 PDT
Sounds like that does cover this case. So we should say optional in the IDL but the code should not generate an Optional<>. Should be really quick to fix.
Comment 4 Darin Adler 2016-05-08 08:26:26 PDT
Comment on attachment 278355 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278355&action=review

> Source/WebCore/bindings/js/JSDOMConvert.h:54
> +template<> inline bool convert<bool>(JSC::ExecState& state, JSC::JSValue value)
> +{
> +    return value.toBoolean(&state);
> +}

I will rebase because this function was added to JSDOMConvert.h by another of my patches last night.

>> Source/WebCore/page/EventSource.cpp:60
>> +inline EventSource::EventSource(ScriptExecutionContext& context, const URL& url, const Optional<Init>& eventSourceInit)
> 
> This is probably my bug but I don't think we should use Optional<> for dictionaries. Web IDL says:
> """
> If the type of an argument is a dictionary type or a union type that has a dictionary type as one of its flattened member types, and that dictionary type and its ancestors have no required members, and the argument is either the final argument or is followed only by optional arguments, then the argument must be specified as optional. Such arguments are always considered to have a default value of an empty dictionary, unless otherwise specified.
> """

I will change this to not use Optional after landing a patch I am working on that fixes the handling of undefined and null and obviates the need for Optional.
Comment 5 Darin Adler 2016-05-08 10:22:19 PDT
Created attachment 278363 [details]
Patch
Comment 6 Darin Adler 2016-05-08 10:51:59 PDT
Patch is doing well on EWS. Ready to get reviewed and land!
Comment 7 Chris Dumez 2016-05-08 11:01:04 PDT
Comment on attachment 278363 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278363&action=review

r=me

> Source/WebCore/ChangeLog:67
> +        * page/EventSource.idl: U

U ?

> Source/WTF/wtf/text/WTFString.h:59
> +WTF_EXPORT_STRING_API uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage

= nullptr

> Source/WebCore/page/EventSource.cpp:289
> +                position++;

++position

> Source/WebCore/page/EventSource.cpp:295
> +        for (unsigned i = position; !lineLength && i < size; i++) {

++i

> Source/WebCore/page/EventSource.cpp:401
> +    auto data = SerializedScriptValue::create(StringView { m_data.data(), size });

Do we need to explicitly say StringView? Wouldn't "{ m_data.data(), size }" work?
Comment 8 Darin Adler 2016-05-08 11:46:12 PDT
Committed r200558: <http://trac.webkit.org/changeset/200558>