LibWeb: Stub out SVGMaskElement
Just enough that we stop creating layout nodes for mask elements, which was making some SVG content look very wrong. :^)
This commit is contained in:
parent
adf70b8a16
commit
9e22f01eba
Notes:
sideshowbarker
2024-07-17 00:23:42 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9e22f01eba Pull-request: https://github.com/SerenityOS/serenity/pull/20474
10 changed files with 99 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x116 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x100 children: inline
|
||||
line 0 width: 100, height: 100, bottom: 100, baseline: 100
|
||||
frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 100x100]
|
||||
SVGSVGBox <svg> at (8,8) content-size 100x100 [SVG] children: inline
|
||||
TextNode <#text>
|
||||
SVGGeometryBox <rect> at (8,8) content-size 100x100 children: not-inline
|
||||
TextNode <#text>
|
||||
TextNode <#text>
|
||||
TextNode <#text>
|
||||
|
||||
PaintableWithLines (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x116]
|
||||
PaintableWithLines (BlockContainer<BODY>) [8,8 784x100]
|
||||
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 100x100]
|
||||
SVGGeometryPaintable (SVGGeometryBox<rect>) [8,8 100x100]
|
|
@ -0,0 +1,7 @@
|
|||
<!doctype html>
|
||||
<svg width="100" height="100" viewBox="0 0 1 1" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="0" y="0" width="1" height="1" fill="green"/>
|
||||
<mask id="mask" x="0" y="0" width="1" height="1">
|
||||
<rect x="0" y="0" width="1" height="1" fill="red"/>
|
||||
</mask>
|
||||
</svg>
|
|
@ -543,6 +543,7 @@ set(SOURCES
|
|||
SVG/SVGLength.cpp
|
||||
SVG/SVGLineElement.cpp
|
||||
SVG/SVGLinearGradientElement.cpp
|
||||
SVG/SVGMaskElement.cpp
|
||||
SVG/SVGPolygonElement.cpp
|
||||
SVG/SVGPolylineElement.cpp
|
||||
SVG/SVGRectElement.cpp
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
#include <LibWeb/SVG/SVGGElement.h>
|
||||
#include <LibWeb/SVG/SVGLineElement.h>
|
||||
#include <LibWeb/SVG/SVGLinearGradientElement.h>
|
||||
#include <LibWeb/SVG/SVGMaskElement.h>
|
||||
#include <LibWeb/SVG/SVGPathElement.h>
|
||||
#include <LibWeb/SVG/SVGPolygonElement.h>
|
||||
#include <LibWeb/SVG/SVGPolylineElement.h>
|
||||
|
@ -444,6 +445,8 @@ static WebIDL::ExceptionOr<JS::GCPtr<SVG::SVGElement>> create_svg_element(JS::Re
|
|||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name)));
|
||||
if (local_name == SVG::TagNames::linearGradient)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGLinearGradientElement>(realm, document, move(qualified_name)));
|
||||
if (local_name == SVG::TagNames::mask)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGMaskElement>(realm, document, move(qualified_name)));
|
||||
if (local_name == SVG::TagNames::path)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name)));
|
||||
if (local_name == SVG::TagNames::polygon)
|
||||
|
|
|
@ -592,6 +592,7 @@ class SVGGeometryElement;
|
|||
class SVGGraphicsElement;
|
||||
class SVGLength;
|
||||
class SVGLineElement;
|
||||
class SVGMaskElement;
|
||||
class SVGPathElement;
|
||||
class SVGPolygonElement;
|
||||
class SVGPolylineElement;
|
||||
|
|
31
Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp
Normal file
31
Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/SVGMaskElementPrototype.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/SVG/SVGMaskElement.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
SVGMaskElement::SVGMaskElement(DOM::Document& document, DOM::QualifiedName tag_name)
|
||||
: SVGGraphicsElement(document, move(tag_name))
|
||||
{
|
||||
}
|
||||
|
||||
SVGMaskElement::~SVGMaskElement() = default;
|
||||
|
||||
void SVGMaskElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGMaskElementPrototype>(realm, "SVGMaskElement"));
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> SVGMaskElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
26
Userland/Libraries/LibWeb/SVG/SVGMaskElement.h
Normal file
26
Userland/Libraries/LibWeb/SVG/SVGMaskElement.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
class SVGMaskElement final : public SVGGraphicsElement {
|
||||
WEB_PLATFORM_OBJECT(SVGMaskElement, SVGGraphicsElement);
|
||||
|
||||
public:
|
||||
virtual ~SVGMaskElement() override;
|
||||
|
||||
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
private:
|
||||
SVGMaskElement(DOM::Document&, DOM::QualifiedName);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
11
Userland/Libraries/LibWeb/SVG/SVGMaskElement.idl
Normal file
11
Userland/Libraries/LibWeb/SVG/SVGMaskElement.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Exposed=Window]
|
||||
interface SVGMaskElement : SVGElement {
|
||||
|
||||
// FIXME: readonly attribute SVGAnimatedEnumeration maskUnits;
|
||||
// FIXME: readonly attribute SVGAnimatedEnumeration maskContentUnits;
|
||||
// FIXME: readonly attribute SVGAnimatedLength x;
|
||||
// FIXME: readonly attribute SVGAnimatedLength y;
|
||||
// FIXME: readonly attribute SVGAnimatedLength width;
|
||||
// FIXME: readonly attribute SVGAnimatedLength height;
|
||||
|
||||
};
|
|
@ -31,6 +31,7 @@ namespace Web::SVG::TagNames {
|
|||
__ENUMERATE_SVG_TAG(desc) \
|
||||
__ENUMERATE_SVG_TAG(foreignObject) \
|
||||
__ENUMERATE_SVG_TAG(linearGradient) \
|
||||
__ENUMERATE_SVG_TAG(mask) \
|
||||
__ENUMERATE_SVG_TAG(radialGradient) \
|
||||
__ENUMERATE_SVG_TAG(script) \
|
||||
__ENUMERATE_SVG_TAG(stop) \
|
||||
|
|
|
@ -218,6 +218,7 @@ libweb_js_bindings(SVG/SVGForeignObjectElement)
|
|||
libweb_js_bindings(SVG/SVGLength)
|
||||
libweb_js_bindings(SVG/SVGLineElement)
|
||||
libweb_js_bindings(SVG/SVGLinearGradientElement)
|
||||
libweb_js_bindings(SVG/SVGMaskElement)
|
||||
libweb_js_bindings(SVG/SVGPathElement)
|
||||
libweb_js_bindings(SVG/SVGPolygonElement)
|
||||
libweb_js_bindings(SVG/SVGPolylineElement)
|
||||
|
|
Loading…
Add table
Reference in a new issue