Skip to content

Commit 78f022f

Browse files
committed
[css-highlight-api] Remove style attribute
Styling should be done via style sheets. If a style attribute becomes available on a CSSPseudoElement Object, we will be able to use that as well. But there's not need to created a dedicated OM based styling mechanism. Closes #4588 Closes #4602
1 parent 3ba5741 commit 78f022f

File tree

1 file changed

+2
-66
lines changed

1 file changed

+2
-66
lines changed

css-highlight-api-1/Overview.bs

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,12 @@ Creating Custom Highlights</h3>
166166
interface Highlight {
167167
constructor(CSSOMString name, AbstractRange... initialRanges);
168168
setlike<AbstractRange>;
169-
attribute CSSStyleDeclaration style;
170169
attribute double priority;
171170
readonly attribute CSSOMString name;
172171
};
173172
</xmp>
174173

175-
See [[#priorities]] for more information on the {{Highlight/priority}} attribute,
176-
and [[#style-attr]] for more information on the {{Highlight/style}} attribute.
174+
See [[#priorities]] for more information on the {{Highlight/priority}} attribute.
177175

178176
<div algorithm="to create a custom highlight">
179177
When the <dfn for=Highlight constructor>Highlight(CSSOMString name, AbstractRange... initialRanges)</dfn> constructor is invoked,
@@ -190,13 +188,6 @@ Creating Custom Highlights</h3>
190188
Set |highlight|'s {{Highlight/name}} to |nameArg|
191189
<li>
192190
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.
200191
<li>
201192
For each |range| of {{initialRanges}},
202193
let |rangeArg| be the result of [=converted to an ECMAScript value|converting=] |range| to an ECMAScript value,
@@ -269,52 +260,6 @@ The Custom Highlight Pseudo-element: ''::highlight()''</h3>
269260
<dfn type><<highlight-name>></dfn> must be a valid CSS <<ident-token>>.
270261

271262

272-
<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).
284-
285-
<div class=example id=style-attr-ex>
286-
287-
The following example achieves the same rendering
288-
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.
291-
292-
<xmp highlight=html>
293-
<body><span>One </span><span>two </span><span>three...</span>
294-
<script>
295-
let r = new Range();
296-
r.setStart(document.body, 0);
297-
r.setEnd(document.body, 2);
298-
299-
let h = new Highlight("inline-highlight", r);
300-
h.style.backgroundColor = "yellow";
301-
h.style.color = "blue";
302-
303-
CSS.highlights.add(h);
304-
</script>
305-
</xmp>
306-
307-
This would be overriden if by any use of ''::highlight(inline-highlight)'' in a stylesheet.
308-
</div>
309-
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-
318263
<h3 id=processing-model>
319264
Processing Model</h3>
320265

@@ -325,21 +270,13 @@ Applicable Properties</h4>
325270
like the built-in [=highlight pseudo-elements=],
326271
can only be styled with a limited set of properties.
327272
See [[css-pseudo-4#highlight-styling]] for the full list.
328-
The same limitation applies to the {{Highlight/style}} attribute of [=custom highlights=].
329273

330274
<h4 id=c-and-h>
331275
Cascading and Inheritance</h4>
332276

333277
The [=cascading=] and [=inheritance=] of [=custom highlight pseudo-elements=] is handled
334278
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()''.
279+
as defined in [[css-pseudo-4#highlight-cascade]].
343280

344281
<h4 id=painting>
345282
Painting</h4>
@@ -499,7 +436,6 @@ Repaints</h3>
499436
The User Agent must also repaint highlights as needed
500437
in response to changes by the author
501438
to the {{Highlight/priority}},
502-
to the {{Highlight/style}},
503439
or to the [=boundary points=] of {{Range}}s
504440
of a [=registered=] [=custom highlight=].
505441

0 commit comments

Comments
 (0)