mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibWeb: Add FIXME whining to debug log if layout produces negative sizes
Negative width/height sizes are not allowed in CSS, so if our layout algorithm resolves something to a negative size, we have boogs. Instead of crashing or rendering something very wrong, we now clamp the values to 0 and whine on the debug log so that someone can go and figure out how we got the negative values in the first place. :^)
This commit is contained in:
parent
4bf10674fa
commit
b3b9ac6201
1 changed files with 10 additions and 0 deletions
|
@ -326,12 +326,22 @@ void LayoutState::UsedValues::set_node(NodeWithStyleAndBoxModelMetrics& node, Us
|
||||||
|
|
||||||
void LayoutState::UsedValues::set_content_width(CSSPixels width)
|
void LayoutState::UsedValues::set_content_width(CSSPixels width)
|
||||||
{
|
{
|
||||||
|
if (width < 0) {
|
||||||
|
// Negative heights are not allowed in CSS. We have a bug somewhere! Clamp to 0 to avoid doing too much damage.
|
||||||
|
dbgln("FIXME: Layout calculated a negative width for {}: {}", m_node->debug_description(), width);
|
||||||
|
width = 0;
|
||||||
|
}
|
||||||
m_content_width = width;
|
m_content_width = width;
|
||||||
m_has_definite_width = true;
|
m_has_definite_width = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutState::UsedValues::set_content_height(CSSPixels height)
|
void LayoutState::UsedValues::set_content_height(CSSPixels height)
|
||||||
{
|
{
|
||||||
|
if (height < 0) {
|
||||||
|
// Negative heights are not allowed in CSS. We have a bug somewhere! Clamp to 0 to avoid doing too much damage.
|
||||||
|
dbgln("FIXME: Layout calculated a negative height for {}: {}", m_node->debug_description(), height);
|
||||||
|
height = 0;
|
||||||
|
}
|
||||||
m_content_height = height;
|
m_content_height = height;
|
||||||
m_has_definite_height = true;
|
m_has_definite_height = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue