mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 05:08:56 +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:
@@ -8,6 +8,7 @@
|
||||
#include <AK/Utf16View.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Utf16String.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Layout/SVGTextBox.h>
|
||||
#include <LibWeb/SVG/AttributeNames.h>
|
||||
@@ -30,6 +31,22 @@ JS::ThrowCompletionOr<void> SVGTextContentElement::initialize(JS::Realm& realm)
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<TextAnchor> SVGTextContentElement::text_anchor() const
|
||||
{
|
||||
if (!layout_node())
|
||||
return {};
|
||||
switch (layout_node()->computed_values().text_anchor()) {
|
||||
case CSS::TextAnchor::Start:
|
||||
return TextAnchor::Start;
|
||||
case CSS::TextAnchor::Middle:
|
||||
return TextAnchor::Middle;
|
||||
case CSS::TextAnchor::End:
|
||||
return TextAnchor::End;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void SVGTextContentElement::attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
{
|
||||
SVGGraphicsElement::attribute_changed(name, value);
|
||||
|
||||
Reference in New Issue
Block a user