зеркало из https://github.com/mozilla/gecko-dev.git
Fixing bug 335450. Remove our extensions to the SVG DOM interfaces. r=tor@acm.org, sr=roc@ocallahan.org
This commit is contained in:
Родитель
53d8b1407e
Коммит
bb79579615
|
@ -271,82 +271,6 @@ NS_IMETHODIMP nsSVGMarkerElement::SetOrientToAngle(nsIDOMSVGAngle *angle)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
||||
float aX, float aY, float aAngle,
|
||||
nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
float scale = 1.0;
|
||||
PRUint16 val;
|
||||
mMarkerUnits->GetAnimVal(&val);
|
||||
if (val == SVG_MARKERUNITS_STROKEWIDTH)
|
||||
scale = aStrokeWidth;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGAngle> a;
|
||||
mOrient->GetAnimVal(getter_AddRefs(a));
|
||||
nsAutoString value;
|
||||
a->GetValueAsString(value);
|
||||
if (!value.EqualsLiteral("auto"))
|
||||
a->GetValue(&aAngle);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
NS_NewSVGMatrix(getter_AddRefs(matrix),
|
||||
cos(aAngle) * scale, sin(aAngle) * scale,
|
||||
-sin(aAngle) * scale, cos(aAngle) * scale,
|
||||
aX, aY);
|
||||
|
||||
*_retval = matrix;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* nsIDOMSVGMatrix getViewboxToViewportTransform (); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGMarkerElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mViewBoxToViewportTransform) {
|
||||
float viewportWidth =
|
||||
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx);
|
||||
float viewportHeight =
|
||||
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx);
|
||||
|
||||
float viewboxX, viewboxY, viewboxWidth, viewboxHeight;
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGRect> vb;
|
||||
mViewBox->GetAnimVal(getter_AddRefs(vb));
|
||||
NS_ASSERTION(vb, "could not get viewbox");
|
||||
vb->GetX(&viewboxX);
|
||||
vb->GetY(&viewboxY);
|
||||
vb->GetWidth(&viewboxWidth);
|
||||
vb->GetHeight(&viewboxHeight);
|
||||
}
|
||||
if (viewboxWidth==0.0f || viewboxHeight==0.0f) {
|
||||
NS_ERROR("XXX. We shouldn't get here. Viewbox width/height is set to 0. Need to disable display of element as per specs.");
|
||||
viewboxWidth = 1.0f;
|
||||
viewboxHeight = 1.0f;
|
||||
}
|
||||
|
||||
float refX =
|
||||
mLengthAttributes[REFX].GetAnimValue(mCoordCtx);
|
||||
float refY =
|
||||
mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
|
||||
|
||||
mViewBoxToViewportTransform =
|
||||
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewboxX + refX, viewboxY + refY,
|
||||
viewboxWidth, viewboxHeight,
|
||||
mPreserveAspectRatio,
|
||||
PR_TRUE);
|
||||
}
|
||||
|
||||
*_retval = mViewBoxToViewportTransform;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
|
@ -417,3 +341,82 @@ nsSVGMarkerElement::GetLengthInfo()
|
|||
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
||||
NS_ARRAY_LENGTH(sLengthInfo));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// public helpers
|
||||
|
||||
nsresult
|
||||
nsSVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
||||
float aX, float aY, float aAngle,
|
||||
nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
float scale = 1.0;
|
||||
PRUint16 val;
|
||||
mMarkerUnits->GetAnimVal(&val);
|
||||
if (val == SVG_MARKERUNITS_STROKEWIDTH)
|
||||
scale = aStrokeWidth;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGAngle> a;
|
||||
mOrient->GetAnimVal(getter_AddRefs(a));
|
||||
nsAutoString value;
|
||||
a->GetValueAsString(value);
|
||||
if (!value.EqualsLiteral("auto"))
|
||||
a->GetValue(&aAngle);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
NS_NewSVGMatrix(getter_AddRefs(matrix),
|
||||
cos(aAngle) * scale, sin(aAngle) * scale,
|
||||
-sin(aAngle) * scale, cos(aAngle) * scale,
|
||||
aX, aY);
|
||||
|
||||
*_retval = matrix;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGMarkerElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mViewBoxToViewportTransform) {
|
||||
float viewportWidth =
|
||||
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx);
|
||||
float viewportHeight =
|
||||
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx);
|
||||
|
||||
float viewboxX, viewboxY, viewboxWidth, viewboxHeight;
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGRect> vb;
|
||||
mViewBox->GetAnimVal(getter_AddRefs(vb));
|
||||
NS_ASSERTION(vb, "could not get viewbox");
|
||||
vb->GetX(&viewboxX);
|
||||
vb->GetY(&viewboxY);
|
||||
vb->GetWidth(&viewboxWidth);
|
||||
vb->GetHeight(&viewboxHeight);
|
||||
}
|
||||
if (viewboxWidth==0.0f || viewboxHeight==0.0f) {
|
||||
NS_ERROR("XXX. We shouldn't get here. Viewbox width/height is set to 0. Need to disable display of element as per specs.");
|
||||
viewboxWidth = 1.0f;
|
||||
viewboxHeight = 1.0f;
|
||||
}
|
||||
|
||||
float refX =
|
||||
mLengthAttributes[REFX].GetAnimValue(mCoordCtx);
|
||||
float refY =
|
||||
mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
|
||||
|
||||
mViewBoxToViewportTransform =
|
||||
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewboxX + refX, viewboxY + refY,
|
||||
viewboxWidth, viewboxHeight,
|
||||
mPreserveAspectRatio,
|
||||
PR_TRUE);
|
||||
}
|
||||
|
||||
*_retval = mViewBoxToViewportTransform;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -82,6 +82,12 @@ public:
|
|||
// nsSVGElement specializations:
|
||||
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
|
||||
|
||||
// public helpers
|
||||
nsresult GetMarkerTransform(float aStrokeWidth,
|
||||
float aX, float aY, float aAngle,
|
||||
nsIDOMSVGMatrix **_retval);
|
||||
nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval);
|
||||
|
||||
protected:
|
||||
|
||||
void SetParentCoordCtxProvider(nsSVGCoordCtxProvider *aContext)
|
||||
|
|
|
@ -657,46 +657,6 @@ nsSVGSVGElement::GetElementById(const nsAString & elementId, nsIDOMElement **_re
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getViewboxToViewportTransform (); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGSVGElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mViewBoxToViewportTransform) {
|
||||
float viewportWidth =
|
||||
mLengthAttributes[WIDTH].GetAnimValue(mCoordCtx);
|
||||
float viewportHeight =
|
||||
mLengthAttributes[HEIGHT].GetAnimValue(mCoordCtx);
|
||||
|
||||
float viewboxX, viewboxY, viewboxWidth, viewboxHeight;
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGRect> vb;
|
||||
mViewBox->GetAnimVal(getter_AddRefs(vb));
|
||||
NS_ASSERTION(vb, "could not get viewbox");
|
||||
vb->GetX(&viewboxX);
|
||||
vb->GetY(&viewboxY);
|
||||
vb->GetWidth(&viewboxWidth);
|
||||
vb->GetHeight(&viewboxHeight);
|
||||
}
|
||||
if (viewboxWidth==0.0f || viewboxHeight==0.0f) {
|
||||
NS_ERROR("XXX. We shouldn't get here. Viewbox width/height is set to 0. Need to disable display of element as per specs.");
|
||||
viewboxWidth = 1.0f;
|
||||
viewboxHeight = 1.0f;
|
||||
}
|
||||
|
||||
mViewBoxToViewportTransform =
|
||||
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewboxX, viewboxY,
|
||||
viewboxWidth, viewboxHeight,
|
||||
mPreserveAspectRatio);
|
||||
}
|
||||
|
||||
*_retval = mViewBoxToViewportTransform;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGFitToViewBox methods
|
||||
|
||||
|
@ -809,7 +769,7 @@ nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix **_retval)
|
|||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> viewportElement = do_QueryInterface(ancestor);
|
||||
nsSVGSVGElement *viewportElement = QI_TO_NSSVGSVGELEMENT(ancestor);
|
||||
if (viewportElement) {
|
||||
rv = viewportElement->GetViewboxToViewportTransform(getter_AddRefs(ancestorCTM));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -1292,6 +1252,48 @@ nsSVGSVGElement::IsEventName(nsIAtom* aName)
|
|||
aName == nsSVGAtoms::onzoom;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// public helpers:
|
||||
|
||||
nsresult
|
||||
nsSVGSVGElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mViewBoxToViewportTransform) {
|
||||
float viewportWidth =
|
||||
mLengthAttributes[WIDTH].GetAnimValue(mCoordCtx);
|
||||
float viewportHeight =
|
||||
mLengthAttributes[HEIGHT].GetAnimValue(mCoordCtx);
|
||||
|
||||
float viewboxX, viewboxY, viewboxWidth, viewboxHeight;
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGRect> vb;
|
||||
mViewBox->GetAnimVal(getter_AddRefs(vb));
|
||||
NS_ASSERTION(vb, "could not get viewbox");
|
||||
vb->GetX(&viewboxX);
|
||||
vb->GetY(&viewboxY);
|
||||
vb->GetWidth(&viewboxWidth);
|
||||
vb->GetHeight(&viewboxHeight);
|
||||
}
|
||||
if (viewboxWidth==0.0f || viewboxHeight==0.0f) {
|
||||
NS_ERROR("XXX. We shouldn't get here. Viewbox width/height is set to 0. Need to disable display of element as per specs.");
|
||||
viewboxWidth = 1.0f;
|
||||
viewboxHeight = 1.0f;
|
||||
}
|
||||
|
||||
mViewBoxToViewportTransform =
|
||||
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewboxX, viewboxY,
|
||||
viewboxWidth, viewboxHeight,
|
||||
mPreserveAspectRatio);
|
||||
}
|
||||
|
||||
*_retval = mViewBoxToViewportTransform;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// implementation helpers
|
||||
|
||||
|
|
|
@ -48,6 +48,11 @@
|
|||
#include "nsSVGCoordCtxProvider.h"
|
||||
#include "nsSVGLength2.h"
|
||||
|
||||
#define QI_TO_NSSVGSVGELEMENT(base) \
|
||||
NS_STATIC_CAST(nsSVGSVGElement*, \
|
||||
NS_STATIC_CAST(nsISVGSVGElement*, \
|
||||
nsCOMPtr<nsISVGSVGElement>(do_QueryInterface(base))));
|
||||
|
||||
typedef nsSVGStylableElement nsSVGSVGElementBase;
|
||||
|
||||
class nsSVGSVGElement : public nsSVGSVGElementBase,
|
||||
|
@ -108,6 +113,10 @@ public:
|
|||
// nsSVGElement specializations:
|
||||
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
|
||||
|
||||
// public helpers:
|
||||
nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval);
|
||||
|
||||
|
||||
protected:
|
||||
// nsSVGElement overrides
|
||||
PRBool IsEventName(nsIAtom* aName);
|
||||
|
|
|
@ -51,7 +51,7 @@ interface nsIDOMSVGMatrix;
|
|||
*
|
||||
*/
|
||||
|
||||
[scriptable, uuid(7d89ceb8-f985-4095-8f24-421910704e5e)]
|
||||
[scriptable, uuid(6a3b7b40-e65a-4e9c-9ee7-ca03ed0a18c7)]
|
||||
interface nsIDOMSVGMarkerElement
|
||||
: nsIDOMSVGElement
|
||||
/*
|
||||
|
@ -87,8 +87,4 @@ interface nsIDOMSVGMarkerElement
|
|||
|
||||
void setOrientToAuto ( );
|
||||
void setOrientToAngle ( in nsIDOMSVGAngle angle );
|
||||
|
||||
// Mozilla extension, not part of W3 SVG DOM:
|
||||
[noscript] nsIDOMSVGMatrix getMarkerTransform(in float strokeWidth, in float x, in float y, in float angle);
|
||||
[noscript] nsIDOMSVGMatrix getViewboxToViewportTransform( );
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ interface nsIDOMSVGAngle;
|
|||
interface nsIDOMSVGMatrix;
|
||||
interface nsIDOMSVGTransform;
|
||||
|
||||
[scriptable, uuid(67b8f41e-3577-4c8a-b1de-bef51186fe08)]
|
||||
[scriptable, uuid(83b04425-9509-49f5-af75-1ae1f8f3e871)]
|
||||
interface nsIDOMSVGSVGElement
|
||||
: nsIDOMSVGElement
|
||||
/*
|
||||
|
@ -118,9 +118,6 @@ interface nsIDOMSVGSVGElement
|
|||
nsIDOMSVGTransform createSVGTransformFromMatrix(in nsIDOMSVGMatrix matrix);
|
||||
DOMString createSVGString();
|
||||
nsIDOMElement getElementById(in DOMString elementId);
|
||||
|
||||
// Mozilla extension, not part of W3 SVG DOM:
|
||||
nsIDOMSVGMatrix getViewboxToViewportTransform();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -565,8 +565,7 @@ nsSVGInnerSVGFrame::GetCanvasTM()
|
|||
|
||||
// append the viewbox to viewport transform:
|
||||
nsCOMPtr<nsIDOMSVGMatrix> viewBoxToViewportTM;
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> svgElement = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(svgElement, "wrong content element");
|
||||
nsSVGSVGElement *svgElement = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
|
||||
svgElement->GetViewboxToViewportTransform(getter_AddRefs(viewBoxToViewportTM));
|
||||
xyTM->Multiply(viewBoxToViewportTM, getter_AddRefs(mCanvasTM));
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ nsSVGMarkerFrame::GetCanvasTM()
|
|||
NS_ASSERTION(parentTM, "null TM");
|
||||
|
||||
// get element
|
||||
nsCOMPtr<nsIDOMSVGMarkerElement> element = do_QueryInterface(mContent);
|
||||
nsSVGMarkerElement *element = NS_STATIC_CAST(nsSVGMarkerElement*, mContent);
|
||||
|
||||
// scale/move marker
|
||||
nsCOMPtr<nsIDOMSVGMatrix> markerTM;
|
||||
|
@ -335,7 +335,7 @@ nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
|
|||
if (parent)
|
||||
parent->GetCanvasTM(getter_AddRefs(parentTransform));
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMarkerElement> element = do_QueryInterface(mContent);
|
||||
nsSVGMarkerElement *element = NS_STATIC_CAST(nsSVGMarkerElement*, mContent);
|
||||
element->GetMarkerTransform(mStrokeWidth, mX, mY, mAngle,
|
||||
getter_AddRefs(markerTransform));
|
||||
|
||||
|
|
|
@ -860,8 +860,7 @@ already_AddRefed<nsIDOMSVGMatrix>
|
|||
nsSVGOuterSVGFrame::GetCanvasTM()
|
||||
{
|
||||
if (!mCanvasTM) {
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> svgElement = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(svgElement, "wrong content element");
|
||||
nsSVGSVGElement *svgElement = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
|
||||
svgElement->GetViewboxToViewportTransform(getter_AddRefs(mCanvasTM));
|
||||
|
||||
if (mZoomAndPan) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче