summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGGraphicsElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGGraphicsElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGGraphicsElement.cpp78
1 files changed, 53 insertions, 25 deletions
diff --git a/Source/WebCore/svg/SVGGraphicsElement.cpp b/Source/WebCore/svg/SVGGraphicsElement.cpp
index 53ba8db0b..f5f929329 100644
--- a/Source/WebCore/svg/SVGGraphicsElement.cpp
+++ b/Source/WebCore/svg/SVGGraphicsElement.cpp
@@ -19,17 +19,16 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGGraphicsElement.h"
-#include "AffineTransform.h"
-#include "Attribute.h"
#include "RenderSVGPath.h"
#include "RenderSVGResource.h"
-#include "SVGElementInstance.h"
+#include "SVGMatrix.h"
#include "SVGNames.h"
#include "SVGPathData.h"
+#include "SVGRect.h"
+#include "SVGStringList.h"
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -44,6 +43,7 @@ END_REGISTER_ANIMATED_PROPERTIES
SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tagName, Document& document)
: SVGElement(tagName, document)
+ , m_shouldIsolateBlending(false)
{
registerAnimatedPropertiesForSVGGraphicsElement();
}
@@ -52,11 +52,21 @@ SVGGraphicsElement::~SVGGraphicsElement()
{
}
+Ref<SVGMatrix> SVGGraphicsElement::getCTMForBindings()
+{
+ return SVGMatrix::create(getCTM());
+}
+
AffineTransform SVGGraphicsElement::getCTM(StyleUpdateStrategy styleUpdateStrategy)
{
return SVGLocatable::computeCTM(this, SVGLocatable::NearestViewportScope, styleUpdateStrategy);
}
+Ref<SVGMatrix> SVGGraphicsElement::getScreenCTMForBindings()
+{
+ return SVGMatrix::create(getScreenCTM());
+}
+
AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdateStrategy)
{
return SVGLocatable::computeCTM(this, SVGLocatable::ScreenScope, styleUpdateStrategy);
@@ -65,7 +75,7 @@ AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdate
AffineTransform SVGGraphicsElement::animatedLocalTransform() const
{
AffineTransform matrix;
- RenderStyle* style = renderer() ? &renderer()->style() : nullptr;
+ auto* style = renderer() ? &renderer()->style() : nullptr;
// If CSS property was set, use that, otherwise fallback to attribute (if set).
if (style && style->hasTransform()) {
@@ -76,6 +86,14 @@ AffineTransform SVGGraphicsElement::animatedLocalTransform() const
// Flatten any 3D transform.
matrix = transform.toAffineTransform();
+ // CSS bakes the zoom factor into lengths, including translation components.
+ // In order to align CSS & SVG transforms, we need to invert this operation.
+ float zoom = style->effectiveZoom();
+ if (zoom != 1) {
+ matrix.setE(matrix.e() / zoom);
+ matrix.setF(matrix.f() / zoom);
+ }
+
} else
transform().concatenate(matrix);
@@ -93,33 +111,26 @@ AffineTransform* SVGGraphicsElement::supplementalTransform()
bool SVGGraphicsElement::isSupportedAttribute(const QualifiedName& attrName)
{
- DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
- if (supportedAttributes.isEmpty()) {
+ static NeverDestroyed<HashSet<QualifiedName>> supportedAttributes;
+ if (supportedAttributes.get().isEmpty()) {
SVGTests::addSupportedAttributes(supportedAttributes);
- supportedAttributes.add(SVGNames::transformAttr);
+ supportedAttributes.get().add(SVGNames::transformAttr);
}
- return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
+ return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName);
}
void SVGGraphicsElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- if (!isSupportedAttribute(name)) {
- SVGElement::parseAttribute(name, value);
- return;
- }
-
if (name == SVGNames::transformAttr) {
- SVGTransformList newList;
+ SVGTransformListValues newList;
newList.parse(value);
detachAnimatedTransformListWrappers(newList.size());
setTransformBaseValue(newList);
return;
}
- if (SVGTests::parseAttribute(name, value))
- return;
-
- ASSERT_NOT_REACHED();
+ SVGElement::parseAttribute(name, value);
+ SVGTests::parseAttribute(name, value);
}
void SVGGraphicsElement::svgAttributeChanged(const QualifiedName& attrName)
@@ -129,7 +140,7 @@ void SVGGraphicsElement::svgAttributeChanged(const QualifiedName& attrName)
return;
}
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
+ InstanceInvalidationGuard guard(*this);
if (SVGTests::handleAttributeChange(this, attrName))
return;
@@ -157,15 +168,19 @@ SVGElement* SVGGraphicsElement::farthestViewportElement() const
return SVGTransformable::farthestViewportElement(this);
}
+Ref<SVGRect> SVGGraphicsElement::getBBoxForBindings()
+{
+ return SVGRect::create(getBBox());
+}
+
FloatRect SVGGraphicsElement::getBBox(StyleUpdateStrategy styleUpdateStrategy)
{
return SVGTransformable::getBBox(this, styleUpdateStrategy);
}
-RenderPtr<RenderElement> SVGGraphicsElement::createElementRenderer(PassRef<RenderStyle> style)
+RenderPtr<RenderElement> SVGGraphicsElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
- // By default, any subclass is expected to do path-based drawing
- return createRenderer<RenderSVGPath>(*this, std::move(style));
+ return createRenderer<RenderSVGPath>(*this, WTFMove(style));
}
void SVGGraphicsElement::toClipPath(Path& path)
@@ -175,6 +190,19 @@ void SVGGraphicsElement::toClipPath(Path& path)
path.transform(animatedLocalTransform());
}
+Ref<SVGStringList> SVGGraphicsElement::requiredFeatures()
+{
+ return SVGTests::requiredFeatures(*this);
+}
+
+Ref<SVGStringList> SVGGraphicsElement::requiredExtensions()
+{
+ return SVGTests::requiredExtensions(*this);
+}
+
+Ref<SVGStringList> SVGGraphicsElement::systemLanguage()
+{
+ return SVGTests::systemLanguage(*this);
}
-#endif // ENABLE(SVG)
+}