Skip to content

Commit

Permalink
Bug 837036 - Remove SVGLocatableElement and SVGTransformableElement I…
Browse files Browse the repository at this point in the history
…DL r=longsonr
  • Loading branch information
dzbarsky committed Feb 1, 2013
1 parent 3ae6821 commit a45c511
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 237 deletions.
2 changes: 0 additions & 2 deletions content/svg/content/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ CPPSRCS = \
SVGLengthList.cpp \
SVGLengthListSMILType.cpp \
SVGLineElement.cpp \
SVGLocatableElement.cpp \
SVGMarkerElement.cpp \
SVGMaskElement.cpp \
SVGMatrix.cpp \
Expand Down Expand Up @@ -176,7 +175,6 @@ EXPORTS_mozilla/dom = \
SVGGraphicsElement.h \
SVGImageElement.h \
SVGLineElement.h \
SVGLocatableElement.h \
SVGMarkerElement.h \
SVGMaskElement.h \
SVGMatrix.h \
Expand Down
1 change: 0 additions & 1 deletion content/svg/content/src/SVGGraphicsElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/dom/SVGGraphicsElement.h"
#include "mozilla/dom/SVGGraphicsElementBinding.h"

namespace mozilla {
namespace dom {
Expand Down
109 changes: 0 additions & 109 deletions content/svg/content/src/SVGLocatableElement.cpp

This file was deleted.

49 changes: 0 additions & 49 deletions content/svg/content/src/SVGLocatableElement.h

This file was deleted.

95 changes: 86 additions & 9 deletions content/svg/content/src/SVGTransformableElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/dom/SVGTransformableElement.h"
#include "mozilla/dom/SVGMatrix.h"
#include "mozilla/dom/SVGSVGElement.h"
#include "DOMSVGAnimatedTransformList.h"
#include "nsContentUtils.h"
#include "nsIDOMMutationEvent.h"
#include "nsIFrame.h"
#include "nsISVGChildFrame.h"
#include "nsSVGRect.h"
#include "nsSVGUtils.h"
#include "nsContentUtils.h"
#include "SVGContentUtils.h"

namespace mozilla {
namespace dom {

//----------------------------------------------------------------------
// nsISupports methods

NS_IMPL_ADDREF_INHERITED(SVGTransformableElement, SVGLocatableElement)
NS_IMPL_RELEASE_INHERITED(SVGTransformableElement, SVGLocatableElement)

NS_INTERFACE_MAP_BEGIN(SVGTransformableElement)
NS_INTERFACE_MAP_ENTRY(mozilla::dom::SVGTransformableElement)
NS_INTERFACE_MAP_END_INHERITING(SVGLocatableElement)
NS_IMPL_ISUPPORTS_INHERITED0(SVGTransformableElement, nsSVGElement)

already_AddRefed<DOMSVGAnimatedTransformList>
SVGTransformableElement::Transform()
Expand All @@ -46,15 +46,15 @@ SVGTransformableElement::IsAttributeMapped(const nsIAtom* name) const
};

return FindAttributeDependence(name, map) ||
SVGLocatableElement::IsAttributeMapped(name);
nsSVGElement::IsAttributeMapped(name);
}

nsChangeHint
SVGTransformableElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
int32_t aModType) const
{
nsChangeHint retval =
SVGLocatableElement::GetAttributeChangeHint(aAttribute, aModType);
nsSVGElement::GetAttributeChangeHint(aAttribute, aModType);
if (aAttribute == nsGkAtoms::transform ||
aAttribute == nsGkAtoms::mozAnimateMotionDummyAttr) {
// We add nsChangeHint_UpdateOverflow so that nsFrame::UpdateOverflow()
Expand Down Expand Up @@ -148,6 +148,83 @@ SVGTransformableElement::GetAnimatedTransformList(uint32_t aFlags)
return mTransforms;
}

nsSVGElement*
SVGTransformableElement::GetNearestViewportElement()
{
return SVGContentUtils::GetNearestViewportElement(this);
}

nsSVGElement*
SVGTransformableElement::GetFarthestViewportElement()
{
return SVGContentUtils::GetOuterSVGElement(this);
}

already_AddRefed<nsIDOMSVGRect>
SVGTransformableElement::GetBBox(ErrorResult& rv)
{
nsIFrame* frame = GetPrimaryFrame(Flush_Layout);

if (!frame || (frame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
rv.Throw(NS_ERROR_FAILURE);
return nullptr;
}

nsISVGChildFrame* svgframe = do_QueryFrame(frame);
if (!svgframe) {
rv.Throw(NS_ERROR_NOT_IMPLEMENTED); // XXX: outer svg
return nullptr;
}

nsCOMPtr<nsIDOMSVGRect> rect;
rv = NS_NewSVGRect(getter_AddRefs(rect), nsSVGUtils::GetBBox(frame));
return rect.forget();
}

already_AddRefed<SVGMatrix>
SVGTransformableElement::GetCTM()
{
nsIDocument* currentDoc = GetCurrentDoc();
if (currentDoc) {
// Flush all pending notifications so that our frames are up to date
currentDoc->FlushPendingNotifications(Flush_Layout);
}
gfxMatrix m = SVGContentUtils::GetCTM(this, false);
nsCOMPtr<SVGMatrix> mat = m.IsSingular() ? nullptr : new SVGMatrix(m);
return mat.forget();
}

already_AddRefed<SVGMatrix>
SVGTransformableElement::GetScreenCTM()
{
nsIDocument* currentDoc = GetCurrentDoc();
if (currentDoc) {
// Flush all pending notifications so that our frames are up to date
currentDoc->FlushPendingNotifications(Flush_Layout);
}
gfxMatrix m = SVGContentUtils::GetCTM(this, true);
nsCOMPtr<SVGMatrix> mat = m.IsSingular() ? nullptr : new SVGMatrix(m);
return mat.forget();
}

already_AddRefed<SVGMatrix>
SVGTransformableElement::GetTransformToElement(SVGGraphicsElement& aElement,
ErrorResult& rv)
{
// the easiest way to do this (if likely to increase rounding error):
nsCOMPtr<SVGMatrix> ourScreenCTM = GetScreenCTM();
nsCOMPtr<SVGMatrix> targetScreenCTM = aElement.GetScreenCTM();
if (!ourScreenCTM || !targetScreenCTM) {
rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
nsCOMPtr<SVGMatrix> tmp = targetScreenCTM->Inverse(rv);
if (rv.Failed()) return nullptr;

nsCOMPtr<SVGMatrix> mat = tmp->Multiply(*ourScreenCTM).get();
return mat.forget();
}

} // namespace dom
} // namespace mozilla

25 changes: 15 additions & 10 deletions content/svg/content/src/SVGTransformableElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,38 @@
#ifndef SVGTransformableElement_h
#define SVGTransformableElement_h

#include "mozilla/dom/SVGLocatableElement.h"
#include "nsSVGElement.h"
#include "gfxMatrix.h"
#include "SVGAnimatedTransformList.h"

#define MOZILLA_SVGTRANSFORMABLEELEMENT_IID \
{ 0x77888cba, 0x0b43, 0x4654, \
{0x96, 0x3c, 0xf5, 0x50, 0xfc, 0xb5, 0x5e, 0x32}}
class nsIDOMSVGRect;

namespace mozilla {
class DOMSVGAnimatedTransformList;

namespace dom {
class SVGTransformableElement : public SVGLocatableElement

class SVGGraphicsElement;
class SVGMatrix;

class SVGTransformableElement : public nsSVGElement
{
public:
SVGTransformableElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGLocatableElement(aNodeInfo) {}
: nsSVGElement(aNodeInfo) {}
virtual ~SVGTransformableElement() {}

NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_SVGTRANSFORMABLEELEMENT_IID)
NS_DECL_ISUPPORTS_INHERITED

// WebIDL
already_AddRefed<DOMSVGAnimatedTransformList> Transform();
nsSVGElement* GetNearestViewportElement();
nsSVGElement* GetFarthestViewportElement();
already_AddRefed<nsIDOMSVGRect> GetBBox(ErrorResult& rv);
already_AddRefed<SVGMatrix> GetCTM();
already_AddRefed<SVGMatrix> GetScreenCTM();
already_AddRefed<SVGMatrix> GetTransformToElement(SVGGraphicsElement& aElement,
ErrorResult& rv);

// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
Expand Down Expand Up @@ -61,9 +69,6 @@ class SVGTransformableElement : public SVGLocatableElement
nsAutoPtr<gfxMatrix> mAnimateMotionTransform;
};

NS_DEFINE_STATIC_IID_ACCESSOR(SVGTransformableElement,
MOZILLA_SVGTRANSFORMABLEELEMENT_IID)

} // namespace dom
} // namespace mozilla

Expand Down
Loading

0 comments on commit a45c511

Please sign in to comment.