mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:07:35 +00:00
LibWeb: Add a bare-bones SVG <g> element
This commit is contained in:
parent
92c08ad4ac
commit
7ac889e533
5 changed files with 55 additions and 0 deletions
|
@ -225,6 +225,7 @@ set(SOURCES
|
||||||
RequestIdleCallback/IdleDeadline.cpp
|
RequestIdleCallback/IdleDeadline.cpp
|
||||||
SVG/AttributeNames.cpp
|
SVG/AttributeNames.cpp
|
||||||
SVG/SVGElement.cpp
|
SVG/SVGElement.cpp
|
||||||
|
SVG/SVGGElement.cpp
|
||||||
SVG/SVGGeometryElement.cpp
|
SVG/SVGGeometryElement.cpp
|
||||||
SVG/SVGGraphicsElement.cpp
|
SVG/SVGGraphicsElement.cpp
|
||||||
SVG/SVGPathElement.cpp
|
SVG/SVGPathElement.cpp
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
#include <LibWeb/HTML/HTMLUListElement.h>
|
#include <LibWeb/HTML/HTMLUListElement.h>
|
||||||
#include <LibWeb/HTML/HTMLUnknownElement.h>
|
#include <LibWeb/HTML/HTMLUnknownElement.h>
|
||||||
#include <LibWeb/HTML/HTMLVideoElement.h>
|
#include <LibWeb/HTML/HTMLVideoElement.h>
|
||||||
|
#include <LibWeb/SVG/SVGGElement.h>
|
||||||
#include <LibWeb/SVG/SVGPathElement.h>
|
#include <LibWeb/SVG/SVGPathElement.h>
|
||||||
#include <LibWeb/SVG/SVGSVGElement.h>
|
#include <LibWeb/SVG/SVGSVGElement.h>
|
||||||
#include <LibWeb/SVG/TagNames.h>
|
#include <LibWeb/SVG/TagNames.h>
|
||||||
|
@ -235,6 +236,8 @@ NonnullRefPtr<Element> create_element(Document& document, const FlyString& tag_n
|
||||||
return adopt_ref(*new SVG::SVGSVGElement(document, move(qualified_name)));
|
return adopt_ref(*new SVG::SVGSVGElement(document, move(qualified_name)));
|
||||||
if (lowercase_tag_name == SVG::TagNames::path)
|
if (lowercase_tag_name == SVG::TagNames::path)
|
||||||
return adopt_ref(*new SVG::SVGPathElement(document, move(qualified_name)));
|
return adopt_ref(*new SVG::SVGPathElement(document, move(qualified_name)));
|
||||||
|
if (lowercase_tag_name == SVG::TagNames::g)
|
||||||
|
return adopt_ref(*new SVG::SVGGElement(document, move(qualified_name)));
|
||||||
|
|
||||||
// FIXME: If name is a valid custom element name, then return HTMLElement.
|
// FIXME: If name is a valid custom element name, then return HTMLElement.
|
||||||
|
|
||||||
|
|
27
Userland/Libraries/LibWeb/SVG/SVGGElement.cpp
Normal file
27
Userland/Libraries/LibWeb/SVG/SVGGElement.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/StringBuilder.h>
|
||||||
|
#include <LibWeb/DOM/Document.h>
|
||||||
|
#include <LibWeb/Layout/SVGGraphicsBox.h>
|
||||||
|
#include <LibWeb/SVG/SVGGElement.h>
|
||||||
|
|
||||||
|
namespace Web::SVG {
|
||||||
|
|
||||||
|
SVGGElement::SVGGElement(DOM::Document& document, QualifiedName qualified_name)
|
||||||
|
: SVGGraphicsElement(document, move(qualified_name))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<Layout::Node> SVGGElement::create_layout_node()
|
||||||
|
{
|
||||||
|
auto style = document().style_resolver().resolve_style(*this);
|
||||||
|
if (style->display() == CSS::Display::None)
|
||||||
|
return nullptr;
|
||||||
|
return adopt_ref(*new Layout::SVGGraphicsBox(document(), *this, move(style)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
Userland/Libraries/LibWeb/SVG/SVGGElement.h
Normal file
23
Userland/Libraries/LibWeb/SVG/SVGGElement.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
||||||
|
|
||||||
|
namespace Web::SVG {
|
||||||
|
|
||||||
|
class SVGGElement final : public SVGGraphicsElement {
|
||||||
|
public:
|
||||||
|
using WrapperType = Bindings::SVGPathElementWrapper;
|
||||||
|
|
||||||
|
SVGGElement(DOM::Document&, QualifiedName);
|
||||||
|
virtual ~SVGGElement() override = default;
|
||||||
|
|
||||||
|
virtual RefPtr<Layout::Node> create_layout_node() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
namespace Web::SVG::TagNames {
|
namespace Web::SVG::TagNames {
|
||||||
|
|
||||||
#define ENUMERATE_SVG_GRAPHICS_TAGS \
|
#define ENUMERATE_SVG_GRAPHICS_TAGS \
|
||||||
|
__ENUMERATE_SVG_TAG(g) \
|
||||||
__ENUMERATE_SVG_TAG(path) \
|
__ENUMERATE_SVG_TAG(path) \
|
||||||
__ENUMERATE_SVG_TAG(svg)
|
__ENUMERATE_SVG_TAG(svg)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue