2007-02-22 15:38:12 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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-02-22 15:38:12 +03:00
|
|
|
|
2012-03-26 15:58:59 +04:00
|
|
|
// Keep in (case-insensitive) order:
|
|
|
|
#include "gfxMatrix.h"
|
2013-01-10 09:30:13 +04:00
|
|
|
#include "mozilla/dom/SVGAElement.h"
|
2013-11-18 18:29:53 +04:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-06-30 15:20:46 +04:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2007-02-22 15:38:12 +03:00
|
|
|
#include "nsSVGUtils.h"
|
2010-07-17 01:42:12 +04:00
|
|
|
#include "SVGLengthList.h"
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2010-07-17 01:42:12 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-11-18 18:29:53 +04:00
|
|
|
typedef nsSVGDisplayContainerFrame nsSVGAFrameBase;
|
2007-02-22 15:38:12 +03:00
|
|
|
|
|
|
|
class nsSVGAFrame : public nsSVGAFrameBase
|
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-02-22 15:38:12 +03:00
|
|
|
protected:
|
|
|
|
nsSVGAFrame(nsStyleContext* aContext) :
|
|
|
|
nsSVGAFrameBase(aContext) {}
|
|
|
|
|
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
2013-03-20 05:47:48 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2009-01-19 21:31:34 +03:00
|
|
|
#endif
|
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
// nsIFrame:
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2007-02-22 15:38:12 +03:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType);
|
2007-02-22 15:38:12 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgAFrame
|
|
|
|
*/
|
|
|
|
virtual nsIAtom* GetType() const;
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGA"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// nsISVGChildFrame interface:
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void NotifySVGChanged(uint32_t aFlags);
|
2007-02-22 15:38:12 +03:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2013-09-11 11:27:45 +04:00
|
|
|
virtual gfxMatrix GetCanvasTM(uint32_t aFor,
|
|
|
|
nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
|
2010-07-17 01:42:12 +04:00
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
private:
|
2011-09-26 01:04:32 +04:00
|
|
|
nsAutoPtr<gfxMatrix> mCanvasTM;
|
2007-02-22 15:38:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
nsIFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
|
|
|
return new (aPresShell) nsSVGAFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGAFrame)
|
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2009-01-19 21:31:34 +03:00
|
|
|
nsSVGAFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2013-01-08 07:22:41 +04:00
|
|
|
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::a),
|
2009-01-19 21:31:34 +03:00
|
|
|
"Trying to construct an SVGAFrame for a "
|
|
|
|
"content element that doesn't support the right interfaces");
|
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
nsSVGAFrameBase::Init(aContent, aParent, aPrevInFlow);
|
2009-01-19 21:31:34 +03:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGAFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-02-22 15:38:12 +03:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
2012-01-28 17:58:17 +04:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::transform) {
|
2013-05-23 11:04:21 +04: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 17:58:17 +04:00
|
|
|
NotifySVGChanged(TRANSFORM_CHANGED);
|
2007-02-22 15:38:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom *
|
|
|
|
nsSVGAFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::svgAFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGChildFrame methods
|
|
|
|
|
2008-01-25 12:27:03 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGAFrame::NotifySVGChanged(uint32_t aFlags)
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
2012-03-11 19:53:36 +04:00
|
|
|
NS_ABORT_IF_FALSE(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
|
|
|
|
"Invalidation logic may need adjusting");
|
|
|
|
|
2008-01-25 12:27:03 +03:00
|
|
|
if (aFlags & TRANSFORM_CHANGED) {
|
|
|
|
// make sure our cached transform matrix gets (lazily) updated
|
2012-07-30 18:20:58 +04:00
|
|
|
mCanvasTM = nullptr;
|
2008-01-25 12:27:03 +03:00
|
|
|
}
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2008-01-25 12:27:03 +03:00
|
|
|
nsSVGAFrameBase::NotifySVGChanged(aFlags);
|
2007-02-22 15:38:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGContainerFrame methods:
|
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
gfxMatrix
|
2013-09-11 11:27:45 +04:00
|
|
|
nsSVGAFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot)
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
2013-09-11 11:27:45 +04:00
|
|
|
if (!(GetStateBits() & NS_FRAME_IS_NONDISPLAY) && !aTransformRoot) {
|
2012-06-30 15:20:46 +04:00
|
|
|
if ((aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) ||
|
|
|
|
(aFor == FOR_HIT_TESTING && NS_SVGDisplayListHitTestingEnabled())) {
|
|
|
|
return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this);
|
|
|
|
}
|
|
|
|
}
|
2007-02-22 15:38:12 +03:00
|
|
|
if (!mCanvasTM) {
|
|
|
|
NS_ASSERTION(mParent, "null parent");
|
2009-04-29 08:31:34 +04:00
|
|
|
|
|
|
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
2013-01-10 09:30:13 +04:00
|
|
|
dom::SVGAElement *content = static_cast<dom::SVGAElement*>(mContent);
|
2009-04-29 08:31:34 +04:00
|
|
|
|
2013-12-27 00:13:57 +04:00
|
|
|
gfxMatrix tm = content->PrependLocalTransformsTo(
|
|
|
|
this == aTransformRoot ? gfxMatrix() :
|
|
|
|
parent->GetCanvasTM(aFor, aTransformRoot));
|
2009-04-29 08:31:34 +04:00
|
|
|
|
2013-12-27 00:13:57 +04:00
|
|
|
mCanvasTM = new gfxMatrix(tm);
|
2007-02-22 15:38:12 +03:00
|
|
|
}
|
|
|
|
|
2011-09-26 01:04:32 +04:00
|
|
|
return *mCanvasTM;
|
2007-02-22 15:38:12 +03:00
|
|
|
}
|