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
4 : *
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/
9 : *
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.
14 : *
15 : * The Original Code is the Mozilla SVG project.
16 : *
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.
21 : *
22 : * Contributor(s):
23 : * Scooter Morris <scootermorris@comcast.net>
24 : *
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.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #include "nsIDOMSVGStopElement.h"
40 : #include "nsStyleContext.h"
41 : #include "nsFrame.h"
42 : #include "nsGkAtoms.h"
43 : #include "nsSVGEffects.h"
44 :
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
48 :
49 : typedef nsFrame nsSVGStopFrameBase;
50 :
51 : class nsSVGStopFrame : public nsSVGStopFrameBase
52 0 : {
53 : friend nsIFrame*
54 : NS_NewSVGStopFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
55 : protected:
56 0 : nsSVGStopFrame(nsStyleContext* aContext) : nsSVGStopFrameBase(aContext) {}
57 :
58 : public:
59 : NS_DECL_FRAMEARENA_HELPERS
60 :
61 : // nsIFrame interface:
62 : #ifdef DEBUG
63 : NS_IMETHOD Init(nsIContent* aContent,
64 : nsIFrame* aParent,
65 : nsIFrame* aPrevInFlow);
66 : #endif
67 :
68 : virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
69 :
70 : NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
71 : nsIAtom* aAttribute,
72 : PRInt32 aModType);
73 :
74 : /**
75 : * Get the "type" of the frame
76 : *
77 : * @see nsGkAtoms::svgStopFrame
78 : */
79 : virtual nsIAtom* GetType() const;
80 :
81 0 : virtual bool IsFrameOfType(PRUint32 aFlags) const
82 : {
83 0 : return nsSVGStopFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
84 : }
85 :
86 : #ifdef DEBUG
87 0 : NS_IMETHOD GetFrameName(nsAString& aResult) const
88 : {
89 0 : return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
90 : }
91 : #endif
92 : };
93 :
94 : //----------------------------------------------------------------------
95 : // Implementation
96 :
97 0 : NS_IMPL_FRAMEARENA_HELPERS(nsSVGStopFrame)
98 :
99 : //----------------------------------------------------------------------
100 : // nsIFrame methods:
101 :
102 : #ifdef DEBUG
103 : NS_IMETHODIMP
104 0 : nsSVGStopFrame::Init(nsIContent* aContent,
105 : nsIFrame* aParent,
106 : nsIFrame* aPrevInFlow)
107 : {
108 0 : nsCOMPtr<nsIDOMSVGStopElement> grad = do_QueryInterface(aContent);
109 0 : NS_ASSERTION(grad, "Content doesn't support nsIDOMSVGStopElement");
110 :
111 0 : return nsSVGStopFrameBase::Init(aContent, aParent, aPrevInFlow);
112 : }
113 : #endif /* DEBUG */
114 :
115 : /* virtual */ void
116 0 : nsSVGStopFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
117 : {
118 0 : nsSVGStopFrameBase::DidSetStyleContext(aOldStyleContext);
119 0 : nsSVGEffects::InvalidateRenderingObservers(this);
120 0 : }
121 :
122 : nsIAtom *
123 0 : nsSVGStopFrame::GetType() const
124 : {
125 0 : return nsGkAtoms::svgStopFrame;
126 : }
127 :
128 : NS_IMETHODIMP
129 0 : nsSVGStopFrame::AttributeChanged(PRInt32 aNameSpaceID,
130 : nsIAtom* aAttribute,
131 : PRInt32 aModType)
132 : {
133 0 : if (aNameSpaceID == kNameSpaceID_None &&
134 : aAttribute == nsGkAtoms::offset) {
135 0 : nsSVGEffects::InvalidateRenderingObservers(this);
136 : }
137 :
138 : return nsSVGStopFrameBase::AttributeChanged(aNameSpaceID,
139 0 : aAttribute, aModType);
140 : }
141 :
142 : // -------------------------------------------------------------------------
143 : // Public functions
144 : // -------------------------------------------------------------------------
145 :
146 0 : nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell,
147 : nsStyleContext* aContext)
148 : {
149 0 : return new (aPresShell) nsSVGStopFrame(aContext);
150 : }
|