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.
public sealed class HighlightRegistry : IEnumerable<KeyValuePair<string, Highlight>>, IReadOnlyCollection<KeyValuePair<string, Highlight>>, IEnumerableRemarks
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
| Name | Description |
|---|---|
| Count | Gets the number of registered highlights. |
Count
Highlights.csMethods
| Name | Description |
|---|---|
| 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() |
Clear()
Highlights.csUnregisters all the highlights.
public void Clear()Delete(string)
Highlights.csGet(string)
Highlights.csReturns the highlight registered under the name, or null.
GetEnumerator()
Highlights.csEnumerates the names and their highlights, including the entries added during the enumeration.
public IEnumerator<KeyValuePair<string, Highlight>> GetEnumerator()Has(string)
Highlights.csHighlightsFromPoint(float, float, HighlightsFromPointOptions?)
Highlights.csReturns 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.csRegisters the highlight under the name, replacing the highlight already registered under it (which keeps its position).
public HighlightRegistry Set(string name, Highlight highlight)