[CSS21] floated :first-letter pseudo-element should act like normal inline (e.g., support line-height)
Categories
(Core :: Layout: Floats, defect, P3)
Tracking
()
People
(Reporter: phiw2, Assigned: jfkthame)
References
(Depends on 1 open bug, Blocks 2 open bugs)
Details
(Keywords: testcase, Whiteboard: tlt-backlog [webcompat:p3])
Attachments
(7 files)
![]() |
Reporter | |
Comment 1•20 years ago
|
||
![]() |
Reporter | |
Comment 2•20 years ago
|
||
![]() |
Reporter | |
Comment 3•20 years ago
|
||
![]() |
||
Comment 4•20 years ago
|
||
Comment 5•20 years ago
|
||
![]() |
||
Comment 6•20 years ago
|
||
Comment 7•20 years ago
|
||
![]() |
||
Comment 8•20 years ago
|
||
![]() |
Reporter | |
Comment 9•20 years ago
|
||
![]() |
||
Comment 10•20 years ago
|
||
![]() |
Reporter | |
Comment 11•20 years ago
|
||
![]() |
Reporter | |
Comment 12•20 years ago
|
||
![]() |
Reporter | |
Comment 13•20 years ago
|
||
![]() |
Reporter | |
Comment 14•20 years ago
|
||
![]() |
||
Comment 15•20 years ago
|
||
![]() |
Reporter | |
Comment 16•20 years ago
|
||
Comment 21•10 years ago
|
||
Updated•9 years ago
|
Updated•9 years ago
|
Updated•9 years ago
|
Comment 24•8 years ago
|
||
Updated•8 years ago
|
Updated•8 years ago
|
Updated•8 years ago
|
Comment 26•8 years ago
|
||
Comment 28•8 years ago
|
||
Updated•8 years ago
|
Updated•8 years ago
|
![]() |
||
Updated•8 years ago
|
![]() |
||
Comment 30•8 years ago
|
||
Comment 31•7 years ago
|
||
Updated•7 years ago
|
Comment 33•7 years ago
|
||
Updated•7 years ago
|
![]() |
||
Updated•7 years ago
|
![]() |
||
Updated•7 years ago
|
Updated•6 years ago
|
Comment 35•6 years ago
|
||
See bug 1547409. Migrating webcompat priority whiteboard tags to project flags.
![]() |
||
Updated•5 years ago
|
![]() |
||
Updated•5 years ago
|
Updated•3 years ago
|
Comment 37•3 years ago
|
||
The severity field for this bug is relatively low, S3. However, the bug has 8 duplicates and 9 See Also bugs.
:TYLin, could you consider increasing the bug severity?
For more information, please visit auto_nag documentation.
Comment 38•3 years ago
|
||
The last needinfo from me was triggered in error by recent activity on the bug. I'm clearing the needinfo since this is a very old bug and I don't know if it's still relevant.
Assignee | ||
Comment 40•3 years ago
|
||
Given that fully implementing initial-letter will take some time (and doesn't help with existing content, as it will need to be adopted by authors), I think we should do something to mitigate the webcompat pain here.
To minimize the risk of regressing existing content that does work well in Firefox, I propose taking a fairly conservative approach here:
(1) Although I think first-letter could benefit from a major refactoring, to move more work to frame-construction time instead of reflow time, let's not do that here; keep the existing code structure and make only minimal changes to achieve a webkit/blink-compatible result;
(2) Implement modified behavior behind a flag, so that we can roll it out initially just to Nightly, and can easily revert to existing behavior in case of problems.
Furthermore, we can probably distinguish between content that works well with our current behavior (typically this would be a "naive" use of first-letter with float:left, and no special effort to adjust the margins around the floated letter) vs content that is authored specifically for the webkit/blink model. In the latter case, the author typically needs to remove excess blank space around the floated letter. I've seen two techniques used for this: setting an unusually small line-height (less than 1em) on the first-letter, so as to reduce the height of its box, or applying negative top and bottom margins to it.
Given this, I think we can usefully implement an "auto" behavior toggle that uses heuristics to choose between our existing "tightly wrapped" behavior and the "loose wrap" model, based on the presence of such line-height or margin values.
Assignee | ||
Comment 41•3 years ago
|
||
https://codepen.io/jfkthame/pen/qBKeBWd has some examples to compare our behavior vs webkit/blink's. Case (1) there shows how our current "tight wrap" behavior gives a better result when an author simply uses float:left on first-letter, without specifically compensating for blank space around the glyph within the font's overall metrics.
Cases (2) and (3) are examples of how authors often handle this, using either negative margins or reduced line-height. Case (2) looks bad in current Firefox, and is typical of the sort of bug reports we get. Case (3) renders the same as (1) for us, as we ignore the line-height property.
The cases where the first-letter glyph has a descender ("y" or "J") show that the webkit/blink behavior doesn't automatically account for this (as gecko does); the author would need to adjust the margin or line-height properties to avoid a clash in these cases. In practice, though, first-letter is almost always applied to descender-less capitals, and so this doesn't often arise.
My proposed change here to use a heuristic to switch between the two behaviors will keep our existing behavior for case (1), while switching to a webkit/blink-compatible result for (2) and (3).
Assignee | ||
Comment 42•3 years ago
|
||
And fix the overflow-float-overflow.html test to do a != comparison, as indicated by the
-notref naming of the reference file.
No behavior change; this is just adjusting a couple of old reftests so they will not be
affected by the exact detail of how we wrap around a floating first-letter (which is
incidental to what they were aiming to test).
Updated•3 years ago
|
Assignee | ||
Comment 43•3 years ago
•
|
||
Historically, Gecko implemented the behavior allowed by CSS2 whereby a floated ::first-letter is "boxed"
tightly around the glyph shape, rather than using constant font-ascent and -descent metrics which may
leave a lot of blank space depending whether the character has any ascender/descender or not.
However, neither webkit nor blink do this, which leads to webcompat pain when sites are constructed
assuming their behavior.
Eventually, I think we should ideally reimplement ::first-letter entirely at frame-construction time,
rather than during reflow. But in the interest of minimizing risk here, and making it easy to flip
between our existing "legacy" behavior and the new "compatible" behavior, this patch leaves the
overall implementation unchanged and just alters the metrics used for the resulting first-letter
frame.
This patch creates an integer pref layout.css.floating-first-letter.tight-glyph-bounds to allow us
to choose between three behaviors:
1: Use tight glyph bounds, and ignore line-height; the baseline of the floated letter automatically
adjusts to wrap text around the "ink box" of the glyph. This is the existing Gecko behavior.
0: Don't use tight glyph bounds, respect line-height: the floated letter acts like a normal <span>
with float positioning; baseline position and vertical size are based on font metrics but not
the specific shape of the individual glyph. This gives a similar result to webkit/blink.
-1: Automatically choose between (1) and (0) based on heuristics to try and detect whether the page
was written with the webkit/blink behavior (0) in mind; specifically, if there is a line-height
of less than 1em, or a negative block-start margin, we assume the author was trying to eliminate
excess blank space that behavior (0) tends to produce, and so we use that model.
Initially, this patch leaves the behavior unchanged for Beta/Release builds, but enables option -1 (use
heuristics to choose which layout model to apply) on Nightly so we can see how that works in practice.
Depends on D165007
Assignee | ||
Comment 44•3 years ago
|
||
Depends on D165008
Comment 45•3 years ago
|
||
Comment 46•3 years ago
•
|
||
Backed out for causing build bustages on nsFirstLetterFrame.cpp
- Backout link
- Push with failures
- Failure Log
- Failure line: /builds/worker/checkouts/gecko/layout/generic/nsFirstLetterFrame.cpp:160:41: error: member access into incomplete type 'nsTextFrame'
and also mochitest failures: https://treeherder.mozilla.org/logviewer?job_id=400126353&repo=autoland
Comment 47•3 years ago
|
||
It also fails on Windows 10 x64 2004 reftests with gfxFont::GetMetrics(nsFontMetrics::FontOrientation crash signature.
- Push with failures
- Failure line: REFTEST PROCESS-CRASH | layout/base/crashtests/429865-1.html | application crashed [@ gfxFont::GetMetrics(nsFontMetrics::FontOrientation)]
Comment 48•3 years ago
|
||
Comment 49•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/7a17a4c4cd6e
https://hg.mozilla.org/mozilla-central/rev/02a4e815c82c
https://hg.mozilla.org/mozilla-central/rev/b476e406831d
Assignee | ||
Updated•3 years ago
|
Updated•2 years ago
|
Description
•