Re: [css-inline] initial-letter in WebKit (feedback after implementing)

On 09/03/2014 03:46 PM, David Hyatt wrote:
> I have added basic support for initial-letter and wanted to provide
> some feedback after implementing it. Note I don't handle ideographic
> baselines yet, nor do I handle vertical text. The property is also
> only applicable to ::first-letter at the moment, so confine your
> testing to examples using only ::first-letter.
>
> Here is my feedback after implementing this property:
>
> (1) initial-letter should become a shorthand for initial-letter-drop
> and initial-letter-height rather than staying a single
> property that specifies two distinct values.

What would be the rationale for this?

> (2) The draft says the initial value is "normal" and yet this isn't
> listed as an allowed value in the grammar (which simply shows 1 or
> two integers). I implemented "normal" and interpreted it as "off",
> i.e., a special value that means ignore the property completely and
> just keep first-letter behavior the way it is now in shipping browsers.

Yes, that is what was intended. See
   http://www.w3.org/mid/537AF67C.5010004@inkedblade.net

The key behavior that we needed to switch was what happens to the next
paragraph when a dropped initial letter is taller than the paragraph.
If that next paragraph begins with a normal first-letter, then it just
wraps around the dropped letter. If the next paragraph begins with a
non-normal first-letter, then it must clear the dropped letter first.

> (3) The spec really needs to talk about where the borders, padding
> and margins are placed around the first-letter. I made the assumption
> that the first-letter extends above the baseline by cap-height and
> below the baseline by the glyph bounds, and so any borders and
> padding you put around the first-letter would snugly fit this area.
> Aesthetically this looked right to me (rather than putting the
> border/padding above the ascent and below the descent).

Yes, this was one of the major reasons to have a specialized property
for this function (rather than relying on float, as the CSS1 spec
proposed).

> (4) Again, getting into border/padding, I assumed that you still
> align the cap-height of the first-letter with the cap-height of
> the line, even if the first-letter has border/padding. In the
> example above, you can see the letter is aligned and the border/
>padding simply "spill up", which means they possibly would overlap
> a previous paragraph. This is consistent with border/padding/margins
> on inlines themselves, and I think it's worth deviating from normal
> float behavior in this case. Here's another example showing what I
> mean (deliberately ugly just to prove a point):

Agreed.

> This does raise a question of whether lines should dodge the bottom
> border/padding of the float, or if they should overlap it. At the
> moment I'm still dodging bottom border/padding/margin. I am inclined
> to suggest that they should overlap, since it's consistent with
> normal inline text behavior with borders and padding.

I think the margin box of the initial letter should be cleared. There
are many examples where, for an illuminated letter, the entire box is
cleared. Including margins here allows the author to provide appropriate
spacing around the visible area (and to make it negative if they want
overlap).

> (6) first-letter clearance is a little strange. Do you expect a floating
> first letter to clear a non-floating first letter? If so, that should
> probably be clarified. I'm not convinced this special case is necessary,
> since it's pretty nonsensical to put first-letters that close together
> anyway.

If by floating first-letter you mean one with 'initial-letters'
not-'normal' (rather than one with 'float: left'), then see above
notes for (2).

> (7) It would be helpful to understand if there are any attributes of
> first-letter that are being changed that do NOT depend on the new
> properties. For example is there an expectation that the borders/padding
> should snugly fit cap-height + descent even without initial-letter being
> specified? If so, that should be added.

The CSS1 and CSS2 specs expected that, but they also expected floated
first letters (::first-letter { float: left; }) to do other kinds of magic.
We do have 'initial-letter: 1' to trigger all of the interesting sizing
behavior here, so it may not be necessary.

~fantasai

Received on Monday, 8 September 2014 14:12:20 UTC