This source file includes following definitions.
- SVGURIReference
- create
- buildPendingResource
- clearResourceReferences
- insertedInto
- removedFrom
- isSupportedAttribute
- parseAttribute
- svgAttributeChanged
- pathElement
- targetPathChanged
- notifyParentOfPathChange
#include "config.h"
#include "core/svg/SVGMPathElement.h"
#include "XLinkNames.h"
#include "core/dom/Document.h"
#include "core/svg/SVGAnimateMotionElement.h"
#include "core/svg/SVGDocumentExtensions.h"
#include "core/svg/SVGElementInstance.h"
#include "core/svg/SVGPathElement.h"
namespace WebCore {
inline SVGMPathElement::SVGMPathElement(Document& document)
: SVGElement(SVGNames::mpathTag, document)
, SVGURIReference(this)
{
ScriptWrappable::init(this);
}
PassRefPtr<SVGMPathElement> SVGMPathElement::create(Document& document)
{
return adoptRef(new SVGMPathElement(document));
}
SVGMPathElement::~SVGMPathElement()
{
clearResourceReferences();
}
void SVGMPathElement::buildPendingResource()
{
clearResourceReferences();
if (!inDocument())
return;
AtomicString id;
Element* target = SVGURIReference::targetElementFromIRIString(hrefString(), document(), &id);
if (!target) {
if (document().accessSVGExtensions().isElementPendingResource(this, id))
return;
if (!id.isEmpty()) {
document().accessSVGExtensions().addPendingResource(id, this);
ASSERT(hasPendingResources());
}
} else if (target->isSVGElement()) {
document().accessSVGExtensions().addElementReferencingTarget(this, toSVGElement(target));
}
targetPathChanged();
}
void SVGMPathElement::clearResourceReferences()
{
document().accessSVGExtensions().removeAllTargetReferencesForElement(this);
}
Node::InsertionNotificationRequest SVGMPathElement::insertedInto(ContainerNode* rootParent)
{
SVGElement::insertedInto(rootParent);
if (rootParent->inDocument())
buildPendingResource();
return InsertionDone;
}
void SVGMPathElement::removedFrom(ContainerNode* rootParent)
{
SVGElement::removedFrom(rootParent);
notifyParentOfPathChange(rootParent);
if (rootParent->inDocument())
clearResourceReferences();
}
bool SVGMPathElement::isSupportedAttribute(const QualifiedName& attrName)
{
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
if (supportedAttributes.isEmpty()) {
SVGURIReference::addSupportedAttributes(supportedAttributes);
}
return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
}
void SVGMPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
SVGParsingError parseError = NoError;
if (!isSupportedAttribute(name)) {
SVGElement::parseAttribute(name, value);
} else if (SVGURIReference::parseAttribute(name, value, parseError)) {
} else {
ASSERT_NOT_REACHED();
}
reportAttributeParsingError(parseError, name, value);
}
void SVGMPathElement::svgAttributeChanged(const QualifiedName& attrName)
{
if (!isSupportedAttribute(attrName)) {
SVGElement::svgAttributeChanged(attrName);
return;
}
SVGElementInstance::InvalidationGuard invalidationGuard(this);
if (SVGURIReference::isKnownAttribute(attrName)) {
buildPendingResource();
return;
}
ASSERT_NOT_REACHED();
}
SVGPathElement* SVGMPathElement::pathElement()
{
Element* target = targetElementFromIRIString(hrefString(), document());
return isSVGPathElement(target) ? toSVGPathElement(target) : 0;
}
void SVGMPathElement::targetPathChanged()
{
notifyParentOfPathChange(parentNode());
}
void SVGMPathElement::notifyParentOfPathChange(ContainerNode* parent)
{
if (isSVGAnimateMotionElement(parent))
toSVGAnimateMotionElement(parent)->updateAnimationPath();
}
}