[csswg-drafts] [css-values-4] Bugs in definition of exceptions for font-relative length units (#5228)

zjopy has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values-4] Bugs in definition of exceptions for font-relative length units ==
When a font-relative length unit is used to set the value of the property that it's defined on, the exceptions defined at the end of [font-relative lengths](https://drafts.csswg.org/css-values-4/#font-relative-length) take effect.

The idea is, to instead use the computed value of the same property of the parent element (case 1). And if no parent element exists, then use the initial value of that property (case 2).

So, or example:

- `em` for `font-size` property of element (other than root element) is case 1.
- `em` or `rem` for `font-size` property of root element is case 2.
- `lh` for `line-height` property of element (other than root element) is case 1.
- `lh` or `rlh` for `line-height` property of root element is case 2.

The textual form of these exceptions is kind of hard to read, and probably caused the author to introduce the following logical bugs.

---

The [spec](https://drafts.csswg.org/css-values-4/#font-relative-length) states for `lh` and `rlh`:

> when `lh` or `rlh` units are used in the value of the line-height property on the element they refer to, they resolve against the computed `line-height` and font metrics of the parent element—or the computed metrics corresponding to the initial values of the `font` and `line-height` properties, if the element has no parent.

In the above table this sentence would translate to

- `lh` **or `rlh`** for `line-height` property of element (other than root element) is case 1.
- `lh` or `rlh` for `line-height` property of root element is case 2.

In other words, `rlh` uses the computed value of the `line-height` property of the parent element (when used on an element other than the root element). This must be a bug, right?

---

Another bug is the loose formulation of the previous sentence. The [spec](https://drafts.csswg.org/css-values-4/#font-relative-length) states:

> When used in the value of the `font-size` property on the element they refer to, they [all these font-relative units] resolve against the computed metrics of the parent element—or against the computed metrics corresponding to the initial values of the `font` and `line-height` properties, if the element has no parent.

By using "they", the sentence specifies the exceptions for all font-relative units instead of only for `em` and `rem` like it should be. This also wrongly includes the `lh` and `rlh` units for which the `font-size` is irrelevant. Additionally, the `line-height` property is mixed in, for which the exceptions is actually defined in the next sentence as seen above.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5228 using your GitHub account

Received on Wednesday, 17 June 2020 11:00:51 UTC