Bumping manifests a=b2g-bump
[gecko.git] / layout / svg / nsSVGGFrame.cpp
blobaf8eaa41bb34e897d01ecff65719ac0f850c206a
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // Main header first:
7 #include "nsSVGGFrame.h"
9 // Keep others in (case-insensitive) order:
10 #include "nsGkAtoms.h"
11 #include "SVGTransformableElement.h"
12 #include "nsIFrame.h"
13 #include "SVGGraphicsElement.h"
14 #include "nsSVGIntegrationUtils.h"
15 #include "nsSVGUtils.h"
17 using namespace mozilla::dom;
19 //----------------------------------------------------------------------
20 // Implementation
22 nsIFrame*
23 NS_NewSVGGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
25 return new (aPresShell) nsSVGGFrame(aContext);
28 NS_IMPL_FRAMEARENA_HELPERS(nsSVGGFrame)
30 #ifdef DEBUG
31 void
32 nsSVGGFrame::Init(nsIContent* aContent,
33 nsContainerFrame* aParent,
34 nsIFrame* aPrevInFlow)
36 NS_ASSERTION(aContent->IsSVG() &&
37 static_cast<nsSVGElement*>(aContent)->IsTransformable(),
38 "The element doesn't support nsIDOMSVGTransformable");
40 nsSVGGFrameBase::Init(aContent, aParent, aPrevInFlow);
42 #endif /* DEBUG */
44 nsIAtom *
45 nsSVGGFrame::GetType() const
47 return nsGkAtoms::svgGFrame;
50 //----------------------------------------------------------------------
51 // nsISVGChildFrame methods
53 void
54 nsSVGGFrame::NotifySVGChanged(uint32_t aFlags)
56 NS_ABORT_IF_FALSE(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
57 "Invalidation logic may need adjusting");
59 if (aFlags & TRANSFORM_CHANGED) {
60 // make sure our cached transform matrix gets (lazily) updated
61 mCanvasTM = nullptr;
64 nsSVGGFrameBase::NotifySVGChanged(aFlags);
67 gfxMatrix
68 nsSVGGFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot)
70 if (!(GetStateBits() & NS_FRAME_IS_NONDISPLAY) && !aTransformRoot) {
71 if (aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) {
72 return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this);
75 if (!mCanvasTM) {
76 NS_ASSERTION(GetParent(), "null parent");
78 nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(GetParent());
79 SVGGraphicsElement *content = static_cast<SVGGraphicsElement*>(mContent);
80 gfxMatrix tm = content->PrependLocalTransformsTo(
81 this == aTransformRoot ? gfxMatrix() :
82 parent->GetCanvasTM(aFor, aTransformRoot));
84 mCanvasTM = new gfxMatrix(tm);
86 return *mCanvasTM;
89 nsresult
90 nsSVGGFrame::AttributeChanged(int32_t aNameSpaceID,
91 nsIAtom* aAttribute,
92 int32_t aModType)
94 if (aNameSpaceID == kNameSpaceID_None &&
95 aAttribute == nsGkAtoms::transform) {
96 // We don't invalidate for transform changes (the layers code does that).
97 // Also note that SVGTransformableElement::GetAttributeChangeHint will
98 // return nsChangeHint_UpdateOverflow for "transform" attribute changes
99 // and cause DoApplyRenderingChangeToTree to make the SchedulePaint call.
100 NotifySVGChanged(TRANSFORM_CHANGED);
103 return NS_OK;