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/. */
6 // Keep in (case-insensitive) order:
7 #include "nsContainerFrame.h"
10 #include "nsSVGEffects.h"
11 #include "nsSVGFilters.h"
13 typedef nsFrame SVGFELeafFrameBase
;
16 * This frame is used by filter primitive elements that don't
17 * have special child elements that provide parameters.
19 class SVGFELeafFrame
: public SVGFELeafFrameBase
22 NS_NewSVGFELeafFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
24 explicit SVGFELeafFrame(nsStyleContext
* aContext
)
25 : SVGFELeafFrameBase(aContext
)
27 AddStateBits(NS_FRAME_SVG_LAYOUT
| NS_FRAME_IS_NONDISPLAY
);
31 NS_DECL_FRAMEARENA_HELPERS
34 virtual void Init(nsIContent
* aContent
,
35 nsContainerFrame
* aParent
,
36 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
39 virtual bool IsFrameOfType(uint32_t aFlags
) const MOZ_OVERRIDE
41 return SVGFELeafFrameBase::IsFrameOfType(aFlags
& ~(nsIFrame::eSVG
));
44 #ifdef DEBUG_FRAME_DUMP
45 virtual nsresult
GetFrameName(nsAString
& aResult
) const MOZ_OVERRIDE
47 return MakeFrameName(NS_LITERAL_STRING("SVGFELeaf"), aResult
);
52 * Get the "type" of the frame
54 * @see nsGkAtoms::svgFELeafFrame
56 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
58 virtual nsresult
AttributeChanged(int32_t aNameSpaceID
,
60 int32_t aModType
) MOZ_OVERRIDE
;
62 virtual bool UpdateOverflow() MOZ_OVERRIDE
{
63 // We don't maintain a visual overflow rect
69 NS_NewSVGFELeafFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
)
71 return new (aPresShell
) SVGFELeafFrame(aContext
);
74 NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame
)
78 SVGFELeafFrame::Init(nsIContent
* aContent
,
79 nsContainerFrame
* aParent
,
80 nsIFrame
* aPrevInFlow
)
82 NS_ASSERTION(aContent
->IsNodeOfType(nsINode::eFILTER
),
83 "Trying to construct an SVGFELeafFrame for a "
84 "content element that doesn't support the right interfaces");
86 SVGFELeafFrameBase::Init(aContent
, aParent
, aPrevInFlow
);
91 SVGFELeafFrame::GetType() const
93 return nsGkAtoms::svgFELeafFrame
;
97 SVGFELeafFrame::AttributeChanged(int32_t aNameSpaceID
,
101 nsSVGFE
*element
= static_cast<nsSVGFE
*>(mContent
);
102 if (element
->AttributeAffectsRendering(aNameSpaceID
, aAttribute
)) {
103 MOZ_ASSERT(GetParent()->GetType() == nsGkAtoms::svgFilterFrame
,
104 "Observers observe the filter, so that's what we must invalidate");
105 nsSVGEffects::InvalidateDirectRenderingObservers(GetParent());
108 return SVGFELeafFrameBase::AttributeChanged(aNameSpaceID
,
109 aAttribute
, aModType
);