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/. */ 5 6 #ifndef __NS_SVGPAINTSERVERFRAME_H__ 7 #define __NS_SVGPAINTSERVERFRAME_H__ 8 9 #include "mozilla/Attributes.h" 10 #include "nsCOMPtr.h" 11 #include "nsFrame.h" 12 #include "nsIFrame.h" 13 #include "nsQueryFrame.h" 14 #include "nsSVGContainerFrame.h" 15 #include "nsSVGUtils.h" 16 17 namespace mozilla { 18 namespace gfx { 19 class DrawTarget; 20 } // namespace gfx 21 } // namespace mozilla 22 23 class gfxContext; 24 class gfxPattern; 25 class nsStyleContext; 26 27 struct gfxRect; 28 29 class nsSVGPaintServerFrame : public nsSVGContainerFrame 30 { 31 protected: 32 typedef mozilla::gfx::DrawTarget DrawTarget; 33 34 explicit nsSVGPaintServerFrame(nsStyleContext* aContext) 35 : nsSVGContainerFrame(aContext) 36 { 37 AddStateBits(NS_FRAME_IS_NONDISPLAY); 38 } 39 40 public: 41 NS_DECL_ABSTRACT_FRAME(nsSVGPaintServerFrame) 42 43 /** 44 * Constructs a gfxPattern of the paint server rendering. 45 * 46 * @param aContextMatrix The transform matrix that is currently applied to 47 * the gfxContext that is being drawn to. This is needed by SVG patterns so 48 * that surfaces of the correct size can be created. (SVG gradients are 49 * vector based, so it's not used there.) 50 */ 51 virtual already_AddRefed<gfxPattern> 52 GetPaintServerPattern(nsIFrame *aSource, 53 const DrawTarget* aDrawTarget, 54 const gfxMatrix& aContextMatrix, 55 nsStyleSVGPaint nsStyleSVG::*aFillOrStroke, 56 float aOpacity, 57 const gfxRect *aOverrideBounds = nullptr) = 0; 58 59 // nsIFrame methods: 60 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, 61 const nsRect& aDirtyRect, 62 const nsDisplayListSet& aLists) override {} 63 64 virtual bool IsFrameOfType(uint32_t aFlags) const override 65 { 66 return nsSVGContainerFrame::IsFrameOfType(aFlags & ~nsIFrame::eSVGPaintServer); 67 } 68 }; 69 70 #endif // __NS_SVGPAINTSERVERFRAME_H__ 71