mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
LibHTML: Use floating point numbers throughout the layout tree
This commit is contained in:
parent
da23864c8d
commit
c628ebda0f
15 changed files with 59 additions and 52 deletions
|
@ -15,21 +15,26 @@ public:
|
|||
, m_value(value)
|
||||
{
|
||||
}
|
||||
Length(float value, Type type)
|
||||
: m_type(type)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
~Length() {}
|
||||
|
||||
bool is_auto() const { return m_type == Type::Auto; }
|
||||
bool is_absolute() const { return m_type == Type::Absolute; }
|
||||
|
||||
int value() const { return m_value; }
|
||||
float value() const { return m_value; }
|
||||
|
||||
String to_string() const
|
||||
{
|
||||
if (is_auto())
|
||||
return "[Length/auto]";
|
||||
return String::format("%d [Length/px]", m_value);
|
||||
return String::format("%g [Length/px]", m_value);
|
||||
}
|
||||
|
||||
int to_px() const
|
||||
float to_px() const
|
||||
{
|
||||
if (is_auto())
|
||||
return 0;
|
||||
|
@ -38,7 +43,7 @@ public:
|
|||
|
||||
private:
|
||||
Type m_type { Type::Auto };
|
||||
int m_value { 0 };
|
||||
float m_value { 0 };
|
||||
};
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const Length& value)
|
||||
|
|
|
@ -101,10 +101,9 @@ void StyleProperties::load_font() const
|
|||
FontCache::the().set({ font_family, font_weight }, *m_font);
|
||||
}
|
||||
|
||||
int StyleProperties::line_height() const
|
||||
float StyleProperties::line_height() const
|
||||
{
|
||||
// FIXME: Allow overriding the line-height. We currently default to 140% which seems to look nice.
|
||||
return (int)(font().glyph_height() * 1.4f);
|
||||
return (float)font().glyph_height() * 1.4f;
|
||||
}
|
||||
|
||||
bool StyleProperties::operator==(const StyleProperties& other) const
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
return *m_font;
|
||||
}
|
||||
|
||||
int line_height() const;
|
||||
float line_height() const;
|
||||
|
||||
bool operator==(const StyleProperties&) const;
|
||||
bool operator!=(const StyleProperties& other) const { return !(*this == other); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue