mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibWeb: Add support for SVG <tspan> elements
This commit is contained in:
parent
0e12503586
commit
b30a1b957d
7 changed files with 74 additions and 1 deletions
34
Userland/Libraries/LibWeb/SVG/SVGTSpanElement.cpp
Normal file
34
Userland/Libraries/LibWeb/SVG/SVGTSpanElement.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Layout/SVGTextBox.h>
|
||||
#include <LibWeb/SVG/SVGTSpanElement.h>
|
||||
#include <LibWeb/SVG/SVGTextElement.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
SVGTSpanElement::SVGTSpanElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGTextPositioningElement(document, move(qualified_name))
|
||||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<void> SVGTSpanElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTSpanElementPrototype>(realm, "SVGTSpanElement"));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> SVGTSpanElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
// Text must be within an SVG <text> element.
|
||||
if (shadow_including_first_ancestor_of_type<SVGTextElement>())
|
||||
return heap().allocate_without_realm<Layout::SVGTextBox>(document(), *this, move(style));
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue