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 __NS_SVGMASKFRAME_H__
8 #define __NS_SVGMASKFRAME_H__
10 #include "mozilla/Attributes.h"
11 #include "mozilla/gfx/2D.h"
12 #include "mozilla/RefPtr.h"
13 #include "gfxPattern.h"
14 #include "gfxMatrix.h"
15 #include "nsSVGContainerFrame.h"
16 #include "nsSVGUtils.h"
22 } // namespace mozilla
24 class nsSVGMaskFrame final
: public nsSVGContainerFrame
{
25 friend nsIFrame
* NS_NewSVGMaskFrame(mozilla::PresShell
* aPresShell
,
26 ComputedStyle
* aStyle
);
28 typedef mozilla::gfx::Matrix Matrix
;
29 typedef mozilla::gfx::SourceSurface SourceSurface
;
30 typedef mozilla::image::imgDrawingParams imgDrawingParams
;
33 explicit nsSVGMaskFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
)
34 : nsSVGContainerFrame(aStyle
, aPresContext
, kClassID
), mInUse(false) {
35 AddStateBits(NS_FRAME_IS_NONDISPLAY
);
39 NS_DECL_FRAMEARENA_HELPERS(nsSVGMaskFrame
)
43 nsIFrame
* maskedFrame
;
44 const gfxMatrix
& toUserSpace
;
46 mozilla::StyleMaskMode maskMode
;
47 imgDrawingParams
& imgParams
;
49 explicit MaskParams(gfxContext
* aCtx
, nsIFrame
* aMaskedFrame
,
50 const gfxMatrix
& aToUserSpace
, float aOpacity
,
51 mozilla::StyleMaskMode aMaskMode
,
52 imgDrawingParams
& aImgParams
)
54 maskedFrame(aMaskedFrame
),
55 toUserSpace(aToUserSpace
),
58 imgParams(aImgParams
) {}
61 // nsSVGMaskFrame method:
64 * Generate a mask surface for the target frame.
66 * The return surface can be null, it's the caller's responsibility to
67 * null-check before dereferencing.
69 already_AddRefed
<SourceSurface
> GetMaskForMaskedFrame(MaskParams
& aParams
);
71 gfxRect
GetMaskArea(nsIFrame
* aMaskedFrame
);
73 virtual nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
74 int32_t aModType
) override
;
77 virtual void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
78 nsIFrame
* aPrevInFlow
) override
;
81 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
82 const nsDisplayListSet
& aLists
) override
{}
84 #ifdef DEBUG_FRAME_DUMP
85 virtual nsresult
GetFrameName(nsAString
& aResult
) const override
{
86 return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult
);
92 * If the mask element transforms its children due to
93 * maskContentUnits="objectBoundingBox" being set on it, this function
94 * returns the resulting transform.
96 gfxMatrix
GetMaskTransform(nsIFrame
* aMaskedFrame
);
98 gfxMatrix mMatrixForChildren
;
99 // recursion prevention flag
102 // nsSVGContainerFrame methods:
103 virtual gfxMatrix
GetCanvasTM() override
;