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)
|
2005-11-11 02:36:29 +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
|
2009-01-19 18:31:34 +00:00
|
|
|
nsSVGGFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2013-03-28 01:23:09 +00:00
|
|
|
NS_ASSERTION(aContent->IsSVG() &&
|
|
|
|
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
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
nsSVGGFrameBase::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
|
|
|
|
2005-04-01 19:56:08 +00:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGGFrame::GetType() const
|
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::svgGFrame;
|
2005-04-01 19:56:08 +00:00
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
// nsISVGChildFrame 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
|
|
|
{
|
2012-03-11 15:53:36 +00:00
|
|
|
NS_ABORT_IF_FALSE(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
|
|
|
|
"Invalidation logic may need adjusting");
|
|
|
|
|
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
|
|
|
|
2008-01-25 09:27:03 +00:00
|
|
|
nsSVGGFrameBase::NotifySVGChanged(aFlags);
|
2004-12-24 16:26:10 +00:00
|
|
|
}
|
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
gfxMatrix
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGGFrame::GetCanvasTM(uint32_t aFor)
|
2004-12-24 16:26:10 +00:00
|
|
|
{
|
2013-07-12 07:13:07 +00:00
|
|
|
if (!(GetStateBits() & NS_FRAME_IS_NONDISPLAY)) {
|
2012-06-30 11:20:46 +00:00
|
|
|
if ((aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) ||
|
|
|
|
(aFor == FOR_HIT_TESTING && NS_SVGDisplayListHitTestingEnabled())) {
|
|
|
|
return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this);
|
|
|
|
}
|
|
|
|
}
|
2006-06-01 15:31:15 +00:00
|
|
|
if (!mCanvasTM) {
|
|
|
|
NS_ASSERTION(mParent, "null parent");
|
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
2013-01-03 06:17:03 +00:00
|
|
|
SVGGraphicsElement *content = static_cast<SVGGraphicsElement*>(mContent);
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2012-06-30 11:20:46 +00:00
|
|
|
gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM(aFor));
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2011-09-25 21:04:32 +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
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
NS_IMETHODIMP
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|