mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:27:45 +00:00
LibWeb: Forbid using CSS::Length as reference value in resolved()
CSSPixels should not be wrapped into CSS::Length before being passed to resolved() to end up resolving percentages without losing precision. Fixes thrashing layout when 33.3333% width is used together with "box-sizing: border-box".
This commit is contained in:
parent
f2cd120fd3
commit
4bc38300ad
10 changed files with 40 additions and 17 deletions
|
@ -97,10 +97,10 @@ public:
|
|||
|
||||
CSSPixels to_px(Layout::Node const& layout_node, CSSPixels reference_value) const
|
||||
{
|
||||
return resolved(layout_node, Length::make_px(reference_value)).to_px(layout_node);
|
||||
return resolved(layout_node, reference_value).to_px(layout_node);
|
||||
}
|
||||
|
||||
T resolved(Layout::Node const& layout_node, T const& reference_value) const
|
||||
Angle resolved(Layout::Node const& layout_node, Angle reference_value) const
|
||||
{
|
||||
return m_value.visit(
|
||||
[&](T const& t) {
|
||||
|
|
|
@ -16,12 +16,7 @@ Size::Size(Type type, LengthPercentage length_percentage)
|
|||
|
||||
CSSPixels Size::to_px(Layout::Node const& node, CSSPixels reference_value) const
|
||||
{
|
||||
return m_length_percentage.resolved(node, CSS::Length::make_px(reference_value)).to_px(node);
|
||||
}
|
||||
|
||||
CSS::Length Size::resolved(Layout::Node const& node, Length const& reference_value) const
|
||||
{
|
||||
return m_length_percentage.resolved(node, reference_value);
|
||||
return m_length_percentage.resolved(node, reference_value).to_px(node);
|
||||
}
|
||||
|
||||
CSS::Length Size::resolved(Layout::Node const& node, CSSPixels reference_value) const
|
||||
|
|
|
@ -46,7 +46,6 @@ public:
|
|||
bool is_none() const { return m_type == Type::None; }
|
||||
|
||||
// FIXME: This is a stopgap API that will go away once all layout code is aware of CSS::Size.
|
||||
CSS::Length resolved(Layout::Node const&, Length const& reference_value) const;
|
||||
CSS::Length resolved(Layout::Node const&, CSSPixels reference_value) const;
|
||||
|
||||
[[nodiscard]] CSSPixels to_px(Layout::Node const&, CSSPixels reference_value) const;
|
||||
|
|
|
@ -20,7 +20,7 @@ Transformation::Transformation(TransformFunction function, Vector<TransformValue
|
|||
Gfx::FloatMatrix4x4 Transformation::to_matrix(Painting::PaintableBox const& paintable_box) const
|
||||
{
|
||||
auto count = m_values.size();
|
||||
auto value = [&](size_t index, CSS::Length const& reference_length = CSS::Length::make_px(0)) -> float {
|
||||
auto value = [&](size_t index, CSSPixels const& reference_length = 0) -> float {
|
||||
return m_values[index].visit(
|
||||
[&](CSS::LengthPercentage const& value) -> double {
|
||||
return value.resolved(paintable_box.layout_node(), reference_length).to_px(paintable_box.layout_node()).to_float();
|
||||
|
@ -34,8 +34,8 @@ Gfx::FloatMatrix4x4 Transformation::to_matrix(Painting::PaintableBox const& pain
|
|||
};
|
||||
|
||||
auto reference_box = paintable_box.absolute_rect();
|
||||
auto width = CSS::Length::make_px(reference_box.width());
|
||||
auto height = CSS::Length::make_px(reference_box.height());
|
||||
auto width = reference_box.width();
|
||||
auto height = reference_box.height();
|
||||
|
||||
switch (m_function) {
|
||||
case CSS::TransformFunction::Matrix:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue