mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 13:17:43 +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:
parent
c6e79124c7
commit
e81594d9a1
8 changed files with 68 additions and 0 deletions
|
@ -267,6 +267,8 @@
|
||||||
#include <LibWeb/Bindings/ResizeObserverPrototype.h>
|
#include <LibWeb/Bindings/ResizeObserverPrototype.h>
|
||||||
#include <LibWeb/Bindings/SVGCircleElementConstructor.h>
|
#include <LibWeb/Bindings/SVGCircleElementConstructor.h>
|
||||||
#include <LibWeb/Bindings/SVGCircleElementPrototype.h>
|
#include <LibWeb/Bindings/SVGCircleElementPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/SVGClipPathElementConstructor.h>
|
||||||
|
#include <LibWeb/Bindings/SVGClipPathElementPrototype.h>
|
||||||
#include <LibWeb/Bindings/SVGElementConstructor.h>
|
#include <LibWeb/Bindings/SVGElementConstructor.h>
|
||||||
#include <LibWeb/Bindings/SVGElementPrototype.h>
|
#include <LibWeb/Bindings/SVGElementPrototype.h>
|
||||||
#include <LibWeb/Bindings/SVGEllipseElementConstructor.h>
|
#include <LibWeb/Bindings/SVGEllipseElementConstructor.h>
|
||||||
|
@ -484,6 +486,7 @@
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(SubtleCrypto) \
|
ADD_WINDOW_OBJECT_INTERFACE(SubtleCrypto) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(SVGElement) \
|
ADD_WINDOW_OBJECT_INTERFACE(SVGElement) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(SVGCircleElement) \
|
ADD_WINDOW_OBJECT_INTERFACE(SVGCircleElement) \
|
||||||
|
ADD_WINDOW_OBJECT_INTERFACE(SVGClipPathElement) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(SVGEllipseElement) \
|
ADD_WINDOW_OBJECT_INTERFACE(SVGEllipseElement) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(SVGGeometryElement) \
|
ADD_WINDOW_OBJECT_INTERFACE(SVGGeometryElement) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(SVGGraphicsElement) \
|
ADD_WINDOW_OBJECT_INTERFACE(SVGGraphicsElement) \
|
||||||
|
|
|
@ -317,6 +317,8 @@ set(SOURCES
|
||||||
SVG/AttributeNames.cpp
|
SVG/AttributeNames.cpp
|
||||||
SVG/AttributeParser.cpp
|
SVG/AttributeParser.cpp
|
||||||
SVG/SVGAnimatedLength.cpp
|
SVG/SVGAnimatedLength.cpp
|
||||||
|
SVG/SVGClipPathElement.cpp
|
||||||
|
SVG/SVGElement.cpp
|
||||||
SVG/SVGElement.cpp
|
SVG/SVGElement.cpp
|
||||||
SVG/SVGGElement.cpp
|
SVG/SVGGElement.cpp
|
||||||
SVG/SVGGeometryElement.cpp
|
SVG/SVGGeometryElement.cpp
|
||||||
|
@ -581,6 +583,7 @@ libweb_js_wrapper(NavigationTiming/PerformanceTiming)
|
||||||
libweb_js_wrapper(RequestIdleCallback/IdleDeadline)
|
libweb_js_wrapper(RequestIdleCallback/IdleDeadline)
|
||||||
libweb_js_wrapper(ResizeObserver/ResizeObserver)
|
libweb_js_wrapper(ResizeObserver/ResizeObserver)
|
||||||
libweb_js_wrapper(SVG/SVGAnimatedLength)
|
libweb_js_wrapper(SVG/SVGAnimatedLength)
|
||||||
|
libweb_js_wrapper(SVG/SVGClipPathElement)
|
||||||
libweb_js_wrapper(SVG/SVGElement)
|
libweb_js_wrapper(SVG/SVGElement)
|
||||||
libweb_js_wrapper(SVG/SVGGeometryElement)
|
libweb_js_wrapper(SVG/SVGGeometryElement)
|
||||||
libweb_js_wrapper(SVG/SVGGraphicsElement)
|
libweb_js_wrapper(SVG/SVGGraphicsElement)
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
#include <LibWeb/HTML/HTMLUnknownElement.h>
|
#include <LibWeb/HTML/HTMLUnknownElement.h>
|
||||||
#include <LibWeb/HTML/HTMLVideoElement.h>
|
#include <LibWeb/HTML/HTMLVideoElement.h>
|
||||||
#include <LibWeb/SVG/SVGCircleElement.h>
|
#include <LibWeb/SVG/SVGCircleElement.h>
|
||||||
|
#include <LibWeb/SVG/SVGClipPathElement.h>
|
||||||
#include <LibWeb/SVG/SVGEllipseElement.h>
|
#include <LibWeb/SVG/SVGEllipseElement.h>
|
||||||
#include <LibWeb/SVG/SVGGElement.h>
|
#include <LibWeb/SVG/SVGGElement.h>
|
||||||
#include <LibWeb/SVG/SVGLineElement.h>
|
#include <LibWeb/SVG/SVGLineElement.h>
|
||||||
|
@ -260,6 +261,9 @@ NonnullRefPtr<Element> create_element(Document& document, FlyString local_name,
|
||||||
return adopt_ref(*new HTML::HTMLElement(document, move(qualified_name)));
|
return adopt_ref(*new HTML::HTMLElement(document, move(qualified_name)));
|
||||||
if (lowercase_tag_name == SVG::TagNames::svg)
|
if (lowercase_tag_name == SVG::TagNames::svg)
|
||||||
return adopt_ref(*new SVG::SVGSVGElement(document, move(qualified_name)));
|
return adopt_ref(*new SVG::SVGSVGElement(document, move(qualified_name)));
|
||||||
|
// FIXME: Support SVG's mixedCase tag names properly.
|
||||||
|
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::clipPath))
|
||||||
|
return adopt_ref(*new SVG::SVGClipPathElement(document, move(qualified_name)));
|
||||||
if (lowercase_tag_name == SVG::TagNames::circle)
|
if (lowercase_tag_name == SVG::TagNames::circle)
|
||||||
return adopt_ref(*new SVG::SVGCircleElement(document, move(qualified_name)));
|
return adopt_ref(*new SVG::SVGCircleElement(document, move(qualified_name)));
|
||||||
if (lowercase_tag_name == SVG::TagNames::ellipse)
|
if (lowercase_tag_name == SVG::TagNames::ellipse)
|
||||||
|
|
|
@ -296,6 +296,7 @@ class ResizeObserver;
|
||||||
namespace Web::SVG {
|
namespace Web::SVG {
|
||||||
class SVGAnimatedLength;
|
class SVGAnimatedLength;
|
||||||
class SVGCircleElement;
|
class SVGCircleElement;
|
||||||
|
class SVGClipPathElement;
|
||||||
class SVGElement;
|
class SVGElement;
|
||||||
class SVGEllipseElement;
|
class SVGEllipseElement;
|
||||||
class SVGGeometryElement;
|
class SVGGeometryElement;
|
||||||
|
@ -522,6 +523,7 @@ class SubmitEventWrapper;
|
||||||
class SubtleCryptoWrapper;
|
class SubtleCryptoWrapper;
|
||||||
class SVGAnimatedLengthWrapper;
|
class SVGAnimatedLengthWrapper;
|
||||||
class SVGCircleElementWrapper;
|
class SVGCircleElementWrapper;
|
||||||
|
class SVGClipPathElementWrapper;
|
||||||
class SVGElementWrapper;
|
class SVGElementWrapper;
|
||||||
class SVGEllipseElementWrapper;
|
class SVGEllipseElementWrapper;
|
||||||
class SVGGeometryElementWrapper;
|
class SVGGeometryElementWrapper;
|
||||||
|
|
25
Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp
Normal file
25
Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h
Normal file
23
Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h
Normal 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
7
Userland/Libraries/LibWeb/SVG/SVGClipPathElement.idl
Normal file
7
Userland/Libraries/LibWeb/SVG/SVGClipPathElement.idl
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[Exposed=Window]
|
||||||
|
interface SVGClipPathElement : SVGElement {
|
||||||
|
|
||||||
|
// FIXME: readonly attribute SVGAnimatedEnumeration clipPathUnits;
|
||||||
|
// FIXME: readonly attribute SVGAnimatedTransformList transform;
|
||||||
|
|
||||||
|
};
|
|
@ -24,6 +24,7 @@ namespace Web::SVG::TagNames {
|
||||||
|
|
||||||
#define ENUMERATE_SVG_TAGS \
|
#define ENUMERATE_SVG_TAGS \
|
||||||
ENUMERATE_SVG_GRAPHICS_TAGS \
|
ENUMERATE_SVG_GRAPHICS_TAGS \
|
||||||
|
__ENUMERATE_SVG_TAG(clipPath) \
|
||||||
__ENUMERATE_SVG_TAG(desc) \
|
__ENUMERATE_SVG_TAG(desc) \
|
||||||
__ENUMERATE_SVG_TAG(foreignObject) \
|
__ENUMERATE_SVG_TAG(foreignObject) \
|
||||||
__ENUMERATE_SVG_TAG(script) \
|
__ENUMERATE_SVG_TAG(script) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue