@@ -44,6 +44,7 @@ Complain About: accidental-2119 yes
4444<pre class=link-defaults>
4545spec:css-color-4; type:property; text:color
4646spec:css-pseudo-4; type:dfn; text:highlight overlay
47+ spec:html; type:element; text:style
4748</pre>
4849
4950<style>
@@ -166,14 +167,12 @@ Creating Custom Highlights</h3>
166167 interface Highlight {
167168 constructor(CSSOMString name, optional sequence<AbstractRange> initialRanges = []);
168169 setlike<AbstractRange>;
169- attribute CSSStyleDeclaration style;
170170 attribute double priority;
171171 readonly attribute CSSOMString name;
172172 };
173173 </xmp>
174174
175- See [[#priorities]] for more information on the {{Highlight/priority}} attribute,
176- and [[#style-attr]] for more information on the {{Highlight/style}} attribute.
175+ See [[#priorities]] for more information on the {{Highlight/priority}} attribute.
177176
178177 <div algorithm="to create a custom highlight">
179178 When the <dfn for=Highlight constructor>Highlight(CSSOMString name, optional sequence<AbstractRange> initialRanges = [])</dfn> constructor is invoked,
@@ -190,13 +189,6 @@ Creating Custom Highlights</h3>
190189 Set |highlight|'s {{Highlight/name}} to |nameArg|
191190 <li>
192191 Set |highlight|'s {{Highlight/priority}} to <code> 0</code> .
193- <li>
194- Set |highlight|'s {{Highlight/style}}
195- to a [=CSS declaration block=] object
196- whose [=readonly flag=] is unset,
197- whose [=parent CSS rule=] is <code> null</code> ,
198- whose [=owner node=] is <code> null</code> ,
199- and whose [=declarations=] list is empty.
200192 <li>
201193 For each |range| of {{initialRanges}} ,
202194 let |rangeArg| be the result of [=converted to an ECMAScript value|converting=] |range| to an ECMAScript value,
@@ -270,24 +262,20 @@ The Custom Highlight Pseudo-element: ''::highlight()''</h3>
270262
271263
272264<h3 id=style-attr>
273- Default Styling of a Custom Highlight</h3>
274-
275- A [=custom highlight=] 's {{Highlight/style}} attribute
276- is a [=CSS declaration block=] object
277- which authors can use to define
278- the [=custom highlight=] 's <dfn>default style</dfn> .
279- This determines the appearance of the [=custom highlight=]
280- when ''::highlight()'' has not been used to specify other styles.
281- (See also [[#c-and-h]] for more information on
282- how to determine which styles apply
283- when several are specified).
265+ Styling of a Custom Highlight via scripting</h3>
266+
267+ The {{CSSPseudoElement/type}} attribute of {{CSSPseudoElement}} (see [[css-pseudo-4]] ) is extended
268+ to accept <code> "::highlight(<<highlight-name>> )"</code> as one of the possible values.
269+ Together with the {{CSSPseudoElement/style}} attribute of {{CSSPseudoElement}} ,
270+ this enables authors to set the appearance of the [=custom highlight=]
271+ entirely through scripting.
284272
285273 <div class=example id=style-attr-ex>
286274
287275 The following example achieves the same rendering
288276 as <a href=#intro-ex>the example in the overview section</a>
289- without using the ''::highlight()'' pseudo- element,
290- by providing a default style via scripting instead.
277+ without any declaration in a <{style}> element
278+ by providing a style attribute via scripting instead.
291279
292280 <xmp highlight=html>
293281 <body><span> One </span><span> two </span><span> three...</span>
@@ -296,25 +284,15 @@ Default Styling of a Custom Highlight</h3>
296284 r.setStart(document.body, 0);
297285 r.setEnd(document.body, 2);
298286
299- let h = new Highlight("inline-highlight", [r] );
300- h.style.backgroundColor = "yellow";
301- h.style.color = "blue";
287+ CSS.highlights.add(new Highlight("inline-highlight", [r] ));
302288
303- CSS.highlights.add(h);
289+ let s = document.documentElement.pseudo("::highlight(inline-highlight)").style;
290+ s.backgroundColor = "yellow";
291+ s.color = "blue";
304292 </script>
305293 </xmp>
306-
307- This would be overriden if by any use of ''::highlight(inline-highlight)'' in a stylesheet.
308294 </div>
309295
310- Issue(4588): Do we really need this?
311- Would it not make more sense to have a generic mechanism to set the style attribute
312- on any pseudo element?
313- In that case I'd also expect it
314- to behave more like [[css-style-attr]]
315- and to have a higher specificity than any selector,
316- instead of being a default filling in if there's not specified style.
317-
318296<h3 id=processing-model>
319297Processing Model</h3>
320298
@@ -325,21 +303,13 @@ Applicable Properties</h4>
325303 like the built-in [=highlight pseudo-elements=] ,
326304 can only be styled with a limited set of properties.
327305 See [[css-pseudo-4#highlight-styling]] for the full list.
328- The same limitation applies to the {{Highlight/style}} attribute of [=custom highlights=] .
329306
330307<h4 id=c-and-h>
331308Cascading and Inheritance</h4>
332309
333310 The [=cascading=] and [=inheritance=] of [=custom highlight pseudo-elements=] is handled
334311 identically to that of the built-in [=highlight pseudo-elements=] ,
335- as defined in [[css-pseudo-4#highlight-cascade]] ,
336- with one addition:
337- similarly to how
338- the User Agent is expected to use the OS-default highlight colors for ''::selection''
339- when neither 'color' nor 'background-color' have been specified,
340- the User Agent must use the styles provided in
341- the {{Highlight/style}} attribute of the corresponding [=custom highlight=]
342- when no applicable property has been specified via ''::highlight()'' .
312+ as defined in [[css-pseudo-4#highlight-cascade]] .
343313
344314<h4 id=painting>
345315Painting</h4>
@@ -499,7 +469,6 @@ Repaints</h3>
499469 The User Agent must also repaint highlights as needed
500470 in response to changes by the author
501471 to the {{Highlight/priority}} ,
502- to the {{Highlight/style}} ,
503472 or to the [=boundary points=] of {{Range}} s
504473 of a [=registered=] [=custom highlight=] .
505474
0 commit comments