diff --git a/Tests/LibWeb/Layout/expected/css-namespace-tag-name-selector.txt b/Tests/LibWeb/Layout/expected/css-namespace-tag-name-selector.txt index f8799eb24b..405253209e 100644 --- a/Tests/LibWeb/Layout/expected/css-namespace-tag-name-selector.txt +++ b/Tests/LibWeb/Layout/expected/css-namespace-tag-name-selector.txt @@ -6,9 +6,9 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline frag 1 from TextNode start: 0, length: 1, rect: [310,146 8x17] baseline: 13.296875 " " frag 2 from BlockContainer start: 0, length: 0, rect: [319,51 0x108] baseline: 110 - SVGSVGBox at (9,9) content-size 300x150 [SVG] children: inline - InlineNode - SVGTextBox (not painted) children: inline + SVGSVGBox at (9,9) content-size 300x150 [SVG] children: not-inline + SVGGraphicsBox at (29,25.015625) content-size 193.59375x67.578125 children: not-inline + SVGTextBox at (29,25.015625) content-size 193.59375x67.578125 children: inline TextNode <#text> TextNode <#text> BlockContainer at (319,51) content-size 0x108 children: not-inline @@ -28,6 +28,8 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [8,8 784x201] PaintableWithLines (BlockContainer(anonymous)) [8,8 784x155] SVGSVGPaintable (SVGSVGBox) [8,8 302x152] + SVGGraphicsPaintable (SVGGraphicsBox) [29,25.015625 193.59375x67.578125] + SVGPathPaintable (SVGTextBox) [29,25.015625 193.59375x67.578125] TextPaintable (TextNode<#text>) PaintableWithLines (BlockContainer) [318,50 2x110] overflow: [319,51 100x100] PaintableWithLines (BlockContainer) [319,51 100x100] diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 6b48b2e96b..406be435ca 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -614,6 +614,7 @@ set(SOURCES Streams/WritableStreamDefaultWriter.cpp SVG/AttributeNames.cpp SVG/AttributeParser.cpp + SVG/SVGAElement.cpp SVG/SVGAnimatedLength.cpp SVG/SVGAnimatedNumber.cpp SVG/SVGAnimatedRect.cpp diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp index 30e87753a6..e10cc9c4ca 100644 --- a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -84,6 +84,7 @@ #include #include #include +#include #include #include #include @@ -482,6 +483,8 @@ static JS::GCPtr create_svg_element(JS::Realm& realm, Document& return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::script) return realm.heap().allocate(realm, document, move(qualified_name)); + if (local_name == SVG::TagNames::a) + return realm.heap().allocate(realm, document, move(qualified_name)); return nullptr; } diff --git a/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp index 800b0873ca..a04e8317e9 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +155,8 @@ static bool is_container_element(Node const& node) auto* dom_node = node.dom_node(); if (!dom_node) return false; + if (is(dom_node)) + return true; if (is(dom_node)) return true; if (is(dom_node)) diff --git a/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp new file mode 100644 index 0000000000..04af8c846a --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +namespace Web::SVG { + +JS_DEFINE_ALLOCATOR(SVGAElement); + +SVGAElement::SVGAElement(DOM::Document& document, DOM::QualifiedName qualified_name) + : SVGGraphicsElement(document, move(qualified_name)) +{ +} + +SVGAElement::~SVGAElement() = default; + +JS::GCPtr SVGAElement::create_layout_node(NonnullRefPtr style) +{ + return heap().allocate_without_realm(document(), *this, move(style)); +} + +} diff --git a/Userland/Libraries/LibWeb/SVG/SVGAElement.h b/Userland/Libraries/LibWeb/SVG/SVGAElement.h new file mode 100644 index 0000000000..c18e1f9d6d --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/SVGAElement.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::SVG { + +class SVGAElement final : public SVGGraphicsElement { + WEB_PLATFORM_OBJECT(SVGAElement, SVGGraphicsElement); + JS_DECLARE_ALLOCATOR(SVGAElement); + +public: + virtual ~SVGAElement() override; + + SVGAElement(DOM::Document&, DOM::QualifiedName); + + virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; +}; + +} diff --git a/Userland/Libraries/LibWeb/SVG/SVGAElement.idl b/Userland/Libraries/LibWeb/SVG/SVGAElement.idl new file mode 100644 index 0000000000..6579472bd8 --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/SVGAElement.idl @@ -0,0 +1,22 @@ +#import +#import + +[Exposed=Window] +interface SVGAElement : SVGGraphicsElement { + + [FIXME, SameObject] readonly attribute SVGAnimatedString target; + [FIXME] attribute DOMString download; + [FIXME] attribute USVString ping; + [FIXME] attribute DOMString rel; + [FIXME, SameObject, PutForwards=value] readonly attribute DOMTokenList relList; + [FIXME] attribute DOMString hreflang; + [FIXME] attribute DOMString type; + + [FIXME] attribute DOMString text; + + [FIXME] attribute DOMString referrerPolicy; + +}; + +// FIXME: SVGAElement includes SVGURIReference; +// FIXME: SVGAElement includes HTMLHyperlinkElementUtils; diff --git a/Userland/Libraries/LibWeb/SVG/TagNames.h b/Userland/Libraries/LibWeb/SVG/TagNames.h index 65c66e9dfd..1d0c0f8309 100644 --- a/Userland/Libraries/LibWeb/SVG/TagNames.h +++ b/Userland/Libraries/LibWeb/SVG/TagNames.h @@ -12,6 +12,7 @@ namespace Web::SVG::TagNames { #define ENUMERATE_SVG_GRAPHICS_TAGS \ + __ENUMERATE_SVG_TAG(a) \ __ENUMERATE_SVG_TAG(circle) \ __ENUMERATE_SVG_TAG(ellipse) \ __ENUMERATE_SVG_TAG(g) \ diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake index f88ba77e9b..b2deda8d4c 100644 --- a/Userland/Libraries/LibWeb/idl_files.cmake +++ b/Userland/Libraries/LibWeb/idl_files.cmake @@ -248,6 +248,7 @@ libweb_js_bindings(Streams/TransformStreamDefaultController) libweb_js_bindings(Streams/WritableStream) libweb_js_bindings(Streams/WritableStreamDefaultController) libweb_js_bindings(Streams/WritableStreamDefaultWriter) +libweb_js_bindings(SVG/SVGAElement) libweb_js_bindings(SVG/SVGAnimatedLength) libweb_js_bindings(SVG/SVGAnimatedNumber) libweb_js_bindings(SVG/SVGAnimatedRect)