1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:37:44 +00:00

LibWeb: Sketch out a very basic SVG <clipPath> element

This element doesn't actually support anything at the moment, but it
still massively speeds up painting performance on Wikipedia! :^)

How? Because we no longer paint SVG <path> elements found inside
<clipPath> elements. SVGClipPathElement::create_layout_node() returns
nullptr which stops the layout tree builder from recursing further into
the subtree, and so the <path> element never gets a layout or paint box.

Mousing over Wikipedia now barely break 50% CPU usage on my machine :^)
This commit is contained in:
Andreas Kling 2022-04-10 19:05:12 +02:00
parent c6e79124c7
commit e81594d9a1
8 changed files with 68 additions and 0 deletions

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/SVG/SVGClipPathElement.h>
namespace Web::SVG {
SVGClipPathElement::SVGClipPathElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGElement(document, move(qualified_name))
{
}
SVGClipPathElement::~SVGClipPathElement()
{
}
RefPtr<Layout::Node> SVGClipPathElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>)
{
return nullptr;
}
}

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/SVG/SVGElement.h>
namespace Web::SVG {
class SVGClipPathElement final : public SVGElement {
public:
using WrapperType = Bindings::SVGClipPathElementWrapper;
SVGClipPathElement(DOM::Document&, DOM::QualifiedName);
virtual ~SVGClipPathElement();
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
};
}

View file

@ -0,0 +1,7 @@
[Exposed=Window]
interface SVGClipPathElement : SVGElement {
// FIXME: readonly attribute SVGAnimatedEnumeration clipPathUnits;
// FIXME: readonly attribute SVGAnimatedTransformList transform;
};

View file

@ -24,6 +24,7 @@ namespace Web::SVG::TagNames {
#define ENUMERATE_SVG_TAGS \
ENUMERATE_SVG_GRAPHICS_TAGS \
__ENUMERATE_SVG_TAG(clipPath) \
__ENUMERATE_SVG_TAG(desc) \
__ENUMERATE_SVG_TAG(foreignObject) \
__ENUMERATE_SVG_TAG(script) \