summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/SVG
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-04-10 19:05:12 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-10 21:35:55 +0200
commite81594d9a1528c57d5c94b475e11efe26a324766 (patch)
tree7c6f70dcfc6bde1e46dc00bd1c9a345931a799b5 /Userland/Libraries/LibWeb/SVG
parentc6e79124c7f479da5bb2b97cc59868763d013d51 (diff)
downloadserenity-e81594d9a1528c57d5c94b475e11efe26a324766.zip
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 :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/SVG')
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp25
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h23
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGClipPathElement.idl7
-rw-r--r--Userland/Libraries/LibWeb/SVG/TagNames.h1
4 files changed, 56 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp
new file mode 100644
index 0000000000..c1a9f0f1a8
--- /dev/null
+++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp
@@ -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;
+}
+
+}
diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h
new file mode 100644
index 0000000000..20755d6842
--- /dev/null
+++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h
@@ -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;
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.idl b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.idl
new file mode 100644
index 0000000000..15b1022160
--- /dev/null
+++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.idl
@@ -0,0 +1,7 @@
+[Exposed=Window]
+interface SVGClipPathElement : SVGElement {
+
+ // FIXME: readonly attribute SVGAnimatedEnumeration clipPathUnits;
+ // FIXME: readonly attribute SVGAnimatedTransformList transform;
+
+};
diff --git a/Userland/Libraries/LibWeb/SVG/TagNames.h b/Userland/Libraries/LibWeb/SVG/TagNames.h
index 8593a204ce..ac005c6af9 100644
--- a/Userland/Libraries/LibWeb/SVG/TagNames.h
+++ b/Userland/Libraries/LibWeb/SVG/TagNames.h
@@ -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) \