michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Keep in (case-insensitive) order: michael@0: #include "nsFrame.h" michael@0: #include "nsGkAtoms.h" michael@0: #include "nsSVGEffects.h" michael@0: #include "nsSVGFilters.h" michael@0: michael@0: typedef nsFrame SVGFELeafFrameBase; michael@0: michael@0: /* michael@0: * This frame is used by filter primitive elements that don't michael@0: * have special child elements that provide parameters. michael@0: */ michael@0: class SVGFELeafFrame : public SVGFELeafFrameBase michael@0: { michael@0: friend nsIFrame* michael@0: NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: protected: michael@0: SVGFELeafFrame(nsStyleContext* aContext) michael@0: : SVGFELeafFrameBase(aContext) michael@0: { michael@0: AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY); michael@0: } michael@0: michael@0: public: michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: #ifdef DEBUG michael@0: virtual void Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* aPrevInFlow) MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return SVGFELeafFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG)); michael@0: } michael@0: michael@0: #ifdef DEBUG_FRAME_DUMP michael@0: virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE michael@0: { michael@0: return MakeFrameName(NS_LITERAL_STRING("SVGFELeaf"), aResult); michael@0: } michael@0: #endif michael@0: michael@0: /** michael@0: * Get the "type" of the frame michael@0: * michael@0: * @see nsGkAtoms::svgFELeafFrame michael@0: */ michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) MOZ_OVERRIDE; michael@0: michael@0: virtual bool UpdateOverflow() MOZ_OVERRIDE { michael@0: // We don't maintain a visual overflow rect michael@0: return false; michael@0: } michael@0: }; michael@0: michael@0: nsIFrame* michael@0: NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) michael@0: { michael@0: return new (aPresShell) SVGFELeafFrame(aContext); michael@0: } michael@0: michael@0: NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame) michael@0: michael@0: #ifdef DEBUG michael@0: void michael@0: SVGFELeafFrame::Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* aPrevInFlow) michael@0: { michael@0: NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER), michael@0: "Trying to construct an SVGFELeafFrame for a " michael@0: "content element that doesn't support the right interfaces"); michael@0: michael@0: SVGFELeafFrameBase::Init(aContent, aParent, aPrevInFlow); michael@0: } michael@0: #endif /* DEBUG */ michael@0: michael@0: nsIAtom * michael@0: SVGFELeafFrame::GetType() const michael@0: { michael@0: return nsGkAtoms::svgFELeafFrame; michael@0: } michael@0: michael@0: nsresult michael@0: SVGFELeafFrame::AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) michael@0: { michael@0: nsSVGFE *element = static_cast(mContent); michael@0: if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) { michael@0: nsSVGEffects::InvalidateRenderingObservers(this); michael@0: } michael@0: michael@0: return SVGFELeafFrameBase::AttributeChanged(aNameSpaceID, michael@0: aAttribute, aModType); michael@0: }