Skip to content

Commit 9b5d776

Browse files
committed
[css-typed-om] CSSImageValue objects.
1 parent 3059811 commit 9b5d776

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

css-typed-om/Overview.bs

+62-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Abstract:
99
Editor: Shane Stephens, shanestephens@google.com
1010
Repository: w3c/css-houdini-drafts
1111
Ignored Vars: type, unit
12+
Ignored Terms: Drawable
1213
</pre>
1314

1415
<pre class=anchors>
@@ -609,6 +610,44 @@ document.querySelector('.example').styleMap.get('background-position').y;
609610

610611
</div>
611612

613+
{{CSSImageValue}} objects {#image-objects}
614+
-------------------------------------
615+
616+
<pre class='idl'>
617+
618+
enum CSSImageState {"ready", "pending", "invalid"};
619+
620+
interface CSSImageValue : CSSStyleValue {
621+
readonly attribute CSSImageState state;
622+
readonly attribute Drawable? drawable;
623+
};
624+
625+
interface CSSURLImageValue : CSSImageValue {
626+
readonly attribute DOMString url;
627+
};
628+
629+
</pre>
630+
631+
{{CSSImageValue}} objects represent values for properties that take <<image>> productions,
632+
for example 'background-image', 'list-style-image', and 'border-image-source'.
633+
634+
The <a attribute for=CSSImageValue>state</a> attribute is set to "pending" if the image requires
635+
network data that has not yet been fetched, to "invalid" if an error means that the image can't be
636+
rendered, and to "ready" otherwise.
637+
638+
The <a attribute for=CSSImageValue>drawable</a> attribute is null if <a attribute for=CSSImageValue>state</a>
639+
is "pending" or "invalid". Otherwise, the {{Drawable}} can be used to render image data via the canvas
640+
API.
641+
642+
Issue: clean up the above wording once Drawables are a thing.
643+
644+
{{CSSURLImageValue}} objects represent {{CSSImageValue}}s that match the <<url>> production. For these
645+
objects, the <a attribute for=CSSURLImageValue>url</a> attribute contains the URL that contains the image.
646+
647+
Issue: We should add a promise that waits for the {{CSSImageState}} to become ready, but
648+
this should probably be deferred until we have cancellable promises.
649+
650+
612651
Mapping of properties to accepted types {#mapping-of-properties-to-accepted-types}
613652
==================================================================================
614653
This section provides a table of which types of {{CSSStyleValue}} a given property can accept.
@@ -693,7 +732,7 @@ Shorthand properties and values are not supported.
693732
</tr>
694733
<tr>
695734
<td>'background-image'</td>
696-
<td>URIValue | {{CSSKeywordValue}}</td>
735+
<td>{{CSSImageValue}}</td>
697736
</tr>
698737
<tr>
699738
<td>'background-origin'</td>
@@ -745,7 +784,7 @@ Shorthand properties and values are not supported.
745784
</tr>
746785
<tr>
747786
<td>'border-image-source'</td>
748-
<td>URIValue | {{CSSKeywordValue}}</td>
787+
<td>{{CSSImageValue}}</td>
749788
</tr>
750789
<tr>
751790
<td>'border-image-width'</td>
@@ -853,7 +892,7 @@ Shorthand properties and values are not supported.
853892
</tr>
854893
<tr>
855894
<td>'list-style-image'</td>
856-
<td>URIValue | {{CSSKeywordValue}}</td>
895+
<td>{{CSSImageValue}}</td>
857896
</tr>
858897
<tr>
859898
<td>'list-style-position'</td>
@@ -1222,6 +1261,22 @@ The following process sets a value for either <var>x</var> or<var>y</var>, depen
12221261
1. amend <var>x</var> (if <var>bias</var> is horizontal) or <var>y</var> (if <var>bias</var> is vertical) by
12231262
adding <var>adjustment</var> to it.
12241263

1264+
{{CSSImageValue}} normalization {#imagevalue-normalization}
1265+
-----------------------------------------------------------
1266+
1267+
Image references are normalized by determining whether the reference is invalid
1268+
(in which case <a attribute for=CSSImageValue>state</a> is set to "invalid") or
1269+
requires network data (in which case <a attribute for=CSSImageValue>state</a>
1270+
is set to "pending"). If data is not required and the reference is valid then
1271+
<a attribute for=CSSImageValue>state</a> is set to "ready" and the
1272+
<a attribute for=CSSImageValue>drawable</a> attribute is provided with a
1273+
{{Drawable}} representing the image.
1274+
1275+
If <a attribute for=CSSImageValue>state</a> is set to "pending" then the image
1276+
reference is reevaluated once the pending data becomes available, according to the
1277+
same rules referenced above.
1278+
1279+
Normalization does not fail for {{CSSImageValue}} objects.
12251280

12261281
Security Considerations {#security-considerations}
12271282
==================================================
@@ -1312,3 +1367,7 @@ During computation, both the <a attribute for=CSSPositionValue>x</a> and
13121367
<a attribute for=CSSPositionValue>y</a> components of a {{CSSPositionValue}} are
13131368
computed according to <a section href='#computed-lengthvalue-objects'></a>.
13141369

1370+
Computed {{CSSImageValue}} objects {#computed-imagevalue-objects}
1371+
-----------------------------------------------------------------
1372+
1373+
{{CSSImageValue}} objects are not modified during computation.

0 commit comments

Comments
 (0)