Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upThe computed `font-size` and `line-height` must be clamped when the specified value is out-of-range #15296
Comments
|
What I'm going to say may be really wrong, due to my ignorance about how style works in servo. Wouldn't it be better if every property that can implement calc() should provide a maximum and minimum value for calc()? |
|
We should add a |
|
That should be |
|
I am pretty sure I fixed this in #16382. |
|
Actually it isn't fixed. The issue can still be reproduced with <div id="test"></div>
<script>
test.style.fontSize = 'calc(-1px)';
alert(getComputedStyle(test).fontSize);
</script> |
|
servo/components/style/properties/longhand/font.mako.rs Lines 801 to 805 in 9a419ec |
|
I'm not sure |
|
Actually am wrong, but there should still not be any |
Refactor how calc() clamping is done on computed values (fixes #15296) <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16889) <!-- Reviewable:end -->
Refactor how calc() clamping is done on computed values (fixes #15296) <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16889) <!-- Reviewable:end -->
Refactor how calc() clamping is done on computed values (fixes #15296) <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16889) <!-- Reviewable:end -->
Although it is invalid to specify something like
font-size: -1px, it is allowed to dofont-size: calc(-1px). In the latter case,font-sizemust be computed to zero rather than-1px.The spec: https://drafts.csswg.org/css-values-3/#calc-range
The relevant code is probably https://github.com/servo/servo/blob/master/components/style/properties/longhand/font.mako.rs#L378-L382
(I found
font-sizeandline-height, but other properties may be affected as well.)