mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:47:35 +00:00
LibWeb: Use IdentifierStyleValue for CSS 'text-decoration-line'
Also 'text-decoration' is actually a shorthand, so treat it that way.
This commit is contained in:
parent
dd9a77099f
commit
4d7ce81835
9 changed files with 96 additions and 3 deletions
|
@ -39,6 +39,7 @@ public:
|
|||
static CSS::WhiteSpace white_space() { return CSS::WhiteSpace::Normal; }
|
||||
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; }
|
||||
};
|
||||
|
||||
struct BorderData {
|
||||
|
@ -54,6 +55,7 @@ public:
|
|||
CSS::Clear clear() const { return m_clear; }
|
||||
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::Position position() const { return m_position; }
|
||||
CSS::WhiteSpace white_space() const { return m_white_space; }
|
||||
const CSS::Length& width() const { return m_width; }
|
||||
|
@ -77,6 +79,7 @@ protected:
|
|||
CSS::Clear m_clear { InitialValues::clear() };
|
||||
Optional<int> m_z_index;
|
||||
CSS::TextAlign m_text_align { InitialValues::text_align() };
|
||||
CSS::TextDecorationLine m_text_decoration_line { InitialValues::text_decoration_line() };
|
||||
CSS::Position m_position { InitialValues::position() };
|
||||
CSS::WhiteSpace m_white_space { InitialValues::white_space() };
|
||||
CSS::Length m_width;
|
||||
|
@ -103,6 +106,7 @@ public:
|
|||
void set_clear(CSS::Clear value) { m_clear = value; }
|
||||
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_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; }
|
||||
|
|
|
@ -239,6 +239,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
|||
if (clear.has_value())
|
||||
style.set_clear(clear.value());
|
||||
|
||||
auto text_decoration_line = specified_style.text_decoration_line();
|
||||
if (text_decoration_line.has_value())
|
||||
style.set_text_decoration_line(text_decoration_line.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, {}));
|
||||
|
|
|
@ -80,13 +80,11 @@ void TextNode::paint_fragment(PaintContext& context, const LineBoxFragment& frag
|
|||
if (phase == PaintPhase::Foreground) {
|
||||
painter.set_font(specified_style().font());
|
||||
auto color = specified_style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text());
|
||||
auto text_decoration = specified_style().string_or_fallback(CSS::PropertyID::TextDecoration, "none");
|
||||
|
||||
if (document().inspected_node() == &dom_node())
|
||||
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Magenta);
|
||||
|
||||
bool is_underline = text_decoration == "underline";
|
||||
if (is_underline)
|
||||
if (style().text_decoration_line() == CSS::TextDecorationLine::Underline)
|
||||
painter.draw_line(enclosing_int_rect(fragment.absolute_rect()).bottom_left().translated(0, 1), enclosing_int_rect(fragment.absolute_rect()).bottom_right().translated(0, 1), color);
|
||||
|
||||
// FIXME: text-transform should be done already in layout, since uppercase glyphs may be wider than lowercase, etc.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue