Bug 116304 - Remove custom code for MessageEvent.ports getter
Summary: Remove custom code for MessageEvent.ports getter
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: http://dev.w3.org/html5/pf-summary/co...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-17 04:37 PDT by Chris Dumez
Modified: 2013-05-23 01:00 PDT (History)
8 users (show)

See Also:


Attachments
Patch (4.78 KB, patch)
2013-05-17 04:57 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2013-05-17 04:37:55 PDT
The "ports" attribute in MessageEvent.idl is currently using a CustomGetter. The attribute is of type "MessagePortArray", which the JSC bindings generator has support for. Therefore, we should be able to get rid of the custom code with minor generator tweaks.
Comment 1 Chris Dumez 2013-05-17 04:57:26 PDT
Created attachment 202062 [details]
Patch
Comment 2 Kentaro Hara 2013-05-17 05:02:00 PDT
Comment on attachment 202062 [details]
Patch

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

> Source/WebCore/dom/MessageEvent.idl:37
> +    [InitializedByEventConstructor] readonly attribute MessagePortArray ports;

Per the spec, this should be 'MessagePort[]?'. Would you fix it in a follow-up patch?

http://dev.w3.org/html5/postmsg/#event-definitions
Comment 3 WebKit Commit Bot 2013-05-17 05:24:18 PDT
Comment on attachment 202062 [details]
Patch

Clearing flags on attachment: 202062

Committed r150249: <http://trac.webkit.org/changeset/150249>
Comment 4 WebKit Commit Bot 2013-05-17 05:24:20 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Chris Dumez 2013-05-17 05:28:22 PDT
(In reply to comment #2)
> (From update of attachment 202062 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=202062&action=review
> 
> > Source/WebCore/dom/MessageEvent.idl:37
> > +    [InitializedByEventConstructor] readonly attribute MessagePortArray ports;
> 
> Per the spec, this should be 'MessagePort[]?'. Would you fix it in a follow-up patch?
> 
> http://dev.w3.org/html5/postmsg/#event-definitions

This is visibly a recent spec change as it wasn't nullable before. I don't know how other browsers behave so this would need to be checked. Do you know the reason behind this change? Having a nullable array makes life harder for JS developers and I'm not sure why having an empty array is not enough.
Comment 6 Kentaro Hara 2013-05-17 05:32:16 PDT
(In reply to comment #5)
> This is visibly a recent spec change as it wasn't nullable before. I don't know how other browsers behave so this would need to be checked. Do you know the reason behind this change? Having a nullable array makes life harder for JS developers and I'm not sure why having an empty array is not enough.

Yeah, needs verification of other browsers. I don't know about nullable, but replacing XXXArray with XXX[] looks like a recent trend.
Comment 7 Alexey Proskuryakov 2013-05-17 09:54:27 PDT
Comment on attachment 202062 [details]
Patch

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

> Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:182
> +    JSValue result = impl->ports() ? jsArray(exec, castedThis->globalObject(), *impl->ports()) : constructEmptyArray(exec, 0, castedThis->globalObject());

It seems unfortunate that we call into DOM twice now. Why can't the result of impl->ports() be cached?
Comment 8 Chris Dumez 2013-05-17 10:07:17 PDT
(In reply to comment #7)
> (From update of attachment 202062 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=202062&action=review
> 
> > Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:182
> > +    JSValue result = impl->ports() ? jsArray(exec, castedThis->globalObject(), *impl->ports()) : constructEmptyArray(exec, 0, castedThis->globalObject());
> 
> It seems unfortunate that we call into DOM twice now. Why can't the result of impl->ports() be cached?

I don't think it is a big issue currently because this code is only used for MessageEvent::ports() currently, which is inlined. However, you have a point that we should cache it to be safe. I will look into it, thanks.
Comment 9 Chris Dumez 2013-05-23 01:00:44 PDT
Addressing ap and Kentaro's feedback in Bug 116653.