summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGForeignObjectElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGForeignObjectElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGForeignObjectElement.cpp74
1 files changed, 30 insertions, 44 deletions
diff --git a/Source/WebCore/svg/SVGForeignObjectElement.cpp b/Source/WebCore/svg/SVGForeignObjectElement.cpp
index 37cc8cd39..c2af1f4e5 100644
--- a/Source/WebCore/svg/SVGForeignObjectElement.cpp
+++ b/Source/WebCore/svg/SVGForeignObjectElement.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ * 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
@@ -19,19 +20,16 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGForeignObjectElement.h"
-#include "Attribute.h"
#include "CSSPropertyNames.h"
#include "RenderSVGForeignObject.h"
#include "RenderSVGResource.h"
-#include "SVGElementInstance.h"
-#include "SVGLength.h"
+#include "SVGLengthValue.h"
#include "SVGNames.h"
#include "XLinkNames.h"
#include <wtf/Assertions.h>
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -64,45 +62,42 @@ inline SVGForeignObjectElement::SVGForeignObjectElement(const QualifiedName& tag
registerAnimatedPropertiesForSVGForeignObjectElement();
}
-PassRefPtr<SVGForeignObjectElement> SVGForeignObjectElement::create(const QualifiedName& tagName, Document& document)
+Ref<SVGForeignObjectElement> SVGForeignObjectElement::create(const QualifiedName& tagName, Document& document)
{
- return adoptRef(new SVGForeignObjectElement(tagName, document));
+ return adoptRef(*new SVGForeignObjectElement(tagName, document));
}
bool SVGForeignObjectElement::isSupportedAttribute(const QualifiedName& attrName)
{
- DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
- if (supportedAttributes.isEmpty()) {
+ static NeverDestroyed<HashSet<QualifiedName>> supportedAttributes;
+ if (supportedAttributes.get().isEmpty()) {
SVGLangSpace::addSupportedAttributes(supportedAttributes);
SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
- supportedAttributes.add(SVGNames::xAttr);
- supportedAttributes.add(SVGNames::yAttr);
- supportedAttributes.add(SVGNames::widthAttr);
- supportedAttributes.add(SVGNames::heightAttr);
+ 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 SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
SVGParsingError parseError = NoError;
- if (!isSupportedAttribute(name))
- SVGGraphicsElement::parseAttribute(name, value);
- else if (name == SVGNames::xAttr)
- setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError));
+ 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 (SVGLangSpace::parseAttribute(name, value)
- || SVGExternalResourcesRequired::parseAttribute(name, value)) {
- } else
- ASSERT_NOT_REACHED();
+ setHeightBaseValue(SVGLengthValue::construct(LengthModeHeight, value, parseError));
reportAttributeParsingError(parseError, name, value);
+
+ SVGGraphicsElement::parseAttribute(name, value);
+ SVGExternalResourcesRequired::parseAttribute(name, value);
}
void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
@@ -112,23 +107,24 @@ void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
return;
}
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
-
- bool isLengthAttribute = attrName == SVGNames::xAttr
- || attrName == SVGNames::yAttr
- || attrName == SVGNames::widthAttr
- || attrName == SVGNames::heightAttr;
+ InstanceInvalidationGuard guard(*this);
+
+ if (attrName == SVGNames::widthAttr
+ || attrName == SVGNames::heightAttr) {
+ invalidateSVGPresentationAttributeStyle();
+ return;
+ }
- if (isLengthAttribute)
+ if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr)
updateRelativeLengthsInformation();
if (auto renderer = this->renderer())
RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
}
-RenderPtr<RenderElement> SVGForeignObjectElement::createElementRenderer(PassRef<RenderStyle> style)
+RenderPtr<RenderElement> SVGForeignObjectElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
- return createRenderer<RenderSVGForeignObject>(*this, std::move(style));
+ return createRenderer<RenderSVGForeignObject>(*this, WTFMove(style));
}
bool SVGForeignObjectElement::childShouldCreateRenderer(const Node& child) const
@@ -159,14 +155,4 @@ bool SVGForeignObjectElement::rendererIsNeeded(const RenderStyle& style)
return SVGGraphicsElement::rendererIsNeeded(style);
}
-bool SVGForeignObjectElement::selfHasRelativeLengths() const
-{
- return x().isRelative()
- || y().isRelative()
- || width().isRelative()
- || height().isRelative();
-}
-
}
-
-#endif