2001-12-12 10:59:31 +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/. */
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2012-03-26 15:58:59 +04:00
|
|
|
// Main header first:
|
2004-11-23 16:51:57 +03:00
|
|
|
#include "nsSVGGFrame.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
|
|
|
|
// Keep others in (case-insensitive) order:
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2013-01-17 00:51:00 +04:00
|
|
|
#include "SVGTransformableElement.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsIFrame.h"
|
2013-01-03 10:17:03 +04:00
|
|
|
#include "SVGGraphicsElement.h"
|
2012-06-30 15:20:46 +04:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsSVGUtils.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2013-01-03 10:17:03 +04:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2005-11-11 05:36:29 +03:00
|
|
|
nsIFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2005-11-11 05:36:29 +03:00
|
|
|
{
|
2009-01-19 21:31:34 +03:00
|
|
|
return new (aPresShell) nsSVGGFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGGFrame)
|
|
|
|
|
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
|
|
|
nsSVGGFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2013-03-28 05:23:09 +04:00
|
|
|
NS_ASSERTION(aContent->IsSVG() &&
|
|
|
|
static_cast<nsSVGElement*>(aContent)->IsTransformable(),
|
2013-03-20 20:50:36 +04:00
|
|
|
"The element doesn't support nsIDOMSVGTransformable");
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
nsSVGGFrameBase::Init(aContent, aParent, aPrevInFlow);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
2009-01-19 21:31:34 +03:00
|
|
|
#endif /* DEBUG */
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2005-04-01 23:56:08 +04:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGGFrame::GetType() const
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::svgGFrame;
|
2005-04-01 23:56:08 +04:00
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03: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 15:39:26 +03:00
|
|
|
// nsISVGChildFrame methods
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2008-01-25 12:27:03 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGGFrame::NotifySVGChanged(uint32_t aFlags)
|
2001-12-12 10:59:31 +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
|
|
|
}
|
2004-11-20 01:52:15 +03:00
|
|
|
|
2008-01-25 12:27:03 +03:00
|
|
|
nsSVGGFrameBase::NotifySVGChanged(aFlags);
|
2004-12-24 19:26:10 +03:00
|
|
|
}
|
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
gfxMatrix
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGGFrame::GetCanvasTM(uint32_t aFor)
|
2004-12-24 19:26:10 +03:00
|
|
|
{
|
2012-06-30 15:20:46 +04:00
|
|
|
if (!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
|
|
|
|
if ((aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) ||
|
|
|
|
(aFor == FOR_HIT_TESTING && NS_SVGDisplayListHitTestingEnabled())) {
|
|
|
|
return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this);
|
|
|
|
}
|
|
|
|
}
|
2006-06-01 19:31:15 +04:00
|
|
|
if (!mCanvasTM) {
|
|
|
|
NS_ASSERTION(mParent, "null parent");
|
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
2013-01-03 10:17:03 +04:00
|
|
|
SVGGraphicsElement *content = static_cast<SVGGraphicsElement*>(mContent);
|
2006-06-01 19:31:15 +04:00
|
|
|
|
2012-06-30 15:20:46 +04:00
|
|
|
gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM(aFor));
|
2006-06-01 19:31:15 +04:00
|
|
|
|
2011-09-26 01:04:32 +04:00
|
|
|
mCanvasTM = new gfxMatrix(tm);
|
2009-04-29 08:31:34 +04:00
|
|
|
}
|
2011-09-26 01:04:32 +04:00
|
|
|
return *mCanvasTM;
|
2004-12-24 19:26:10 +03:00
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2006-06-01 19:31:15 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGGFrame::AttributeChanged(int32_t aNameSpaceID,
|
2006-06-01 19:31:15 +04:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2006-06-01 19:31:15 +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);
|
2006-06-01 19:31:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|