From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- layout/svg/nsSVGGFrame.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 layout/svg/nsSVGGFrame.cpp (limited to 'layout/svg/nsSVGGFrame.cpp') diff --git a/layout/svg/nsSVGGFrame.cpp b/layout/svg/nsSVGGFrame.cpp new file mode 100644 index 000000000..1fc124956 --- /dev/null +++ b/layout/svg/nsSVGGFrame.cpp @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +// Main header first: +#include "nsSVGGFrame.h" + +// Keep others in (case-insensitive) order: +#include "nsGkAtoms.h" +#include "SVGTransformableElement.h" +#include "nsIFrame.h" +#include "SVGGraphicsElement.h" +#include "nsSVGIntegrationUtils.h" +#include "nsSVGUtils.h" + +using namespace mozilla::dom; + +//---------------------------------------------------------------------- +// Implementation + +nsIFrame* +NS_NewSVGGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) +{ + return new (aPresShell) nsSVGGFrame(aContext); +} + +NS_IMPL_FRAMEARENA_HELPERS(nsSVGGFrame) + +#ifdef DEBUG +void +nsSVGGFrame::Init(nsIContent* aContent, + nsContainerFrame* aParent, + nsIFrame* aPrevInFlow) +{ + NS_ASSERTION(aContent->IsSVGElement() && + static_cast(aContent)->IsTransformable(), + "The element doesn't support nsIDOMSVGTransformable"); + + nsSVGDisplayContainerFrame::Init(aContent, aParent, aPrevInFlow); +} +#endif /* DEBUG */ + +nsIAtom * +nsSVGGFrame::GetType() const +{ + return nsGkAtoms::svgGFrame; +} + +//---------------------------------------------------------------------- +// nsISVGChildFrame methods + +void +nsSVGGFrame::NotifySVGChanged(uint32_t aFlags) +{ + MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED), + "Invalidation logic may need adjusting"); + + if (aFlags & TRANSFORM_CHANGED) { + // make sure our cached transform matrix gets (lazily) updated + mCanvasTM = nullptr; + } + + nsSVGDisplayContainerFrame::NotifySVGChanged(aFlags); +} + +gfxMatrix +nsSVGGFrame::GetCanvasTM() +{ + if (!mCanvasTM) { + NS_ASSERTION(GetParent(), "null parent"); + + nsSVGContainerFrame *parent = static_cast(GetParent()); + SVGGraphicsElement *content = static_cast(mContent); + + gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM()); + + mCanvasTM = new gfxMatrix(tm); + } + return *mCanvasTM; +} + +nsresult +nsSVGGFrame::AttributeChanged(int32_t aNameSpaceID, + nsIAtom* aAttribute, + int32_t aModType) +{ + if (aNameSpaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::transform) { + // 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. + NotifySVGChanged(TRANSFORM_CHANGED); + } + + return NS_OK; +} -- cgit v1.2.3