@@ -161,16 +161,25 @@ Creating Custom Highlights</h3>
161
161
See [[#range-invalidation]] for more details about this choice and its implications.
162
162
163
163
<xmp class="idl">
164
+ enum HighlightType {
165
+ "highlight",
166
+ "spelling-error",
167
+ "grammar-error"
168
+ };
169
+
164
170
[Exposed=Window]
165
171
interface Highlight {
166
172
constructor(AbstractRange... initialRanges);
167
173
setlike<AbstractRange>;
168
174
attribute long priority;
175
+ attribute HighlightType type;
169
176
};
170
177
</xmp>
171
178
172
179
See [[#priorities]] for more information on the {{Highlight/priority}} attribute.
173
180
181
+ See [[#highlight-types]] for more information on the {{Highlight/type}} attribute.
182
+
174
183
<div algorithm="to create a custom highlight">
175
184
When the <dfn for=Highlight constructor>Highlight(AbstractRange... initialRanges)</dfn> constructor is invoked,
176
185
run the following steps:
@@ -180,6 +189,8 @@ Creating Custom Highlights</h3>
180
189
Let |highlight| be the new {{Highlight}} object.
181
190
<li>
182
191
Set |highlight|'s {{Highlight/priority}} to <code> 0</code> .
192
+ <li>
193
+ Set |highlight|'s {{Highlight/type}} to {{HighlightType/highlight}} .
183
194
<li>
184
195
For each |range| of {{initialRanges}} ,
185
196
let |rangeArg| be the result of [=converted to an ECMAScript value|converting=] |range| to an ECMAScript value,
@@ -450,6 +461,44 @@ Priority of Overlapping Highlights</h4>
450
461
</div>
451
462
</div>
452
463
464
+ <h4 id=highlight-types>
465
+ Highlight types</h4>
466
+
467
+ A [=custom highlight=] 's {{Highlight/type}} attribute is used by authors to specify the semantic
468
+ meaning of the highlight. This allows assistive technologies to include this meaning when
469
+ exposing the highlight to users.
470
+
471
+ A custom highlight will have a default type of {{HighlightType/highlight}} if its
472
+ {{Highlight/type}} attribute has not been explicitly set.
473
+
474
+ Note: Authors should set a [=custom highlight=] 's {{Highlight/type}} to
475
+ {{HighlightType/spelling-error}} when that [=custom highlight=] is being used to emphasize
476
+ misspelled content. Authors should set a [=custom highlight=] 's {{Highlight/type}} to
477
+ {{HighlightType/grammar-error}} when that [=custom highlight=] is being used to emphasize
478
+ content that is grammatically incorrect. For all other use cases {{Highlight/type}} should
479
+ be left as {{HighlightType/highlight}} .
480
+
481
+ UAs should make [=custom highlight=] s available to assistive technologies. When exposing a
482
+ highlight using a given platform accessibility API, UAs should expose the semantic meaning of
483
+ the highlight as specified by its {{Highlight/type}} attribute with as much specificity as
484
+ possible for that accessibility API.
485
+
486
+ Note: For example, if a platform accessibility API has the capability to express spelling errors
487
+ and grammar errors specifically, then UAs should use these capabilities to convey the semantics
488
+ for highlights with {{HighlightType/spelling-error}} and {{HighlightType/spelling-error}} .
489
+ If an accessibility API only has the capability to express spelling errors, then UAs should
490
+ convey both highlights with {{HighlightType/spelling-error}} and with
491
+ {{HighlightType/grammar-error}} using spelling error semantics. If an accessibility API has
492
+ support for expressing neither spelling errors nor grammar errors, then UAs should expose all
493
+ highlights as generic {{HighlightType/highlight}} regardless of their actual {{Highlight/type}} .
494
+
495
+ Note: This initial set of types was chosen because they are expected to be popular use cases
496
+ for Highlight API and there is some existing support for expressing their semantics in platform
497
+ accessibility APIs today. Accessibility APIs currently don't have any way to express the
498
+ specific semantics of other expected Highlight API use cases. More types may be added to
499
+ {{HighlightType}} as accessibility APIs gain support for expressing additional popular use
500
+ cases of Highlight API.
501
+
453
502
<h2 id=responding-to-changes>
454
503
Responding to Changes</h2>
455
504
0 commit comments