summaryrefslogtreecommitdiffstats
path: root/layout/svg/nsSVGGFrame.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /layout/svg/nsSVGGFrame.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/svg/nsSVGGFrame.cpp')
-rw-r--r--layout/svg/nsSVGGFrame.cpp98
1 files changed, 98 insertions, 0 deletions
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<nsSVGElement*>(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<nsSVGContainerFrame*>(GetParent());
+ SVGGraphicsElement *content = static_cast<SVGGraphicsElement*>(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;
+}