1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/svg/SVGFELeafFrame.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +// Keep in (case-insensitive) order: 1.10 +#include "nsFrame.h" 1.11 +#include "nsGkAtoms.h" 1.12 +#include "nsSVGEffects.h" 1.13 +#include "nsSVGFilters.h" 1.14 + 1.15 +typedef nsFrame SVGFELeafFrameBase; 1.16 + 1.17 +/* 1.18 + * This frame is used by filter primitive elements that don't 1.19 + * have special child elements that provide parameters. 1.20 + */ 1.21 +class SVGFELeafFrame : public SVGFELeafFrameBase 1.22 +{ 1.23 + friend nsIFrame* 1.24 + NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); 1.25 +protected: 1.26 + SVGFELeafFrame(nsStyleContext* aContext) 1.27 + : SVGFELeafFrameBase(aContext) 1.28 + { 1.29 + AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY); 1.30 + } 1.31 + 1.32 +public: 1.33 + NS_DECL_FRAMEARENA_HELPERS 1.34 + 1.35 +#ifdef DEBUG 1.36 + virtual void Init(nsIContent* aContent, 1.37 + nsIFrame* aParent, 1.38 + nsIFrame* aPrevInFlow) MOZ_OVERRIDE; 1.39 +#endif 1.40 + 1.41 + virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE 1.42 + { 1.43 + return SVGFELeafFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG)); 1.44 + } 1.45 + 1.46 +#ifdef DEBUG_FRAME_DUMP 1.47 + virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE 1.48 + { 1.49 + return MakeFrameName(NS_LITERAL_STRING("SVGFELeaf"), aResult); 1.50 + } 1.51 +#endif 1.52 + 1.53 + /** 1.54 + * Get the "type" of the frame 1.55 + * 1.56 + * @see nsGkAtoms::svgFELeafFrame 1.57 + */ 1.58 + virtual nsIAtom* GetType() const MOZ_OVERRIDE; 1.59 + 1.60 + virtual nsresult AttributeChanged(int32_t aNameSpaceID, 1.61 + nsIAtom* aAttribute, 1.62 + int32_t aModType) MOZ_OVERRIDE; 1.63 + 1.64 + virtual bool UpdateOverflow() MOZ_OVERRIDE { 1.65 + // We don't maintain a visual overflow rect 1.66 + return false; 1.67 + } 1.68 +}; 1.69 + 1.70 +nsIFrame* 1.71 +NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) 1.72 +{ 1.73 + return new (aPresShell) SVGFELeafFrame(aContext); 1.74 +} 1.75 + 1.76 +NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame) 1.77 + 1.78 +#ifdef DEBUG 1.79 +void 1.80 +SVGFELeafFrame::Init(nsIContent* aContent, 1.81 + nsIFrame* aParent, 1.82 + nsIFrame* aPrevInFlow) 1.83 +{ 1.84 + NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER), 1.85 + "Trying to construct an SVGFELeafFrame for a " 1.86 + "content element that doesn't support the right interfaces"); 1.87 + 1.88 + SVGFELeafFrameBase::Init(aContent, aParent, aPrevInFlow); 1.89 +} 1.90 +#endif /* DEBUG */ 1.91 + 1.92 +nsIAtom * 1.93 +SVGFELeafFrame::GetType() const 1.94 +{ 1.95 + return nsGkAtoms::svgFELeafFrame; 1.96 +} 1.97 + 1.98 +nsresult 1.99 +SVGFELeafFrame::AttributeChanged(int32_t aNameSpaceID, 1.100 + nsIAtom* aAttribute, 1.101 + int32_t aModType) 1.102 +{ 1.103 + nsSVGFE *element = static_cast<nsSVGFE*>(mContent); 1.104 + if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) { 1.105 + nsSVGEffects::InvalidateRenderingObservers(this); 1.106 + } 1.107 + 1.108 + return SVGFELeafFrameBase::AttributeChanged(aNameSpaceID, 1.109 + aAttribute, aModType); 1.110 +}