Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / layout / svg / base / src / nsSVGStopFrame.cpp
blobe79b786c37b66adb54e96ef75fc286521ddc0275
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is the Mozilla SVG project.
17 * The Initial Developer of the Original Code is
18 * Scooter Morris.
19 * Portions created by the Initial Developer are Copyright (C) 2004
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Scooter Morris <scootermorris@comcast.net>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsIDOMSVGStopElement.h"
40 #include "nsStyleContext.h"
41 #include "nsFrame.h"
42 #include "nsGkAtoms.h"
43 #include "nsSVGEffects.h"
45 // This is a very simple frame whose only purpose is to capture style change
46 // events and propagate them to the parent. Most of the heavy lifting is done
47 // within the nsSVGGradientFrame, which is the parent for this frame
49 typedef nsFrame nsSVGStopFrameBase;
51 class nsSVGStopFrame : public nsSVGStopFrameBase
53 friend nsIFrame*
54 NS_NewSVGStopFrame(nsIPresShell* aPresShell, nsIContent* aContent,
55 nsIFrame* aParentFrame, nsStyleContext* aContext);
56 protected:
57 nsSVGStopFrame(nsStyleContext* aContext) : nsSVGStopFrameBase(aContext) {}
59 public:
60 // nsIFrame interface:
61 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
63 NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
64 nsIAtom* aAttribute,
65 PRInt32 aModType);
67 /**
68 * Get the "type" of the frame
70 * @see nsGkAtoms::svgStopFrame
72 virtual nsIAtom* GetType() const;
74 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
76 return nsSVGStopFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
79 #ifdef DEBUG
80 // nsIFrameDebug interface:
81 NS_IMETHOD GetFrameName(nsAString& aResult) const
83 return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
85 #endif
88 //----------------------------------------------------------------------
89 // Implementation
91 //----------------------------------------------------------------------
92 // nsIFrame methods:
94 /* virtual */ void
95 nsSVGStopFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
97 nsSVGStopFrameBase::DidSetStyleContext(aOldStyleContext);
98 nsSVGEffects::InvalidateRenderingObservers(this);
101 nsIAtom *
102 nsSVGStopFrame::GetType() const
104 return nsGkAtoms::svgStopFrame;
107 NS_IMETHODIMP
108 nsSVGStopFrame::AttributeChanged(PRInt32 aNameSpaceID,
109 nsIAtom* aAttribute,
110 PRInt32 aModType)
112 if (aNameSpaceID == kNameSpaceID_None &&
113 aAttribute == nsGkAtoms::offset) {
114 nsSVGEffects::InvalidateRenderingObservers(this);
117 return nsSVGStopFrameBase::AttributeChanged(aNameSpaceID,
118 aAttribute, aModType);
121 // -------------------------------------------------------------------------
122 // Public functions
123 // -------------------------------------------------------------------------
125 nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell,
126 nsIContent* aContent,
127 nsIFrame* aParentFrame,
128 nsStyleContext* aContext)
130 nsCOMPtr<nsIDOMSVGStopElement> grad = do_QueryInterface(aContent);
131 NS_ASSERTION(grad, "NS_NewSVGStopFrame -- Content doesn't support nsIDOMSVGStopElement");
132 if (!grad)
133 return nsnull;
135 return new (aPresShell) nsSVGStopFrame(aContext);