stylo: support ::first-line

NEW
Assigned to

Status

()

Core
CSS Parsing and Computation
P1
normal
6 months ago
2 days ago

People

(Reporter: heycam, Assigned: bz, NeedInfo)

Tracking

(Depends on: 2 bugs, Blocks: 4 bugs)

Firefox Tracking Flags

(Not tracked)

Details

Comment hidden (empty)
Blocks: 1324665
Blocks: 1324673
Blocks: 1324705
So the complexity here includes all the stuff we need to do to support ::first-line (bug 1324618), _plus_ the added complications of how to deal with multiple inline frames inheriting from the same style context.

So we'll probably want to look at bug 1324618 first (or at least simultaneously).
Depends on: 1324618
There's also the complexity of how the kids of first-letter inherit.

Given this document:

<!DOCTYPE html>
<style>
  div { border-color: purple; color: yellow }
  div::first-line { border-color: green; color: blue; }
  span { color: inherit; border-color: inherit; border-style: solid;
         border-width: 5px}
</style>
<div><span>Text</span></div>

per spec and in Gecko the span has a purple border and blue color.  (Chrome doesn't implement the spec here, but it does other weird stuff; for example "display" in the <span> _does_ inherit from the <div>.  The spec's setup was decided on as the sanest thing to produce something kinda like observable behavior in important cases and not special-case any particular properties.)
(In reply to Boris Zbarsky [:bz] (still a bit busy) from comment #2)
> There's also the complexity of how the kids of first-letter inherit.

Do you mean first-line?

> 
> Given this document:
> 
> <!DOCTYPE html>
> <style>
>   div { border-color: purple; color: yellow }
>   div::first-line { border-color: green; color: blue; }
>   span { color: inherit; border-color: inherit; border-style: solid;
>          border-width: 5px}
> </style>
> <div><span>Text</span></div>
> 
> per spec and in Gecko the span has a purple border and blue color.

Huh. Why the different inheritance sources for border-color and color?
> Do you mean first-line?

Yes.

> Why the different inheritance sources for border-color and color:

Because color inherits by default and border-color does not.  Per spec, props that inherit by default inherit from first-line and props that do not inherit by default inherit from the DOM parent.  Or at least that _used_ to be the case when Gecko implemented it.  Looking at https://www.w3.org/TR/css3-selectors/#first-formatted-line last paragraph it says:

  During CSS inheritance, the portion of a child element that occurs on the first line only inherits
  properties applicable to the ::first-line pseudo-element from the ::first-line pseudo-element. For
  all other properties inheritence is from the non-pseudo-element parent of the first line pseudo
  element. (The portion of a child element that does not occur on the first line always inherits
  from the parent of that child.) 

so they apparently went back to determining where to inherit from on a fairly ad-hoc per-property basis? :(
Flags: needinfo?(dbaron)
So I guess per-spec border-color and background-color should inherit differently (because the former does not apply and the latter does).  In Gecko they inherit identically, since neither inherits by default...
(In reply to Boris Zbarsky [:bz] (still a bit busy) from comment #4)
> Because color inherits by default and border-color does not.  Per spec,
> props that inherit by default inherit from first-line and props that do not
> inherit by default inherit from the DOM parent.  Or at least that _used_ to
> be the case when Gecko implemented it.  Looking at
> https://www.w3.org/TR/css3-selectors/#first-formatted-line last paragraph it
> says:
> 
>   During CSS inheritance, the portion of a child element that occurs on the
> first line only inherits
>   properties applicable to the ::first-line pseudo-element from the
> ::first-line pseudo-element. For
>   all other properties inheritence is from the non-pseudo-element parent of
> the first line pseudo
>   element. (The portion of a child element that does not occur on the first
> line always inherits
>   from the parent of that child.) 
> 
> so they apparently went back to determining where to inherit from on a
> fairly ad-hoc per-property basis? :(

I don't recall the discussion that led to this.

It's probably worth investigating both:
 * what WG discussion led to that spec text
 * whether other browsers implement it

I'll leave the needinfo? to do that (at least the first) at some point later, although somebody else could also investigate it first...
Assignee: nobody → bzbarsky
Priority: -- → P1
Depends on: 1352743
Blocks: 1324348
Depends on: 1369187
Depends on: 1375315
Blocks: 1375338
You need to log in before you can comment on or make changes to this bug.