2001-12-12 07:59:31 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2012-03-26 11:58:59 +00:00
|
|
|
// Main header first:
|
2004-11-23 13:51:57 +00:00
|
|
|
#include "nsSVGGFrame.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
|
|
|
|
// Keep others in (case-insensitive) order:
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2013-01-16 20:51:00 +00:00
|
|
|
#include "SVGTransformableElement.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
#include "nsIFrame.h"
|
2013-01-03 06:17:03 +00:00
|
|
|
#include "SVGGraphicsElement.h"
|
2012-06-30 11:20:46 +00:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
#include "nsSVGUtils.h"
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-01-03 06:17:03 +00:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2005-11-11 02:36:29 +00:00
|
|
|
nsIFrame*
|
2009-01-19 18:31:34 +00:00
|
|
|
NS_NewSVGGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2016-04-18 07:08:01 +00:00
|
|
|
{
|
2009-01-19 18:31:34 +00:00
|
|
|
return new (aPresShell) nsSVGGFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGGFrame)
|
|
|
|
|
2009-01-19 18:31:34 +00:00
|
|
|
#ifdef DEBUG
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2014-05-24 22:20:40 +00:00
|
|
|
nsSVGGFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2009-01-19 18:31:34 +00:00
|
|
|
{
|
2015-03-03 11:08:59 +00:00
|
|
|
NS_ASSERTION(aContent->IsSVGElement() &&
|
2013-03-28 01:23:09 +00:00
|
|
|
static_cast<nsSVGElement*>(aContent)->IsTransformable(),
|
2013-03-20 16:50:36 +00:00
|
|
|
"The element doesn't support nsIDOMSVGTransformable");
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2016-04-18 07:08:01 +00:00
|
|
|
nsSVGDisplayContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
2009-01-19 18:31:34 +00:00
|
|
|
#endif /* DEBUG */
|
2001-12-12 07:59:31 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-02-09 18:24:31 +00:00
|
|
|
// nsSVGDisplayableFrame methods
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2008-01-25 09:27:03 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGGFrame::NotifySVGChanged(uint32_t aFlags)
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
|
|
|
|
"Invalidation logic may need adjusting");
|
2012-03-11 15:53:36 +00:00
|
|
|
|
2008-01-25 09:27:03 +00:00
|
|
|
if (aFlags & TRANSFORM_CHANGED) {
|
|
|
|
// make sure our cached transform matrix gets (lazily) updated
|
2012-07-30 14:20:58 +00:00
|
|
|
mCanvasTM = nullptr;
|
2008-01-25 09:27:03 +00:00
|
|
|
}
|
2004-11-19 22:52:15 +00:00
|
|
|
|
2016-04-18 07:08:01 +00:00
|
|
|
nsSVGDisplayContainerFrame::NotifySVGChanged(aFlags);
|
2004-12-24 16:26:10 +00:00
|
|
|
}
|
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
gfxMatrix
|
2014-09-08 11:28:50 +00:00
|
|
|
nsSVGGFrame::GetCanvasTM()
|
2004-12-24 16:26:10 +00:00
|
|
|
{
|
2006-06-01 15:31:15 +00:00
|
|
|
if (!mCanvasTM) {
|
2014-05-24 22:20:41 +00:00
|
|
|
NS_ASSERTION(GetParent(), "null parent");
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2014-05-24 22:20:41 +00:00
|
|
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(GetParent());
|
2017-08-26 22:58:38 +00:00
|
|
|
SVGGraphicsElement *content = static_cast<SVGGraphicsElement*>(GetContent());
|
2014-09-08 11:28:50 +00:00
|
|
|
|
|
|
|
gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM());
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2013-12-26 20:13:57 +00:00
|
|
|
mCanvasTM = new gfxMatrix(tm);
|
2009-04-29 04:31:34 +00:00
|
|
|
}
|
2011-09-25 21:04:32 +00:00
|
|
|
return *mCanvasTM;
|
2004-12-24 16:26:10 +00:00
|
|
|
}
|
2005-09-06 22:30:40 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGGFrame::AttributeChanged(int32_t aNameSpaceID,
|
2006-06-01 15:31:15 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aModType)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::transform) {
|
2013-05-23 07:04:21 +00: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 13:58:17 +00:00
|
|
|
NotifySVGChanged(TRANSFORM_CHANGED);
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
2016-04-18 07:08:01 +00:00
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|