Support mixed number, unit value, and percent for calc() parser

NEW
Unassigned

Status

()

defect
P3
normal
3 years ago
11 months ago

People

(Reporter: boris, Unassigned)

Tracking

(Blocks 2 bugs, {dev-doc-needed})

Firefox Tracking Flags

(Not tracked)

Details

()

Reporter

Description

3 years ago
According to Bug 594933 comment 28 and 29, the unit checking in the parsing code needs additional changes. For example, our code can parse calc(1 + 2) and calc(1px + 2px),

but doesn't accept calc(1 + 2px),

which ought to be accepted for line-height, stroke-dashoffset, and stroke-width. There is various code in the functions inside of ParseCalc that needs updating, and some comments also need updating. There's currently no spec for it, but it's better to handle this case.
Also, my understanding from bug 594933 is that other browser engines don't currently support this (I think that's silly, but it's also the reason I said fixing bug 594933 without this was OK).  If that changes, somebody should update this bug to say so!
Reporter

Updated

3 years ago
Blocks: 1218257
No longer depends on: 1218257
(In reply to Boris Chiou [:boris] from comment #0)
> For example, our code can parse calc(1 + 2)

(To clarify something that confused me initially -- so, you're right that we do support that expression *for line-height*, but we don't support calc(number+number) or calc(integer+integer) in general, e.g. in the number-valued "opacity" property or the integer-valued "z-index" property.  Bug 1296209 partly covers that.  calc(1+2) only works for "line-height" via a custom "SetLineHeightCalcOps" calc-handling class that lives in nsRuleNode.cpp right now.)
Reporter

Updated

3 years ago
See Also: → 1278264
Blocks: 1278264
Priority: -- → P3
Blocks: 1298537
What's possible for calc() and what not is outlined in https://drafts.csswg.org/css-values-3/#calc-notation.

Sebastian
You need to log in before you can comment on or make changes to this bug.