mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
LibWeb: Add an initial implementation of SVG text-anchor
This only handles very simple <text> elements, but this is enough (with the font-size changes) to improve the badges on the GitHub README a fair bit.
This commit is contained in:
parent
4cdb4de049
commit
30277f385c
10 changed files with 77 additions and 0 deletions
|
@ -83,6 +83,7 @@ public:
|
|||
static CSS::FillRule fill_rule() { return CSS::FillRule::Nonzero; }
|
||||
static float stroke_opacity() { return 1.0f; }
|
||||
static float stop_opacity() { return 1.0f; }
|
||||
static CSS::TextAnchor text_anchor() { return CSS::TextAnchor::Start; }
|
||||
static CSS::Length border_radius() { return Length::make_px(0); }
|
||||
static Variant<CSS::VerticalAlign, CSS::LengthPercentage> vertical_align() { return CSS::VerticalAlign::Baseline; }
|
||||
static CSS::LengthBox inset() { return { CSS::Length::make_auto(), CSS::Length::make_auto(), CSS::Length::make_auto(), CSS::Length::make_auto() }; }
|
||||
|
@ -312,6 +313,7 @@ public:
|
|||
LengthPercentage const& stroke_width() const { return m_inherited.stroke_width; }
|
||||
Color stop_color() const { return m_noninherited.stop_color; }
|
||||
float stop_opacity() const { return m_noninherited.stop_opacity; }
|
||||
CSS::TextAnchor text_anchor() const { return m_inherited.text_anchor; }
|
||||
|
||||
Vector<CSS::Transformation> const& transformations() const { return m_noninherited.transformations; }
|
||||
CSS::TransformOrigin const& transform_origin() const { return m_noninherited.transform_origin; }
|
||||
|
@ -357,6 +359,7 @@ protected:
|
|||
float fill_opacity { InitialValues::fill_opacity() };
|
||||
float stroke_opacity { InitialValues::stroke_opacity() };
|
||||
LengthPercentage stroke_width { Length::make_px(1) };
|
||||
CSS::TextAnchor text_anchor { InitialValues::text_anchor() };
|
||||
|
||||
Vector<ShadowData> text_shadow;
|
||||
} m_inherited;
|
||||
|
@ -538,6 +541,7 @@ public:
|
|||
void set_stroke_width(LengthPercentage value) { m_inherited.stroke_width = value; }
|
||||
void set_stop_color(Color value) { m_noninherited.stop_color = value; }
|
||||
void set_stop_opacity(float value) { m_noninherited.stop_opacity = value; }
|
||||
void set_text_anchor(CSS::TextAnchor value) { m_inherited.text_anchor = value; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -275,6 +275,11 @@
|
|||
"to-zero",
|
||||
"up"
|
||||
],
|
||||
"text-anchor": [
|
||||
"start",
|
||||
"middle",
|
||||
"end"
|
||||
],
|
||||
"text-align": [
|
||||
"center",
|
||||
"justify",
|
||||
|
|
|
@ -1862,6 +1862,13 @@
|
|||
],
|
||||
"percentages-resolve-to": "length"
|
||||
},
|
||||
"text-anchor": {
|
||||
"inherited": true,
|
||||
"initial": "start",
|
||||
"valid-types": [
|
||||
"text-anchor"
|
||||
]
|
||||
},
|
||||
"text-align": {
|
||||
"inherited": true,
|
||||
"initial": "left",
|
||||
|
|
|
@ -589,6 +589,12 @@ bool StyleProperties::operator==(StyleProperties const& other) const
|
|||
return true;
|
||||
}
|
||||
|
||||
Optional<CSS::TextAnchor> StyleProperties::text_anchor() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::TextAnchor);
|
||||
return value_id_to_text_anchor(value->to_identifier());
|
||||
}
|
||||
|
||||
Optional<CSS::TextAlign> StyleProperties::text_align() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::TextAlign);
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
Optional<LengthPercentage> length_percentage(CSS::PropertyID) const;
|
||||
LengthBox length_box(CSS::PropertyID left_id, CSS::PropertyID top_id, CSS::PropertyID right_id, CSS::PropertyID bottom_id, const CSS::Length& default_value) const;
|
||||
Color color_or_fallback(CSS::PropertyID, Layout::NodeWithStyle const&, Color fallback) const;
|
||||
Optional<CSS::TextAnchor> text_anchor() const;
|
||||
Optional<CSS::TextAlign> text_align() const;
|
||||
Optional<CSS::TextJustify> text_justify() const;
|
||||
CSS::Length border_spacing_horizontal() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue