This source file includes following definitions.
- m_pathSegList
- create
- getTotalLength
- getPointAtLength
- getPathSegAtLength
- createSVGPathSegClosePath
- createSVGPathSegMovetoAbs
- createSVGPathSegMovetoRel
- createSVGPathSegLinetoAbs
- createSVGPathSegLinetoRel
- createSVGPathSegCurvetoCubicAbs
- createSVGPathSegCurvetoCubicRel
- createSVGPathSegCurvetoQuadraticAbs
- createSVGPathSegCurvetoQuadraticRel
- createSVGPathSegArcAbs
- createSVGPathSegArcRel
- createSVGPathSegLinetoHorizontalAbs
- createSVGPathSegLinetoHorizontalRel
- createSVGPathSegLinetoVerticalAbs
- createSVGPathSegLinetoVerticalRel
- createSVGPathSegCurvetoCubicSmoothAbs
- createSVGPathSegCurvetoCubicSmoothRel
- createSVGPathSegCurvetoQuadraticSmoothAbs
- createSVGPathSegCurvetoQuadraticSmoothRel
- isSupportedAttribute
- parseAttribute
- svgAttributeChanged
- invalidateMPathDependencies
- insertedInto
- removedFrom
- pathSegListChanged
- getBBox
#include "config.h"
#include "core/svg/SVGPathElement.h"
#include "core/rendering/svg/RenderSVGPath.h"
#include "core/rendering/svg/RenderSVGResource.h"
#include "core/svg/SVGElementInstance.h"
#include "core/svg/SVGMPathElement.h"
#include "core/svg/SVGPathSegArcAbs.h"
#include "core/svg/SVGPathSegArcRel.h"
#include "core/svg/SVGPathSegClosePath.h"
#include "core/svg/SVGPathSegCurvetoCubicAbs.h"
#include "core/svg/SVGPathSegCurvetoCubicRel.h"
#include "core/svg/SVGPathSegCurvetoCubicSmoothAbs.h"
#include "core/svg/SVGPathSegCurvetoCubicSmoothRel.h"
#include "core/svg/SVGPathSegCurvetoQuadraticAbs.h"
#include "core/svg/SVGPathSegCurvetoQuadraticRel.h"
#include "core/svg/SVGPathSegCurvetoQuadraticSmoothAbs.h"
#include "core/svg/SVGPathSegCurvetoQuadraticSmoothRel.h"
#include "core/svg/SVGPathSegLinetoAbs.h"
#include "core/svg/SVGPathSegLinetoHorizontalAbs.h"
#include "core/svg/SVGPathSegLinetoHorizontalRel.h"
#include "core/svg/SVGPathSegLinetoRel.h"
#include "core/svg/SVGPathSegLinetoVerticalAbs.h"
#include "core/svg/SVGPathSegLinetoVerticalRel.h"
#include "core/svg/SVGPathSegMovetoAbs.h"
#include "core/svg/SVGPathSegMovetoRel.h"
#include "core/svg/SVGPathUtilities.h"
#include "core/svg/SVGPointTearOff.h"
namespace WebCore {
inline SVGPathElement::SVGPathElement(Document& document)
: SVGGeometryElement(SVGNames::pathTag, document)
, m_pathLength(SVGAnimatedNumber::create(this, SVGNames::pathLengthAttr, SVGNumber::create()))
, m_pathSegList(SVGAnimatedPath::create(this, SVGNames::dAttr))
{
ScriptWrappable::init(this);
addToPropertyMap(m_pathLength);
addToPropertyMap(m_pathSegList);
}
PassRefPtr<SVGPathElement> SVGPathElement::create(Document& document)
{
return adoptRef(new SVGPathElement(document));
}
float SVGPathElement::getTotalLength()
{
float totalLength = 0;
getTotalLengthOfSVGPathByteStream(pathByteStream(), totalLength);
return totalLength;
}
PassRefPtr<SVGPointTearOff> SVGPathElement::getPointAtLength(float length)
{
FloatPoint point;
getPointAtLengthOfSVGPathByteStream(pathByteStream(), length, point);
return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnimVal);
}
unsigned SVGPathElement::getPathSegAtLength(float length)
{
unsigned pathSeg = 0;
getSVGPathSegAtLengthFromSVGPathByteStream(pathByteStream(), length, pathSeg);
return pathSeg;
}
PassRefPtr<SVGPathSegClosePath> SVGPathElement::createSVGPathSegClosePath()
{
return SVGPathSegClosePath::create(0, PathSegUndefinedRole);
}
PassRefPtr<SVGPathSegMovetoAbs> SVGPathElement::createSVGPathSegMovetoAbs(float x, float y)
{
return SVGPathSegMovetoAbs::create(0, PathSegUndefinedRole, x, y);
}
PassRefPtr<SVGPathSegMovetoRel> SVGPathElement::createSVGPathSegMovetoRel(float x, float y)
{
return SVGPathSegMovetoRel::create(0, PathSegUndefinedRole, x, y);
}
PassRefPtr<SVGPathSegLinetoAbs> SVGPathElement::createSVGPathSegLinetoAbs(float x, float y)
{
return SVGPathSegLinetoAbs::create(0, PathSegUndefinedRole, x, y);
}
PassRefPtr<SVGPathSegLinetoRel> SVGPathElement::createSVGPathSegLinetoRel(float x, float y)
{
return SVGPathSegLinetoRel::create(0, PathSegUndefinedRole, x, y);
}
PassRefPtr<SVGPathSegCurvetoCubicAbs> SVGPathElement::createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2)
{
return SVGPathSegCurvetoCubicAbs::create(0, PathSegUndefinedRole, x, y, x1, y1, x2, y2);
}
PassRefPtr<SVGPathSegCurvetoCubicRel> SVGPathElement::createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2)
{
return SVGPathSegCurvetoCubicRel::create(0, PathSegUndefinedRole, x, y, x1, y1, x2, y2);
}
PassRefPtr<SVGPathSegCurvetoQuadraticAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1)
{
return SVGPathSegCurvetoQuadraticAbs::create(0, PathSegUndefinedRole, x, y, x1, y1);
}
PassRefPtr<SVGPathSegCurvetoQuadraticRel> SVGPathElement::createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1)
{
return SVGPathSegCurvetoQuadraticRel::create(0, PathSegUndefinedRole, x, y, x1, y1);
}
PassRefPtr<SVGPathSegArcAbs> SVGPathElement::createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
{
return SVGPathSegArcAbs::create(0, PathSegUndefinedRole, x, y, r1, r2, angle, largeArcFlag, sweepFlag);
}
PassRefPtr<SVGPathSegArcRel> SVGPathElement::createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
{
return SVGPathSegArcRel::create(0, PathSegUndefinedRole, x, y, r1, r2, angle, largeArcFlag, sweepFlag);
}
PassRefPtr<SVGPathSegLinetoHorizontalAbs> SVGPathElement::createSVGPathSegLinetoHorizontalAbs(float x)
{
return SVGPathSegLinetoHorizontalAbs::create(0, PathSegUndefinedRole, x);
}
PassRefPtr<SVGPathSegLinetoHorizontalRel> SVGPathElement::createSVGPathSegLinetoHorizontalRel(float x)
{
return SVGPathSegLinetoHorizontalRel::create(0, PathSegUndefinedRole, x);
}
PassRefPtr<SVGPathSegLinetoVerticalAbs> SVGPathElement::createSVGPathSegLinetoVerticalAbs(float y)
{
return SVGPathSegLinetoVerticalAbs::create(0, PathSegUndefinedRole, y);
}
PassRefPtr<SVGPathSegLinetoVerticalRel> SVGPathElement::createSVGPathSegLinetoVerticalRel(float y)
{
return SVGPathSegLinetoVerticalRel::create(0, PathSegUndefinedRole, y);
}
PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2)
{
return SVGPathSegCurvetoCubicSmoothAbs::create(0, PathSegUndefinedRole, x, y, x2, y2);
}
PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2)
{
return SVGPathSegCurvetoCubicSmoothRel::create(0, PathSegUndefinedRole, x, y, x2, y2);
}
PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y)
{
return SVGPathSegCurvetoQuadraticSmoothAbs::create(0, PathSegUndefinedRole, x, y);
}
PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y)
{
return SVGPathSegCurvetoQuadraticSmoothRel::create(0, PathSegUndefinedRole, x, y);
}
bool SVGPathElement::isSupportedAttribute(const QualifiedName& attrName)
{
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
if (supportedAttributes.isEmpty()) {
supportedAttributes.add(SVGNames::dAttr);
supportedAttributes.add(SVGNames::pathLengthAttr);
}
return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
}
void SVGPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (!isSupportedAttribute(name)) {
SVGGeometryElement::parseAttribute(name, value);
return;
}
SVGParsingError parseError = NoError;
if (name == SVGNames::dAttr) {
m_pathSegList->setBaseValueAsString(value, parseError);
} else if (name == SVGNames::pathLengthAttr) {
m_pathLength->setBaseValueAsString(value, parseError);
if (parseError == NoError && m_pathLength->baseValue()->value() < 0)
document().accessSVGExtensions().reportError("A negative value for path attribute <pathLength> is not allowed");
} else {
ASSERT_NOT_REACHED();
}
reportAttributeParsingError(parseError, name, value);
}
void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName)
{
if (!isSupportedAttribute(attrName)) {
SVGGeometryElement::svgAttributeChanged(attrName);
return;
}
SVGElementInstance::InvalidationGuard invalidationGuard(this);
RenderSVGPath* renderer = toRenderSVGPath(this->renderer());
if (attrName == SVGNames::dAttr) {
if (renderer)
renderer->setNeedsShapeUpdate();
invalidateMPathDependencies();
}
if (renderer)
RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
}
void SVGPathElement::invalidateMPathDependencies()
{
if (HashSet<SVGElement*>* dependencies = document().accessSVGExtensions().setOfElementsReferencingTarget(this)) {
HashSet<SVGElement*>::iterator end = dependencies->end();
for (HashSet<SVGElement*>::iterator it = dependencies->begin(); it != end; ++it) {
if (isSVGMPathElement(**it))
toSVGMPathElement(*it)->targetPathChanged();
}
}
}
Node::InsertionNotificationRequest SVGPathElement::insertedInto(ContainerNode* rootParent)
{
SVGGeometryElement::insertedInto(rootParent);
invalidateMPathDependencies();
return InsertionDone;
}
void SVGPathElement::removedFrom(ContainerNode* rootParent)
{
SVGGeometryElement::removedFrom(rootParent);
invalidateMPathDependencies();
}
void SVGPathElement::pathSegListChanged(ListModification listModification)
{
m_pathSegList->baseValue()->clearByteStream();
invalidateSVGAttributes();
RenderSVGPath* renderer = toRenderSVGPath(this->renderer());
if (!renderer)
return;
renderer->setNeedsShapeUpdate();
RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
}
FloatRect SVGPathElement::getBBox()
{
document().updateLayoutIgnorePendingStylesheets();
if (!renderer())
return FloatRect();
RenderSVGPath* renderer = toRenderSVGPath(this->renderer());
return renderer->path().boundingRect();
}
}