mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +00:00
LibWeb: Use IdentifierStyleValue for CSS 'list-style-type'
This commit is contained in:
parent
c630ae517e
commit
9c76c4f0cf
7 changed files with 52 additions and 1 deletions
|
@ -464,6 +464,14 @@ static Optional<CSS::ValueID> value_id_from_string(const String& string)
|
||||||
return CSS::ValueID::FullWidth;
|
return CSS::ValueID::FullWidth;
|
||||||
if (string.equals_ignoring_case("full-size-kana"))
|
if (string.equals_ignoring_case("full-size-kana"))
|
||||||
return CSS::ValueID::FullSizeKana;
|
return CSS::ValueID::FullSizeKana;
|
||||||
|
if (string.equals_ignoring_case("disc"))
|
||||||
|
return CSS::ValueID::Disc;
|
||||||
|
if (string.equals_ignoring_case("circle"))
|
||||||
|
return CSS::ValueID::Circle;
|
||||||
|
if (string.equals_ignoring_case("square"))
|
||||||
|
return CSS::ValueID::Square;
|
||||||
|
if (string.equals_ignoring_case("decimal"))
|
||||||
|
return CSS::ValueID::Decimal;
|
||||||
if (string.starts_with("-libweb-palette-", CaseSensitivity::CaseInsensitive))
|
if (string.starts_with("-libweb-palette-", CaseSensitivity::CaseInsensitive))
|
||||||
return value_id_for_palette_string(string.substring_view(16, string.length() - 16));
|
return value_id_for_palette_string(string.substring_view(16, string.length() - 16));
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -453,4 +453,26 @@ Optional<CSS::TextTransform> StyleProperties::text_transform() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<CSS::ListStyleType> StyleProperties::list_style_type() const
|
||||||
|
{
|
||||||
|
auto value = property(CSS::PropertyID::ListStyleType);
|
||||||
|
if (!value.has_value())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
switch (value.value()->to_identifier()) {
|
||||||
|
case CSS::ValueID::None:
|
||||||
|
return CSS::ListStyleType::None;
|
||||||
|
case CSS::ValueID::Disc:
|
||||||
|
return CSS::ListStyleType::Disc;
|
||||||
|
case CSS::ValueID::Circle:
|
||||||
|
return CSS::ListStyleType::Circle;
|
||||||
|
case CSS::ValueID::Square:
|
||||||
|
return CSS::ListStyleType::Square;
|
||||||
|
case CSS::ValueID::Decimal:
|
||||||
|
return CSS::ListStyleType::Decimal;
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
Optional<CSS::LineStyle> line_style(CSS::PropertyID) const;
|
Optional<CSS::LineStyle> line_style(CSS::PropertyID) const;
|
||||||
Optional<CSS::TextDecorationLine> text_decoration_line() const;
|
Optional<CSS::TextDecorationLine> text_decoration_line() const;
|
||||||
Optional<CSS::TextTransform> text_transform() const;
|
Optional<CSS::TextTransform> text_transform() const;
|
||||||
|
Optional<CSS::ListStyleType> list_style_type() const;
|
||||||
|
|
||||||
const Gfx::Font& font() const
|
const Gfx::Font& font() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,6 +156,10 @@ enum class ValueID {
|
||||||
Lowercase,
|
Lowercase,
|
||||||
FullWidth,
|
FullWidth,
|
||||||
FullSizeKana,
|
FullSizeKana,
|
||||||
|
Disc,
|
||||||
|
Circle,
|
||||||
|
Square,
|
||||||
|
Decimal,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Position {
|
enum class Position {
|
||||||
|
@ -239,6 +243,14 @@ enum class LineStyle {
|
||||||
Outset,
|
Outset,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ListStyleType {
|
||||||
|
None,
|
||||||
|
Disc,
|
||||||
|
Circle,
|
||||||
|
Square,
|
||||||
|
Decimal,
|
||||||
|
};
|
||||||
|
|
||||||
class StyleValue : public RefCounted<StyleValue> {
|
class StyleValue : public RefCounted<StyleValue> {
|
||||||
public:
|
public:
|
||||||
virtual ~StyleValue();
|
virtual ~StyleValue();
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
static CSS::TextTransform text_transform() { return CSS::TextTransform::None; }
|
static CSS::TextTransform text_transform() { return CSS::TextTransform::None; }
|
||||||
static Color color() { return Color::Black; }
|
static Color color() { return Color::Black; }
|
||||||
static Color background_color() { return Color::Transparent; }
|
static Color background_color() { return Color::Transparent; }
|
||||||
|
static CSS::ListStyleType list_style_type() { return CSS::ListStyleType::Disc; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BorderData {
|
struct BorderData {
|
||||||
|
@ -81,6 +82,8 @@ public:
|
||||||
Color color() const { return m_color; }
|
Color color() const { return m_color; }
|
||||||
Color background_color() const { return m_background_color; }
|
Color background_color() const { return m_background_color; }
|
||||||
|
|
||||||
|
CSS::ListStyleType list_style_type() const { return m_list_style_type; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CSS::Float m_float { InitialValues::float_() };
|
CSS::Float m_float { InitialValues::float_() };
|
||||||
CSS::Clear m_clear { InitialValues::clear() };
|
CSS::Clear m_clear { InitialValues::clear() };
|
||||||
|
@ -105,6 +108,7 @@ protected:
|
||||||
BorderData m_border_bottom;
|
BorderData m_border_bottom;
|
||||||
Color m_color { InitialValues::color() };
|
Color m_color { InitialValues::color() };
|
||||||
Color m_background_color { InitialValues::background_color() };
|
Color m_background_color { InitialValues::background_color() };
|
||||||
|
CSS::ListStyleType m_list_style_type { InitialValues::list_style_type() };
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImmutableLayoutStyle final : public LayoutStyle {
|
class ImmutableLayoutStyle final : public LayoutStyle {
|
||||||
|
@ -131,6 +135,7 @@ public:
|
||||||
void set_offset(const CSS::LengthBox& offset) { m_offset = offset; }
|
void set_offset(const CSS::LengthBox& offset) { m_offset = offset; }
|
||||||
void set_margin(const CSS::LengthBox& margin) { m_margin = margin; }
|
void set_margin(const CSS::LengthBox& margin) { m_margin = margin; }
|
||||||
void set_padding(const CSS::LengthBox& padding) { m_padding = padding; }
|
void set_padding(const CSS::LengthBox& padding) { m_padding = padding; }
|
||||||
|
void set_list_style_type(CSS::ListStyleType value) { m_list_style_type = value; }
|
||||||
BorderData& border_left() { return m_border_left; }
|
BorderData& border_left() { return m_border_left; }
|
||||||
BorderData& border_top() { return m_border_top; }
|
BorderData& border_top() { return m_border_top; }
|
||||||
BorderData& border_right() { return m_border_right; }
|
BorderData& border_right() { return m_border_right; }
|
||||||
|
|
|
@ -45,7 +45,7 @@ void ListItemBox::layout_marker()
|
||||||
m_marker = nullptr;
|
m_marker = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (specified_style().string_or_fallback(CSS::PropertyID::ListStyleType, "disc") == "none")
|
if (style().list_style_type() == CSS::ListStyleType::None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_marker) {
|
if (!m_marker) {
|
||||||
|
|
|
@ -247,6 +247,9 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
if (text_transform.has_value())
|
if (text_transform.has_value())
|
||||||
style.set_text_transform(text_transform.value());
|
style.set_text_transform(text_transform.value());
|
||||||
|
|
||||||
|
if (auto list_style_type = specified_style.list_style_type(); list_style_type.has_value())
|
||||||
|
style.set_list_style_type(list_style_type.value());
|
||||||
|
|
||||||
style.set_color(specified_style.color_or_fallback(CSS::PropertyID::Color, document(), Color::Transparent));
|
style.set_color(specified_style.color_or_fallback(CSS::PropertyID::Color, document(), Color::Transparent));
|
||||||
style.set_background_color(specified_style.color_or_fallback(CSS::PropertyID::BackgroundColor, document(), Color::Transparent));
|
style.set_background_color(specified_style.color_or_fallback(CSS::PropertyID::BackgroundColor, document(), Color::Transparent));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue