1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-06-29 07:20:21 +00:00

LibWeb: Add the bare minimum to render SVGAElement (<a>)

(cherry picked from commit 85a4cfc59bc901e860ba60c51ad1fc9c0cf4e669)
This commit is contained in:
Andreas Kling 2024-06-23 17:05:47 +02:00 committed by Nico Weber
parent 19e4b138af
commit f72805398b
9 changed files with 87 additions and 3 deletions

View File

@ -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 <svg> at (9,9) content-size 300x150 [SVG] children: inline
InlineNode <a>
SVGTextBox <text> (not painted) children: inline
SVGSVGBox <svg> at (9,9) content-size 300x150 [SVG] children: not-inline
SVGGraphicsBox <a> at (29,25.015625) content-size 193.59375x67.578125 children: not-inline
SVGTextBox <text> at (29,25.015625) content-size 193.59375x67.578125 children: inline
TextNode <#text>
TextNode <#text>
BlockContainer <math> at (319,51) content-size 0x108 children: not-inline
@ -28,6 +28,8 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x201]
PaintableWithLines (BlockContainer(anonymous)) [8,8 784x155]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 302x152]
SVGGraphicsPaintable (SVGGraphicsBox<a>) [29,25.015625 193.59375x67.578125]
SVGPathPaintable (SVGTextBox<text>) [29,25.015625 193.59375x67.578125]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<math>) [318,50 2x110] overflow: [319,51 100x100]
PaintableWithLines (BlockContainer<a>) [319,51 100x100]

View File

@ -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

View File

@ -84,6 +84,7 @@
#include <LibWeb/MathML/MathMLElement.h>
#include <LibWeb/MathML/TagNames.h>
#include <LibWeb/Namespace.h>
#include <LibWeb/SVG/SVGAElement.h>
#include <LibWeb/SVG/SVGCircleElement.h>
#include <LibWeb/SVG/SVGClipPathElement.h>
#include <LibWeb/SVG/SVGDefsElement.h>
@ -482,6 +483,8 @@ static JS::GCPtr<SVG::SVGElement> create_svg_element(JS::Realm& realm, Document&
return realm.heap().allocate<SVG::SVGUseElement>(realm, document, move(qualified_name));
if (local_name == SVG::TagNames::script)
return realm.heap().allocate<SVG::SVGScriptElement>(realm, document, move(qualified_name));
if (local_name == SVG::TagNames::a)
return realm.heap().allocate<SVG::SVGAElement>(realm, document, move(qualified_name));
return nullptr;
}

View File

@ -16,6 +16,7 @@
#include <LibWeb/Layout/SVGFormattingContext.h>
#include <LibWeb/Layout/SVGGeometryBox.h>
#include <LibWeb/Layout/SVGMaskBox.h>
#include <LibWeb/SVG/SVGAElement.h>
#include <LibWeb/SVG/SVGClipPathElement.h>
#include <LibWeb/SVG/SVGForeignObjectElement.h>
#include <LibWeb/SVG/SVGGElement.h>
@ -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<SVG::SVGAElement>(dom_node))
return true;
if (is<SVG::SVGUseElement>(dom_node))
return true;
if (is<SVG::SVGSymbolElement>(dom_node))

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Layout/SVGGraphicsBox.h>
#include <LibWeb/SVG/SVGAElement.h>
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<Layout::Node> SVGAElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
{
return heap().allocate_without_realm<Layout::SVGGraphicsBox>(document(), *this, move(style));
}
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/SVG/SVGGraphicsElement.h>
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<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
};
}

View File

@ -0,0 +1,22 @@
#import <HTML/HTMLHyperlinkElementUtils.idl>
#import <SVG/SVGURIReference.idl>
[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;

View File

@ -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) \

View File

@ -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)