summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGPatternElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGPatternElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGPatternElement.cpp173
1 files changed, 78 insertions, 95 deletions
diff --git a/Source/WebCore/svg/SVGPatternElement.cpp b/Source/WebCore/svg/SVGPatternElement.cpp
index ec4c0ba6f..b136b4fca 100644
--- a/Source/WebCore/svg/SVGPatternElement.cpp
+++ b/Source/WebCore/svg/SVGPatternElement.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
* Copyright (C) Research In Motion Limited 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
@@ -20,12 +21,9 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGPatternElement.h"
#include "AffineTransform.h"
-#include "Attribute.h"
#include "Document.h"
#include "FloatConversion.h"
#include "GraphicsContext.h"
@@ -33,14 +31,14 @@
#include "PatternAttributes.h"
#include "RenderSVGContainer.h"
#include "RenderSVGResourcePattern.h"
-#include "SVGElementInstance.h"
#include "SVGFitToViewBox.h"
#include "SVGGraphicsElement.h"
#include "SVGNames.h"
#include "SVGRenderSupport.h"
-#include "SVGSVGElement.h"
+#include "SVGStringList.h"
#include "SVGTransformable.h"
#include "XLinkNames.h"
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -86,70 +84,71 @@ inline SVGPatternElement::SVGPatternElement(const QualifiedName& tagName, Docume
registerAnimatedPropertiesForSVGPatternElement();
}
-PassRefPtr<SVGPatternElement> SVGPatternElement::create(const QualifiedName& tagName, Document& document)
+Ref<SVGPatternElement> SVGPatternElement::create(const QualifiedName& tagName, Document& document)
{
- return adoptRef(new SVGPatternElement(tagName, document));
+ return adoptRef(*new SVGPatternElement(tagName, document));
}
bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName)
{
- DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
- if (supportedAttributes.isEmpty()) {
+ static NeverDestroyed<HashSet<QualifiedName>> supportedAttributes;
+ if (supportedAttributes.get().isEmpty()) {
SVGURIReference::addSupportedAttributes(supportedAttributes);
SVGTests::addSupportedAttributes(supportedAttributes);
SVGLangSpace::addSupportedAttributes(supportedAttributes);
SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
SVGFitToViewBox::addSupportedAttributes(supportedAttributes);
- supportedAttributes.add(SVGNames::patternUnitsAttr);
- supportedAttributes.add(SVGNames::patternContentUnitsAttr);
- supportedAttributes.add(SVGNames::patternTransformAttr);
- supportedAttributes.add(SVGNames::xAttr);
- supportedAttributes.add(SVGNames::yAttr);
- supportedAttributes.add(SVGNames::widthAttr);
- supportedAttributes.add(SVGNames::heightAttr);
+ supportedAttributes.get().add(SVGNames::patternUnitsAttr);
+ supportedAttributes.get().add(SVGNames::patternContentUnitsAttr);
+ supportedAttributes.get().add(SVGNames::patternTransformAttr);
+ 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 SVGPatternElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- SVGParsingError parseError = NoError;
-
- if (!isSupportedAttribute(name))
- SVGElement::parseAttribute(name, value);
- else if (name == SVGNames::patternUnitsAttr) {
- SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
+ if (name == SVGNames::patternUnitsAttr) {
+ auto propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
if (propertyValue > 0)
setPatternUnitsBaseValue(propertyValue);
return;
- } else if (name == SVGNames::patternContentUnitsAttr) {
- SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
+ }
+ if (name == SVGNames::patternContentUnitsAttr) {
+ auto propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
if (propertyValue > 0)
setPatternContentUnitsBaseValue(propertyValue);
return;
- } else if (name == SVGNames::patternTransformAttr) {
- SVGTransformList newList;
+ }
+ if (name == SVGNames::patternTransformAttr) {
+ SVGTransformListValues newList;
newList.parse(value);
detachAnimatedPatternTransformListWrappers(newList.size());
setPatternTransformBaseValue(newList);
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, ForbidNegativeLengths));
+ setWidthBaseValue(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
else if (name == SVGNames::heightAttr)
- setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
- else if (SVGURIReference::parseAttribute(name, value)
- || SVGTests::parseAttribute(name, value)
- || SVGLangSpace::parseAttribute(name, value)
- || SVGExternalResourcesRequired::parseAttribute(name, value)
- || SVGFitToViewBox::parseAttribute(this, name, value)) {
- } else
- ASSERT_NOT_REACHED();
+ setHeightBaseValue(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
reportAttributeParsingError(parseError, name, value);
+
+ SVGElement::parseAttribute(name, value);
+ SVGURIReference::parseAttribute(name, value);
+ SVGTests::parseAttribute(name, value);
+ SVGExternalResourcesRequired::parseAttribute(name, value);
+ SVGFitToViewBox::parseAttribute(this, name, value);
}
void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName)
@@ -159,13 +158,15 @@ void SVGPatternElement::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();
@@ -182,68 +183,45 @@ void SVGPatternElement::childrenChanged(const ChildChange& change)
object->setNeedsLayout();
}
-RenderPtr<RenderElement> SVGPatternElement::createElementRenderer(PassRef<RenderStyle> style)
+RenderPtr<RenderElement> SVGPatternElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
- return createRenderer<RenderSVGResourcePattern>(*this, std::move(style));
+ return createRenderer<RenderSVGResourcePattern>(*this, WTFMove(style));
}
-static void setPatternAttributes(const SVGPatternElement& element, PatternAttributes& attributes)
+void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const
{
- if (!attributes.hasX() && element.hasAttribute(SVGNames::xAttr))
- attributes.setX(element.x());
+ if (!attributes.hasX() && hasAttribute(SVGNames::xAttr))
+ attributes.setX(x());
- if (!attributes.hasY() && element.hasAttribute(SVGNames::yAttr))
- attributes.setY(element.y());
+ if (!attributes.hasY() && hasAttribute(SVGNames::yAttr))
+ attributes.setY(y());
- if (!attributes.hasWidth() && element.hasAttribute(SVGNames::widthAttr))
- attributes.setWidth(element.width());
+ if (!attributes.hasWidth() && hasAttribute(SVGNames::widthAttr))
+ attributes.setWidth(width());
- if (!attributes.hasHeight() && element.hasAttribute(SVGNames::heightAttr))
- attributes.setHeight(element.height());
+ if (!attributes.hasHeight() && hasAttribute(SVGNames::heightAttr))
+ attributes.setHeight(height());
- if (!attributes.hasViewBox() && element.hasAttribute(SVGNames::viewBoxAttr) && element.viewBoxIsValid())
- attributes.setViewBox(element.viewBox());
+ if (!attributes.hasViewBox() && hasAttribute(SVGNames::viewBoxAttr) && viewBoxIsValid())
+ attributes.setViewBox(viewBox());
- if (!attributes.hasPreserveAspectRatio() && element.hasAttribute(SVGNames::preserveAspectRatioAttr))
- attributes.setPreserveAspectRatio(element.preserveAspectRatio());
+ if (!attributes.hasPreserveAspectRatio() && hasAttribute(SVGNames::preserveAspectRatioAttr))
+ attributes.setPreserveAspectRatio(preserveAspectRatio());
- if (!attributes.hasPatternUnits() && element.hasAttribute(SVGNames::patternUnitsAttr))
- attributes.setPatternUnits(element.patternUnits());
+ if (!attributes.hasPatternUnits() && hasAttribute(SVGNames::patternUnitsAttr))
+ attributes.setPatternUnits(patternUnits());
- if (!attributes.hasPatternContentUnits() && element.hasAttribute(SVGNames::patternContentUnitsAttr))
- attributes.setPatternContentUnits(element.patternContentUnits());
+ if (!attributes.hasPatternContentUnits() && hasAttribute(SVGNames::patternContentUnitsAttr))
+ attributes.setPatternContentUnits(patternContentUnits());
- if (!attributes.hasPatternTransform() && element.hasAttribute(SVGNames::patternTransformAttr)) {
+ if (!attributes.hasPatternTransform() && hasAttribute(SVGNames::patternTransformAttr)) {
AffineTransform transform;
- element.patternTransform().concatenate(transform);
+ patternTransform().concatenate(transform);
attributes.setPatternTransform(transform);
}
- if (!attributes.hasPatternContentElement() && element.childElementCount())
- attributes.setPatternContentElement(&element);
-}
-
-void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const
-{
- HashSet<const SVGPatternElement*> processedPatterns;
- const SVGPatternElement* current = this;
-
- while (true) {
- setPatternAttributes(*current, attributes);
- processedPatterns.add(current);
-
- // Respect xlink:href, take attributes from referenced element
- Element* refElement = SVGURIReference::targetElementFromIRIString(current->href(), document());
- if (refElement && isSVGPatternElement(refElement)) {
- current = toSVGPatternElement(refElement);
-
- // Cycle detection
- if (processedPatterns.contains(current))
- return;
- } else
- return;
- }
- ASSERT_NOT_REACHED();
+ if (!attributes.hasPatternContentElement() && childElementCount())
+ attributes.setPatternContentElement(this);
}
AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGLocatable::CTMScope) const
@@ -253,14 +231,19 @@ AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGLocatable::C
return matrix;
}
-bool SVGPatternElement::selfHasRelativeLengths() const
+Ref<SVGStringList> SVGPatternElement::requiredFeatures()
{
- return x().isRelative()
- || y().isRelative()
- || width().isRelative()
- || height().isRelative();
+ return SVGTests::requiredFeatures(*this);
}
+Ref<SVGStringList> SVGPatternElement::requiredExtensions()
+{
+ return SVGTests::requiredExtensions(*this);
}
-#endif // ENABLE(SVG)
+Ref<SVGStringList> SVGPatternElement::systemLanguage()
+{
+ return SVGTests::systemLanguage(*this);
+}
+
+}