Bug 1748835 [wpt PR 32273] - Avoid reftest-wait timeout if ::target-text is unsupport...
[gecko.git] / layout / svg / SVGPaintServerFrame.h
blob76b187664f3767114e4b459d0318a0e43f53eb9e
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);
54 public:
55 using imgDrawingParams = image::imgDrawingParams;
57 NS_DECL_ABSTRACT_FRAME(SVGPaintServerFrame)
58 NS_DECL_QUERYFRAME
59 NS_DECL_QUERYFRAME_TARGET(SVGPaintServerFrame)
61 /**
62 * Constructs a gfxPattern of the paint server rendering.
64 * @param aContextMatrix The transform matrix that is currently applied to
65 * the gfxContext that is being drawn to. This is needed by SVG patterns so
66 * that surfaces of the correct size can be created. (SVG gradients are
67 * vector based, so it's not used there.)
69 virtual already_AddRefed<gfxPattern> GetPaintServerPattern(
70 nsIFrame* aSource, const DrawTarget* aDrawTarget,
71 const gfxMatrix& aContextMatrix, StyleSVGPaint nsStyleSVG::*aFillOrStroke,
72 float aOpacity, imgDrawingParams& aImgParams,
73 const gfxRect* aOverrideBounds = nullptr) = 0;
75 // nsIFrame methods:
76 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
77 const nsDisplayListSet& aLists) override {}
80 } // namespace mozilla
82 #endif // LAYOUT_SVG_SVGPAINTSERVERFRAME_H_