mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
LibWeb: Use IdentifierStyleValue for CSS 'text-transform'
This commit is contained in:
parent
4d7ce81835
commit
78a51933ad
7 changed files with 59 additions and 3 deletions
|
@ -40,6 +40,7 @@ public:
|
|||
static CSS::TextAlign text_align() { return CSS::TextAlign::Left; }
|
||||
static CSS::Position position() { return CSS::Position::Static; }
|
||||
static CSS::TextDecorationLine text_decoration_line() { return CSS::TextDecorationLine::None; }
|
||||
static CSS::TextTransform text_transform() { return CSS::TextTransform::None; }
|
||||
};
|
||||
|
||||
struct BorderData {
|
||||
|
@ -56,6 +57,7 @@ public:
|
|||
Optional<int> z_index() const { return m_z_index; }
|
||||
CSS::TextAlign text_align() const { return m_text_align; }
|
||||
CSS::TextDecorationLine text_decoration_line() const { return m_text_decoration_line; }
|
||||
CSS::TextTransform text_transform() const { return m_text_transform; }
|
||||
CSS::Position position() const { return m_position; }
|
||||
CSS::WhiteSpace white_space() const { return m_white_space; }
|
||||
const CSS::Length& width() const { return m_width; }
|
||||
|
@ -80,6 +82,7 @@ protected:
|
|||
Optional<int> m_z_index;
|
||||
CSS::TextAlign m_text_align { InitialValues::text_align() };
|
||||
CSS::TextDecorationLine m_text_decoration_line { InitialValues::text_decoration_line() };
|
||||
CSS::TextTransform m_text_transform { InitialValues::text_transform() };
|
||||
CSS::Position m_position { InitialValues::position() };
|
||||
CSS::WhiteSpace m_white_space { InitialValues::white_space() };
|
||||
CSS::Length m_width;
|
||||
|
@ -107,6 +110,7 @@ public:
|
|||
void set_z_index(Optional<int> value) { m_z_index = value; }
|
||||
void set_text_align(CSS::TextAlign text_align) { m_text_align = text_align; }
|
||||
void set_text_decoration_line(CSS::TextDecorationLine value) { m_text_decoration_line = value; }
|
||||
void set_text_transform(CSS::TextTransform value) { m_text_transform = value; }
|
||||
void set_position(CSS::Position position) { m_position = position; }
|
||||
void set_white_space(CSS::WhiteSpace value) { m_white_space = value; }
|
||||
void set_width(const CSS::Length& width) { m_width = width; }
|
||||
|
|
|
@ -243,6 +243,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
|||
if (text_decoration_line.has_value())
|
||||
style.set_text_decoration_line(text_decoration_line.value());
|
||||
|
||||
auto text_transform = specified_style.text_transform();
|
||||
if (text_transform.has_value())
|
||||
style.set_text_transform(text_transform.value());
|
||||
|
||||
style.set_z_index(specified_style.z_index());
|
||||
style.set_width(specified_style.length_or_fallback(CSS::PropertyID::Width, {}));
|
||||
style.set_min_width(specified_style.length_or_fallback(CSS::PropertyID::MinWidth, {}));
|
||||
|
|
|
@ -89,10 +89,10 @@ void TextNode::paint_fragment(PaintContext& context, const LineBoxFragment& frag
|
|||
|
||||
// FIXME: text-transform should be done already in layout, since uppercase glyphs may be wider than lowercase, etc.
|
||||
auto text = m_text_for_rendering;
|
||||
auto text_transform = specified_style().string_or_fallback(CSS::PropertyID::TextTransform, "none");
|
||||
if (text_transform == "uppercase")
|
||||
auto text_transform = style().text_transform();
|
||||
if (text_transform == CSS::TextTransform::Uppercase)
|
||||
text = m_text_for_rendering.to_uppercase();
|
||||
if (text_transform == "lowercase")
|
||||
if (text_transform == CSS::TextTransform::Lowercase)
|
||||
text = m_text_for_rendering.to_lowercase();
|
||||
|
||||
painter.draw_text(enclosing_int_rect(fragment.absolute_rect()), text.substring_view(fragment.start(), fragment.length()), Gfx::TextAlignment::CenterLeft, color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue