[review]font-size:0 ignored

VERIFIED FIXED in mozilla0.9.8

Status

()

Core
CSS Parsing and Computation
P3
normal
VERIFIED FIXED
16 years ago
16 years ago

People

(Reporter: Aaron Kaluszka, Assigned: Pierre Saslawsky)

Tracking

({css1, css2, fonts})

Trunk
mozilla0.9.8
css1, css2, fonts
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

16 years ago
font-size:0 does not work.. it does not matter if units are given or not.. it is
completely ignored.
CSS2 15.2.4 says font-size can take <length> (4.3.2 defined as any number) but
negative lengths are illegal.
Zero is not illegal but Mozilla treats it as such.
(Reporter)

Comment 1

16 years ago
also, font-size:0.1mm doesn't work either (rounded down to 0?)
(Reporter)

Comment 2

16 years ago
Also, anything below font-size:4% doesn't work either (relative to default 16px)
*** Bug 89598 has been marked as a duplicate of this bug. ***
(Reporter)

Comment 4

16 years ago
From DUP bug 89590: "It's a severe limitation. IE 5 makes text invisible, and 
it's extremely useful - e.g. using this feature you can turn "annotated 
version" of your document to "not annotaed" by just setting font size to 0pt in 
CSS for "div.annotation" style (provided all annotations are enclosed as "<div 
class=annotation></div>')."

I'd also like to add that it is necessary for certain Standards mode 
compatibility issues.  In order to truly remove those bug 22274 "image 
descenders" a font-size of zero applied to the body is a workaround.
(Reporter)

Updated

16 years ago
Keywords: mozilla0.9.3, nsbeta1
Bug 89598 is the DUP, not 89590.
(Reporter)

Comment 6

16 years ago
yeah.. strike-through 8s and 0s look nearly identical
(Reporter)

Comment 7

16 years ago
CSS1 5.2.6 also mentions this.  Marking css1.  Can we get an update on this one?
Keywords: css1
rbs: This is probably an easy fix while you're in the fonts code... :-)

Updated

16 years ago
Blocks: 104166
(Assignee)

Comment 9

16 years ago
"font-size: 0pt" doesn't make the text invisible on IE5/win98, it makes it 1px 
high.  On MacNav4, WinNav4 and MacIE5, the declaration is more or less ignored 
(the size is 'normal' but the line-height can be slightly affected).  Still, 
regardless of what the other browsers do, I don't think we have to worry about 
emulating their behavior.  We could just fix it.
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla0.9.6
(Assignee)

Updated

16 years ago
Target Milestone: mozilla0.9.6 → mozilla0.9.7
(Assignee)

Updated

16 years ago
Target Milestone: mozilla0.9.7 → mozilla0.9.8
(Reporter)

Comment 10

16 years ago
AFAIK IE5.5 and IE6 handle this properly, btw.
(Assignee)

Comment 11

16 years ago
The problem appears to be that native toolbox functions refuse to set the text 
size to 0 (eg. on the Mac, ::TextSize(0) is ignored).  Here is a patch that fixes 
the problem in XP code.

Marc/RBS: please r/sr
Summary: font-size:0 ignored → [review]font-size:0 ignored
(Assignee)

Comment 12

16 years ago
Created attachment 61969 [details] [diff] [review]
patch
(Assignee)

Comment 13

16 years ago
Created attachment 61970 [details]
testcase

Comment 14

16 years ago
> The problem appears to be that native toolbox functions refuse to set the text 
> size to 0 (eg. on the Mac, ::TextSize(0) is ignored).

Similar story on Windows. There is no special-case of font-size:0 on Windows, 
and nothing is breaking down. So I was curious to understand why, and I just 
looked at the GDI documentation, and it says that when the font-size is passed 
as 0, "the font mapper uses a default height value when it searches for a 
match." In other words, the font metrics' ascent, descent, etc, are still going
to be non-zero. That may be why other browsers gave the general impression that 
the declaration is ignored. 

Looking at the patch, I first had the impression that it will achieve the same 
effect as a textframe with an empty content, and I was wondering what will 
happen when the block code will apply its min-height rule. At first, it seemed 
that things wouldn't collapse into nothingness since the line-height is 
supposedly non-zero. But after applying and testing the patch, things worked out 
well. The case that didn't work and left a visible blank line was:
<p><span style="font-size:0pt">...invisible text...</span></p>

I am leaning towards thinking that the line-height may be coming from the 
font-size. And since the block code collapses empty lineboxes in your testcase 
and its line-height is 0, it disappears... In the other case, the min-height 
applies.

Anyway r=rbs, since authors can work-around the limitation by putting the 
declaration in the correct place.

Note: might be worth special-casing font-size:0 when setting the line-height in 
bug 95267 to avoid to regress this fix.

Comment 15

16 years ago
Comment on attachment 61969 [details] [diff] [review]
patch

r=rbs
Attachment #61969 - Flags: review+
(Reporter)

Updated

16 years ago
Keywords: css2, fonts, patch, review

Comment 16

16 years ago
Comment on attachment 61969 [details] [diff] [review]
patch

sr=attinasi
Attachment #61969 - Flags: superreview+
(Assignee)

Comment 17

16 years ago
fixed
Status: ASSIGNED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → FIXED
(Reporter)

Comment 18

16 years ago
sweet
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.