From c7f6c0079350930e3f8ae61c29cea7aff20eefc3 Mon Sep 17 00:00:00 2001 From: Jiewei Qian Date: Fri, 8 Nov 2024 14:48:29 +1100 Subject: [PATCH 1/3] spec: update remaining "in parallel" steps to use tasks --- spec.bs | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/spec.bs b/spec.bs index 2edacf5..9129204 100644 --- a/spec.bs +++ b/spec.bs @@ -191,15 +191,21 @@ The same {{HandwritingModelConstraint}} can be used to invoke {{Navigator/create
When {{Navigator/queryHandwritingRecognizer(constraint)}} method is invoked, do the following: - 1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, [=exception/throw=] a new {{TypeError}} + 1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, return [=a promise rejected with=] a new {{TypeError}}. 1. Let |p| be [=a new promise=]. - 1. Run the following step [=in parallel=] - 1. If |constraint|'s {{HandwritingModelConstraint/languages}} member is an empty array, [=/resolve=] |p| with `null` and abort. + 1. Run the following step [=in parallel=]: 1. Convert |constraint| into a suitable form for handwriting recognizer. - 1. If the user agent can't find or create a [=handwriting recognizer=] that satisfies the converted |constraint|, [=/resolve=] |p| with `null` and abort. - 1. Let |result| be a new {{HandwritingRecognizerQueryResult}} - 1. Convert the handwriting recognizer's feature description, and fills in all members of |result|,. - 1. [=/Resolve=] |p| with |result|. + 1. If any of the following is true: + * |constraint|'s {{HandwritingModelConstraint/languages}} member is an empty [=list=]. + * The user agent can't find or create a platform-dependent [=handwriting recognizer=] that satisfies the converted |constraint|. + + [=Queue a handwriting recognition API task=] to resolve |p| with with `null` and abort the remaining steps. + + 1. Otherwise, [=queue a handwriting recognition API task=] to: + 1. Let |result| be a new {{HandwritingRecognizerQueryResult}} + 1. Convert the handwriting recognizer's feature description, and populate all members of |result|. + 1. [=/Resolve=] |p| with |result|. + 1. Return |p|. The implementation should follow these rules when converting to {{HandwritingRecognizerQueryResult}} and {{HandwritingHintsQueryResult}}: * If the recognizer doesn't accept any hint, set {{HandwritingRecognizerQueryResult/hints}} to `null`. @@ -317,18 +323,22 @@ This method creates a {{HandwritingRecognizer}} object that satisfies the provid
When {{Navigator/createHandwritingRecognizer(constraint)}} method is invoked, do the following: - 1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, [=exception/throw=] a new {{TypeError}} + 1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, return [=a promise rejected with=] {{TypeError}}. 1. Let |p| be [=a new promise=]. - 1. Run the following step [=in parallel=] - 1. If |constraint|'s {{HandwritingModelConstraint/languages}} is an empty array, [=/reject=] |p| with a new {{DOMException}} whose {{DOMException/name}} attribute is {{"NotSupportedError"}} and abort. - 1. Convert |constraint| into a suitable form for [=handwriting recognizer=]. - 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. - 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"}}. - 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: - * If the web application shouldn't retry, {{"OperationError"}}. - * Otherwise {{"UnknownError"}}. - 1. Let |result| be a new {{HandwritingRecognizer}} object, whose [=HandwritingRecognizer/active=] flag is `true` - 1. [=/Resolve=] |p| with |result|. + 1. Run the following step [=in parallel=]: + 1. Convert |constraint| into a suitable form for creating a platform-dependent [=handwriting recognizer=]. + 1. If the user agent can't create or prepare a [=handwriting recognizer=] to perform recognitions, [=queue a Handwriting Recognition API task=] to [=/reject=] |p| with a new {{DOMException}} according to the failure cause, then abort the remaining steps: + * If |constraint|'s {{HandwritingModelConstraint/languages}} is an empty [=list=], {{"NotSupportedError"}}. + * If the user agent can't find a platform-dependent [=handwriting recognizer=] that satisfies the converted |constraint|, {{"NotSupportedError"}}. + * If creating a [=handwriting recognizer=] would cause the user agent to exceed its limit for total number of active recognizer, {{"QuotaExceededError"}}. + * If the web application can retry calling this method, {{OperationError}}. + * For all other failure causes, {{"UnknownError"}} + 1. [=Queue a Handwriting Recognition API task=] to: + 1. Let |result| be a new {{HandwritingRecognizer}} object. + 1. Associate |result| with the platform-dependent [=handwriting recognizer=] created in the previous step. + 1. Set |result|.[=HandwritingRecognizer/active=] flag to `true`. + 1. [=/Resolve=] |p| with |result|. + 1. Return |p|

Use a recognizer

From fba14dc8faf6a84d6424538f3358d9176e6ae8b9 Mon Sep 17 00:00:00 2001 From: Jiewei Qian Date: Mon, 11 Nov 2024 13:34:49 +1100 Subject: [PATCH 2/3] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Daoust --- spec.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.bs b/spec.bs index 9129204..c0a6ac1 100644 --- a/spec.bs +++ b/spec.bs @@ -193,13 +193,13 @@ The same {{HandwritingModelConstraint}} can be used to invoke {{Navigator/create 1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, return [=a promise rejected with=] a new {{TypeError}}. 1. Let |p| be [=a new promise=]. - 1. Run the following step [=in parallel=]: + 1. Run the following steps [=in parallel=]: 1. Convert |constraint| into a suitable form for handwriting recognizer. 1. If any of the following is true: * |constraint|'s {{HandwritingModelConstraint/languages}} member is an empty [=list=]. * The user agent can't find or create a platform-dependent [=handwriting recognizer=] that satisfies the converted |constraint|. - [=Queue a handwriting recognition API task=] to resolve |p| with with `null` and abort the remaining steps. + [=Queue a handwriting recognition API task=] to resolve |p| with `null` and abort the remaining steps. 1. Otherwise, [=queue a handwriting recognition API task=] to: 1. Let |result| be a new {{HandwritingRecognizerQueryResult}} @@ -325,7 +325,7 @@ This method creates a {{HandwritingRecognizer}} object that satisfies the provid 1. If |constraint| doesn't have a {{HandwritingModelConstraint/languages}} member, return [=a promise rejected with=] {{TypeError}}. 1. Let |p| be [=a new promise=]. - 1. Run the following step [=in parallel=]: + 1. Run the following steps [=in parallel=]: 1. Convert |constraint| into a suitable form for creating a platform-dependent [=handwriting recognizer=]. 1. If the user agent can't create or prepare a [=handwriting recognizer=] to perform recognitions, [=queue a Handwriting Recognition API task=] to [=/reject=] |p| with a new {{DOMException}} according to the failure cause, then abort the remaining steps: * If |constraint|'s {{HandwritingModelConstraint/languages}} is an empty [=list=], {{"NotSupportedError"}}. From 3a94a9e4c039f323acb01a3e6a69f17f526c802e Mon Sep 17 00:00:00 2001 From: Jiewei Qian Date: Mon, 18 Nov 2024 17:37:19 +1100 Subject: [PATCH 3/3] queue if-otherwise --- spec.bs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/spec.bs b/spec.bs index c0a6ac1..bf70b89 100644 --- a/spec.bs +++ b/spec.bs @@ -327,17 +327,18 @@ This method creates a {{HandwritingRecognizer}} object that satisfies the provid 1. Let |p| be [=a new promise=]. 1. Run the following steps [=in parallel=]: 1. Convert |constraint| into a suitable form for creating a platform-dependent [=handwriting recognizer=]. - 1. If the user agent can't create or prepare a [=handwriting recognizer=] to perform recognitions, [=queue a Handwriting Recognition API task=] to [=/reject=] |p| with a new {{DOMException}} according to the failure cause, then abort the remaining steps: - * If |constraint|'s {{HandwritingModelConstraint/languages}} is an empty [=list=], {{"NotSupportedError"}}. - * If the user agent can't find a platform-dependent [=handwriting recognizer=] that satisfies the converted |constraint|, {{"NotSupportedError"}}. - * If creating a [=handwriting recognizer=] would cause the user agent to exceed its limit for total number of active recognizer, {{"QuotaExceededError"}}. - * If the web application can retry calling this method, {{OperationError}}. - * For all other failure causes, {{"UnknownError"}} 1. [=Queue a Handwriting Recognition API task=] to: - 1. Let |result| be a new {{HandwritingRecognizer}} object. - 1. Associate |result| with the platform-dependent [=handwriting recognizer=] created in the previous step. - 1. Set |result|.[=HandwritingRecognizer/active=] flag to `true`. - 1. [=/Resolve=] |p| with |result|. + 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: + * If |constraint|'s {{HandwritingModelConstraint/languages}} is an empty [=list=], {{"NotSupportedError"}}. + * If the user agent can't find a platform-dependent [=handwriting recognizer=] that satisfies the converted |constraint|, {{"NotSupportedError"}}. + * If creating a [=handwriting recognizer=] would cause the user agent to exceed its limit for total number of active recognizer, {{"QuotaExceededError"}}. + * If the web application can retry calling this method, {{OperationError}}. + * For all other failure causes, {{"UnknownError"}} + 1. Otherwise: + 1. Let |result| be a new {{HandwritingRecognizer}} object. + 1. Associate |result| with the platform-dependent [=handwriting recognizer=] created in the previous step. + 1. Set |result|.[=HandwritingRecognizer/active=] flag to `true`. + 1. [=/Resolve=] |p| with |result|. 1. Return |p|