W3C home > Mailing lists > Public > public-device-apis@w3.org > September 2012

Re: [vibra] Adding [NoInterfaceObject] to the Vibration interface

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 5 Sep 2012 03:09:06 -0700
Message-ID: <CA+c2ei9aQnWPJBMj7uXtBgTTY-m_r4+cyp9GHM9oHxkdxMXbfA@mail.gmail.com>
To: Anssi Kostiainen <anssi.kostiainen@nokia.com>
Cc: (wrong string) Œ기™ Kwon <kihong.kwon@samsung.com>
Since this isn't a new object, but rather just additional properties
on the window.navigator object, we should remove the interface
completely and just do:

partial interface Navigator {
    void vibrate (unsigned long time);
    void vibrate (unsigned long[] pattern);
}

That is effectively equivalent to having a "[NoInterfaceObject]
Vibration" interface. The only difference that I can think of is if we
start adding functions which takes arguments of type "Vibration", but
I hope we have no such plans.

Note that having a "real" interface without [NoInterfaceObject] is
useless here since Vibration.prototype won't be in the prototype chain
of window.navigator since the Navigator interface doesn't inherit the
Vibration interface.

/ Jonas

On Wed, Sep 5, 2012 at 1:47 AM, Anssi Kostiainen
<anssi.kostiainen@nokia.com> wrote:
> Hi All, Justin, Kihong,
>
> I noticed none of the known implementations [1] expose Vibration interface in the global context, so I updated the Vibration API Editor's Draft [2] to match the implementations. I.e. I added [NoInterfaceObject] to the Vibration interface as follows:
>
> Navigator implements Vibration;
>
> [NoInterfaceObject]
> interface Vibration {
>     void vibrate (unsigned long time);
>     void vibrate (unsigned long[] pattern);
> };
>
> This change does not break feature detection as the usual pattern can still be used:
>
> if (typeof navigator.vibrate === 'function') {
>     console.log('Vibration API supported');
> }
>
> Let me know if there are concerns with this change.
>
> -Anssi
>
> [1] http://www.w3.org/2009/dap/wiki/ImplementationStatus#Vibration_API
> [2] http://dev.w3.org/2009/dap/vibration/
>
> [The reason we're using "[NoInterfaceObject] interface Foo" and "Bar implements Foo" instead of "partial interface Bar" is to allow other APIs to implement the Vibration interface instead of -- no pun intended -- respec'ing it. E.g. we've discussed use cases around Gamepad API re-using Vibration in the past in this group.]
>
>
Received on Wednesday, 5 September 2012 10:15:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 5 September 2012 10:15:35 GMT