Re: Vibration: throwing and pause

>>> * In step 10 say "run the following substeps asynchronously".
>>
>> Is this well-defined?
>>
>> Perhaps the right thing is to "spawn a task," but my network
>> connection is too poor for me to look that up right now!
>
> I believe we could also say "Run the remainder of these steps
> asynchronously, and return true from the method."

The HTML5 spec uses this terminology twice, so that's good enough for me.

I don't think we want to return false when the pattern is 0, the empty
list, or if the device doesn't support vibration.  At the very least,
this exposes to pages whether the device supports vibration, which I
thought was something we wanted to avoid.  But also, vibrate([])
"succeeds" if it gets to step (9), so it should return true, I think.

> [[
>
> 1. Let pattern be the value of the first argument.
>
> 2. If pattern is a list, proceed to the next step. Otherwise run
>    the following substeps:
>    1. Let list be an initially empty list, and add pattern to
>       list.
>    2. Let pattern be list.
>
> 3. If any entry of pattern exceeds an implementation-dependent
>    limit, then return false and abort these steps.
>
> 4. If the length of pattern is even, then remove the last entry in
>    pattern.
>
> 5. If the length of pattern exceeds an implementation dependent
>    limit, then return false and abort these steps.
>
> 6. If the hidden attribute [PAGE-VISIBILITY] is set to true,
>    then return false and abort these steps.
>
> [ Note 1 ]
>
> 7. An implementation may return false and abort the algorithm
>    at this point.
>
> [ Note 2 ]
>
> 8. Cancel the pre-existing instance of the processing vibration
>    patterns algorithm, if any.
>
> 9. If pattern is 0, an empty list, or if the device does not
>    provide a vibration mechanism (or it is disabled), then return
>    false and abort these steps.
>
> [NEW] Run the remainder of these steps asynchronously, and return
>       true from the method.
>
> 10. For each time in pattern, run the following substeps:
>    1. If the index of time is even (the first entry has index 0),
>       vibrate the device for time milliseconds.
>    2. Otherwise spin the event loop for time milliseconds.
>
> ]]
>
> Let's try to hash this algorithm out in email first. Please
> review the proposal and let me know if there are any bugs.
>
> Thanks,
>
> -Anssi

Received on Tuesday, 16 April 2013 08:15:15 UTC