mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibWeb: Account for Calculated
in Length methods
We were ignoring this in a couple of places.
This commit is contained in:
parent
64f112c4ea
commit
a07fed4e53
2 changed files with 14 additions and 6 deletions
|
@ -48,6 +48,8 @@ Length Length::make_calculated(NonnullRefPtr<CalculatedStyleValue> calculated_st
|
|||
|
||||
Length Length::percentage_of(Percentage const& percentage) const
|
||||
{
|
||||
VERIFY(!is_calculated());
|
||||
|
||||
if (is_auto()) {
|
||||
dbgln("Attempting to get percentage of an auto length, this seems wrong? But for now we just return the original length.");
|
||||
return *this;
|
||||
|
@ -104,6 +106,15 @@ float Length::to_px(Layout::Node const& layout_node) const
|
|||
return to_px(viewport_rect, layout_node.font().metrics('M'), layout_node.computed_values().font_size(), root_element->layout_node()->computed_values().font_size());
|
||||
}
|
||||
|
||||
String Length::to_string() const
|
||||
{
|
||||
if (is_calculated())
|
||||
return m_calculated_style->to_string();
|
||||
if (is_auto())
|
||||
return "auto";
|
||||
return String::formatted("{}{}", m_value, unit_name());
|
||||
}
|
||||
|
||||
const char* Length::unit_name() const
|
||||
{
|
||||
switch (m_type) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue