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_SVGMASKFRAME_H_
8 #define LAYOUT_SVG_SVGMASKFRAME_H_
10 #include "mozilla/Attributes.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/SVGContainerFrame.h"
13 #include "mozilla/gfx/2D.h"
14 #include "gfxPattern.h"
15 #include "gfxMatrix.h"
21 } // namespace mozilla
23 nsIFrame
* NS_NewSVGMaskFrame(mozilla::PresShell
* aPresShell
,
24 mozilla::ComputedStyle
* aStyle
);
28 class SVGMaskFrame final
: public SVGContainerFrame
{
29 friend nsIFrame
* ::NS_NewSVGMaskFrame(mozilla::PresShell
* aPresShell
,
30 ComputedStyle
* aStyle
);
32 using Matrix
= gfx::Matrix
;
33 using SourceSurface
= gfx::SourceSurface
;
34 using imgDrawingParams
= image::imgDrawingParams
;
37 explicit SVGMaskFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
)
38 : SVGContainerFrame(aStyle
, aPresContext
, kClassID
), mInUse(false) {
39 AddStateBits(NS_FRAME_IS_NONDISPLAY
|
40 NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER
);
44 NS_DECL_FRAMEARENA_HELPERS(SVGMaskFrame
)
48 nsIFrame
* maskedFrame
;
49 const gfxMatrix
& toUserSpace
;
51 StyleMaskMode maskMode
;
52 imgDrawingParams
& imgParams
;
54 explicit MaskParams(gfx::DrawTarget
* aDt
, nsIFrame
* aMaskedFrame
,
55 const gfxMatrix
& aToUserSpace
, float aOpacity
,
56 StyleMaskMode aMaskMode
, imgDrawingParams
& aImgParams
)
58 maskedFrame(aMaskedFrame
),
59 toUserSpace(aToUserSpace
),
62 imgParams(aImgParams
) {}
65 // SVGMaskFrame method:
68 * Generate a mask surface for the target frame.
70 * The return surface can be null, it's the caller's responsibility to
71 * null-check before dereferencing.
73 already_AddRefed
<SourceSurface
> GetMaskForMaskedFrame(MaskParams
& aParams
);
75 gfxRect
GetMaskArea(nsIFrame
* aMaskedFrame
);
77 nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
78 int32_t aModType
) override
;
81 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
82 nsIFrame
* aPrevInFlow
) override
;
85 void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
86 const nsDisplayListSet
& aLists
) override
{}
88 #ifdef DEBUG_FRAME_DUMP
89 nsresult
GetFrameName(nsAString
& aResult
) const override
{
90 return MakeFrameName(u
"SVGMask"_ns
, aResult
);
96 * If the mask element transforms its children due to
97 * maskContentUnits="objectBoundingBox" being set on it, this function
98 * returns the resulting transform.
100 gfxMatrix
GetMaskTransform(nsIFrame
* aMaskedFrame
);
102 gfxMatrix mMatrixForChildren
;
103 // recursion prevention flag
106 // SVGContainerFrame methods:
107 gfxMatrix
GetCanvasTM() override
;
110 } // namespace mozilla
112 #endif // LAYOUT_SVG_SVGMASKFRAME_H_