From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/svg/SVGGraphicsElement.cpp | 78 +++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 25 deletions(-) (limited to 'Source/WebCore/svg/SVGGraphicsElement.cpp') 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 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 SVGGraphicsElement::getCTMForBindings() +{ + return SVGMatrix::create(getCTM()); +} + AffineTransform SVGGraphicsElement::getCTM(StyleUpdateStrategy styleUpdateStrategy) { return SVGLocatable::computeCTM(this, SVGLocatable::NearestViewportScope, styleUpdateStrategy); } +Ref 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, supportedAttributes, ()); - if (supportedAttributes.isEmpty()) { + static NeverDestroyed> supportedAttributes; + if (supportedAttributes.get().isEmpty()) { SVGTests::addSupportedAttributes(supportedAttributes); - supportedAttributes.add(SVGNames::transformAttr); + supportedAttributes.get().add(SVGNames::transformAttr); } - return supportedAttributes.contains(attrName); + return supportedAttributes.get().contains(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 SVGGraphicsElement::getBBoxForBindings() +{ + return SVGRect::create(getBBox()); +} + FloatRect SVGGraphicsElement::getBBox(StyleUpdateStrategy styleUpdateStrategy) { return SVGTransformable::getBBox(this, styleUpdateStrategy); } -RenderPtr SVGGraphicsElement::createElementRenderer(PassRef style) +RenderPtr SVGGraphicsElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&) { - // By default, any subclass is expected to do path-based drawing - return createRenderer(*this, std::move(style)); + return createRenderer(*this, WTFMove(style)); } void SVGGraphicsElement::toClipPath(Path& path) @@ -175,6 +190,19 @@ void SVGGraphicsElement::toClipPath(Path& path) path.transform(animatedLocalTransform()); } +Ref SVGGraphicsElement::requiredFeatures() +{ + return SVGTests::requiredFeatures(*this); +} + +Ref SVGGraphicsElement::requiredExtensions() +{ + return SVGTests::requiredExtensions(*this); +} + +Ref SVGGraphicsElement::systemLanguage() +{ + return SVGTests::systemLanguage(*this); } -#endif // ENABLE(SVG) +} -- cgit v1.2.1