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 "nsStyleContext.h" michael@0: #include "nsSVGEffects.h" michael@0: michael@0: // This is a very simple frame whose only purpose is to capture style change michael@0: // events and propagate them to the parent. Most of the heavy lifting is done michael@0: // within the nsSVGGradientFrame, which is the parent for this frame michael@0: michael@0: typedef nsFrame nsSVGStopFrameBase; michael@0: michael@0: class nsSVGStopFrame : public nsSVGStopFrameBase michael@0: { michael@0: friend nsIFrame* michael@0: NS_NewSVGStopFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: protected: michael@0: nsSVGStopFrame(nsStyleContext* aContext) michael@0: : nsSVGStopFrameBase(aContext) michael@0: { michael@0: AddStateBits(NS_FRAME_IS_NONDISPLAY); michael@0: } michael@0: michael@0: public: michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // nsIFrame interface: 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: void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) 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: /** michael@0: * Get the "type" of the frame michael@0: * michael@0: * @see nsGkAtoms::svgStopFrame michael@0: */ michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsSVGStopFrameBase::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("SVGStop"), aResult); michael@0: } michael@0: #endif michael@0: }; michael@0: michael@0: //---------------------------------------------------------------------- michael@0: // Implementation michael@0: michael@0: NS_IMPL_FRAMEARENA_HELPERS(nsSVGStopFrame) michael@0: michael@0: //---------------------------------------------------------------------- michael@0: // nsIFrame methods: michael@0: michael@0: #ifdef DEBUG michael@0: void michael@0: nsSVGStopFrame::Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* aPrevInFlow) michael@0: { michael@0: NS_ASSERTION(aContent->IsSVG(nsGkAtoms::stop), "Content is not a stop element"); michael@0: michael@0: nsSVGStopFrameBase::Init(aContent, aParent, aPrevInFlow); michael@0: } michael@0: #endif /* DEBUG */ michael@0: michael@0: nsIAtom * michael@0: nsSVGStopFrame::GetType() const michael@0: { michael@0: return nsGkAtoms::svgStopFrame; michael@0: } michael@0: michael@0: nsresult michael@0: nsSVGStopFrame::AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) michael@0: { michael@0: if (aNameSpaceID == kNameSpaceID_None && michael@0: aAttribute == nsGkAtoms::offset) { michael@0: nsSVGEffects::InvalidateRenderingObservers(this); michael@0: } michael@0: michael@0: return nsSVGStopFrameBase::AttributeChanged(aNameSpaceID, michael@0: aAttribute, aModType); michael@0: } michael@0: michael@0: // ------------------------------------------------------------------------- michael@0: // Public functions michael@0: // ------------------------------------------------------------------------- michael@0: michael@0: nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell, michael@0: nsStyleContext* aContext) michael@0: { michael@0: return new (aPresShell) nsSVGStopFrame(aContext); michael@0: }