1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/svg/SVGFEContainerFrame.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,109 @@ 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 "nsContainerFrame.h" 1.11 +#include "nsGkAtoms.h" 1.12 +#include "nsIFrame.h" 1.13 +#include "nsLiteralString.h" 1.14 +#include "nsSVGEffects.h" 1.15 +#include "nsSVGFilters.h" 1.16 + 1.17 +typedef nsContainerFrame SVGFEContainerFrameBase; 1.18 + 1.19 +/* 1.20 + * This frame is used by filter primitive elements that 1.21 + * have special child elements that provide parameters. 1.22 + */ 1.23 +class SVGFEContainerFrame : public SVGFEContainerFrameBase 1.24 +{ 1.25 + friend nsIFrame* 1.26 + NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); 1.27 +protected: 1.28 + SVGFEContainerFrame(nsStyleContext* aContext) 1.29 + : SVGFEContainerFrameBase(aContext) 1.30 + { 1.31 + AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY); 1.32 + } 1.33 + 1.34 +public: 1.35 + NS_DECL_FRAMEARENA_HELPERS 1.36 + 1.37 + virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE 1.38 + { 1.39 + return SVGFEContainerFrameBase::IsFrameOfType( 1.40 + aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer)); 1.41 + } 1.42 + 1.43 +#ifdef DEBUG_FRAME_DUMP 1.44 + virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE 1.45 + { 1.46 + return MakeFrameName(NS_LITERAL_STRING("SVGFEContainer"), aResult); 1.47 + } 1.48 +#endif 1.49 + 1.50 +#ifdef DEBUG 1.51 + virtual void Init(nsIContent* aContent, 1.52 + nsIFrame* aParent, 1.53 + nsIFrame* aPrevInFlow) MOZ_OVERRIDE; 1.54 +#endif 1.55 + /** 1.56 + * Get the "type" of the frame 1.57 + * 1.58 + * @see nsGkAtoms::svgFEContainerFrame 1.59 + */ 1.60 + virtual nsIAtom* GetType() const MOZ_OVERRIDE; 1.61 + 1.62 + virtual nsresult AttributeChanged(int32_t aNameSpaceID, 1.63 + nsIAtom* aAttribute, 1.64 + int32_t aModType) MOZ_OVERRIDE; 1.65 + 1.66 + virtual bool UpdateOverflow() MOZ_OVERRIDE { 1.67 + // We don't maintain a visual overflow rect 1.68 + return false; 1.69 + } 1.70 +}; 1.71 + 1.72 +nsIFrame* 1.73 +NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) 1.74 +{ 1.75 + return new (aPresShell) SVGFEContainerFrame(aContext); 1.76 +} 1.77 + 1.78 +NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame) 1.79 + 1.80 +#ifdef DEBUG 1.81 +void 1.82 +SVGFEContainerFrame::Init(nsIContent* aContent, 1.83 + nsIFrame* aParent, 1.84 + nsIFrame* aPrevInFlow) 1.85 +{ 1.86 + NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER), 1.87 + "Trying to construct an SVGFEContainerFrame for a " 1.88 + "content element that doesn't support the right interfaces"); 1.89 + 1.90 + SVGFEContainerFrameBase::Init(aContent, aParent, aPrevInFlow); 1.91 +} 1.92 +#endif /* DEBUG */ 1.93 + 1.94 +nsIAtom * 1.95 +SVGFEContainerFrame::GetType() const 1.96 +{ 1.97 + return nsGkAtoms::svgFEContainerFrame; 1.98 +} 1.99 + 1.100 +nsresult 1.101 +SVGFEContainerFrame::AttributeChanged(int32_t aNameSpaceID, 1.102 + nsIAtom* aAttribute, 1.103 + int32_t aModType) 1.104 +{ 1.105 + nsSVGFE *element = static_cast<nsSVGFE*>(mContent); 1.106 + if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) { 1.107 + nsSVGEffects::InvalidateRenderingObservers(this); 1.108 + } 1.109 + 1.110 + return SVGFEContainerFrameBase::AttributeChanged(aNameSpaceID, 1.111 + aAttribute, aModType); 1.112 +}