2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-26 04:58:59 -07:00
|
|
|
// Keep in (case-insensitive) order:
|
|
|
|
#include "gfxMatrix.h"
|
2013-01-09 21:30:13 -08:00
|
|
|
#include "mozilla/dom/SVGAElement.h"
|
2013-11-18 06:29:53 -08:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-06-30 04:20:46 -07:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGUtils.h"
|
2010-07-16 14:42:12 -07:00
|
|
|
#include "SVGLengthList.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-16 14:42:12 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-11-18 06:29:53 -08:00
|
|
|
typedef nsSVGDisplayContainerFrame nsSVGAFrameBase;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsSVGAFrame : public nsSVGAFrameBase
|
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 10:31:34 -08:00
|
|
|
NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit nsSVGAFrame(nsStyleContext* aContext) :
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSVGAFrameBase(aContext) {}
|
|
|
|
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2009-01-19 10:31:34 -08:00
|
|
|
#ifdef DEBUG
|
2014-05-24 15:20:40 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2009-01-19 10:31:34 -08:00
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIFrame:
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIAtom* aAttribute,
|
2015-03-21 09:28:04 -07:00
|
|
|
int32_t aModType) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgAFrame
|
|
|
|
*/
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGA"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// nsISVGChildFrame interface:
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void NotifySVGChanged(uint32_t aFlags) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
2010-07-16 14:42:12 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2011-09-25 14:04:32 -07:00
|
|
|
nsAutoPtr<gfxMatrix> mCanvasTM;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
nsIFrame*
|
2009-01-19 10:31:34 -08:00
|
|
|
NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return new (aPresShell) nsSVGAFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGAFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
2009-01-19 10:31:34 -08:00
|
|
|
#ifdef DEBUG
|
2013-03-19 18:47:48 -07:00
|
|
|
void
|
2014-05-24 15:20:40 -07:00
|
|
|
nsSVGAFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2009-01-19 10:31:34 -08:00
|
|
|
{
|
2015-03-03 03:08:59 -08:00
|
|
|
NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::a),
|
2009-01-19 10:31:34 -08:00
|
|
|
"Trying to construct an SVGAFrame for a "
|
|
|
|
"content element that doesn't support the right interfaces");
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
nsSVGAFrameBase::Init(aContent, aParent, aPrevInFlow);
|
2009-01-19 10:31:34 -08:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSVGAFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-28 05:58:17 -08:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::transform) {
|
2013-05-23 00:04:21 -07:00
|
|
|
// We don't invalidate for transform changes (the layers code does that).
|
|
|
|
// Also note that SVGTransformableElement::GetAttributeChangeHint will
|
|
|
|
// return nsChangeHint_UpdateOverflow for "transform" attribute changes
|
|
|
|
// and cause DoApplyRenderingChangeToTree to make the SchedulePaint call.
|
2012-01-28 05:58:17 -08:00
|
|
|
NotifySVGChanged(TRANSFORM_CHANGED);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom *
|
|
|
|
nsSVGAFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::svgAFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGChildFrame methods
|
|
|
|
|
2008-01-25 01:27:03 -08:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSVGAFrame::NotifySVGChanged(uint32_t aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
|
|
|
|
"Invalidation logic may need adjusting");
|
2012-03-11 08:53:36 -07:00
|
|
|
|
2008-01-25 01:27:03 -08:00
|
|
|
if (aFlags & TRANSFORM_CHANGED) {
|
|
|
|
// make sure our cached transform matrix gets (lazily) updated
|
2012-07-30 07:20:58 -07:00
|
|
|
mCanvasTM = nullptr;
|
2008-01-25 01:27:03 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-25 01:27:03 -08:00
|
|
|
nsSVGAFrameBase::NotifySVGChanged(aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGContainerFrame methods:
|
|
|
|
|
2009-04-28 21:31:34 -07:00
|
|
|
gfxMatrix
|
2014-09-08 04:28:50 -07:00
|
|
|
nsSVGAFrame::GetCanvasTM()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (!mCanvasTM) {
|
2014-05-24 15:20:41 -07:00
|
|
|
NS_ASSERTION(GetParent(), "null parent");
|
2009-04-28 21:31:34 -07:00
|
|
|
|
2014-05-24 15:20:41 -07:00
|
|
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(GetParent());
|
2013-01-09 21:30:13 -08:00
|
|
|
dom::SVGAElement *content = static_cast<dom::SVGAElement*>(mContent);
|
2009-04-28 21:31:34 -07:00
|
|
|
|
2014-09-08 04:28:50 -07:00
|
|
|
gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM());
|
2009-04-28 21:31:34 -07:00
|
|
|
|
2013-12-26 12:13:57 -08:00
|
|
|
mCanvasTM = new gfxMatrix(tm);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-25 14:04:32 -07:00
|
|
|
return *mCanvasTM;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|