Re: [css3-page][css3-mediaqueries] Changing element styles on page breaks

On 2/24/12 1:17 PM, Tab Atkins Jr. wrote:
> 1)
> <p><::first-line>I'm a short paragraph.<span>I only</span></::first-line>
> <span>have a few lines.</span></p>
>
> 2)
> <p><::first-line>I'm a short paragraph.
> </::first-line><span><::first-line>I only</::first-line>
> have a few lines.</span></p>
...
> The tiny handful of properties that ::first-line is allowed to have is
> deliberately chosen to only contain ones where you can't tell the
> difference between the above two scenarios.

Uh, no.  Just no.  You can trivially tell the difference using 
background properties.  Or font-size, for that matter; see below.

> This allows authors to
> pretend that they have the first structure (which is simpler to think
> about)

And which the spec currently requires, insofar as CSS2.1 5.12.1 requires 
anything.

> while implementations actually use the second structure (which
> avoids breaking things based on properties on the<span>).

I really wish you wouldn't say "implementations" when you mean "I think 
WebKit"... ;)

Gecko uses the first structure.

Black-box testing using this testcase:

   <!DOCTYPE html>
   <style>
     p { font-size: 100px; }
     p::first-line {
       background: url(http://www.w3.org/StyleSheets/TR/logo-REC) no-repeat;
       font-size: 10px;
       span { border-left: solid 1em black; }
     }
   </style>
   <p>I'm a short paragraph.  <span>I only<br>
   have a few lines.</span></p>

suggests that Presto either uses the first structure or is pretending 
very hard to do so.  WebKit possibly uses the second structure (and 
fakes the bit with the background image somehow), sine it makes the left 
border 100px wide.  Trident leaves 100px of space for the border, but 
only paints it 10px wide; I'm not quire sure what their internal 
representation is, based on that.

All of the browsers involved only show one copy of the border image, 
which is just not consistent with the second structure, of course.

And hello, lack of interop!

As far as I can tell, the spec currently calls for the Gecko/Presto 
behavior here.

> If you tried to *force* the first structure (by declaring that the first part
> of the<span>  is a child of the ::first-line), you get a *lot* of
> things potentially going wrong.

Like what?

Note that you do have to make sure that the <span> inherits properties 
that are not inherited by default from the <p>, not from the 
<::first-line>.  If you do that, things more or less work.

-Boris

Received on Friday, 24 February 2012 18:41:07 UTC