SVGPolyElement.cpp [plain text]
#include "config.h"
#include "SVGPolyElement.h"
#include "Document.h"
#include "RenderSVGPath.h"
#include "RenderSVGResource.h"
#include "SVGDocumentExtensions.h"
#include "SVGParserUtilities.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(SVGPolyElement);
SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document& document)
: SVGGeometryElement(tagName, document)
{
static std::once_flag onceFlag;
std::call_once(onceFlag, [] {
PropertyRegistry::registerProperty<SVGNames::pointsAttr, &SVGPolyElement::m_points>();
});
}
void SVGPolyElement::parseAttribute(const QualifiedName& name, const AtomString& value)
{
if (name == SVGNames::pointsAttr) {
if (!m_points->baseVal()->parse(value))
document().accessSVGExtensions().reportError("Problem parsing points=\"" + value + "\"");
return;
}
SVGGeometryElement::parseAttribute(name, value);
}
void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName)
{
if (attrName == SVGNames::pointsAttr) {
if (auto* renderer = downcast<RenderSVGPath>(this->renderer())) {
InstanceInvalidationGuard guard(*this);
renderer->setNeedsShapeUpdate();
RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
}
return;
}
SVGGeometryElement::svgAttributeChanged(attrName);
}
size_t SVGPolyElement::approximateMemoryCost() const
{
size_t pointsCost = m_points->baseVal()->items().size() * sizeof(FloatPoint);
return sizeof(*this) + (renderer() ? pointsCost * 2 + sizeof(RenderSVGPath) : pointsCost);
}
}