W3C home > Mailing lists > Public > www-style@w3.org > September 2009

[css2] ::first-line and inheritance

From: Giovanni Campagna <scampa.giovanni@gmail.com>
Date: Wed, 2 Sep 2009 18:28:42 +0200
Message-ID: <65307430909020928h53559dbfh4731d5336e4d1bd7@mail.gmail.com>
To: www-style@w3.org
Run-in discussion has uncovered again the pandora's box of
::first-line inheritance.
I once submitted a proposal,
<http://www.w3.org/2002/02/mid/65307430904140653v74522676j4cd98cb48ce3e3cc@mail.gmail.com;list=www-style>
to make every "strange" pseudo-element innermost. While this could
work for ::selection and maybe ::first-letter, it is not backward
compatible with current rendering of ::first-line.
Some times later I sent a second proposal,
<http://lists.w3.org/Archives/Public/www-style/2009Jun/0492.html>,
that solved the problem of multiple computed values by sidestepping
completely computed values at rendering time.

Since I believe that current text is ambiguous and breaks the general
CSS model, and because I'd like to see ::last-line and ::nth-line in
CSS4/5 (which require a consistent model, and not considering
:first-line an historical error), I would like to renew the proposal
n2, with some amendments caused by previous misunderstandings of the
inline formatting model, and by the latest message by Bert Bos (to
avoid any reference to a tree-like formatting structure)

First of all, the Computed Values for a Specified Value of "inherit"
completely ignore the existence of "::first-line" pseudo-elements and
it are just the same as the Computed Value of the parent, as it would
normally be.
Then we change css2 5.12.1 to say:
----
A "line-level pseudo-element" represents a line box of its _superior parent_.
Only block-level elements may be superior parents of a _line level_
pseudo-element. Only "line-height", "vertical-align", "word-spacing",
"letter-spacing", "text-transform", the _background properties_ and
the _font properties_ apply to _line level_ pseudo-elements.

The "line-height" and _font properties_ property are used for the
_strut_ at the beginning of the line box represented by the
_line-level_ pseudo-element, instead of the respective properties on
the _superior parent_.
The _background properties_ and  "text-decoration", apply to the line
box. These properties don't affect inline boxes inside the line box,
just adding a background layer and a text decoration on bottom of
existing ones.
The _font properties_, "word-spacing", "letter-spacing" and
"text-transform"  instead affect boxes inside. Inline boxes that
- are inside the line box
- are generated by an element (or _structural pseudo-element_) that
has a Specified Value for the relevant properties of "inherit",
instead of finding the Used Value from the Computed Value of the
element they belong, they find it from the _innermost line-level
pseudo-element_ representing the line box in which they reside, if a
value is specified on those, different from the initial value.
The "innermost line-level pseudo-element" is the line-level
pseudo-element belonging to the deepest element.

CSS2 only defines one line-level pseudo-element, :first-line,
representing the first line box. Future versions of CSS may add more.
----
Assumptions:
- the "superior parent" is the element to which the pseudo-element is
attached (definition from CSS3 Generated Content)
- properties inherited by default are just normal properties with a
declaration in the UA like:
*, *:before, *:after, *:first-letter {
color:inherit;
font:inherit;
line-height:inherit;
/* etc. */
}
(please note, there is :first-line in the selector, so we can check
the presence of a property by looking for the initial value)

I hope that this proposal will be discussed soon, or the
backward-compatibility problem may become bigger and bigger,
preventing us from a consistent model that doesn't leak information
from the formatting structure into the inheritance processing.

Giovanni
Received on Wednesday, 2 September 2009 16:29:23 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:20 GMT