summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGMaskElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGMaskElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGMaskElement.cpp96
1 files changed, 51 insertions, 45 deletions
diff --git a/Source/WebCore/svg/SVGMaskElement.cpp b/Source/WebCore/svg/SVGMaskElement.cpp
index 42ed45ff5..f7a4180df 100644
--- a/Source/WebCore/svg/SVGMaskElement.cpp
+++ b/Source/WebCore/svg/SVGMaskElement.cpp
@@ -4,6 +4,7 @@
* Copyright (C) 2005 Alexander Kellett <lypanov@kde.org>
* Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
* Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
+ * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,17 +23,15 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGMaskElement.h"
-#include "Attribute.h"
#include "RenderSVGResourceMasker.h"
-#include "SVGElementInstance.h"
#include "SVGNames.h"
#include "SVGRenderSupport.h"
+#include "SVGStringList.h"
#include "SVGUnitTypes.h"
#include "StyleResolver.h"
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -72,59 +71,59 @@ inline SVGMaskElement::SVGMaskElement(const QualifiedName& tagName, Document& do
registerAnimatedPropertiesForSVGMaskElement();
}
-PassRefPtr<SVGMaskElement> SVGMaskElement::create(const QualifiedName& tagName, Document& document)
+Ref<SVGMaskElement> SVGMaskElement::create(const QualifiedName& tagName, Document& document)
{
- return adoptRef(new SVGMaskElement(tagName, document));
+ return adoptRef(*new SVGMaskElement(tagName, document));
}
bool SVGMaskElement::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);
SVGLangSpace::addSupportedAttributes(supportedAttributes);
SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
- supportedAttributes.add(SVGNames::maskUnitsAttr);
- supportedAttributes.add(SVGNames::maskContentUnitsAttr);
- supportedAttributes.add(SVGNames::xAttr);
- supportedAttributes.add(SVGNames::yAttr);
- supportedAttributes.add(SVGNames::widthAttr);
- supportedAttributes.add(SVGNames::heightAttr);
+ supportedAttributes.get().add(SVGNames::maskUnitsAttr);
+ supportedAttributes.get().add(SVGNames::maskContentUnitsAttr);
+ supportedAttributes.get().add(SVGNames::xAttr);
+ supportedAttributes.get().add(SVGNames::yAttr);
+ supportedAttributes.get().add(SVGNames::widthAttr);
+ supportedAttributes.get().add(SVGNames::heightAttr);
}
- return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
+ return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName);
}
void SVGMaskElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- SVGParsingError parseError = NoError;
-
- if (!isSupportedAttribute(name))
- SVGElement::parseAttribute(name, value);
- else if (name == SVGNames::maskUnitsAttr) {
- SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
+ if (name == SVGNames::maskUnitsAttr) {
+ auto propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
if (propertyValue > 0)
setMaskUnitsBaseValue(propertyValue);
return;
- } else if (name == SVGNames::maskContentUnitsAttr) {
- SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
+ }
+ if (name == SVGNames::maskContentUnitsAttr) {
+ auto propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
if (propertyValue > 0)
setMaskContentUnitsBaseValue(propertyValue);
return;
- } else if (name == SVGNames::xAttr)
- setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError));
+ }
+
+ SVGParsingError parseError = NoError;
+
+ if (name == SVGNames::xAttr)
+ setXBaseValue(SVGLengthValue::construct(LengthModeWidth, value, parseError));
else if (name == SVGNames::yAttr)
- setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError));
+ setYBaseValue(SVGLengthValue::construct(LengthModeHeight, value, parseError));
else if (name == SVGNames::widthAttr)
- setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseError));
+ setWidthBaseValue(SVGLengthValue::construct(LengthModeWidth, value, parseError));
else if (name == SVGNames::heightAttr)
- setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseError));
- else if (SVGTests::parseAttribute(name, value)
- || SVGLangSpace::parseAttribute(name, value)
- || SVGExternalResourcesRequired::parseAttribute(name, value)) {
- } else
- ASSERT_NOT_REACHED();
+ setHeightBaseValue(SVGLengthValue::construct(LengthModeHeight, value, parseError));
reportAttributeParsingError(parseError, name, value);
+
+ SVGElement::parseAttribute(name, value);
+ SVGTests::parseAttribute(name, value);
+ SVGExternalResourcesRequired::parseAttribute(name, value);
}
void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName)
@@ -134,13 +133,15 @@ void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName)
return;
}
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
-
+ InstanceInvalidationGuard guard(*this);
+
if (attrName == SVGNames::xAttr
|| attrName == SVGNames::yAttr
|| attrName == SVGNames::widthAttr
- || attrName == SVGNames::heightAttr)
- updateRelativeLengthsInformation();
+ || attrName == SVGNames::heightAttr) {
+ invalidateSVGPresentationAttributeStyle();
+ return;
+ }
if (RenderObject* object = renderer())
object->setNeedsLayout();
@@ -157,19 +158,24 @@ void SVGMaskElement::childrenChanged(const ChildChange& change)
object->setNeedsLayout();
}
-RenderPtr<RenderElement> SVGMaskElement::createElementRenderer(PassRef<RenderStyle> style)
+RenderPtr<RenderElement> SVGMaskElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
- return createRenderer<RenderSVGResourceMasker>(*this, std::move(style));
+ return createRenderer<RenderSVGResourceMasker>(*this, WTFMove(style));
}
-bool SVGMaskElement::selfHasRelativeLengths() const
+Ref<SVGStringList> SVGMaskElement::requiredFeatures()
{
- return x().isRelative()
- || y().isRelative()
- || width().isRelative()
- || height().isRelative();
+ return SVGTests::requiredFeatures(*this);
}
+Ref<SVGStringList> SVGMaskElement::requiredExtensions()
+{
+ return SVGTests::requiredExtensions(*this);
}
-#endif // ENABLE(SVG)
+Ref<SVGStringList> SVGMaskElement::systemLanguage()
+{
+ return SVGTests::systemLanguage(*this);
+}
+
+}