Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-values-4] Cyclic dependency between lh and font-relative units #9018

Closed
xiaochengh opened this issue Jun 29, 2023 · 6 comments
Closed
Labels
css-values-4 Current Work

Comments

@xiaochengh
Copy link
Contributor

xiaochengh commented Jun 29, 2023

The spec only covers two cases of cyclic dependency:

  • Font-relative units used in font-size
  • lh/rlh used in line-height

There are more cases that are not covered:

  1. Font-relative units used in other font properties that affect font selection, e.g., font-weight: calc(10ex / 1px)
  2. Dependency cycle formed by font properties and line-height, e.g., line-height: 2em; font-size: 1lh

(Edit: 2 is already covered, as lh is considered a font-relative length unit)

Right now (1) isn't surfaced in any browser because no one supports calc(10ex / 1px) yet. But this will also surface if functions like atan2() and sign() that can convert a <length> into a non-length type is properly implemented. This has also been discussed in #8169

For (2), currently Blink and WebKit are breaking the cycle by using parent's line height to compute fon-size (see (test case)[https://jsfiddle.net/3rojdnsc/]). Gecko hasn't implemented lh yet.

I don't have a strong opinion on how exactly the cycle should be broken, and I guess it doesn't matter because there's no real use case with such dependency cycles. We just need a solution for spec completeness.

@Loirooriol
Copy link
Contributor

(1) is basically #8169
(2) was discussed in #2115:

RES0LVED: define lh unit resolution to be that of the parent when the lh unit is spec on line height or font size

It's already covered in the spec, note that lh is considered to be a local font-relative length unit.

BTW, registered properties introduce another cycle: w3c/css-houdini-drafts#1080

@xiaochengh
Copy link
Contributor Author

(1) is basically #8169

Their topics are different, unless we want to repurpose #8169 to discuss dependency instead?

It's already covered in the spec, note that lh is considered to be a local font-relative length unit.

Thanks for the pointer! Then we don't have an issue here.

BTW, registered properties introduce another cycle: w3c/css-houdini-drafts#1080

I think this is already covered by https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles?

However, for backward compatibility reasons, we can't adopt the same approach (i.e., make everything in the cycle invalid) for built-in properties.

@Loirooriol
Copy link
Contributor

I think this is already covered by https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles?

That only handles registered properties with a syntax of <length> or <length-percentage>, but with unit algebra we may have cycles with e.g. <number> or <angle>. See the examples in the issue.

@andruud
Copy link
Member

andruud commented Jul 3, 2023

Can we simply extend the behavior that font-relative units have in font-size to all font-* properties? And to any other properties that affect font selection?

@SebastianZ SebastianZ added the css-values-4 Current Work label Jul 5, 2023
@Loirooriol
Copy link
Contributor

Anything else to do here after the resolution in #8169 (comment) ?

@xiaochengh
Copy link
Contributor Author

Nope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-values-4 Current Work
Projects
None yet
Development

No branches or pull requests

4 participants