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_
11 #include "mozilla/Attributes.h"
12 #include "mozilla/SVGContainerFrame.h"
16 #include "nsQueryFrame.h"
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
{
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
);
44 class SVGPaintServerFrame
: public SVGContainerFrame
{
46 using DrawTarget
= gfx::DrawTarget
;
48 SVGPaintServerFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
,
50 : SVGContainerFrame(aStyle
, aPresContext
, aID
) {
51 AddStateBits(NS_FRAME_IS_NONDISPLAY
|
52 NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER
);
56 using imgDrawingParams
= image::imgDrawingParams
;
58 NS_DECL_ABSTRACT_FRAME(SVGPaintServerFrame
)
60 NS_DECL_QUERYFRAME_TARGET(SVGPaintServerFrame
)
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;
77 void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
78 const nsDisplayListSet
& aLists
) override
{}
81 } // namespace mozilla
83 #endif // LAYOUT_SVG_SVGPAINTSERVERFRAME_H_