You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
spec: update remaining "in parallel" steps to use tasks (#37)
Update queryHandwritingRecognizer and createHandwritingRecognizer to adopt in parallel algorithm best practices.
Co-authored-by: François Daoust <fd@tidoust.net>
When {{Navigator/queryHandwritingRecognizer(constraint)}} method is invoked, do the following:
193
193
194
-
1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, [=exception/throw=] a new {{TypeError}}
194
+
1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, return [=a promise rejected with=] a new {{TypeError}}.
195
195
1. Let |p| be [=a new promise=].
196
-
1. Run the following step [=in parallel=]
197
-
1. If |constraint|'s {{HandwritingModelConstraint/languages}} member is an empty array, [=/resolve=] |p| with `null` and abort.
196
+
1. Run the following steps [=in parallel=]:
198
197
1. <a lt="convert">Convert |constraint| into a suitable form for handwriting recognizer</a>.
199
-
1. If the user agent can't find or create a [=handwriting recognizer=] that satisfies the converted |constraint|, [=/resolve=] |p| with `null` and abort.
200
-
1. Let |result| be a new {{HandwritingRecognizerQueryResult}}
201
-
1. <a lt="convert">Convert the handwriting recognizer's feature description</a>, and fills in all members of |result|,.
202
-
1. [=/Resolve=] |p| with |result|.
198
+
1. If any of the following is true:
199
+
* |constraint|'s {{HandwritingModelConstraint/languages}} member is an empty [=list=].
200
+
* The user agent can't find or create a platform-dependent [=handwriting recognizer=] that satisfies the converted |constraint|.
201
+
202
+
[=Queue a handwriting recognition API task=] to resolve |p| with `null` and abort the remaining steps.
203
+
204
+
1. Otherwise, [=queue a handwriting recognition API task=] to:
205
+
1. Let |result| be a new {{HandwritingRecognizerQueryResult}}
206
+
1. <a lt="convert">Convert the handwriting recognizer's feature description</a>, and populate all members of |result|.
207
+
1. [=/Resolve=] |p| with |result|.
208
+
1. Return |p|.
203
209
204
210
The implementation should follow these rules when converting to {{HandwritingRecognizerQueryResult}} and {{HandwritingHintsQueryResult}}:
205
211
* If the recognizer doesn't accept any hint, set {{HandwritingRecognizerQueryResult/hints}} to `null`.
@@ -317,18 +323,23 @@ This method creates a {{HandwritingRecognizer}} object that satisfies the provid
When {{Navigator/createHandwritingRecognizer(constraint)}} method is invoked, do the following:
319
325
320
-
1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, [=exception/throw=] a new {{TypeError}}
326
+
1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, return [=a promise rejected with=]{{TypeError}}.
321
327
1. Let |p| be [=a new promise=].
322
-
1. Run the following step [=in parallel=]
323
-
1. If |constraint|'s {{HandwritingModelConstraint/languages}} is an empty array, [=/reject=] |p| with a new {{DOMException}} whose {{DOMException/name}} attribute is {{"NotSupportedError"}} and abort.
324
-
1. <a lt="convert">Convert |constraint| into a suitable form</a> for [=handwriting recognizer=].
325
-
1. If the user agent can't find a [=handwriting recognizer=] that satisfies the converted |constraint|, [=/reject=] |p| with a new {{DOMException}} whose {{DOMException/name}} attribute is {{"NotSupportedError"}} and abort.
326
-
1. If creating a [=handwriting recognizer=] would cause the user agent to exceed its limit for total number of active recognizer, [=/reject=] |p| with a new {{DOMException}} whose {{DOMException/name}} attribute is {{"QuotaExceededError"}}.
327
-
1. If the user agent can't prepare [=handwriting recognizer=] to perform recognitions, [=/reject=] |p| with a new {{DOMException}} object whose name depending on the failure cause and abort:
328
-
* If the web application shouldn't retry, {{"OperationError"}}.
329
-
* Otherwise {{"UnknownError"}}.
330
-
1. Let |result| be a new {{HandwritingRecognizer}} object, whose [=HandwritingRecognizer/active=] flag is `true`
331
-
1. [=/Resolve=] |p| with |result|.
328
+
1. Run the following steps [=in parallel=]:
329
+
1. <a lt="convert">Convert |constraint| into a suitable form</a> for creating a platform-dependent [=handwriting recognizer=].
330
+
1. [=Queue a Handwriting Recognition API task=] to:
331
+
1. If the user agent can't create or prepare a [=handwriting recognizer=] to perform recognitions, [=/reject=] |p| with a new {{DOMException}} according to the failure cause:
332
+
* If |constraint|'s {{HandwritingModelConstraint/languages}} is an empty [=list=], {{"NotSupportedError"}}.
333
+
* If the user agent can't find a platform-dependent [=handwriting recognizer=] that satisfies the converted |constraint|, {{"NotSupportedError"}}.
334
+
* If creating a [=handwriting recognizer=] would cause the user agent to exceed its limit for total number of active recognizer, {{"QuotaExceededError"}}.
335
+
* If the web application can retry calling this method, {{OperationError}}.
336
+
* For all other failure causes, {{"UnknownError"}}
337
+
1. Otherwise:
338
+
1. Let |result| be a new {{HandwritingRecognizer}} object.
339
+
1. Associate |result| with the platform-dependent [=handwriting recognizer=] created in the previous step.
340
+
1. Set |result|.[=HandwritingRecognizer/active=] flag to `true`.
0 commit comments