mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:57:35 +00:00
LibWeb: Cache the used CSS text-align property on LayoutNodeWithStyle
This commit is contained in:
parent
ae181e1573
commit
f4ecb5362f
6 changed files with 28 additions and 16 deletions
|
@ -229,19 +229,19 @@ bool StyleProperties::operator==(const StyleProperties& other) const
|
|||
return true;
|
||||
}
|
||||
|
||||
CSS::ValueID StyleProperties::text_align() const
|
||||
CSS::TextAlign StyleProperties::text_align() const
|
||||
{
|
||||
auto string = string_or_fallback(CSS::PropertyID::TextAlign, "left");
|
||||
if (string == "center")
|
||||
return CSS::ValueID::Center;
|
||||
return CSS::TextAlign::Center;
|
||||
if (string == "right")
|
||||
return CSS::ValueID::Right;
|
||||
return CSS::TextAlign::Right;
|
||||
if (string == "justify")
|
||||
return CSS::ValueID::Justify;
|
||||
return CSS::TextAlign::Justify;
|
||||
if (string == "-libweb-center")
|
||||
return CSS::ValueID::VendorSpecificCenter;
|
||||
return CSS::TextAlign::VendorSpecificCenter;
|
||||
// Otherwise, just assume "left"..
|
||||
return CSS::ValueID::Left;
|
||||
return CSS::TextAlign::Left;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
Length length_or_fallback(CSS::PropertyID, const Length& fallback, float reference_for_percentages) const;
|
||||
String string_or_fallback(CSS::PropertyID, const StringView& fallback) const;
|
||||
Color color_or_fallback(CSS::PropertyID, const Document&, Color fallback) const;
|
||||
CSS::ValueID text_align() const;
|
||||
CSS::TextAlign text_align() const;
|
||||
|
||||
const Gfx::Font& font() const
|
||||
{
|
||||
|
|
|
@ -114,6 +114,15 @@ enum class Position {
|
|||
Fixed,
|
||||
Sticky,
|
||||
};
|
||||
|
||||
enum class TextAlign {
|
||||
Left,
|
||||
Center,
|
||||
Right,
|
||||
Justify,
|
||||
VendorSpecificCenter,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
class StyleValue : public RefCounted<StyleValue> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue