mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 23:39:02 +00:00
LibWeb: Clamp layout content sizes to a max value instead of crashing
We've historically asserted that no "saturated" size values end up as final metrics for boxes in layout. This always had a chance of producing false positives, since you can trivially create extremely large boxes with CSS. The reason we had those assertions was to catch bugs in our own engine code where we'd incorrectly end up with non-finite values in layout algorithms. At this point, we've found and fixed all known bugs of that nature, and what remains are a bunch of false positives on pages that create very large scrollable areas, iframes etc. So, let's change it! We now clamp content width and height of boxes to 17895700 pixels, apparently the same cap as Firefox uses. There's also the issue of calc() being able to produce non-finite values. Note that we don't clamp the result of calc() directly, but instead just clamp values when assigning them to content sizes. Fixes #645. Fixes #1236. Fixes #1249. Fixes #1908. Fixes #3057.
This commit is contained in:
parent
da579e11b0
commit
4f855286d7
Notes:
github-actions[bot]
2025-02-05 17:46:43 +00:00
Author: https://github.com/awesomekling
Commit: 4f855286d7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3465
7 changed files with 40 additions and 50 deletions
|
@ -4896,10 +4896,7 @@ RefPtr<CSS::CSSStyleValue> parse_dimension_value(StringView string)
|
|||
}
|
||||
auto integer_value = number_string.string_view().to_number<double>();
|
||||
|
||||
// NOTE: This is apparently the largest value allowed by Firefox.
|
||||
static float max_dimension_value = 17895700;
|
||||
|
||||
float value = min(*integer_value, max_dimension_value);
|
||||
float value = min(*integer_value, CSSPixels::max_dimension_value);
|
||||
|
||||
// 6. If position is past the end of input, then return value as a length.
|
||||
if (position == input.end())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue