|
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/. */ |
|
5 |
|
6 // Keep in (case-insensitive) order: |
|
7 #include "nsFrame.h" |
|
8 #include "nsGkAtoms.h" |
|
9 #include "nsSVGEffects.h" |
|
10 #include "nsSVGFilters.h" |
|
11 |
|
12 typedef nsFrame SVGFELeafFrameBase; |
|
13 |
|
14 /* |
|
15 * This frame is used by filter primitive elements that don't |
|
16 * have special child elements that provide parameters. |
|
17 */ |
|
18 class SVGFELeafFrame : public SVGFELeafFrameBase |
|
19 { |
|
20 friend nsIFrame* |
|
21 NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
22 protected: |
|
23 SVGFELeafFrame(nsStyleContext* aContext) |
|
24 : SVGFELeafFrameBase(aContext) |
|
25 { |
|
26 AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY); |
|
27 } |
|
28 |
|
29 public: |
|
30 NS_DECL_FRAMEARENA_HELPERS |
|
31 |
|
32 #ifdef DEBUG |
|
33 virtual void Init(nsIContent* aContent, |
|
34 nsIFrame* aParent, |
|
35 nsIFrame* aPrevInFlow) MOZ_OVERRIDE; |
|
36 #endif |
|
37 |
|
38 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
|
39 { |
|
40 return SVGFELeafFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG)); |
|
41 } |
|
42 |
|
43 #ifdef DEBUG_FRAME_DUMP |
|
44 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE |
|
45 { |
|
46 return MakeFrameName(NS_LITERAL_STRING("SVGFELeaf"), aResult); |
|
47 } |
|
48 #endif |
|
49 |
|
50 /** |
|
51 * Get the "type" of the frame |
|
52 * |
|
53 * @see nsGkAtoms::svgFELeafFrame |
|
54 */ |
|
55 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
56 |
|
57 virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
|
58 nsIAtom* aAttribute, |
|
59 int32_t aModType) MOZ_OVERRIDE; |
|
60 |
|
61 virtual bool UpdateOverflow() MOZ_OVERRIDE { |
|
62 // We don't maintain a visual overflow rect |
|
63 return false; |
|
64 } |
|
65 }; |
|
66 |
|
67 nsIFrame* |
|
68 NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) |
|
69 { |
|
70 return new (aPresShell) SVGFELeafFrame(aContext); |
|
71 } |
|
72 |
|
73 NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame) |
|
74 |
|
75 #ifdef DEBUG |
|
76 void |
|
77 SVGFELeafFrame::Init(nsIContent* aContent, |
|
78 nsIFrame* aParent, |
|
79 nsIFrame* aPrevInFlow) |
|
80 { |
|
81 NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER), |
|
82 "Trying to construct an SVGFELeafFrame for a " |
|
83 "content element that doesn't support the right interfaces"); |
|
84 |
|
85 SVGFELeafFrameBase::Init(aContent, aParent, aPrevInFlow); |
|
86 } |
|
87 #endif /* DEBUG */ |
|
88 |
|
89 nsIAtom * |
|
90 SVGFELeafFrame::GetType() const |
|
91 { |
|
92 return nsGkAtoms::svgFELeafFrame; |
|
93 } |
|
94 |
|
95 nsresult |
|
96 SVGFELeafFrame::AttributeChanged(int32_t aNameSpaceID, |
|
97 nsIAtom* aAttribute, |
|
98 int32_t aModType) |
|
99 { |
|
100 nsSVGFE *element = static_cast<nsSVGFE*>(mContent); |
|
101 if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) { |
|
102 nsSVGEffects::InvalidateRenderingObservers(this); |
|
103 } |
|
104 |
|
105 return SVGFELeafFrameBase::AttributeChanged(aNameSpaceID, |
|
106 aAttribute, aModType); |
|
107 } |