mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
When setting `font-family: monospace;` in CSS, we have to interpret the keyword font sizes (small, medium, large, etc) as slightly smaller for historical reasons. Normally the medium font size is 16px, but for monospace it's 13px. The way this needs to behave is extremely strange: When encountering `font-family: monospace`, we have to go back and replay the CSS cascade as if the medium font size had been 13px all along. Otherwise relative values like 2em/200%/etc could have gotten lost in the inheritance chain. We implement this in a fairly naive way by explicitly checking for `font-family: monospace` (note: it has to be *exactly* like that, it can't be `font-family: monospace, Courier` or similar.) When encountered, we simply walk the element ancestors and re-run the cascade for the font-size property. This is clumsy and inefficient, but it does work for the common cases. Other browsers do more elaborate things that we should eventually care about as well, such as user-configurable font settings, per-language behavior, etc. For now, this is just something that allows us to handle more WPT tests where things fall apart due to unexpected font sizes. To learn more about the wonders of font-size, see this blog post: https://manishearth.github.io/blog/2017/08/10/font-size-an-unexpectedly-complex-css-property/
2 lines
16 B
Text
2 lines
16 B
Text
Top: 13
|
|
Left: 8
|