Skip to content

Commit 5e4d591

Browse files
authored
[css-highlight-api-1] Add type enum attribute to Highlight w3c#6498 (w3c#6724)
* Add `type` attribute to `Highlight` * Say what UAs should do with the type. Explain why initial set of types was chosen.
1 parent ef1feeb commit 5e4d591

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

css-highlight-api-1/Overview.bs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,25 @@ Creating Custom Highlights</h3>
161161
See [[#range-invalidation]] for more details about this choice and its implications.
162162

163163
<xmp class="idl">
164+
enum HighlightType {
165+
"highlight",
166+
"spelling-error",
167+
"grammar-error"
168+
};
169+
164170
[Exposed=Window]
165171
interface Highlight {
166172
constructor(AbstractRange... initialRanges);
167173
setlike<AbstractRange>;
168174
attribute long priority;
175+
attribute HighlightType type;
169176
};
170177
</xmp>
171178

172179
See [[#priorities]] for more information on the {{Highlight/priority}} attribute.
173180

181+
See [[#highlight-types]] for more information on the {{Highlight/type}} attribute.
182+
174183
<div algorithm="to create a custom highlight">
175184
When the <dfn for=Highlight constructor>Highlight(AbstractRange... initialRanges)</dfn> constructor is invoked,
176185
run the following steps:
@@ -180,6 +189,8 @@ Creating Custom Highlights</h3>
180189
Let |highlight| be the new {{Highlight}} object.
181190
<li>
182191
Set |highlight|'s {{Highlight/priority}} to <code>0</code>.
192+
<li>
193+
Set |highlight|'s {{Highlight/type}} to {{HighlightType/highlight}}.
183194
<li>
184195
For each |range| of {{initialRanges}},
185196
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>
450461
</div>
451462
</div>
452463

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+
453502
<h2 id=responding-to-changes>
454503
Responding to Changes</h2>
455504

0 commit comments

Comments
 (0)