From 8949b0def6e509223eaba495612742d1a7e0147d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 15 Sep 2021 00:26:16 +0200 Subject: LibWeb: Add an SVG::AttributeNames namespace There are a whole bunch of SVG attributes, and we shouldn't mix them in with the HTML attributes. This patch adds some of them to the new namespace, but there are more to be added. :^) --- Userland/Libraries/LibWeb/CMakeLists.txt | 1 + Userland/Libraries/LibWeb/SVG/AttributeNames.cpp | 29 ++++++++ Userland/Libraries/LibWeb/SVG/AttributeNames.h | 84 ++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 Userland/Libraries/LibWeb/SVG/AttributeNames.cpp create mode 100644 Userland/Libraries/LibWeb/SVG/AttributeNames.h (limited to 'Userland') diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index be00a699de..e38790964d 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -221,6 +221,7 @@ set(SOURCES Page/Page.cpp Painting/BorderPainting.cpp Painting/StackingContext.cpp + SVG/AttributeNames.cpp SVG/SVGElement.cpp SVG/SVGGeometryElement.cpp SVG/SVGGraphicsElement.cpp diff --git a/Userland/Libraries/LibWeb/SVG/AttributeNames.cpp b/Userland/Libraries/LibWeb/SVG/AttributeNames.cpp new file mode 100644 index 0000000000..f8953aa822 --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/AttributeNames.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace Web::SVG::AttributeNames { + +#define __ENUMERATE_SVG_ATTRIBUTE(name) FlyString name; +ENUMERATE_SVG_ATTRIBUTES(__ENUMERATE_SVG_ATTRIBUTE) +#undef __ENUMERATE_SVG_ATTRIBUTE + +[[gnu::constructor]] static void initialize() +{ + static bool s_initialized = false; + if (s_initialized) + return; + +#define __ENUMERATE_SVG_ATTRIBUTE(name) \ + name = #name; + ENUMERATE_SVG_ATTRIBUTES(__ENUMERATE_SVG_ATTRIBUTE) +#undef __ENUMERATE_SVG_ATTRIBUTE + + s_initialized = true; +} + +} diff --git a/Userland/Libraries/LibWeb/SVG/AttributeNames.h b/Userland/Libraries/LibWeb/SVG/AttributeNames.h new file mode 100644 index 0000000000..e8c746eab4 --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/AttributeNames.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::SVG::AttributeNames { + +#define ENUMERATE_SVG_ATTRIBUTES(E) \ + E(attributeName) \ + E(attributeType) \ + E(baseFrequency) \ + E(baseProfile) \ + E(calcMode) \ + E(clipPathUnits) \ + E(contentScriptType) \ + E(contentStyleType) \ + E(diffuseConstant) \ + E(edgeMode) \ + E(filterUnits) \ + E(glyphRef) \ + E(gradientTransform) \ + E(gradientUnits) \ + E(height) \ + E(kernelMatrix) \ + E(kernelUnitLength) \ + E(keyPoints) \ + E(keySplines) \ + E(keyTimes) \ + E(lengthAdjust) \ + E(limitingConeAngle) \ + E(markerHeight) \ + E(markerUnits) \ + E(markerWidth) \ + E(maskContentUnits) \ + E(maskUnits) \ + E(numOctaves) \ + E(pathLength) \ + E(patternContentUnits) \ + E(patternTransform) \ + E(patternUnits) \ + E(pointsAtX) \ + E(pointsAtY) \ + E(pointsAtZ) \ + E(preserveAlpha) \ + E(preserveAspectRatio) \ + E(primitiveUnits) \ + E(refX) \ + E(refY) \ + E(repeatCount) \ + E(repeatDur) \ + E(requiredExtensions) \ + E(requiredFeatures) \ + E(specularConstant) \ + E(specularExponent) \ + E(spreadMethod) \ + E(startOffset) \ + E(stdDeviation) \ + E(stitchTiles) \ + E(surfaceScale) \ + E(systemLanguage) \ + E(tableValues) \ + E(targetX) \ + E(targetY) \ + E(textLength) \ + E(version) \ + E(viewBox) \ + E(viewTarget) \ + E(width) \ + E(x) \ + E(xChannelSelector) \ + E(y) \ + E(yChannelSelector) \ + E(zoomAndPan) + +#define __ENUMERATE_SVG_ATTRIBUTE(name) extern FlyString name; +ENUMERATE_SVG_ATTRIBUTES(__ENUMERATE_SVG_ATTRIBUTE) +#undef __ENUMERATE_SVG_ATTRIBUTE + +} -- cgit v1.2.3