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