Bug 353172 - remove nsSVGCoordCtxProvider.

Patch by malex@cs.utexas.edu and tor, r=jwatt+roc, sr=roc
This commit is contained in:
tor%cs.brown.edu 2007-03-09 16:27:01 +00:00
Родитель 85a6ccb4d8
Коммит 72f5c788dc
43 изменённых файлов: 359 добавлений и 1010 удалений

Просмотреть файл

@ -83,7 +83,6 @@ CPPSRCS = \
nsSVGCircleElement.cpp \
nsSVGClassValue.cpp \
nsSVGClipPathElement.cpp \
nsSVGCoordCtxProvider.cpp \
nsSVGDataParser.cpp \
nsSVGDefsElement.cpp \
nsSVGDescElement.cpp \
@ -159,8 +158,6 @@ EXPORTS = \
nsISVGValue.h \
nsISVGValueObserver.h \
nsISVGValueUtils.h \
nsSVGCoordCtxProvider.h \
nsSVGCoordCtx.h \
nsSVGNumber.h \
nsSVGRect.h \
nsSVGPoint.h \

Просмотреть файл

@ -40,22 +40,21 @@
#define __NS_ISVGLENGTH_H__
#include "nsIDOMSVGLength.h"
class nsSVGCoordCtx;
#include "nsWeakPtr.h"
////////////////////////////////////////////////////////////////////////
// nsISVGLength: private interface for svg lengths
// {ADFA6DD4-7E59-4FA2-BF55-BCE7D40C9F88}
// {DB02FD38-3C77-4c52-8DBD-C0A47F9DEDAD}
#define NS_ISVGLENGTH_IID \
{ 0xadfa6dd4, 0x7e59, 0x4fa2, { 0xbf, 0x55, 0xbc, 0xe7, 0xd4, 0x0c, 0x9f, 0x88 } }
{ 0xdb02fd38, 0x3c77, 0x4c52, { 0x8d, 0xbd, 0xc0, 0xa4, 0x7f, 0x9d, 0xed, 0xad } }
class nsISVGLength : public nsIDOMSVGLength
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGLENGTH_IID)
NS_IMETHOD SetContext(nsSVGCoordCtx* ctx)=0;
NS_IMETHOD SetContext(nsIWeakReference *aContext, PRUint8 aCtxType)=0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGLength, NS_ISVGLENGTH_IID)

Просмотреть файл

@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_ISVGLENGTHLIST_H__
#define __NS_ISVGLENGTHLIST_H__
#include "nsIDOMSVGLengthList.h"
class nsSVGCoordCtx;
////////////////////////////////////////////////////////////////////////
// nsISVGLengthList: private interface for svg lengthlists
// {0857CC15-896D-4E3B-A985-125B398C7867}
#define NS_ISVGLENGTHLIST_IID \
{ 0x0857cc15, 0x896d, 0x4e3b, { 0xa9, 0x85, 0x12, 0x5b, 0x39, 0x8c, 0x78, 0x67 } }
class nsISVGLengthList : public nsIDOMSVGLengthList
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGLENGTHLIST_IID)
NS_IMETHOD SetContext(nsSVGCoordCtx* ctx)=0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGLengthList, NS_ISVGLENGTHLIST_IID)
#endif // __NS_ISVGLENGTHLIST_H__

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsISupports.h"
#include "nsIDOMSVGSVGElement.h"
class nsSVGCoordCtxProvider;
class nsSVGSVGElement;
class nsIDOMSVGNumber;
class nsISVGEnum;
@ -51,14 +51,13 @@ class nsISVGEnum;
// nsISVGSVGElement: private interface implemented by <svg>-elements
#define NS_ISVGSVGELEMENT_IID \
{ 0x7f22b121, 0x9522, 0x4840, { 0xb1, 0x0e, 0x07, 0x48, 0xfa, 0xe1, 0xb3, 0xf8 } }
{ 0x65195064, 0x9a5f, 0x42df, { 0xa1, 0x1f, 0x4c, 0x05, 0xbc, 0xa4, 0xe7, 0x28 } }
class nsISVGSVGElement : public nsIDOMSVGSVGElement
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGSVGELEMENT_IID)
NS_IMETHOD SetParentCoordCtxProvider(nsSVGCoordCtxProvider *parentCtx)=0;
NS_IMETHOD GetCurrentScaleNumber(nsIDOMSVGNumber **aResult)=0;
NS_IMETHOD GetZoomAndPanEnum(nsISVGEnum **aResult)=0;
@ -89,11 +88,6 @@ public:
NS_IMETHOD_(float) GetPreviousScale()=0;
NS_IMETHOD_(float) GetPreviousTranslate_x()=0;
NS_IMETHOD_(float) GetPreviousTranslate_y()=0;
/**
* Our viewport or viewbox is changing - throw away the cached value.
*/
NS_IMETHOD_(void) InvalidateViewBoxToViewport()=0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGSVGElement, NS_ISVGSVGELEMENT_IID)

Просмотреть файл

@ -1,85 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex@croczilla.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_NSSVGCOORDCTX_H__
#define __NS_NSSVGCOORDCTX_H__
#include "nsCOMPtr.h"
#include "nsIDOMSVGNumber.h"
#include "nsSVGNumber.h"
////////////////////////////////////////////////////////////////////////
// nsSVGCoordCtx: ref-counted class used as a context for
// percentage/unit-based calculation on svg lengths
class nsSVGCoordCtx
{
public:
float GetMillimeterPerPixel() { return mmPerPx; }
already_AddRefed<nsIDOMSVGNumber> GetLength() {
nsIDOMSVGNumber *rv = mLength.get();
NS_IF_ADDREF(rv);
return rv;
}
nsrefcnt AddRef() { return ++mRefCnt; }
nsrefcnt Release() {
--mRefCnt;
if (mRefCnt == 0) {
mRefCnt = 1; // stabilize
delete this;
return 0;
}
return mRefCnt;
}
protected:
friend class nsSVGCoordCtxHolder;
nsSVGCoordCtx() : mRefCnt(1) { // addrefs
NS_NewSVGNumber(getter_AddRefs(mLength));
}
PRUint32 mRefCnt;
float mmPerPx;
nsCOMPtr<nsIDOMSVGNumber> mLength;
};
#endif // __NS_NSSVGCOORDCTX_H__

Просмотреть файл

@ -1,163 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex@croczilla.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsSVGCoordCtxProvider.h"
#include "nsISVGValue.h"
#include "nsISVGValueUtils.h"
#include "nsSVGUtils.h"
#include <math.h>
////////////////////////////////////////////////////////////////////////
// nsSVGCoordCtxHolder implementation
nsSVGCoordCtxHolder::nsSVGCoordCtxHolder()
: mCtxX(dont_AddRef(new nsSVGCoordCtx)),
mCtxY(dont_AddRef(new nsSVGCoordCtx)),
mCtxUnspec(dont_AddRef(new nsSVGCoordCtx))
{}
nsSVGCoordCtxHolder::~nsSVGCoordCtxHolder()
{
if (mCtxRect)
NS_REMOVE_SVGVALUE_OBSERVER(mCtxRect);
}
//----------------------------------------------------------------------
// nsISupports methods:
NS_IMPL_ADDREF(nsSVGCoordCtxHolder)
NS_IMPL_RELEASE(nsSVGCoordCtxHolder)
NS_INTERFACE_MAP_BEGIN(nsSVGCoordCtxHolder)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValueObserver)
NS_INTERFACE_MAP_END
//----------------------------------------------------------------------
// nsISVGValueObserver methods:
NS_IMETHODIMP
nsSVGCoordCtxHolder::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
return NS_OK;
}
NS_IMETHODIMP
nsSVGCoordCtxHolder::DidModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
Update();
return NS_OK;
}
//----------------------------------------------------------------------
void
nsSVGCoordCtxHolder::SetContextRect(nsIDOMSVGRect* ctxRect)
{
if (mCtxRect)
NS_REMOVE_SVGVALUE_OBSERVER(mCtxRect);
mCtxRect = ctxRect;
if (mCtxRect) {
NS_ADD_SVGVALUE_OBSERVER(mCtxRect);
Update();
}
}
void
nsSVGCoordCtxHolder::SetMMPerPx(float mmPerPxX, float mmPerPxY)
{
mCtxX->mmPerPx = mmPerPxX;
mCtxY->mmPerPx = mmPerPxY;
mCtxUnspec->mmPerPx = (float)sqrt((mmPerPxX*mmPerPxX + mmPerPxY*mmPerPxY)/2.0);
}
void
nsSVGCoordCtxHolder::Update()
{
float w,h;
mCtxRect->GetWidth(&w);
mCtxRect->GetHeight(&h);
mCtxX->mLength->SetValue(w);
mCtxY->mLength->SetValue(h);
mCtxUnspec->mLength->SetValue((float)sqrt((w*w+h*h)/2.0));
}
already_AddRefed<nsSVGCoordCtx>
nsSVGCoordCtxHolder::GetContextX()
{
nsSVGCoordCtx *rv = mCtxX.get();
NS_IF_ADDREF(rv);
return rv;
}
already_AddRefed<nsSVGCoordCtx>
nsSVGCoordCtxHolder::GetContextY()
{
nsSVGCoordCtx *rv = mCtxY.get();
NS_IF_ADDREF(rv);
return rv;
}
already_AddRefed<nsSVGCoordCtx>
nsSVGCoordCtxHolder::GetContextUnspecified()
{
nsSVGCoordCtx *rv = mCtxUnspec.get();
NS_IF_ADDREF(rv);
return rv;
}
already_AddRefed<nsSVGCoordCtx>
nsSVGCoordCtxProvider::GetCtxByType(PRUint16 aCtxType)
{
if (!mInner)
return nsnull;
switch (aCtxType) {
case nsSVGUtils::X:
return mInner->GetContextX();
case nsSVGUtils::Y:
return mInner->GetContextY();
case nsSVGUtils::XY:
return mInner->GetContextUnspecified();
}
return nsnull;
}

Просмотреть файл

@ -1,122 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex@croczilla.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_SVGCOORDCTXPROVIDER_H__
#define __NS_SVGCOORDCTXPROVIDER_H__
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsSVGCoordCtx.h"
#include "nsIDOMSVGRect.h"
#include "nsISVGValueObserver.h"
#include "nsWeakReference.h"
////////////////////////////////////////////////////////////////////////
// nsSVGCoordCtxHolder: This is a private inner helper class for
// nsSVGCoordCtxProvider. It holds the actual coordinate contexts; the
// accessors (GetContextX,etc.) on nsSVGCoordCtxProvider are delegated
// to it. The sole purpose for having this separate inner class is to
// hide the nsISVGValueObserver interface which we require to listen
// in on viewbox (mCtxRect) size changes.
class nsSVGCoordCtxHolder : nsISVGValueObserver
{
private:
friend class nsSVGCoordCtxProvider;
nsSVGCoordCtxHolder(); // addrefs
~nsSVGCoordCtxHolder();
// nsISupports interface:
NS_DECL_ISUPPORTS
// nsISVGValueObserver interface:
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
void SetContextRect(nsIDOMSVGRect* ctxRect);
void SetMMPerPx(float mmPerPxX, float mmPerPxY);
void Update();
already_AddRefed<nsSVGCoordCtx> GetContextX();
already_AddRefed<nsSVGCoordCtx> GetContextY();
already_AddRefed<nsSVGCoordCtx> GetContextUnspecified();
nsCOMPtr<nsIDOMSVGRect> mCtxRect;
nsRefPtr<nsSVGCoordCtx> mCtxX;
nsRefPtr<nsSVGCoordCtx> mCtxY;
nsRefPtr<nsSVGCoordCtx> mCtxUnspec;
};
////////////////////////////////////////////////////////////////////////
// pseudo interface nsSVGCoordCtxProvider
// {0C083184-4462-4B5D-B925-0BEC5A7E6779}
#define NS_SVGCOORDCTXPROVIDER_IID \
{ 0x0c083184, 0x4462, 0x4b5d, { 0xb9, 0x25, 0x0b, 0xec, 0x5a, 0x7e, 0x67, 0x79 } }
class nsSVGCoordCtxProvider : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_SVGCOORDCTXPROVIDER_IID)
nsSVGCoordCtxProvider() : mInner(new nsSVGCoordCtxHolder) {}
already_AddRefed<nsSVGCoordCtx> GetContextX() { return mInner ? mInner->GetContextX() : nsnull; }
already_AddRefed<nsSVGCoordCtx> GetContextY() { return mInner ? mInner->GetContextY() : nsnull; }
already_AddRefed<nsSVGCoordCtx> GetContextUnspecified() { return mInner ? mInner->GetContextUnspecified() : nsnull; }
already_AddRefed<nsSVGCoordCtx> GetCtxByType(PRUint16 aCtxType);
protected:
void SetCoordCtxRect(nsIDOMSVGRect* ctxRect) { if(mInner) mInner->SetContextRect(ctxRect); }
void SetCoordCtxMMPerPx(float mmPerPxX, float mmPerPxY) {
if(mInner)
mInner->SetMMPerPx(mmPerPxX, mmPerPxY);
}
private:
nsRefPtr<nsSVGCoordCtxHolder> mInner;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsSVGCoordCtxProvider,
NS_SVGCOORDCTXPROVIDER_IID)
#endif // __NS_SVGCOORDCTXPROVIDER_H__

Просмотреть файл

@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGElement.h"
#include "nsSVGSVGElement.h"
#include "nsIDocument.h"
#include "nsRange.h"
#include "nsIDOMAttr.h"
@ -65,8 +66,6 @@
#include "nsIScriptGlobalObject.h"
#include "nsIEventListenerManager.h"
#include "nsSVGUtils.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsSVGCoordCtx.h"
#include "nsSVGLength2.h"
#include "nsSVGNumber2.h"
#include <stdarg.h>
@ -128,28 +127,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericElement)
//----------------------------------------------------------------------
// nsIContent methods
nsresult
nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
PRBool aCompileEventHandlers)
{
nsresult rv = nsGenericElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
ParentChainChanged();
return rv;
}
void
nsSVGElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
{
nsGenericElement::UnbindFromTree(aDeep, aNullParent);
ParentChainChanged();
}
nsIAtom *
nsSVGElement::GetIDAttributeName() const
{
@ -678,33 +655,6 @@ nsSVGElement::DidModifySVGObservable(nsISVGValue* aObservable,
modification, hasListeners, PR_TRUE);
}
//----------------------------------------------------------------------
// recursive helper to call ParentChainChanged across non-SVG elements
static void CallParentChainChanged(nsIContent*elem)
{
NS_ASSERTION(elem, "null element");
PRUint32 count = elem->GetChildCount();
for (PRUint32 i=0; i<count; ++i) {
nsIContent* child = elem->GetChildAt(i);
if (child && child->IsNodeOfType(nsINode::eSVG)) {
NS_STATIC_CAST(nsSVGElement*, child)->ParentChainChanged();
}
else {
// non-svg element might have an svg child, so recurse
CallParentChainChanged(child);
}
}
}
void
nsSVGElement::ParentChainChanged()
{
CallParentChainChanged(this);
}
//----------------------------------------------------------------------
// Implementation Helpers:
@ -877,22 +827,12 @@ nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr)
return aAttr;
}
nsSVGCoordCtx *
nsSVGElement::GetCtxByType(PRUint16 aCtxType)
nsSVGSVGElement *
nsSVGElement::GetCtx()
{
nsCOMPtr<nsIDOMSVGSVGElement> svg;
GetOwnerSVGElement(getter_AddRefs(svg));
// outermost svg?
if (!svg)
return nsnull;
nsCOMPtr<nsSVGCoordCtxProvider> ctx = do_QueryInterface(svg);
nsRefPtr<nsSVGCoordCtx> rv = ctx->GetCtxByType(aCtxType);
// ugh...
return rv.get();
return NS_STATIC_CAST(nsSVGSVGElement*, svg.get());
}
nsSVGElement::LengthAttributesInfo
@ -929,7 +869,7 @@ nsSVGElement::GetAnimatedLengthValues(float *aFirst, ...)
NS_ASSERTION(info.mLengthCount > 0,
"GetAnimatedLengthValues on element with no length attribs");
nsCOMPtr<nsSVGCoordCtxProvider> ctx;
nsSVGSVGElement *ctx = nsnull;
float *f = aFirst;
PRUint32 i = 0;
@ -942,7 +882,7 @@ nsSVGElement::GetAnimatedLengthValues(float *aFirst, ...)
PRUint8 type = info.mLengths[i].GetSpecifiedUnitType();
if (type != nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER &&
type != nsIDOMSVGLength::SVG_LENGTHTYPE_PX)
ctx = nsSVGUtils::GetCoordContextProvider(this);
ctx = GetCtx();
}
*f = info.mLengths[i++].GetAnimValue(ctx);
f = va_arg(args, float*);

Просмотреть файл

@ -53,7 +53,7 @@
#include "nsWeakReference.h"
#include "nsICSSStyleRule.h"
class nsSVGCoordCtx;
class nsSVGSVGElement;
class nsSVGLength2;
class nsSVGNumber2;
@ -71,11 +71,6 @@ public:
// nsIContent interface methods
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
PRBool aCompileEventHandlers);
virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
PRBool aNullParent = PR_TRUE);
virtual nsIAtom *GetIDAttributeName() const;
virtual nsIAtom *GetClassAttributeName() const;
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
@ -116,9 +111,8 @@ public:
// nsISupportsWeakReference
// implementation inherited from nsSupportsWeakReference
nsSVGCoordCtx *GetCtxByType(PRUint16 aCtxType);
nsSVGSVGElement* GetCtx();
virtual void ParentChainChanged();
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeNumber(PRUint8 aAttrEnum, PRBool aDoSetAttr);

Просмотреть файл

@ -38,7 +38,6 @@
#include "nsSVGLength.h"
#include "nsCOMPtr.h"
#include "nsISVGSVGElement.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsSVGAnimatedEnumeration.h"
#include "nsSVGAnimatedInteger.h"
#include "nsSVGAnimatedString.h"

Просмотреть файл

@ -39,7 +39,6 @@
#include "nsSVGLength.h"
#include "nsCOMPtr.h"
#include "nsISVGSVGElement.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsSVGForeignObjectElement.h"
nsSVGElement::LengthInfo nsSVGForeignObjectElement::sLengthInfo[4] =

Просмотреть файл

@ -180,18 +180,6 @@ nsSVGGradientElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
return NS_OK;
}
//----------------------------------------------------------------------
// nsSVGElement methods
void nsSVGGradientElement::ParentChainChanged()
{
// Gradient length properties are relative to the target element
// (the one calling the gradient), so we don't set their
// contexts here.
// Also, gradient child elements (stops) don't have any length
// properties, so no need to recurse into children here.
}
//----------------------------------------------------------------------
// nsIContent methods

Просмотреть файл

@ -66,9 +66,6 @@ public:
// URI Reference
NS_DECL_NSIDOMSVGURIREFERENCE
// nsSVGElement specializations:
virtual void ParentChainChanged();
// nsIContent
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;

Просмотреть файл

@ -41,7 +41,6 @@
#include "nsSVGAnimatedString.h"
#include "nsCOMPtr.h"
#include "nsISVGSVGElement.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nsSVGAnimatedPreserveAspectRatio.h"

Просмотреть файл

@ -39,16 +39,18 @@
#include "nsSVGLength.h"
#include "nsIDOMSVGMatrix.h"
#include "nsIDOMSVGRect.h"
#include "nsGkAtoms.h"
#include "nsSVGValue.h"
#include "nsTextFormatter.h"
#include "prdtoa.h"
#include "nsCRT.h"
#include "nsSVGCoordCtx.h"
#include "nsSVGSVGElement.h"
#include "nsIDOMSVGNumber.h"
#include "nsISVGValueUtils.h"
#include "nsWeakReference.h"
#include "nsContentUtils.h"
#include "nsIDOMSVGAnimatedRect.h"
////////////////////////////////////////////////////////////////////////
// nsSVGLength class
@ -77,8 +79,8 @@ public:
NS_DECL_NSIDOMSVGLENGTH
// nsISVGLength interface:
NS_IMETHOD SetContext(nsSVGCoordCtx* context);
NS_IMETHOD SetContext(nsIWeakReference *aContext, PRUint8 aCtxType);
// nsISVGValue interface:
NS_IMETHOD SetValueString(const nsAString& aValue);
NS_IMETHOD GetValueString(nsAString& aValue);
@ -99,10 +101,14 @@ protected:
PRBool IsValidUnitType(PRUint16 unit);
void MaybeAddAsObserver();
void MaybeRemoveAsObserver();
// helper - returns a rect if we need to observe it (percentage length)
already_AddRefed<nsIDOMSVGRect> MaybeGetCtxRect();
nsWeakPtr mElement; // owning element - weakptr to avoid reference loop
float mValueInSpecifiedUnits;
PRUint16 mSpecifiedUnitType;
nsRefPtr<nsSVGCoordCtx> mContext;
PRUint8 mCtxType;
};
@ -143,7 +149,8 @@ NS_NewSVGLength(nsISVGLength** result,
nsSVGLength::nsSVGLength(float value,
PRUint16 unit)
: mValueInSpecifiedUnits(value),
mSpecifiedUnitType(unit)
mSpecifiedUnitType(unit),
mCtxType(0)
{
// we don't have a context yet, so we don't call MaybeAddAsObserver()
}
@ -486,7 +493,7 @@ nsSVGLength::ConvertToSpecifiedUnits(PRUint16 unitType)
//----------------------------------------------------------------------
// nsISVGLength methods:
NS_IMETHODIMP
nsSVGLength::SetContext(nsSVGCoordCtx* context)
nsSVGLength::SetContext(nsIWeakReference *aContext, PRUint8 aCtxType)
{
/* Unless our unit type is SVG_LENGTHTYPE_NUMBER or SVG_LENGTHTYPE_PX, our
user unit value is determined by our context and we must notify our
@ -498,7 +505,8 @@ nsSVGLength::SetContext(nsSVGCoordCtx* context)
MaybeRemoveAsObserver();
}
mContext = context;
mElement = aContext;
mCtxType = aCtxType;
if (mSpecifiedUnitType != SVG_LENGTHTYPE_NUMBER &&
mSpecifiedUnitType != SVG_LENGTHTYPE_PX) {
@ -514,32 +522,35 @@ nsSVGLength::SetContext(nsSVGCoordCtx* context)
float nsSVGLength::mmPerPixel()
{
if (!mContext) {
nsCOMPtr<nsIContent> element = do_QueryReferent(mElement);
if (!element) {
NS_WARNING("no context in mmPerPixel()");
return 1.0f;
}
float mmPerPx = mContext->GetMillimeterPerPixel();
nsSVGSVGElement *ctx =
NS_STATIC_CAST(nsSVGElement*, element.get())->GetCtx();
float mmPerPx = ctx->GetMMPerPx(mCtxType);
if (mmPerPx == 0.0f) {
NS_ASSERTION(mmPerPx != 0.0f, "invalid mm/pixels");
mmPerPx = 1e-4f; // some small value
}
return mmPerPx;
}
float nsSVGLength::AxisLength()
{
if (!mContext) {
nsCOMPtr<nsIContent> element = do_QueryReferent(mElement);
if (!element) {
NS_WARNING("no context in AxisLength()");
return 1.0f;
}
nsCOMPtr<nsIDOMSVGNumber> num = mContext->GetLength();
NS_ASSERTION(num != nsnull, "null interface");
float d;
num->GetValue(&d);
nsSVGSVGElement *ctx =
NS_STATIC_CAST(nsSVGElement*, element.get())->GetCtx();
float d = ctx->GetLength(mCtxType);
if (d == 0.0f) {
NS_WARNING("zero axis length");
@ -557,21 +568,32 @@ PRBool nsSVGLength::IsValidUnitType(PRUint16 unit)
return PR_FALSE;
}
already_AddRefed<nsIDOMSVGRect> nsSVGLength::MaybeGetCtxRect()
{
if ((mSpecifiedUnitType == SVG_LENGTHTYPE_PERCENTAGE) && mElement) {
nsCOMPtr<nsIContent> element = do_QueryReferent(mElement);
if (element) {
nsSVGSVGElement *ctx =
NS_STATIC_CAST(nsSVGElement*, element.get())->GetCtx();
if (ctx)
return ctx->GetCtxRect();
}
}
return nsnull;
}
void nsSVGLength::MaybeAddAsObserver()
{
if ((mSpecifiedUnitType==SVG_LENGTHTYPE_PERCENTAGE) &&
mContext) {
nsCOMPtr<nsIDOMSVGNumber> num = mContext->GetLength();
NS_ADD_SVGVALUE_OBSERVER(num);
}
nsCOMPtr<nsIDOMSVGRect> rect = MaybeGetCtxRect();
if (rect)
NS_ADD_SVGVALUE_OBSERVER(rect);
}
void nsSVGLength::MaybeRemoveAsObserver()
{
if ((mSpecifiedUnitType==SVG_LENGTHTYPE_PERCENTAGE) &&
mContext) {
nsCOMPtr<nsIDOMSVGNumber> num = mContext->GetLength();
NS_REMOVE_SVGVALUE_OBSERVER(num);
}
nsCOMPtr<nsIDOMSVGRect> rect = MaybeGetCtxRect();
if (rect)
NS_REMOVE_SVGVALUE_OBSERVER(rect);
}

Просмотреть файл

@ -42,7 +42,8 @@
#include "prdtoa.h"
#include "nsCRT.h"
#include "nsTextFormatter.h"
#include "nsSVGCoordCtx.h"
#include "nsIDOMSVGNumber.h"
#include "nsSVGSVGElement.h"
NS_IMPL_ADDREF(nsSVGLength2::DOMBaseVal)
NS_IMPL_RELEASE(nsSVGLength2::DOMBaseVal)
@ -135,32 +136,29 @@ GetValueString(nsAString &aValueAsString, float aValue, PRUint16 aUnitType)
aValueAsString.Append(unitString);
}
static float
GetMMPerPixel(nsSVGCoordCtx *aCtx)
float
nsSVGLength2::GetMMPerPixel(nsSVGSVGElement *aCtx)
{
if (!aCtx)
return 1;
float mmPerPx = aCtx->GetMillimeterPerPixel();
float mmPerPx = aCtx->GetMMPerPx(mCtxType);
if (mmPerPx == 0.0f) {
NS_ASSERTION(mmPerPx != 0.0f, "invalid mm/pixels");
mmPerPx = 1e-4f; // some small value
}
return mmPerPx;
}
static float
GetAxisLength(nsSVGCoordCtx *aCtx)
float
nsSVGLength2::GetAxisLength(nsSVGSVGElement *aCtx)
{
if (!aCtx)
return 1;
nsCOMPtr<nsIDOMSVGNumber> num = aCtx->GetLength();
NS_ASSERTION(num != nsnull, "null interface");
float d;
num->GetValue(&d);
float d = aCtx->GetLength(mCtxType);
if (d == 0.0f) {
NS_WARNING("zero axis length");
@ -254,30 +252,15 @@ nsSVGLength2::GetAnimValueString(nsAString & aValueAsString)
float
nsSVGLength2::ConvertToUserUnits(float aVal, nsSVGElement *aSVGElement)
{
nsSVGCoordCtx *ctx = nsnull;
if (mSpecifiedUnitType == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER ||
mSpecifiedUnitType == nsIDOMSVGLength::SVG_LENGTHTYPE_PX)
return aVal;
if (mSpecifiedUnitType != nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER &&
mSpecifiedUnitType != nsIDOMSVGLength::SVG_LENGTHTYPE_PX)
ctx = aSVGElement->GetCtxByType(mCtxType);
return ConvertToUserUnits(aVal, ctx);
return ConvertToUserUnits(aVal, aSVGElement->GetCtx());
}
float
nsSVGLength2::ConvertToUserUnits(float aVal, nsSVGCoordCtxProvider *aProvider)
{
nsSVGCoordCtx *ctx = nsnull;
if (aProvider &&
mSpecifiedUnitType != nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER &&
mSpecifiedUnitType != nsIDOMSVGLength::SVG_LENGTHTYPE_PX)
ctx = aProvider->GetCtxByType(mCtxType).get();
return ConvertToUserUnits(aVal, ctx);
}
float
nsSVGLength2::ConvertToUserUnits(float aVal, nsSVGCoordCtx *aCtx)
nsSVGLength2::ConvertToUserUnits(float aVal, nsSVGSVGElement *aCtx)
{
switch (mSpecifiedUnitType) {
case nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER:
@ -308,11 +291,11 @@ nsSVGLength2::ConvertToUserUnits(float aVal, nsSVGCoordCtx *aCtx)
void
nsSVGLength2::SetBaseValue(float aValue, nsSVGElement *aSVGElement)
{
nsSVGCoordCtx *ctx = nsnull;
nsSVGSVGElement *ctx = nsnull;
if (mSpecifiedUnitType != nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER &&
mSpecifiedUnitType != nsIDOMSVGLength::SVG_LENGTHTYPE_PX)
ctx = aSVGElement->GetCtxByType(mCtxType);
ctx = aSVGElement->GetCtx();
switch (mSpecifiedUnitType) {
case nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER:

Просмотреть файл

@ -42,7 +42,6 @@
#include "nsSVGUtils.h"
#include "nsSVGElement.h"
#include "nsDOMError.h"
#include "nsSVGCoordCtxProvider.h"
class nsSVGLength2
{
@ -81,9 +80,9 @@ public:
float GetAnimValInSpecifiedUnits() { return mAnimVal; }
float GetBaseValInSpecifiedUnits() { return mBaseVal; }
float GetBaseValue(nsSVGCoordCtxProvider* aProvider)
float GetBaseValue(nsSVGSVGElement* aProvider)
{ return ConvertToUserUnits(mBaseVal, aProvider); }
float GetAnimValue(nsSVGCoordCtxProvider* aProvider)
float GetAnimValue(nsSVGSVGElement* aProvider)
{ return ConvertToUserUnits(mAnimVal, aProvider); }
nsresult ToDOMBaseVal(nsIDOMSVGLength **aResult, nsSVGElement* aSVGElement);
@ -100,9 +99,10 @@ private:
PRUint8 mCtxType; // X, Y or Unspecified
PRPackedBool mIsAnimated;
float ConvertToUserUnits(float aValue, nsSVGCoordCtx *aCtx);
float GetMMPerPixel(nsSVGSVGElement *aCtx);
float GetAxisLength(nsSVGSVGElement *aCtx);
float ConvertToUserUnits(float aValue, nsSVGElement *aSVGElement);
float ConvertToUserUnits(float aValue, nsSVGCoordCtxProvider *aProvider);
float ConvertToUserUnits(float aValue, nsSVGSVGElement *aProvider);
void SetBaseValue(float aValue, nsSVGElement *aSVGElement);
void SetBaseValueInSpecifiedUnits(float aValue, nsSVGElement *aSVGElement);
void NewValueSpecifiedUnits(PRUint16 aUnitType, float aValue,

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsVoidArray.h"
#include "nsDOMError.h"
#include "nsReadableUtils.h"
#include "nsSVGCoordCtx.h"
#include "nsSVGSVGElement.h"
#include "nsCRT.h"
#include "nsISVGValueUtils.h"
#include "nsContentUtils.h"
@ -51,14 +51,15 @@
////////////////////////////////////////////////////////////////////////
// nsSVGLengthList
class nsSVGLengthList : public nsISVGLengthList,
class nsSVGLengthList : public nsIDOMSVGLengthList,
public nsSVGValue,
public nsISVGValueObserver
{
protected:
friend nsresult NS_NewSVGLengthList(nsISVGLengthList** result);
friend nsresult NS_NewSVGLengthList(nsIDOMSVGLengthList** result,
nsSVGElement *aContext);
nsSVGLengthList();
nsSVGLengthList(nsSVGElement *aContext);
~nsSVGLengthList();
// void Init();
@ -69,9 +70,6 @@ public:
// nsIDOMSVGLengthList interface:
NS_DECL_NSIDOMSVGLENGTHLIST
// nsISVGLengthList interface:
NS_IMETHOD SetContext(nsSVGCoordCtx* context);
// remainder of nsISVGValue interface:
NS_IMETHOD SetValueString(const nsAString& aValue);
NS_IMETHOD GetValueString(nsAString& aValue);
@ -95,15 +93,18 @@ protected:
void ReleaseLengths();
nsAutoVoidArray mLengths;
nsRefPtr<nsSVGCoordCtx> mContext;
nsWeakPtr mContext; // needs to be weak to avoid reference loop
PRUint8 mCtxType;
};
//----------------------------------------------------------------------
// Implementation
nsSVGLengthList::nsSVGLengthList()
nsSVGLengthList::nsSVGLengthList(nsSVGElement *aContext)
: mCtxType(0)
{
mContext = do_GetWeakReference(NS_STATIC_CAST(nsGenericElement*, aContext));
}
nsSVGLengthList::~nsSVGLengthList()
@ -120,7 +121,6 @@ NS_IMPL_RELEASE(nsSVGLengthList)
NS_INTERFACE_MAP_BEGIN(nsSVGLengthList)
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLengthList)
NS_INTERFACE_MAP_ENTRY(nsISVGLengthList)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGLengthList)
@ -294,22 +294,6 @@ nsSVGLengthList::AppendItem(nsIDOMSVGLength *newItem, nsIDOMSVGLength **_retval)
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGLengthList methods:
NS_IMETHODIMP
nsSVGLengthList::SetContext(nsSVGCoordCtx *context)
{
mContext = context;
PRInt32 count = mLengths.Count();
for (PRInt32 i = 0; i < count; ++i) {
nsISVGLength* length = ElementAt(i);
length->SetContext(mContext);
}
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGValueObserver methods
@ -339,7 +323,7 @@ nsSVGLengthList::ReleaseLengths()
PRInt32 count = mLengths.Count();
for (PRInt32 i = 0; i < count; ++i) {
nsISVGLength* length = ElementAt(i);
length->SetContext(nsnull);
length->SetContext(nsnull, 0);
NS_REMOVE_SVGVALUE_OBSERVER(length);
NS_RELEASE(length);
}
@ -364,7 +348,7 @@ nsSVGLengthList::AppendElement(nsISVGLength* aElement)
// list':
// aElement->SetListOwner(this);
aElement->SetContext(mContext);
aElement->SetContext(mContext, mCtxType);
mLengths.AppendElement((void*)aElement);
NS_ADD_SVGVALUE_OBSERVER(aElement);
DidModify();
@ -393,7 +377,7 @@ nsSVGLengthList::InsertElementAt(nsISVGLength* aElement, PRInt32 index)
// list':
// aElement->SetListOwner(this);
aElement->SetContext(mContext);
aElement->SetContext(mContext, mCtxType);
mLengths.InsertElementAt((void*)aElement, index);
NS_ADD_SVGVALUE_OBSERVER(aElement);
@ -405,11 +389,11 @@ nsSVGLengthList::InsertElementAt(nsISVGLength* aElement, PRInt32 index)
// Exported creation functions:
nsresult
NS_NewSVGLengthList(nsISVGLengthList** result)
NS_NewSVGLengthList(nsIDOMSVGLengthList** result, nsSVGElement *aContext)
{
*result = nsnull;
nsSVGLengthList* lengthList = new nsSVGLengthList();
nsSVGLengthList* lengthList = new nsSVGLengthList(aContext);
if (!lengthList) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(lengthList);

Просмотреть файл

@ -39,9 +39,11 @@
#ifndef __NS_SVGLENGTHLIST_H__
#define __NS_SVGLENGTHLIST_H__
#include "nsISVGLengthList.h"
#include "nsIDOMSVGLengthList.h"
class nsSVGElement;
nsresult
NS_NewSVGLengthList(nsISVGLengthList** result);
NS_NewSVGLengthList(nsIDOMSVGLengthList** result, nsSVGElement *aContext);
#endif //__NS_SVGLENGTHLIST_H__

Просмотреть файл

@ -342,7 +342,7 @@ nsSVGMarkerElement::DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr)
}
void
nsSVGMarkerElement::SetParentCoordCtxProvider(nsSVGCoordCtxProvider *aContext)
nsSVGMarkerElement::SetParentCoordCtxProvider(nsSVGSVGElement *aContext)
{
mCoordCtx = aContext;
mViewBoxToViewportTransform = nsnull;

Просмотреть файл

@ -91,7 +91,7 @@ public:
protected:
void SetParentCoordCtxProvider(nsSVGCoordCtxProvider *aContext);
void SetParentCoordCtxProvider(nsSVGSVGElement *aContext);
virtual LengthAttributesInfo GetLengthInfo();
@ -99,7 +99,7 @@ protected:
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
nsSVGCoordCtxProvider *mCoordCtx;
nsSVGSVGElement *mCoordCtx;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMarkerUnits;
nsCOMPtr<nsIDOMSVGAnimatedAngle> mOrient;

Просмотреть файл

@ -89,7 +89,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGSVGElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLocatable)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGZoomAndPan)
NS_INTERFACE_MAP_ENTRY(nsISVGSVGElement)
NS_INTERFACE_MAP_ENTRY(nsSVGCoordCtxProvider)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGSVGElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGSVGElementBase)
@ -97,7 +96,10 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGSVGElementBase)
// Implementation
nsSVGSVGElement::nsSVGSVGElement(nsINodeInfo* aNodeInfo)
: nsSVGSVGElementBase(aNodeInfo), mCoordCtx(nsnull), mRedrawSuspendCount(0)
: nsSVGSVGElementBase(aNodeInfo),
mCoordCtx(nsnull),
mCoordCtxMmPerPx(0),
mRedrawSuspendCount(0)
{
}
@ -129,8 +131,6 @@ nsSVGSVGElement::Init()
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::viewBox, mViewBox);
NS_ENSURE_SUCCESS(rv,rv);
// initialize coordinate context with viewbox:
SetCoordCtxRect(viewbox);
}
// DOM property: preserveAspectRatio , #IMPLIED attrib: preserveAspectRatio
@ -788,9 +788,12 @@ nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix **_retval)
float x=0, y=0;
nsCOMPtr<nsIDOMSVGMatrix> tmp;
if (ancestorCount == 0) {
// our immediate parent is an SVG element. get our 'x' and 'y' attribs
x = mLengthAttributes[X].GetAnimValue(mCoordCtx);
y = mLengthAttributes[Y].GetAnimValue(mCoordCtx);
// our immediate parent is an SVG element. get our 'x' and 'y' attribs.
// cast to nsSVGElement so we get our ancestor coord context.
x = mLengthAttributes[X].GetAnimValue(NS_STATIC_CAST(nsSVGElement*,
this));
y = mLengthAttributes[Y].GetAnimValue(NS_STATIC_CAST(nsSVGElement*,
this));
}
else {
// We have an SVG ancestor, but with non-SVG content between us
@ -896,8 +899,11 @@ nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **_retval)
nsCOMPtr<nsIDOMSVGMatrix> tmp;
if (ancestorCount == 0) {
// our immediate parent is an SVG element. get our 'x' and 'y' attribs
x = mLengthAttributes[X].GetAnimValue(mCoordCtx);
y = mLengthAttributes[Y].GetAnimValue(mCoordCtx);
// cast to nsSVGElement so we get our ancestor coord context.
x = mLengthAttributes[X].GetAnimValue(NS_STATIC_CAST(nsSVGElement*,
this));
y = mLengthAttributes[Y].GetAnimValue(NS_STATIC_CAST(nsSVGElement*,
this));
}
else {
// We have an SVG ancestor, but with non-SVG content between us
@ -976,31 +982,6 @@ nsSVGSVGElement::SetZoomAndPan(PRUint16 aZoomAndPan)
//----------------------------------------------------------------------
// nsISVGSVGElement methods:
NS_IMETHODIMP
nsSVGSVGElement::SetParentCoordCtxProvider(nsSVGCoordCtxProvider *parentCtx)
{
if (!parentCtx) {
NS_ERROR("null parent context");
return NS_ERROR_FAILURE;
}
mCoordCtx = parentCtx;
// set parent's mmPerPx on our coord contexts:
float mmPerPxX = nsRefPtr<nsSVGCoordCtx>(parentCtx->GetContextX())->GetMillimeterPerPixel();
float mmPerPxY = nsRefPtr<nsSVGCoordCtx>(parentCtx->GetContextY())->GetMillimeterPerPixel();
SetCoordCtxMMPerPx(mmPerPxX, mmPerPxY);
if (!HasAttr(kNameSpaceID_None, nsGkAtoms::viewBox)) {
nsCOMPtr<nsIDOMSVGRect> vb;
mViewBox->GetAnimVal(getter_AddRefs(vb));
vb->SetWidth(mLengthAttributes[WIDTH].GetAnimValue(mCoordCtx));
vb->SetHeight(mLengthAttributes[HEIGHT].GetAnimValue(mCoordCtx));
}
return NS_OK;
}
NS_IMETHODIMP
nsSVGSVGElement::GetCurrentScaleNumber(nsIDOMSVGNumber **aResult)
{
@ -1129,17 +1110,13 @@ nsresult
nsSVGSVGElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify)
{
if (aNamespaceID == kNameSpaceID_None &&
aName == nsGkAtoms::viewBox && mCoordCtx) {
nsCOMPtr<nsIDOMSVGRect> vb;
mViewBox->GetAnimVal(getter_AddRefs(vb));
vb->SetX(0);
vb->SetY(0);
vb->SetWidth(mLengthAttributes[WIDTH].GetAnimValue(mCoordCtx));
vb->SetHeight(mLengthAttributes[HEIGHT].GetAnimValue(mCoordCtx));
nsSVGSVGElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::viewBox) {
InvalidateTransformNotifyFrame();
}
return nsSVGSVGElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
return NS_OK;
}
//----------------------------------------------------------------------
@ -1241,37 +1218,45 @@ 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);
float viewportWidth, viewportHeight;
nsSVGSVGElement *ctx = GetCtx();
if (!ctx) {
// outer svg
viewportWidth = mViewportWidth;
viewportHeight = mViewportHeight;
} else {
viewportWidth = mLengthAttributes[WIDTH].GetAnimValue(ctx);
viewportHeight = mLengthAttributes[HEIGHT].GetAnimValue(ctx);
}
*_retval = mViewBoxToViewportTransform;
NS_IF_ADDREF(*_retval);
float viewboxX, viewboxY, viewboxWidth, viewboxHeight;
if (HasAttr(kNameSpaceID_None, nsGkAtoms::viewBox)) {
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);
} else {
viewboxX = viewboxY = 0.0f;
viewboxWidth = viewportWidth;
viewboxHeight = viewportHeight;
}
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;
}
nsCOMPtr<nsIDOMSVGMatrix> xform =
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
viewboxX, viewboxY,
viewboxWidth, viewboxHeight,
mPreserveAspectRatio);
xform.swap(*_retval);
return rv;
}
@ -1323,8 +1308,6 @@ nsSVGSVGElement::InvalidateTransformNotifyFrame()
nsIPresShell* presShell = doc->GetShellAt(0);
if (!presShell) return;
mViewBoxToViewportTransform = nsnull;
nsIFrame* frame = presShell->GetPrimaryFrameFor(this);
if (frame) {
nsISVGSVGFrame* svgframe;
@ -1343,6 +1326,94 @@ nsSVGSVGElement::InvalidateTransformNotifyFrame()
}
}
//----------------------------------------------------------------------
// nsSVGSVGElement
void
nsSVGSVGElement::SetCoordCtxRect(nsIDOMSVGRect* aCtxRect)
{
if (mLengthAttributes[WIDTH].GetSpecifiedUnitType() ==
nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE) {
aCtxRect->GetWidth(&mViewportWidth);
mViewportWidth *=
mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() / 100.0f;
} else {
mViewportWidth = mLengthAttributes[WIDTH].GetAnimValue(this);
}
if (mLengthAttributes[HEIGHT].GetSpecifiedUnitType() ==
nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE) {
aCtxRect->GetHeight(&mViewportHeight);
mViewportHeight *=
mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() / 100.0f;
} else {
mViewportHeight = mLengthAttributes[HEIGHT].GetAnimValue(this);
}
}
already_AddRefed<nsIDOMSVGRect>
nsSVGSVGElement::GetCtxRect() {
nsCOMPtr<nsIDOMSVGRect> vb;
if (HasAttr(kNameSpaceID_None, nsGkAtoms::viewBox)) {
mViewBox->GetAnimVal(getter_AddRefs(vb));
} else {
nsSVGSVGElement *ctx = GetCtx();
float w, h;
if (ctx) {
w = mLengthAttributes[WIDTH].GetAnimValue(ctx);
h = mLengthAttributes[HEIGHT].GetAnimValue(ctx);
} else {
w = mViewportWidth;
h = mViewportHeight;
}
NS_NewSVGRect(getter_AddRefs(vb), 0, 0, w, h);
}
nsIDOMSVGRect *retval = nsnull;
vb.swap(retval);
return retval;
}
float
nsSVGSVGElement::GetLength(PRUint8 aCtxType) {
float h, w;
if (HasAttr(kNameSpaceID_None, nsGkAtoms::viewBox)) {
nsCOMPtr<nsIDOMSVGRect> vb;
mViewBox->GetAnimVal(getter_AddRefs(vb));
vb->GetHeight(&h);
vb->GetWidth(&w);
} else {
nsSVGSVGElement *ctx = GetCtx();
if (ctx) {
w = mLengthAttributes[WIDTH].GetAnimValue(ctx);
h = mLengthAttributes[HEIGHT].GetAnimValue(ctx);
} else {
w = mViewportWidth;
h = mViewportHeight;
}
}
switch (aCtxType) {
case nsSVGUtils::X:
return w;
case nsSVGUtils::Y:
return h;
case nsSVGUtils::XY:
return (float)sqrt((w*w+h*h)/2.0);
}
return 0;
}
float
nsSVGSVGElement::GetMMPerPx(PRUint8 aCtxType)
{
if (mCoordCtxMmPerPx == 0.0f) {
GetScreenPixelToMillimeterX(&mCoordCtxMmPerPx);
}
return mCoordCtxMmPerPx;
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -1351,15 +1422,7 @@ nsSVGSVGElement::DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr)
{
nsSVGSVGElementBase::DidChangeLength(aAttrEnum, aDoSetAttr);
if (mCoordCtx && !HasAttr(kNameSpaceID_None, nsGkAtoms::viewBox) &&
(aAttrEnum == WIDTH || aAttrEnum == HEIGHT)) {
nsCOMPtr<nsIDOMSVGRect> vb;
mViewBox->GetAnimVal(getter_AddRefs(vb));
vb->SetWidth(mLengthAttributes[WIDTH].GetAnimValue(mCoordCtx));
vb->SetHeight(mLengthAttributes[HEIGHT].GetAnimValue(mCoordCtx));
} else {
InvalidateTransformNotifyFrame();
}
InvalidateTransformNotifyFrame();
}
nsSVGElement::LengthAttributesInfo

Просмотреть файл

@ -45,7 +45,7 @@
#include "nsIDOMSVGFitToViewBox.h"
#include "nsIDOMSVGLocatable.h"
#include "nsIDOMSVGZoomAndPan.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsIDOMSVGMatrix.h"
#include "nsSVGLength2.h"
#define QI_TO_NSSVGSVGELEMENT(base) \
@ -59,8 +59,7 @@ class nsSVGSVGElement : public nsSVGSVGElementBase,
public nsISVGSVGElement, // : nsIDOMSVGSVGElement
public nsIDOMSVGFitToViewBox,
public nsIDOMSVGLocatable,
public nsIDOMSVGZoomAndPan,
public nsSVGCoordCtxProvider
public nsIDOMSVGZoomAndPan
{
friend class nsSVGOuterSVGFrame;
friend class nsSVGInnerSVGFrame;
@ -72,7 +71,12 @@ protected:
virtual ~nsSVGSVGElement();
nsresult Init();
// nsSVGSVGElement methods:
void SetCoordCtxRect(nsIDOMSVGRect* aCtxRect);
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGSVGELEMENT_IID)
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGSVGELEMENT
@ -86,7 +90,6 @@ public:
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGSVGElementBase::)
// nsISVGSVGElement interface:
NS_IMETHOD SetParentCoordCtxProvider(nsSVGCoordCtxProvider *parentCtx);
NS_IMETHOD GetCurrentScaleNumber(nsIDOMSVGNumber **aResult);
NS_IMETHOD GetZoomAndPanEnum(nsISVGEnum **aResult);
NS_IMETHOD SetCurrentScaleTranslate(float s, float x, float y);
@ -95,7 +98,6 @@ public:
NS_IMETHOD_(float) GetPreviousTranslate_x();
NS_IMETHOD_(float) GetPreviousTranslate_y();
NS_IMETHOD_(float) GetPreviousScale();
NS_IMETHOD_(void) InvalidateViewBoxToViewport() { mViewBoxToViewportTransform = nsnull; }
// nsIContent interface
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -112,6 +114,11 @@ public:
// nsSVGElement specializations:
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
// nsSVGSVGElement methods:
float GetLength(PRUint8 mCtxType);
float GetMMPerPx(PRUint8 mCtxType = 0);
already_AddRefed<nsIDOMSVGRect> GetCtxRect();
// public helpers:
nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval);
@ -133,11 +140,13 @@ protected:
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
nsSVGCoordCtxProvider *mCoordCtx;
nsSVGSVGElement *mCoordCtx;
nsCOMPtr<nsIDOMSVGAnimatedRect> mViewBox;
nsCOMPtr<nsIDOMSVGMatrix> mViewBoxToViewportTransform;
nsCOMPtr<nsIDOMSVGAnimatedPreserveAspectRatio> mPreserveAspectRatio;
float mViewportWidth, mViewportHeight; // valid only for outersvg
float mCoordCtxMmPerPx;
// zoom and pan
// IMPORTANT: only RecordCurrentScaleTranslate should change the "mPreviousX"
// members below - see the comment in RecordCurrentScaleTranslate

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsSVGAnimatedLengthList.h"
#include "nsSVGLengthList.h"
#include "nsISVGSVGElement.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsSVGSVGElement.h"
#include "nsISVGTextContentMetrics.h"
#include "nsIFrame.h"
#include "nsDOMError.h"
@ -77,9 +77,6 @@ public:
// nsIContent interface
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
// nsSVGElement specializations:
virtual void ParentChainChanged();
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected:
@ -136,8 +133,8 @@ nsSVGTSpanElement::Init()
// DOM property: nsIDOMSVGTextPositioningElement::x, #IMPLIED attrib: x
{
nsCOMPtr<nsISVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList));
nsCOMPtr<nsIDOMSVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList), this);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedLengthList(getter_AddRefs(mX),
lengthList);
@ -148,8 +145,8 @@ nsSVGTSpanElement::Init()
// DOM property: nsIDOMSVGTextPositioningElement::y, #IMPLIED attrib: y
{
nsCOMPtr<nsISVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList));
nsCOMPtr<nsIDOMSVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList), this);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedLengthList(getter_AddRefs(mY),
lengthList);
@ -160,8 +157,8 @@ nsSVGTSpanElement::Init()
// DOM property: nsIDOMSVGTextPositioningElement::dx, #IMPLIED attrib: dx
{
nsCOMPtr<nsISVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList));
nsCOMPtr<nsIDOMSVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList), this);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedLengthList(getter_AddRefs(mdX),
lengthList);
@ -172,8 +169,8 @@ nsSVGTSpanElement::Init()
// DOM property: nsIDOMSVGTextPositioningElement::dy, #IMPLIED attrib: dy
{
nsCOMPtr<nsISVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList));
nsCOMPtr<nsIDOMSVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList), this);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedLengthList(getter_AddRefs(mdY),
lengthList);
@ -379,64 +376,6 @@ nsSVGTSpanElement::IsAttributeMapped(const nsIAtom* name) const
nsSVGTSpanElementBase::IsAttributeMapped(name);
}
//----------------------------------------------------------------------
// nsSVGElement methods
void nsSVGTSpanElement::ParentChainChanged()
{
// set new context information on our length-properties:
nsCOMPtr<nsIDOMSVGSVGElement> dom_elem;
GetOwnerSVGElement(getter_AddRefs(dom_elem));
if (!dom_elem) return;
nsCOMPtr<nsSVGCoordCtxProvider> ctx = do_QueryInterface(dom_elem);
NS_ASSERTION(ctx, "<svg> element missing interface");
// x:
{
nsCOMPtr<nsIDOMSVGLengthList> dom_lengthlist;
mX->GetAnimVal(getter_AddRefs(dom_lengthlist));
nsCOMPtr<nsISVGLengthList> lengthlist = do_QueryInterface(dom_lengthlist);
NS_ASSERTION(lengthlist, "svg lengthlist missing interface");
lengthlist->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextX()));
}
// y:
{
nsCOMPtr<nsIDOMSVGLengthList> dom_lengthlist;
mY->GetAnimVal(getter_AddRefs(dom_lengthlist));
nsCOMPtr<nsISVGLengthList> lengthlist = do_QueryInterface(dom_lengthlist);
NS_ASSERTION(lengthlist, "svg lengthlist missing interface");
lengthlist->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextY()));
}
// dx:
{
nsCOMPtr<nsIDOMSVGLengthList> dom_lengthlist;
mdX->GetAnimVal(getter_AddRefs(dom_lengthlist));
nsCOMPtr<nsISVGLengthList> lengthlist = do_QueryInterface(dom_lengthlist);
NS_ASSERTION(lengthlist, "svg lengthlist missing interface");
lengthlist->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextX()));
}
// dy:
{
nsCOMPtr<nsIDOMSVGLengthList> dom_lengthlist;
mdY->GetAnimVal(getter_AddRefs(dom_lengthlist));
nsCOMPtr<nsISVGLengthList> lengthlist = do_QueryInterface(dom_lengthlist);
NS_ASSERTION(lengthlist, "svg lengthlist missing interface");
lengthlist->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextY()));
}
// recurse into child content:
nsSVGTSpanElementBase::ParentChainChanged();
}
//----------------------------------------------------------------------
// nsSVGElement overrides

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsSVGAnimatedLengthList.h"
#include "nsSVGLengthList.h"
#include "nsISVGSVGElement.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsSVGSVGElement.h"
#include "nsISVGTextContentMetrics.h"
#include "nsIFrame.h"
#include "nsDOMError.h"
@ -76,9 +76,6 @@ public:
// nsIContent interface
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
// nsSVGElement specializations:
virtual void ParentChainChanged();
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -133,8 +130,8 @@ nsSVGTextElement::Init()
// DOM property: nsIDOMSVGTextPositioningElement::x, #IMPLIED attrib: x
{
nsCOMPtr<nsISVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList));
nsCOMPtr<nsIDOMSVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList), this);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedLengthList(getter_AddRefs(mX),
lengthList);
@ -145,8 +142,8 @@ nsSVGTextElement::Init()
// DOM property: nsIDOMSVGTextPositioningElement::y, #IMPLIED attrib: y
{
nsCOMPtr<nsISVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList));
nsCOMPtr<nsIDOMSVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList), this);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedLengthList(getter_AddRefs(mY),
lengthList);
@ -157,8 +154,8 @@ nsSVGTextElement::Init()
// DOM property: nsIDOMSVGTextPositioningElement::dx, #IMPLIED attrib: dx
{
nsCOMPtr<nsISVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList));
nsCOMPtr<nsIDOMSVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList), this);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedLengthList(getter_AddRefs(mdX),
lengthList);
@ -169,8 +166,8 @@ nsSVGTextElement::Init()
// DOM property: nsIDOMSVGTextPositioningElement::dy, #IMPLIED attrib: dy
{
nsCOMPtr<nsISVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList));
nsCOMPtr<nsIDOMSVGLengthList> lengthList;
rv = NS_NewSVGLengthList(getter_AddRefs(lengthList), this);
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedLengthList(getter_AddRefs(mdY),
lengthList);
@ -372,64 +369,6 @@ nsSVGTextElement::IsAttributeMapped(const nsIAtom* name) const
nsSVGTextElementBase::IsAttributeMapped(name);
}
//----------------------------------------------------------------------
// nsSVGElement methods
void nsSVGTextElement::ParentChainChanged()
{
// set new context information on our length-properties:
nsCOMPtr<nsIDOMSVGSVGElement> dom_elem;
GetOwnerSVGElement(getter_AddRefs(dom_elem));
if (!dom_elem) return;
nsCOMPtr<nsSVGCoordCtxProvider> ctx = do_QueryInterface(dom_elem);
NS_ASSERTION(ctx, "<svg> element missing interface");
// x:
{
nsCOMPtr<nsIDOMSVGLengthList> dom_lengthlist;
mX->GetAnimVal(getter_AddRefs(dom_lengthlist));
nsCOMPtr<nsISVGLengthList> lengthlist = do_QueryInterface(dom_lengthlist);
NS_ASSERTION(lengthlist, "svg lengthlist missing interface");
lengthlist->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextX()));
}
// y:
{
nsCOMPtr<nsIDOMSVGLengthList> dom_lengthlist;
mY->GetAnimVal(getter_AddRefs(dom_lengthlist));
nsCOMPtr<nsISVGLengthList> lengthlist = do_QueryInterface(dom_lengthlist);
NS_ASSERTION(lengthlist, "svg lengthlist missing interface");
lengthlist->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextY()));
}
// dx:
{
nsCOMPtr<nsIDOMSVGLengthList> dom_lengthlist;
mdX->GetAnimVal(getter_AddRefs(dom_lengthlist));
nsCOMPtr<nsISVGLengthList> lengthlist = do_QueryInterface(dom_lengthlist);
NS_ASSERTION(lengthlist, "svg lengthlist missing interface");
lengthlist->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextX()));
}
// dy:
{
nsCOMPtr<nsIDOMSVGLengthList> dom_lengthlist;
mdY->GetAnimVal(getter_AddRefs(dom_lengthlist));
nsCOMPtr<nsISVGLengthList> lengthlist = do_QueryInterface(dom_lengthlist);
NS_ASSERTION(lengthlist, "svg lengthlist missing interface");
lengthlist->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextY()));
}
// recurse into child content:
nsSVGTextElementBase::ParentChainChanged();
}
//----------------------------------------------------------------------
// implementation helpers:

Просмотреть файл

@ -39,7 +39,7 @@
#include "nsGkAtoms.h"
#include "nsIDOMSVGAnimatedLength.h"
#include "nsISVGSVGElement.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsIDOMSVGAnimatedString.h"
#include "nsSVGAnimatedString.h"
#include "nsIDOMDocument.h"
#include "nsIDOMSVGSVGElement.h"

Просмотреть файл

@ -166,6 +166,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../../content/xbl/src \
-I$(srcdir)/../../view/src \
-I$(srcdir)/../../dom/src/base \
-I$(srcdir)/../../content/svg/content/src \
$(NULL)
ifdef MOZ_MATHML

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsSVGUtils.h"
#include "nsSVGGraphicElement.h"
#include "gfxContext.h"
#include "nsIDOMSVGRect.h"
//----------------------------------------------------------------------
// Implementation

Просмотреть файл

@ -100,15 +100,6 @@ nsSVGContainerFrame::Init(nsIContent* aContent,
return rv;
}
already_AddRefed<nsSVGCoordCtxProvider>
nsSVGContainerFrame::GetCoordContextProvider()
{
NS_ASSERTION(mParent, "null parent");
nsSVGContainerFrame *containerFrame = NS_STATIC_CAST(nsSVGContainerFrame*,
mParent);
return containerFrame->GetCoordContextProvider();
}
NS_IMETHODIMP
nsSVGDisplayContainerFrame::InitSVG()
{

Просмотреть файл

@ -40,7 +40,7 @@
#include "nsContainerFrame.h"
#include "nsISVGChildFrame.h"
#include "nsIDOMSVGMatrix.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsSVGSVGElement.h"
typedef nsContainerFrame nsSVGContainerFrameBase;
@ -79,7 +79,6 @@ public:
nsIFrame* aPrevInFlow);
virtual already_AddRefed<nsIDOMSVGMatrix> GetCanvasTM() { return nsnull; }
virtual already_AddRefed<nsSVGCoordCtxProvider> GetCoordContextProvider();
};
class nsSVGDisplayContainerFrame : public nsSVGContainerFrame,

Просмотреть файл

@ -193,10 +193,14 @@ nsSVGGeometryFrame::DidModifySVGObservable(nsISVGValue* observable,
float
nsSVGGeometryFrame::GetStrokeWidth()
{
nsSVGElement *ctx = NS_STATIC_CAST(nsSVGElement*,
GetType() == nsGkAtoms::svgGlyphFrame ?
mContent->GetParent() : mContent);
return
nsSVGUtils::CoordToFloat(GetPresContext(),
GetType() == nsGkAtoms::svgGlyphFrame ? mContent->GetParent() : mContent,
GetStyleSVG()->mStrokeWidth);
ctx,
GetStyleSVG()->mStrokeWidth);
}
nsresult
@ -217,7 +221,9 @@ nsSVGGeometryFrame::GetStrokeDashArray(gfxFloat **aDashes, PRUint32 *aCount)
if (dashes) {
for (PRUint32 i = 0; i < count; i++) {
dashes[i] =
nsSVGUtils::CoordToFloat(presContext, mContent, dasharray[i]);
nsSVGUtils::CoordToFloat(presContext,
NS_STATIC_CAST(nsSVGElement*, mContent),
dasharray[i]);
if (dashes[i] < 0.0f) {
delete [] dashes;
return NS_OK;
@ -244,7 +250,8 @@ float
nsSVGGeometryFrame::GetStrokeDashoffset()
{
return
nsSVGUtils::CoordToFloat(GetPresContext(), mContent,
nsSVGUtils::CoordToFloat(GetPresContext(),
NS_STATIC_CAST(nsSVGElement*, mContent),
GetStyleSVG()->mStrokeDashoffset);
}

Просмотреть файл

@ -47,6 +47,7 @@
#include "nsSVGGeometryFrame.h"
#include "nsSVGGradientFrame.h"
#include "gfxContext.h"
#include "nsIDOMSVGRect.h"
//----------------------------------------------------------------------
// Implementation
@ -611,7 +612,7 @@ nsSVGLinearGradientFrame::GradientLookupAttribute(nsIAtom *aAtomName,
"Unknown gradientUnits type");
return element->mLengthAttributes[aEnumName].
GetAnimValue(NS_STATIC_CAST(nsSVGCoordCtxProvider*, nsnull));
GetAnimValue(NS_STATIC_CAST(nsSVGSVGElement*, nsnull));
}
cairo_pattern_t *
@ -691,7 +692,7 @@ nsSVGRadialGradientFrame::GradientLookupAttribute(nsIAtom *aAtomName,
"Unknown gradientUnits type");
return element->mLengthAttributes[aEnumName].
GetAnimValue(NS_STATIC_CAST(nsSVGCoordCtxProvider*, nsnull));
GetAnimValue(NS_STATIC_CAST(nsSVGSVGElement*, nsnull));
}
cairo_pattern_t *

Просмотреть файл

@ -87,14 +87,12 @@ public:
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect);
NS_IMETHOD InitialUpdate();
NS_IMETHOD NotifyCanvasTMChanged(PRBool suppressInvalidation);
NS_IMETHOD SetMatrixPropagation(PRBool aPropagate);
NS_IMETHOD SetOverrideCTM(nsIDOMSVGMatrix *aCTM);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);
// nsSVGContainerFrame methods:
virtual already_AddRefed<nsSVGCoordCtxProvider> GetCoordContextProvider();
virtual already_AddRefed<nsIDOMSVGMatrix> GetCanvasTM();
// nsISVGValueObserver
@ -113,8 +111,6 @@ public:
protected:
void UpdateCoordCtx();
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsCOMPtr<nsIDOMSVGMatrix> mOverrideCTM;
@ -138,16 +134,6 @@ nsSVGInnerSVGFrame::nsSVGInnerSVGFrame(nsStyleContext* aContext) :
#endif
}
void
nsSVGInnerSVGFrame::UpdateCoordCtx()
{
nsSVGContainerFrame *containerFrame = NS_STATIC_CAST(nsSVGContainerFrame*,
mParent);
nsSVGSVGElement *svgElement = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
svgElement->SetParentCoordCtxProvider(nsRefPtr<nsSVGCoordCtxProvider>(containerFrame->GetCoordContextProvider()));
}
//----------------------------------------------------------------------
// nsISupports methods
@ -210,20 +196,10 @@ nsSVGInnerSVGFrame::NotifyCanvasTMChanged(PRBool suppressInvalidation)
{
// make sure our cached transform matrix gets (lazily) updated
mCanvasTM = nsnull;
nsSVGSVGElement *svg = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
svg->InvalidateViewBoxToViewport();
return nsSVGInnerSVGFrameBase::NotifyCanvasTMChanged(suppressInvalidation);
}
NS_IMETHODIMP
nsSVGInnerSVGFrame::InitialUpdate()
{
UpdateCoordCtx();
return nsSVGInnerSVGFrameBase::InitialUpdate();
}
NS_IMETHODIMP
nsSVGInnerSVGFrame::SetMatrixPropagation(PRBool aPropagate)
{
@ -311,18 +287,6 @@ nsSVGInnerSVGFrame::NotifyViewportChange()
//----------------------------------------------------------------------
// nsSVGContainerFrame methods:
already_AddRefed<nsSVGCoordCtxProvider>
nsSVGInnerSVGFrame::GetCoordContextProvider()
{
NS_ASSERTION(mContent, "null parent");
// Our <svg> content element is the CoordContextProvider for our children:
nsSVGCoordCtxProvider *provider;
CallQueryInterface(mContent, &provider);
return provider;
}
already_AddRefed<nsIDOMSVGMatrix>
nsSVGInnerSVGFrame::GetCanvasTM()
{

Просмотреть файл

@ -307,7 +307,7 @@ nsSVGMarkerFrame::GetType() const
}
void
nsSVGMarkerFrame::SetParentCoordCtxProvider(nsSVGCoordCtxProvider *aContext)
nsSVGMarkerFrame::SetParentCoordCtxProvider(nsSVGSVGElement *aContext)
{
nsSVGMarkerElement *marker = NS_STATIC_CAST(nsSVGMarkerElement*, mContent);
marker->SetParentCoordCtxProvider(aContext);
@ -324,9 +324,8 @@ nsSVGMarkerFrame::AutoMarkerReferencer::AutoMarkerReferencer(
mFrame->mInUse = PR_TRUE;
mFrame->mMarkedFrame = aMarkedFrame;
nsRefPtr<nsSVGCoordCtxProvider> ctx =
nsSVGUtils::GetCoordContextProvider(NS_STATIC_CAST(nsSVGElement*,
aMarkedFrame->GetContent()));
nsSVGSVGElement *ctx =
NS_STATIC_CAST(nsSVGElement*, aMarkedFrame->GetContent())->GetCtx();
mFrame->SetParentCoordCtxProvider(ctx);
}

Просмотреть файл

@ -137,7 +137,7 @@ private:
};
// nsSVGMarkerFrame methods:
void SetParentCoordCtxProvider(nsSVGCoordCtxProvider *aContext);
void SetParentCoordCtxProvider(nsSVGSVGElement *aContext);
// recursion prevention flag
PRPackedBool mInUse;

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsSVGMaskElement.h"
#include "nsIDOMSVGMatrix.h"
#include "gfxContext.h"
#include "nsIDOMSVGRect.h"
//----------------------------------------------------------------------
// Implementation

Просмотреть файл

@ -159,16 +159,8 @@ nsSVGOuterSVGFrame::nsSVGOuterSVGFrame(nsStyleContext* aContext)
NS_IMETHODIMP
nsSVGOuterSVGFrame::InitSVG()
{
nsresult rv;
// we are an *outer* svg element, so this frame will become the
// coordinate context for our content element:
float mmPerPx = 25.4f / GetPresContext()->AppUnitsToDevPixels(GetPresContext()->AppUnitsPerInch());
SetCoordCtxMMPerPx(mmPerPx, mmPerPx);
nsCOMPtr<nsISVGSVGElement> SVGElement = do_QueryInterface(mContent);
NS_ASSERTION(SVGElement, "wrong content element");
SVGElement->SetParentCoordCtxProvider(this);
nsIDocument* doc = mContent->GetCurrentDoc();
if (doc) {
@ -196,7 +188,6 @@ nsSVGOuterSVGFrame::InitSVG()
NS_INTERFACE_MAP_BEGIN(nsSVGOuterSVGFrame)
NS_INTERFACE_MAP_ENTRY(nsISVGSVGFrame)
NS_INTERFACE_MAP_ENTRY(nsSVGCoordCtxProvider)
NS_INTERFACE_MAP_END_INHERITING(nsSVGOuterSVGFrameBase)
//----------------------------------------------------------------------
@ -253,7 +244,10 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
nsCOMPtr<nsIDOMSVGRect> r;
NS_NewSVGRect(getter_AddRefs(r), 0, 0, preferredWidth, preferredHeight);
SetCoordCtxRect(r);
nsSVGSVGElement *svgElem = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
NS_ENSURE_TRUE(svgElem, NS_ERROR_FAILURE);
svgElem->SetCoordCtxRect(r);
#ifdef DEBUG
// some debug stuff:
@ -287,14 +281,11 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
// Let's work out our desired dimensions.
nsSVGSVGElement *svg = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
svg->SetParentCoordCtxProvider(this);
float width =
svg->mLengthAttributes[nsSVGSVGElement::WIDTH].GetAnimValue(this);
float height =
svg->mLengthAttributes[nsSVGSVGElement::HEIGHT].GetAnimValue(this);
aDesiredSize.width = nsPresContext::CSSPixelsToAppUnits(width);
aDesiredSize.height = nsPresContext::CSSPixelsToAppUnits(height);
aDesiredSize.width =
nsPresContext::CSSPixelsToAppUnits(svg->mViewportWidth);
aDesiredSize.height =
nsPresContext::CSSPixelsToAppUnits(svg->mViewportHeight);
// XXX add in CSS borders ??
@ -303,7 +294,6 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
// tell our element that the viewbox to viewport transform needs refreshing,
// and set us up to draw
svg->InvalidateViewBoxToViewport();
NotifyViewportChange();
UnsuspendRedraw();
@ -386,6 +376,22 @@ nsDisplaySVG::Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
Paint(*aCtx, aDirtyRect, aBuilder->ToReferenceFrame(mFrame));
}
NS_IMETHODIMP
nsSVGOuterSVGFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
if (aNameSpaceID == kNameSpaceID_None &&
!(GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
(aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height)) {
AddStateBits(NS_FRAME_IS_DIRTY);
GetPresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eStyleChange);
}
return NS_OK;
}
nsIFrame*
nsSVGOuterSVGFrame::GetFrameForPoint(const nsPoint& aPoint)
{
@ -628,18 +634,6 @@ nsSVGOuterSVGFrame::GetCanvasTM()
return retval;
}
already_AddRefed<nsSVGCoordCtxProvider>
nsSVGOuterSVGFrame::GetCoordContextProvider()
{
NS_ASSERTION(mContent, "null parent");
// Our <svg> content element is the CoordContextProvider for our children:
nsSVGCoordCtxProvider *provider;
CallQueryInterface(mContent, &provider);
return provider;
}
//----------------------------------------------------------------------
// Implementation helpers

Просмотреть файл

@ -41,7 +41,6 @@
#include "nsSVGContainerFrame.h"
#include "nsISVGSVGFrame.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsISVGEnum.h"
#include "nsIDOMSVGPoint.h"
#include "nsIDOMSVGNumber.h"
@ -52,8 +51,7 @@
typedef nsSVGDisplayContainerFrame nsSVGOuterSVGFrameBase;
class nsSVGOuterSVGFrame : public nsSVGOuterSVGFrameBase,
public nsISVGSVGFrame,
public nsSVGCoordCtxProvider
public nsISVGSVGFrame
{
friend nsIFrame*
NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
@ -81,10 +79,6 @@ public:
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
// We don't define an AttributeChanged method since changes to the
// 'x', 'y', 'width' and 'height' attributes of our content object
// are handled in nsSVGSVGElement::DidModifySVGObservable
nsIFrame* GetFrameForPoint(const nsPoint& aPoint);
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
@ -108,6 +102,10 @@ public:
}
#endif
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);
// nsSVGOuterSVGFrame methods:
/* Invalidate takes a nsRect in screen pixel coordinates */
@ -121,7 +119,6 @@ public:
// nsSVGContainerFrame methods:
virtual already_AddRefed<nsIDOMSVGMatrix> GetCanvasTM();
virtual already_AddRefed<nsSVGCoordCtxProvider> GetCoordContextProvider();
protected:
// implementation helpers:

Просмотреть файл

@ -627,7 +627,7 @@ nsSVGPatternFrame::GetPatternRect(nsIDOMSVGRect **patternRect,
static float
GetLengthValue(nsSVGLength2 *aLength)
{
return aLength->GetAnimValue(NS_STATIC_CAST(nsSVGCoordCtxProvider*, nsnull));
return aLength->GetAnimValue(NS_STATIC_CAST(nsSVGSVGElement*, nsnull));
}
nsresult

Просмотреть файл

@ -113,7 +113,8 @@ nsSVGTextPathFrame::Init(nsIContent* aContent,
if (!mStartOffset)
return NS_ERROR_FAILURE;
NS_NewSVGLengthList(getter_AddRefs(mX));
NS_NewSVGLengthList(getter_AddRefs(mX),
NS_STATIC_CAST(nsSVGElement*, mContent));
if (mX) {
nsCOMPtr<nsIDOMSVGLength> length;
mX->AppendItem(mStartOffset, getter_AddRefs(length));
@ -141,7 +142,7 @@ nsSVGTextPathFrame::GetType() const
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextPathFrame::GetX()
{
nsISVGLengthList *retval = mX;
nsIDOMSVGLengthList *retval = mX;
NS_IF_ADDREF(retval);
return retval;
}

Просмотреть файл

@ -107,7 +107,7 @@ private:
nsCOMPtr<nsIDOMSVGAnimatedString> mHref;
nsCOMPtr<nsIDOMSVGPathSegList> mSegments;
nsCOMPtr<nsISVGLengthList> mX;
nsCOMPtr<nsIDOMSVGLengthList> mX;
};
#endif

Просмотреть файл

@ -40,7 +40,7 @@
#include "nsIDOMSVGSVGElement.h"
#include "nsStyleCoord.h"
#include "nsPresContext.h"
#include "nsSVGCoordCtxProvider.h"
#include "nsSVGSVGElement.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIFrame.h"
@ -403,8 +403,9 @@ nsSVGUtils::ReportToConsole(nsIDocument* doc,
}
float
nsSVGUtils::CoordToFloat(nsPresContext *aPresContext, nsIContent *aContent,
const nsStyleCoord &aCoord)
nsSVGUtils::CoordToFloat(nsPresContext *aPresContext,
nsSVGElement *aContent,
const nsStyleCoord &aCoord)
{
float val = 0.0f;
@ -419,19 +420,19 @@ nsSVGUtils::CoordToFloat(nsPresContext *aPresContext, nsIContent *aContent,
break;
case eStyleUnit_Percent: {
nsCOMPtr<nsIDOMSVGElement> element = do_QueryInterface(aContent);
nsCOMPtr<nsIDOMSVGSVGElement> owner;
element->GetOwnerSVGElement(getter_AddRefs(owner));
nsCOMPtr<nsSVGCoordCtxProvider> ctx = do_QueryInterface(owner);
nsSVGSVGElement *ctx = aContent->GetCtx();
nsCOMPtr<nsISVGLength> length;
NS_NewSVGLength(getter_AddRefs(length), aCoord.GetPercentValue() * 100.0f,
NS_NewSVGLength(getter_AddRefs(length),
aCoord.GetPercentValue() * 100.0f,
nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
if (!ctx || !length)
break;
length->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextUnspecified()));
nsWeakPtr weakCtx =
do_GetWeakReference(NS_STATIC_CAST(nsGenericElement*, ctx));
length->SetContext(weakCtx, nsSVGUtils::XY);
length->GetValue(&val);
break;
}
@ -559,7 +560,7 @@ nsSVGUtils::ObjectSpace(nsIDOMSVGRect *aRect, nsSVGLength2 *aLength)
nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE) {
fraction = aLength->GetAnimValInSpecifiedUnits() / 100;
} else
fraction = aLength->GetAnimValue(NS_STATIC_CAST(nsSVGCoordCtxProvider*,
fraction = aLength->GetAnimValue(NS_STATIC_CAST(nsSVGSVGElement*,
nsnull));
return fraction * axis;
@ -1084,22 +1085,6 @@ nsSVGUtils::HitTestChildren(nsIFrame *aFrame, float x, float y,
*aResult = nsnull;
}
already_AddRefed<nsSVGCoordCtxProvider>
nsSVGUtils::GetCoordContextProvider(nsSVGElement *aElement)
{
nsCOMPtr<nsIDOMSVGSVGElement> owner;
nsresult rv = aElement->GetOwnerSVGElement(getter_AddRefs(owner));
// GetOwnerSVGElement can fail during teardown
if (NS_FAILED(rv) || !owner)
return nsnull;
nsSVGCoordCtxProvider *ctx;
CallQueryInterface(owner, &ctx);
return ctx;
}
nsRect
nsSVGUtils::GetCoveredRegion(const nsFrameList &aFrames)
{

Просмотреть файл

@ -65,7 +65,7 @@ class nsISVGValueObserver;
class nsIAtom;
class nsSVGLength2;
class nsSVGElement;
class nsSVGCoordCtxProvider;
class nsSVGSVGElement;
class nsAttrValue;
class gfxContext;
class gfxASurface;
@ -182,7 +182,8 @@ public:
* Factor (straight userspace), Coord (dimensioned), and Percent (of
* the current SVG viewport)
*/
static float CoordToFloat(nsPresContext *aPresContext, nsIContent *aContent,
static float CoordToFloat(nsPresContext *aPresContext,
nsSVGElement *aContent,
const nsStyleCoord &aCoord);
/*
* Gets an internal frame for an element referenced by a URI. Note that this
@ -277,12 +278,6 @@ public:
*/
static already_AddRefed<nsIDOMSVGMatrix> GetCanvasTM(nsIFrame *aFrame);
/*
* Get element's coordinate context provider.
*/
static already_AddRefed<nsSVGCoordCtxProvider>
GetCoordContextProvider(nsSVGElement *aElement);
/*
* Get frame's covered region by walking the children and doing union.
*/