Skip to content

Commit 6e147e9

Browse files
committed
Cleaned up and better specified the element() section.
1 parent 258e0c3 commit 6e147e9

2 files changed

Lines changed: 54 additions & 21 deletions

File tree

css3-images/Overview.html

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
<h1>CSS Image Values and Replaced Content Module Level 3</h1>
2121

22-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 14 December
22+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 15 December
2323
2010</h2>
2424

2525
<dl>
2626
<dt>This version:</dt>
27-
<!-- <dd><a href="http://www.w3.org/TR/2010/CR-css3-images-20101214/">http://www.w3.org/TR/2010/CR-css3-images-20101214/</a></dd> -->
27+
<!-- <dd><a href="http://www.w3.org/TR/2010/CR-css3-images-20101215/">http://www.w3.org/TR/2010/CR-css3-images-20101215/</a></dd> -->
2828

2929
<dd><a
3030
href="http://dev.w3.org/csswg/css3-images/">http://dev.w3.org/csswg/css3-images/</a>
@@ -482,36 +482,65 @@ <h3 id=element-reference><span class=secno>4.3. </span>Using Elements as
482482
function is an ID selector, the function references the element matched
483483
by the selector. If it's an identifier, the function references the
484484
element who's <dfn id=css-element-reference-identifier>CSS element
485-
reference identifier</dfn> is the identifier. (CSS does not define how
486-
an element acquires a &lsquo;<a
485+
reference identifier</dfn> is the given identifier. (CSS does not define
486+
how an element acquires a &lsquo;<a
487487
href="#css-element-reference-identifier"><code class=css>CSS element
488488
reference identifier</code></a>&rsquo;; that is determined by the host
489489
language.) If no element in the document matches the selector, or no
490490
element has the identifier as its &lsquo;<a
491491
href="#css-element-reference-identifier"><code class=css>CSS element
492492
reference identifier</code></a>&rsquo;, the function represents a fully
493493
transparent image with no intrinsic dimensions, equivalent to
494-
<code>image(transparent)</code>. Otherwise, the function represents an
495-
image with width and height equal to the width and height of the
496-
referenced element, with an appearance exactly equivalent to that of the
497-
referenced element. Whether or not the referenced element is currently
498-
being rendered on-screen, for media types where this is relevant, must
499-
not affect the appearance of the image represented by the function; the
500-
image must always be equivalent to how the element would appear when
501-
rendered on-screen. If the document changes so that which element is
502-
matched, or whether an element is matched at all, changes, the image
503-
represented by the function must change accordingly.</p>
494+
<code>image(transparent)</code>. If the document changes so that which
495+
element is matched, or whether an element is matched at all, changes,
496+
the image represented by the function must change accordingly.</p>
497+
498+
<p>If the &lsquo;<code class=css>element()</code>&rsquo; function refers
499+
to an element, then it represents an image with width and height equal
500+
to the width and height of the margin box of the referenced element. The
501+
image must be constructed by rendering the referenced element and its
502+
descendants at the same size that the element would be in its document,
503+
over an infinite transparent black background, positioned so that the
504+
edges of the margin box of the element is flush with the edges of the
505+
image. <span class=note>If the element has decorations or descendants
506+
that extend outside the margin box, these will be clipped to the margin
507+
box in the generated image by default. &lsquo;<code
508+
class=css>background-repeat:extend</code>&rsquo; may allow the author to
509+
override this behavior so that decorations and descendants outside the
510+
margin box are still painted.</span> If the referenced element or an
511+
ancestor of the referenced element has a transform applied to it, the
512+
transform must be ignored for the purpose of constructing this image
513+
(transforms on descendants must be unaffected).</p>
504514

505515
<p>If the argument passed to &lsquo;<code
506516
class=css>element()</code>&rsquo; isn't an ID selector or an ident, it
507517
is a syntax error.</p>
508518

509519
<div class=example> TODO: copy an example from the MozHacks article</div>
510520

511-
<div class=issue> This can pretty obviously result in dependency cycles.
512-
An element can try to use itself as a background, for example. I need to
513-
add a section about determining the dependency graph and what to do when
514-
a cycle is detected.</div>
521+
<div>
522+
<h4 class="no-num no-toc" id=element-cycles>Detecting and Resolving
523+
Circular Relationships Introduced by &lsquo;<code
524+
class=css>element()</code>&rsquo;</h4>
525+
526+
<p>The &lsquo;<code class=css>element()</code>&rsquo; function can
527+
produce nonsensical circular relationships, such as an element using
528+
itself as its own background. These relationships can be easily and
529+
reliably detected and resolved, however, by keeping track of a
530+
dependency graph and using common cycle-detection algorithms.</p>
531+
532+
<p>Populate the dependency graph initially by having every element
533+
depend on each of its children. Then, whenever a property on an element
534+
A uses the &lsquo;<code class=css>element()</code>&rsquo; function to
535+
refer to an element B, add an edge to the graph by having A depend on
536+
B. If a dependency cycle is detected, any &lsquo;<code
537+
class=css>element()</code>&rsquo; functions that produced a dependency
538+
in the cycle represent a fully transparent image with no intrinsic
539+
dimensions.</p>
540+
541+
<p class=issue>Someone else needs to review this and make sure that I'm
542+
not missing any cycles.</p>
543+
</div>
515544
</div>
516545

517546
<div>

css3-images/Overview.src.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,17 @@ <h3 id=element-reference>Using Elements as Images: The ''element()'' notation</h
231231
<p>The ''element()'' function allows an author to reference an element in the document that should be used as an image. As the referenced element changes, for example, by the user typing into a &lt;textarea> element or a script drawing into a &lt;canvas> element in HTML, the image produced by the ''element()'' function stays in sync, allowing dynamic effects such as script-animated background images or previews of the next slide in a slideshow. The syntax for ''element()'' is defined as:</p>
232232
<pre class=prod><dfn>&lt;element-reference></dfn> = element( [&lt;id-selector> | &lt;identifier> ] )</pre>
233233
<p>where &lt;id-selector> is an ID selector [[!SELECT]], and &lt;identifier> is an identifer [[!CSS3VAL]].</p>
234-
<p>If the argument to the ''element()'' function is an ID selector, the function references the element matched by the selector. If it's an identifier, the function references the element who's <dfn>CSS element reference identifier</dfn> is the identifier. (CSS does not define how an element acquires a ''CSS element reference identifier''; that is determined by the host language.) If no element in the document matches the selector, or no element has the identifier as its ''CSS element reference identifier'', the function represents a fully transparent image with no intrinsic dimensions, equivalent to <code>image(transparent)</code>. Otherwise, the function represents an image with width and height equal to the width and height of the referenced element, with an appearance exactly equivalent to that of the referenced element. Whether or not the referenced element is currently being rendered on-screen, for media types where this is relevant, must not affect the appearance of the image represented by the function; the image must always be equivalent to how the element would appear when rendered on-screen. If the document changes so that which element is matched, or whether an element is matched at all, changes, the image represented by the function must change accordingly.</p>
234+
<p>If the argument to the ''element()'' function is an ID selector, the function references the element matched by the selector. If it's an identifier, the function references the element who's <dfn>CSS element reference identifier</dfn> is the given identifier. (CSS does not define how an element acquires a ''CSS element reference identifier''; that is determined by the host language.) If no element in the document matches the selector, or no element has the identifier as its ''CSS element reference identifier'', the function represents a fully transparent image with no intrinsic dimensions, equivalent to <code>image(transparent)</code>. If the document changes so that which element is matched, or whether an element is matched at all, changes, the image represented by the function must change accordingly.</p>
235+
<p>If the ''element()'' function refers to an element, then it represents an image with width and height equal to the width and height of the margin box of the referenced element. The image must be constructed by rendering the referenced element and its descendants at the same size that the element would be in its document, over an infinite transparent black background, positioned so that the edges of the margin box of the element is flush with the edges of the image. <span class=note>If the element has decorations or descendants that extend outside the margin box, these will be clipped to the margin box in the generated image by default. ''background-repeat:extend'' may allow the author to override this behavior so that decorations and descendants outside the margin box are still painted.</span> If the referenced element or an ancestor of the referenced element has a transform applied to it, the transform must be ignored for the purpose of constructing this image (transforms on descendants must be unaffected).</p>
235236
<p>If the argument passed to ''element()'' isn't an ID selector or an ident, it is a syntax error.</p>
236237
<div class=example>
237238
TODO: copy an example from the MozHacks article
238239
</div>
239-
<div class=issue>
240-
This can pretty obviously result in dependency cycles. An element can try to use itself as a background, for example. I need to add a section about determining the dependency graph and what to do when a cycle is detected.
240+
<div>
241+
<h4 class="no-num no-toc" id=element-cycles>Detecting and Resolving Circular Relationships Introduced by ''element()''</h4>
242+
<p>The ''element()'' function can produce nonsensical circular relationships, such as an element using itself as its own background. These relationships can be easily and reliably detected and resolved, however, by keeping track of a dependency graph and using common cycle-detection algorithms.</p>
243+
<p>Populate the dependency graph initially by having every element depend on each of its children. Then, whenever a property on an element A uses the ''element()'' function to refer to an element B, add an edge to the graph by having A depend on B. If a dependency cycle is detected, any ''element()'' functions that produced a dependency in the cycle represent a fully transparent image with no intrinsic dimensions.</p>
244+
<p class=issue>Someone else needs to review this and make sure that I'm not missing any cycles.</p>
241245
</div>
242246
</div>
243247

0 commit comments

Comments
 (0)