static v8::Handle<v8::Value> getPresentationAttributeCallback(const v8::Arguments& args) { INC_STATS("DOM.SVGMarkerElement.getPresentationAttribute"); SVGMarkerElement* imp = V8SVGMarkerElement::toNative(args.Holder()); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, name, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)); return toV8(imp->getPresentationAttribute(name)); }
AffineTransform RenderSVGResourceMarker::viewportTransform() const { SVGMarkerElement* marker = toSVGMarkerElement(element()); ASSERT(marker); return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height()); }
static v8::Handle<v8::Value> setOrientToAutoCallback(const v8::Arguments& args) { INC_STATS("DOM.SVGMarkerElement.setOrientToAuto"); SVGMarkerElement* imp = V8SVGMarkerElement::toNative(args.Holder()); imp->setOrientToAuto(); return v8::Handle<v8::Value>(); }
JSValue* JSSVGMarkerElementPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) { if (!thisObj->inherits(&JSSVGMarkerElement::info)) return throwError(exec, TypeError); JSSVGMarkerElement* castedThisObj = static_cast<JSSVGMarkerElement*>(thisObj); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(castedThisObj->impl()); switch (id) { case JSSVGMarkerElement::SetOrientToAutoFuncNum: { imp->setOrientToAuto(); return jsUndefined(); } case JSSVGMarkerElement::SetOrientToAngleFuncNum: { SVGAngle* angle = toSVGAngle(args[0]); imp->setOrientToAngle(angle); return jsUndefined(); } case JSSVGMarkerElement::GetPresentationAttributeFuncNum: { String name = args[0]->toString(exec); KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getPresentationAttribute(name))); return result; } } return 0; }
void SVGShapePainter::paintMarker(const PaintInfo& paintInfo, RenderSVGResourceMarker& marker, const MarkerPosition& position, float strokeWidth) { // An empty viewBox disables rendering. SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element()); ASSERT(markerElement); if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->viewBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->value().isEmpty()) return; OwnPtr<DisplayItemList> displayItemList; if (RuntimeEnabledFeatures::slimmingPaintEnabled()) displayItemList = DisplayItemList::create(); GraphicsContext recordingContext(nullptr, displayItemList.get()); recordingContext.beginRecording(m_renderSVGShape.paintInvalidationRectInLocalCoordinates()); PaintInfo markerPaintInfo(paintInfo); markerPaintInfo.context = &recordingContext; { TransformRecorder transformRecorder(*markerPaintInfo.context, marker.displayItemClient(), marker.markerTransformation(position.origin, position.angle, strokeWidth)); OwnPtr<FloatClipRecorder> clipRecorder; if (SVGRenderSupport::isOverflowHidden(&marker)) clipRecorder = adoptPtr(new FloatClipRecorder(recordingContext, marker.displayItemClient(), markerPaintInfo.phase, marker.viewport())); SVGContainerPainter(marker).paint(markerPaintInfo); } if (displayItemList) displayItemList->replay(&recordingContext); RefPtr<const SkPicture> recording = recordingContext.endRecording(); paintInfo.context->drawPicture(recording.get()); }
void RenderSVGContainer::calcViewport() { SVGElement* svgelem = static_cast<SVGElement*>(element()); if (svgelem->hasTagName(SVGNames::svgTag)) { SVGSVGElement* svg = static_cast<SVGSVGElement*>(element()); if (!selfNeedsLayout() && !svg->hasRelativeValues()) return; float x = 0.0f; float y = 0.0f; if (parent()->isSVGContainer()) { x = svg->x().value(); y = svg->y().value(); } float w = svg->width().value(); float h = svg->height().value(); m_viewport = FloatRect(x, y, w, h); } else if (svgelem->hasTagName(SVGNames::markerTag)) { if (!selfNeedsLayout()) return; SVGMarkerElement* svg = static_cast<SVGMarkerElement*>(element()); float w = svg->markerWidth().value(); float h = svg->markerHeight().value(); m_viewport = FloatRect(0.0f, 0.0f, w, h); } }
nsresult nsSVGMarkerFrame::PaintMark(gfxContext& aContext, const gfxMatrix& aToMarkedFrameUserSpace, nsSVGPathGeometryFrame *aMarkedFrame, nsSVGMark *aMark, float aStrokeWidth) { // If the flag is set when we get here, it means this marker frame // has already been used painting the current mark, and the document // has a marker reference loop. if (mInUse) return NS_OK; AutoMarkerReferencer markerRef(this, aMarkedFrame); SVGMarkerElement *marker = static_cast<SVGMarkerElement*>(mContent); if (!marker->HasValidDimensions()) { return NS_OK; } const nsSVGViewBoxRect viewBox = marker->GetViewBoxRect(); if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) { // We must disable rendering if the viewBox width or height are zero. return NS_OK; } mStrokeWidth = aStrokeWidth; mX = aMark->x; mY = aMark->y; mAutoAngle = aMark->angle; mIsStart = aMark->type == nsSVGMark::eStart; Matrix viewBoxTM = marker->GetViewBoxTransform(); Matrix markerTM = marker->GetMarkerTransform(mStrokeWidth, mX, mY, mAutoAngle, mIsStart); gfxMatrix markTM = ThebesMatrix(viewBoxTM) * ThebesMatrix(markerTM) * aToMarkedFrameUserSpace; if (StyleDisplay()->IsScrollableOverflow()) { aContext.Save(); gfxRect clipRect = nsSVGUtils::GetClipRectForFrame(this, viewBox.x, viewBox.y, viewBox.width, viewBox.height); nsSVGUtils::SetClipRect(&aContext, markTM, clipRect); } nsIFrame* kid = GetAnonymousChildFrame(this); nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); // The CTM of each frame referencing us may be different. SVGFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED); nsSVGUtils::PaintFrameWithEffects(kid, aContext, markTM); if (StyleDisplay()->IsScrollableOverflow()) aContext.Restore(); return NS_OK; }
FloatPoint RenderSVGResourceMarker::referencePoint() const { SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node()); ASSERT(marker); return FloatPoint(marker->refX().value(marker), marker->refY().value(marker)); }
JSValue jsSVGMarkerElementPreserveAspectRatio(ExecState* exec, const Identifier&, const PropertySlot& slot) { UNUSED_PARAM(exec); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(static_cast<JSSVGMarkerElement*>(asObject(slot.slotBase()))->impl()); RefPtr<SVGAnimatedPreserveAspectRatio> obj = imp->preserveAspectRatioAnimated(); return toJS(exec, obj.get(), imp); }
JSValue jsSVGMarkerElementClassName(ExecState* exec, const Identifier&, const PropertySlot& slot) { UNUSED_PARAM(exec); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(static_cast<JSSVGMarkerElement*>(asObject(slot.slotBase()))->impl()); RefPtr<SVGAnimatedString> obj = imp->classNameAnimated(); return toJS(exec, obj.get(), imp); }
JSValue jsSVGMarkerElementExternalResourcesRequired(ExecState* exec, const Identifier&, const PropertySlot& slot) { UNUSED_PARAM(exec); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(static_cast<JSSVGMarkerElement*>(asObject(slot.slotBase()))->impl()); RefPtr<SVGAnimatedBoolean> obj = imp->externalResourcesRequiredAnimated(); return toJS(exec, obj.get(), imp); }
static void xmlspaceAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.SVGMarkerElement.xmlspace._set"); SVGMarkerElement* imp = V8SVGMarkerElement::toNative(info.Holder()); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<>, v, value); imp->setXmlspace(v); return; }
bool LayoutSVGResourceMarker::shouldPaint() const { // An empty viewBox disables rendering. SVGMarkerElement* marker = toSVGMarkerElement(element()); ASSERT(marker); return !marker->viewBox()->isSpecified() || !marker->viewBox()->currentValue()->isValid() || !marker->viewBox()->currentValue()->value().isEmpty(); }
FloatPoint LayoutSVGResourceMarker::referencePoint() const { SVGMarkerElement* marker = toSVGMarkerElement(element()); ASSERT(marker); SVGLengthContext lengthContext(marker); return FloatPoint(marker->refX()->currentValue()->value(lengthContext), marker->refY()->currentValue()->value(lengthContext)); }
JSValue jsSVGMarkerElementStyle(ExecState* exec, JSValue slotBase, const Identifier&) { JSSVGMarkerElement* castedThis = static_cast<JSSVGMarkerElement*>(asObject(slotBase)); UNUSED_PARAM(exec); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->style())); return result; }
JSValue jsSVGMarkerElementXmlspace(ExecState* exec, JSValue slotBase, const Identifier&) { JSSVGMarkerElement* castedThis = static_cast<JSSVGMarkerElement*>(asObject(slotBase)); UNUSED_PARAM(exec); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(castedThis->impl()); JSValue result = jsString(exec, imp->xmlspace()); return result; }
FloatPoint RenderSVGResourceMarker::referencePoint() const { SVGMarkerElement* marker = toSVGMarkerElement(element()); ASSERT(marker); SVGLengthContext lengthContext(marker); return FloatPoint(marker->refXCurrentValue().value(lengthContext), marker->refYCurrentValue().value(lengthContext)); }
JSValue jsSVGMarkerElementPreserveAspectRatio(ExecState* exec, JSValue slotBase, const Identifier&) { JSSVGMarkerElement* castedThis = static_cast<JSSVGMarkerElement*>(asObject(slotBase)); UNUSED_PARAM(exec); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(castedThis->impl()); RefPtr<SVGAnimatedPreserveAspectRatio> obj = imp->preserveAspectRatioAnimated(); JSValue result = toJS(exec, castedThis->globalObject(), obj.get(), imp); return result; }
JSValue jsSVGMarkerElementExternalResourcesRequired(ExecState* exec, JSValue slotBase, const Identifier&) { JSSVGMarkerElement* castedThis = static_cast<JSSVGMarkerElement*>(asObject(slotBase)); UNUSED_PARAM(exec); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(castedThis->impl()); RefPtr<SVGAnimatedBoolean> obj = imp->externalResourcesRequiredAnimated(); JSValue result = toJS(exec, castedThis->globalObject(), obj.get(), imp); return result; }
JSValue* jsSVGMarkerElementPrototypeFunctionSetOrientToAuto(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSSVGMarkerElement::s_info)) return throwError(exec, TypeError); JSSVGMarkerElement* castedThisObj = static_cast<JSSVGMarkerElement*>(thisValue); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(castedThisObj->impl()); imp->setOrientToAuto(); return jsUndefined(); }
JSValue JSC_HOST_CALL jsSVGMarkerElementPrototypeFunctionSetOrientToAuto(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSSVGMarkerElement::s_info)) return throwError(exec, TypeError); JSSVGMarkerElement* castedThisObj = static_cast<JSSVGMarkerElement*>(asObject(thisValue)); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(castedThisObj->impl()); imp->setOrientToAuto(); return jsUndefined(); }
float RenderSVGResourceMarker::angle() const { SVGMarkerElement* marker = toSVGMarkerElement(element()); ASSERT(marker); float angle = -1; if (marker->orientTypeCurrentValue() == SVGMarkerOrientAngle) angle = marker->orientAngleCurrentValue().value(); return angle; }
float RenderSVGResourceMarker::angle() const { SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node()); ASSERT(marker); float angle = -1; if (marker->orientType() == SVGMarkerOrientAngle) angle = marker->orientAngle().value(); return angle; }
float LayoutSVGResourceMarker::angle() const { SVGMarkerElement* marker = toSVGMarkerElement(element()); ASSERT(marker); float angle = -1; if (marker->orientType()->currentValue()->enumValue() == SVGMarkerOrientAngle) angle = marker->orientAngle()->currentValue()->value(); return angle; }
SVGBBox nsSVGMarkerFrame::GetMarkBBoxContribution(const gfxMatrix &aToBBoxUserspace, uint32_t aFlags, nsSVGPathGeometryFrame *aMarkedFrame, const nsSVGMark *aMark, float aStrokeWidth) { SVGBBox bbox; // If the flag is set when we get here, it means this marker frame // has already been used in calculating the current mark bbox, and // the document has a marker reference loop. if (mInUse) return bbox; AutoMarkerReferencer markerRef(this, aMarkedFrame); SVGMarkerElement *content = static_cast<SVGMarkerElement*>(mContent); const nsSVGViewBoxRect viewBox = content->GetViewBoxRect(); if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) { return bbox; } mStrokeWidth = aStrokeWidth; mX = aMark->x; mY = aMark->y; mAutoAngle = aMark->angle; mIsStart = aMark->type == nsSVGMark::eStart; gfxMatrix markerTM = content->GetMarkerTransform(mStrokeWidth, mX, mY, mAutoAngle, mIsStart); gfxMatrix viewBoxTM = content->GetViewBoxTransform(); gfxMatrix tm = viewBoxTM * markerTM * aToBBoxUserspace; for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { nsISVGChildFrame* child = do_QueryFrame(kid); if (child) { // When we're being called to obtain the invalidation area, we need to // pass down all the flags so that stroke is included. However, once DOM // getBBox() accepts flags, maybe we should strip some of those here? // We need to include zero width/height vertical/horizontal lines, so we have // to use UnionEdges. bbox.UnionEdges(child->GetBBoxContribution(tm, aFlags)); } } return bbox; }
nsresult nsSVGMarkerFrame::PaintMark(nsRenderingContext *aContext, nsSVGPathGeometryFrame *aMarkedFrame, nsSVGMark *aMark, float aStrokeWidth) { // If the flag is set when we get here, it means this marker frame // has already been used painting the current mark, and the document // has a marker reference loop. if (mInUse) return NS_OK; AutoMarkerReferencer markerRef(this, aMarkedFrame); SVGMarkerElement *marker = static_cast<SVGMarkerElement*>(mContent); const nsSVGViewBoxRect viewBox = marker->GetViewBoxRect(); if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) { // We must disable rendering if the viewBox width or height are zero. return NS_OK; } mStrokeWidth = aStrokeWidth; mX = aMark->x; mY = aMark->y; mAutoAngle = aMark->angle; mIsStart = aMark->type == nsSVGMark::eStart; gfxContext *gfx = aContext->ThebesContext(); if (StyleDisplay()->IsScrollableOverflow()) { gfx->Save(); gfxRect clipRect = nsSVGUtils::GetClipRectForFrame(this, viewBox.x, viewBox.y, viewBox.width, viewBox.height); nsSVGUtils::SetClipRect(gfx, GetCanvasTM(nsISVGChildFrame::FOR_PAINTING), clipRect); } for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { // The CTM of each frame referencing us may be different. SVGFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED); nsSVGUtils::PaintFrameWithEffects(aContext, nullptr, kid); } } if (StyleDisplay()->IsScrollableOverflow()) gfx->Restore(); return NS_OK; }
static v8::Handle<v8::Value> setOrientToAngleCallback(const v8::Arguments& args) { INC_STATS("DOM.SVGMarkerElement.setOrientToAngle"); SVGMarkerElement* imp = V8SVGMarkerElement::toNative(args.Holder()); EXCEPTION_BLOCK(RefPtr<SVGPropertyTearOff<SVGAngle> >, angle, V8SVGAngle::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8SVGAngle::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0); if (!angle) { V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR); return v8::Handle<v8::Value>(); } imp->setOrientToAngle(angle->propertyReference()); return v8::Handle<v8::Value>(); }
nsISMILAttr* nsSVGAngle::ToSMILAttr(nsSVGElement *aSVGElement) { if (aSVGElement->NodeInfo()->Equals(nsGkAtoms::marker, kNameSpaceID_SVG)) { SVGMarkerElement *marker = static_cast<SVGMarkerElement*>(aSVGElement); return new SMILOrient(marker->GetOrientType(), this, aSVGElement); } // SMILOrient would not be useful for general angle attributes (also, // "orient" is the only animatable <angle>-valued attribute in SVG 1.1). NS_NOTREACHED("Trying to animate unknown angle attribute."); return nullptr; }
TransformationMatrix RenderSVGViewportContainer::viewportTransform() const { if (element()->hasTagName(SVGNames::svgTag)) { SVGSVGElement* svg = static_cast<SVGSVGElement*>(element()); return svg->viewBoxToViewTransform(viewport().width(), viewport().height()); } else if (element()->hasTagName(SVGNames::markerTag)) { SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(element()); return marker->viewBoxToViewTransform(viewport().width(), viewport().height()); } return TransformationMatrix(); }
JSValue* jsSVGMarkerElementPrototypeFunctionGetPresentationAttribute(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSSVGMarkerElement::s_info)) return throwError(exec, TypeError); JSSVGMarkerElement* castedThisObj = static_cast<JSSVGMarkerElement*>(thisValue); SVGMarkerElement* imp = static_cast<SVGMarkerElement*>(castedThisObj->impl()); const UString& name = args.at(exec, 0)->toString(exec); JSC::JSValue* result = toJS(exec, WTF::getPtr(imp->getPresentationAttribute(name))); return result; }