HighlightRegistry Class

The custom highlights registered for a document (https://drafts.csswg.org/css-highlight-api-1/#highlight-registry), returned by CSS.highlights and Document.Highlights. It is a maplike<DOMString, Highlight>: the entries are enumerated in insertion order (replacing the highlight of a name keeps its position), and, as for a JavaScript Map, an enumeration sees the changes made while it is in progress.

Remarks

The registered highlights do not change the computed styles (the ::highlight(name) pseudo-elements are styled whether a highlight is registered under the name or not). highlightsFromPoint() hit tests the client rectangles of the ranges (see HighlightRegistry.HighlightsFromPoint).

See also

Implements

Properties

NameDescription
CountGets the number of registered highlights.

Gets the number of registered highlights.

public int Count { get; }

Property value

int

Methods

NameDescription
Clear()Unregisters all the highlights.
Delete(string)Unregisters the highlight of the name. Returns whether a highlight was registered under the name.
Get(string)Returns the highlight registered under the name, or null.
GetEnumerator()Enumerates the names and their highlights, including the entries added during the enumeration.
Has(string)Returns whether a highlight is registered under the name.
HighlightsFromPoint(float, float, HighlightsFromPointOptions?)Returns the highlights hit at a point of the viewport (https://drafts.csswg.org/css-highlight-api-1/#interactions), with their ranges whose client rectangles (Range.GetClientRects) contain the point, by descending priority (the highlight registered last first when the priorities are equal). Nothing is returned for a point outside of the viewport, or when the topmost box at the point is in a shadow tree that is not in options; the ranges of another tree than the node at the point (e.g. a range of the light tree around a shadow host) do not highlight it.
Set(string, Highlight)Registers the highlight under the name, replacing the highlight already registered under it (which keeps its position).
System.Collections.IEnumerable.GetEnumerator()

Unregisters all the highlights.

public void Clear()

Delete(string)

Highlights.cs

Unregisters the highlight of the name. Returns whether a highlight was registered under the name.

public bool Delete(string name)

Parameters

name string

Returns

bool

Get(string)

Highlights.cs

Returns the highlight registered under the name, or null.

public Highlight? Get(string name)

Parameters

name string

Returns

Highlight?

GetEnumerator()

Highlights.cs

Enumerates the names and their highlights, including the entries added during the enumeration.

public IEnumerator<KeyValuePair<string, Highlight>> GetEnumerator()

Has(string)

Highlights.cs

Returns whether a highlight is registered under the name.

public bool Has(string name)

Parameters

name string

Returns

bool

HighlightsFromPoint(float, float, HighlightsFromPointOptions?)

Highlights.cs

Returns the highlights hit at a point of the viewport (https://drafts.csswg.org/css-highlight-api-1/#interactions), with their ranges whose client rectangles (Range.GetClientRects) contain the point, by descending priority (the highlight registered last first when the priorities are equal). Nothing is returned for a point outside of the viewport, or when the topmost box at the point is in a shadow tree that is not in options; the ranges of another tree than the node at the point (e.g. a range of the light tree around a shadow host) do not highlight it.

public IReadOnlyList<HighlightHitResult> HighlightsFromPoint(float x, float y, HighlightsFromPointOptions? options = null)

Set(string, Highlight)

Highlights.cs

Registers the highlight under the name, replacing the highlight already registered under it (which keeps its position).

public HighlightRegistry Set(string name, Highlight highlight)

Parameters

name string
highlight Highlight

Returns

HighlightRegistry

System.Collections.IEnumerable.GetEnumerator()

Highlights.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.