Beispiel #1
0
static v8::Handle<v8::Value> getPresentationAttributeCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathElement.getPresentationAttribute");
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, name, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
    return toV8(imp->getPresentationAttribute(name));
}
Beispiel #2
0
static v8::Handle<v8::Value> getPointAtLengthCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathElement.getPointAtLength");
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    EXCEPTION_BLOCK(float, distance, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)->NumberValue()));
    return toV8(WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(imp->getPointAtLength(distance))));
}
Beispiel #3
0
static v8::Handle<v8::Value> createSVGPathSegLinetoVerticalRelCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathElement.createSVGPathSegLinetoVerticalRel");
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    EXCEPTION_BLOCK(float, y, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)->NumberValue()));
    return toV8(imp->createSVGPathSegLinetoVerticalRel(y));
}
Beispiel #4
0
static v8::Handle<v8::Value> hasExtensionCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathElement.hasExtension");
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, extension, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
    return v8Boolean(imp->hasExtension(extension));
}
static v8::Handle<v8::Value> createSVGPathSegCurvetoQuadraticSmoothRelCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    V8TRYCATCH(float, x, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, y, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)->NumberValue()));
    return toV8Fast(imp->createSVGPathSegCurvetoQuadraticSmoothRel(x, y), args, imp);
}
Beispiel #6
0
static v8::Handle<v8::Value> getPathSegAtLengthCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathElement.getPathSegAtLength");
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    EXCEPTION_BLOCK(float, distance, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)->NumberValue()));
    return v8::Integer::NewFromUnsigned(imp->getPathSegAtLength(distance));
}
static void xmlspaceAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(info.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, v, value);
    imp->setXmlspace(v);
    return;
}
Beispiel #8
0
static void xmlspaceAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.SVGPathElement.xmlspace._set");
    SVGPathElement* imp = V8SVGPathElement::toNative(info.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<>, v, value);
    imp->setXmlspace(v);
    return;
}
Beispiel #9
0
static v8::Handle<v8::Value> createSVGPathSegCurvetoCubicSmoothAbsCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathElement.createSVGPathSegCurvetoCubicSmoothAbs");
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    EXCEPTION_BLOCK(float, x, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)->NumberValue()));
    EXCEPTION_BLOCK(float, y, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)->NumberValue()));
    EXCEPTION_BLOCK(float, x2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)->NumberValue()));
    EXCEPTION_BLOCK(float, y2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 3, MissingIsUndefined)->NumberValue()));
    return toV8(imp->createSVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2));
}
static v8::Handle<v8::Value> createSVGPathSegCurvetoCubicAbsCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    V8TRYCATCH(float, x, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, y, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, x1, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, y1, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 3, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, x2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 4, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, y2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 5, DefaultIsUndefined)->NumberValue()));
    return toV8Fast(imp->createSVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2), args, imp);
}
static v8::Handle<v8::Value> createSVGPathSegArcRelCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    V8TRYCATCH(float, x, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, y, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, r1, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, r2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 3, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, angle, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 4, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(bool, largeArcFlag, MAYBE_MISSING_PARAMETER(args, 5, DefaultIsUndefined)->BooleanValue());
    V8TRYCATCH(bool, sweepFlag, MAYBE_MISSING_PARAMETER(args, 6, DefaultIsUndefined)->BooleanValue());
    return toV8Fast(imp->createSVGPathSegArcRel(x, y, r1, r2, angle, largeArcFlag, sweepFlag), args, imp);
}
Beispiel #12
0
static v8::Handle<v8::Value> createSVGPathSegArcRelCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathElement.createSVGPathSegArcRel");
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    EXCEPTION_BLOCK(float, x, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)->NumberValue()));
    EXCEPTION_BLOCK(float, y, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)->NumberValue()));
    EXCEPTION_BLOCK(float, r1, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)->NumberValue()));
    EXCEPTION_BLOCK(float, r2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 3, MissingIsUndefined)->NumberValue()));
    EXCEPTION_BLOCK(float, angle, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 4, MissingIsUndefined)->NumberValue()));
    EXCEPTION_BLOCK(bool, largeArcFlag, MAYBE_MISSING_PARAMETER(args, 5, MissingIsUndefined)->BooleanValue());
    EXCEPTION_BLOCK(bool, sweepFlag, MAYBE_MISSING_PARAMETER(args, 6, MissingIsUndefined)->BooleanValue());
    return toV8(imp->createSVGPathSegArcRel(x, y, r1, r2, angle, largeArcFlag, sweepFlag));
}
static v8::Handle<v8::Value> getTransformToElementCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
        V8TRYCATCH(SVGElement*, element, V8SVGElement::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8SVGElement::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
        SVGMatrix result = imp->getTransformToElement(element, ec);
        if (UNLIKELY(ec))
            goto fail;
        return toV8Fast(WTF::getPtr(SVGPropertyTearOff<SVGMatrix>::create(result)), args, imp);
    }
fail:
    return setDOMException(ec, args.GetIsolate());
}
Path SVGAnimateMotionElement::animationPath()
{
    for (Node* child = firstChild(); child; child->nextSibling()) {
        if (child->hasTagName(SVGNames::mpathTag)) {
            SVGMPathElement* mPath = static_cast<SVGMPathElement*>(child);
            SVGPathElement* pathElement = mPath->pathElement();
            if (pathElement)
                return pathElement->toPathData();
            // The spec would probably have us throw up an error here, but instead we try to fall back to the d value
        }
    }
    if (hasAttribute(SVGNames::dAttr))
        return m_path;
    return Path();
}
Beispiel #15
0
static v8::Handle<v8::Value> getTransformToElementCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathElement.getTransformToElement");
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    EXCEPTION_BLOCK(SVGElement*, element, V8SVGElement::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8SVGElement::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
    SVGMatrix result = imp->getTransformToElement(element, ec);
    if (UNLIKELY(ec))
        goto fail;
    return toV8(WTF::getPtr(SVGPropertyTearOff<SVGMatrix>::create(result)));
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
Path SVGAnimateMotionElement::animationPath() const
{
    for (Node* child = firstChild(); child; child = child->nextSibling()) {
        if (child->hasTagName(SVGNames::mpathTag)) {
            SVGMPathElement* mPath = static_cast<SVGMPathElement*>(child);
            SVGPathElement* pathElement = mPath->pathElement();
            Path path;
            if (pathElement)
                pathElement->toPathData(path);
            return path;
        }
    }
    if (hasAttribute(SVGNames::pathAttr))
        return m_path;
    return Path();
}
Beispiel #17
0
void JSSVGPathElement::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
    switch (token) {
    case XmllangAttrNum: {
        SVGPathElement* imp = static_cast<SVGPathElement*>(impl());

        imp->setXmllang(value->toString(exec));
        break;
    }
    case XmlspaceAttrNum: {
        SVGPathElement* imp = static_cast<SVGPathElement*>(impl());

        imp->setXmlspace(value->toString(exec));
        break;
    }
    }
}
static TextStream& operator<<(TextStream& ts, const RenderSVGShape& shape)
{
    writePositionAndStyle(ts, shape);

    ASSERT(shape.node()->isSVGElement());
    SVGElement* svgElement = toSVGElement(shape.node());
    SVGLengthContext lengthContext(svgElement);

    if (svgElement->hasTagName(SVGNames::rectTag)) {
        SVGRectElement* element = static_cast<SVGRectElement*>(svgElement);
        writeNameValuePair(ts, "x", element->x().value(lengthContext));
        writeNameValuePair(ts, "y", element->y().value(lengthContext));
        writeNameValuePair(ts, "width", element->width().value(lengthContext));
        writeNameValuePair(ts, "height", element->height().value(lengthContext));
    } else if (svgElement->hasTagName(SVGNames::lineTag)) {
        SVGLineElement* element = static_cast<SVGLineElement*>(svgElement);
        writeNameValuePair(ts, "x1", element->x1().value(lengthContext));
        writeNameValuePair(ts, "y1", element->y1().value(lengthContext));
        writeNameValuePair(ts, "x2", element->x2().value(lengthContext));
        writeNameValuePair(ts, "y2", element->y2().value(lengthContext));
    } else if (svgElement->hasTagName(SVGNames::ellipseTag)) {
        SVGEllipseElement* element = static_cast<SVGEllipseElement*>(svgElement);
        writeNameValuePair(ts, "cx", element->cx().value(lengthContext));
        writeNameValuePair(ts, "cy", element->cy().value(lengthContext));
        writeNameValuePair(ts, "rx", element->rx().value(lengthContext));
        writeNameValuePair(ts, "ry", element->ry().value(lengthContext));
    } else if (svgElement->hasTagName(SVGNames::circleTag)) {
        SVGCircleElement* element = static_cast<SVGCircleElement*>(svgElement);
        writeNameValuePair(ts, "cx", element->cx().value(lengthContext));
        writeNameValuePair(ts, "cy", element->cy().value(lengthContext));
        writeNameValuePair(ts, "r", element->r().value(lengthContext));
    } else if (svgElement->hasTagName(SVGNames::polygonTag) || svgElement->hasTagName(SVGNames::polylineTag)) {
        SVGPolyElement* element = static_cast<SVGPolyElement*>(svgElement);
        writeNameAndQuotedValue(ts, "points", element->pointList().valueAsString());
    } else if (svgElement->hasTagName(SVGNames::pathTag)) {
        SVGPathElement* element = toSVGPathElement(svgElement);
        String pathString;
        // FIXME: We should switch to UnalteredParsing here - this will affect the path dumping output of dozens of tests.
        buildStringFromByteStream(element->pathByteStream(), pathString, NormalizedParsing);
        writeNameAndQuotedValue(ts, "data", pathString);
    } else
        ASSERT_NOT_REACHED();
    return ts;
}
void SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromMpathElem(
    SVGMPathElement* aMpathElem) {
  mPathSourceType = ePathSourceType_Mpath;

  // Use the path that's the target of our chosen <mpath> child.
  SVGPathElement* pathElem = aMpathElem->GetReferencedPath();
  if (pathElem) {
    const SVGPathData& path = pathElem->GetAnimPathSegList()->GetAnimValue();
    // Path data must contain of at least one path segment (if the path data
    // doesn't begin with a valid "M", then it's invalid).
    if (path.Length()) {
      bool ok =
          path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
      if (ok && mPathVertices.Length()) {
        mPath = pathElem->GetOrBuildPathForMeasuring();
      }
    }
  }
}
Beispiel #20
0
Path RenderSVGTextPath::layoutPath() const
{
    SVGTextPathElement* textPathElement = static_cast<SVGTextPathElement*>(element());
        String pathId = SVGURIReference::getTarget(textPathElement->href());
    Element* targetElement = textPathElement->document()->getElementById(pathId);    
    if (!targetElement || !targetElement->hasTagName(SVGNames::pathTag))
        return Path();
    
    SVGPathElement* pathElement = static_cast<SVGPathElement*>(targetElement);
    
    Path pathData = pathElement->toPathData();
    // Spec:  The transform attribute on the referenced 'path' element represents a
    // supplemental transformation relative to the current user coordinate system for
    // the current 'text' element, including any adjustments to the current user coordinate
    // system due to a possible transform attribute on the current 'text' element.
    // http://www.w3.org/TR/SVG/text.html#TextPathElement
    pathData.transform(pathElement->animatedLocalTransform());
    return pathData;
}
Beispiel #21
0
Path RenderSVGTextPath::layoutPath() const
{
    Element* targetElement = SVGURIReference::targetElementFromIRIString(textPathElement().href(), document());
    if (!targetElement || !targetElement->hasTagName(SVGNames::pathTag))
        return Path();
    
    SVGPathElement* pathElement = toSVGPathElement(targetElement);
    
    Path pathData;
    updatePathFromGraphicsElement(pathElement, pathData);

    // Spec:  The transform attribute on the referenced 'path' element represents a
    // supplemental transformation relative to the current user coordinate system for
    // the current 'text' element, including any adjustments to the current user coordinate
    // system due to a possible transform attribute on the current 'text' element.
    // http://www.w3.org/TR/SVG/text.html#TextPathElement
    pathData.transform(pathElement->animatedLocalTransform());
    return pathData;
}
static v8::Handle<v8::Value> getPresentationAttributeCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, name, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    return toV8Fast(imp->getPresentationAttribute(name), args, imp);
}
static v8::Handle<v8::Value> getPointAtLengthCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    V8TRYCATCH(float, distance, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)->NumberValue()));
    return toV8Fast(WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(imp->getPointAtLength(distance))), args, imp);
}
static v8::Handle<v8::Value> pathSegListAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(info.Holder());
    return toV8Fast(WTF::getPtr(imp->pathSegList()), info, imp);
}
static v8::Handle<v8::Value> pathLengthAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(info.Holder());
    return toV8Fast(imp->pathLengthAnimated(), info, imp);
}
static v8::Handle<v8::Value> getPathSegAtLengthCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    V8TRYCATCH(float, distance, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)->NumberValue()));
    return v8UnsignedInteger(imp->getPathSegAtLength(distance), args.GetIsolate());
}
static v8::Handle<v8::Value> getScreenCTMCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    return toV8Fast(WTF::getPtr(SVGPropertyTearOff<SVGMatrix>::create(imp->getScreenCTM())), args, imp);
}
static v8::Handle<v8::Value> hasExtensionCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, extension, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    return v8Boolean(imp->hasExtension(extension), args.GetIsolate());
}
static v8::Handle<v8::Value> createSVGPathSegClosePathCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    return toV8Fast(imp->createSVGPathSegClosePath(), args, imp);
}
static v8::Handle<v8::Value> createSVGPathSegLinetoHorizontalAbsCallback(const v8::Arguments& args)
{
    SVGPathElement* imp = V8SVGPathElement::toNative(args.Holder());
    V8TRYCATCH(float, x, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)->NumberValue()));
    return toV8Fast(imp->createSVGPathSegLinetoHorizontalAbs(x), args, imp);
}