Closed Bug 1813536 Opened 1 year ago Closed 1 year ago

Inconsistent computed-style serialization of line-height vs font shorthand

Categories

(Core :: CSS Parsing and Computation, defect)

defect

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

Details

Attachments

(1 file)

This Firefox behavior seems a little odd to me:

> document.body.style.font = "bold 10px / 1.5 serif"
< "bold 10px / 1.5 serif"
> window.getComputedStyle(document.body).font
< "700 10px / 1.5 serif"
> window.getComputedStyle(document.body).lineHeight
< "15px"

Note that the line-height value, specified in the shorthand as 1.5, has been serialized as 1.5 in the font shorthand of the computed style, but as 15px in the longhand line-height property.

In contrast, Chrome serializes it as 15px in both the shorthand and longhand, which is at least consistent.

(Safari also serializes the line height as 15px in both cases, although it has other issues with the shorthand...)

AFAICS from the CSS2 spec for line-height, the computed value is supposed to be "for <length> and <percentage> the absolute value; otherwise as specified", which would seem to imply that 1.5 would be the expected computed value; but the only place I see this is in the Firefox version of the shorthand; everywhere else, it is resolved to the absolute value 15px.

So maybe that spec is obsolete and we should just converge on using the absolute value? The current inconsistency seems undesirable.

(And presumably the spec for line-height should be updated and moved to a newer spec, but currently everything seems to refer back to CSS2.)

Severity: -- → S3

This makes the serialization of the 'font' shorthand on computed style return the line-height
as an absolute length rather than a number (font-size multiplier), which is consistent with
what the line-height longhand already returns, and with other browsers.

(See also https://github.com/w3c/csswg-drafts/issues/8385.)

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Attachment #9315360 - Attachment description: Bug 1813536 - Resolve <number> to <length> for computed line-height. r=#firefox-style-system-reviewers → Bug 1813536 - Resolve <number> to <length> in ToResolvedValue for line-height. r=#firefox-style-system-reviewers
See Also: → 1814626
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/481e2ec41b3a
Resolve <number> to <length> in ToResolvedValue for line-height. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: