no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / svg / SVGPaintServerFrame.h
blobe17d17bd10d360cdd70aaece84aaef6aea2a5396
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef LAYOUT_SVG_SVGPAINTSERVERFRAME_H_
8 #define LAYOUT_SVG_SVGPAINTSERVERFRAME_H_
10 #include "gfxRect.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/SVGContainerFrame.h"
13 #include "nsCOMPtr.h"
14 #include "nsIFrame.h"
15 #include "nsIFrame.h"
16 #include "nsQueryFrame.h"
18 class gfxContext;
19 class gfxPattern;
21 namespace mozilla {
22 namespace gfx {
23 class DrawTarget;
24 } // namespace gfx
26 /**
27 * RAII class used to temporarily set and remove the
28 * NS_FRAME_DRAWING_AS_PAINTSERVER frame state bit while a frame is being
29 * drawn as a paint server.
31 class MOZ_RAII AutoSetRestorePaintServerState {
32 public:
33 explicit AutoSetRestorePaintServerState(nsIFrame* aFrame) : mFrame(aFrame) {
34 mFrame->AddStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
36 ~AutoSetRestorePaintServerState() {
37 mFrame->RemoveStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
40 private:
41 nsIFrame* mFrame;
44 class SVGPaintServerFrame : public SVGContainerFrame {
45 protected:
46 using DrawTarget = gfx::DrawTarget;
48 SVGPaintServerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
49 ClassID aID)
50 : SVGContainerFrame(aStyle, aPresContext, aID) {
51 AddStateBits(NS_FRAME_IS_NONDISPLAY |
52 NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER);
55 public:
56 using imgDrawingParams = image::imgDrawingParams;
58 NS_DECL_ABSTRACT_FRAME(SVGPaintServerFrame)
59 NS_DECL_QUERYFRAME
60 NS_DECL_QUERYFRAME_TARGET(SVGPaintServerFrame)
62 /**
63 * Constructs a gfxPattern of the paint server rendering.
65 * @param aContextMatrix The transform matrix that is currently applied to
66 * the gfxContext that is being drawn to. This is needed by SVG patterns so
67 * that surfaces of the correct size can be created. (SVG gradients are
68 * vector based, so it's not used there.)
70 virtual already_AddRefed<gfxPattern> GetPaintServerPattern(
71 nsIFrame* aSource, const DrawTarget* aDrawTarget,
72 const gfxMatrix& aContextMatrix, StyleSVGPaint nsStyleSVG::*aFillOrStroke,
73 float aOpacity, imgDrawingParams& aImgParams,
74 const gfxRect* aOverrideBounds = nullptr) = 0;
76 // nsIFrame methods:
77 void BuildDisplayList(nsDisplayListBuilder* aBuilder,
78 const nsDisplayListSet& aLists) override {}
81 } // namespace mozilla
83 #endif // LAYOUT_SVG_SVGPAINTSERVERFRAME_H_