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_CSSCLIPPATHINSTANCE_H_
8 #define LAYOUT_SVG_CSSCLIPPATHINSTANCE_H_
10 #include "gfxMatrix.h"
12 #include "mozilla/gfx/2D.h"
14 #include "nsStyleStruct.h"
21 class MOZ_STACK_CLASS CSSClipPathInstance
{
22 using DrawTarget
= gfx::DrawTarget
;
23 using Path
= gfx::Path
;
24 using Rect
= gfx::Rect
;
27 static void ApplyBasicShapeOrPathClip(gfxContext
& aContext
, nsIFrame
* aFrame
,
28 const gfxMatrix
& aTransform
);
29 static RefPtr
<Path
> CreateClipPathForFrame(gfx::DrawTarget
* aDt
,
31 const gfxMatrix
& aTransform
);
32 // aPoint is in CSS pixels.
33 static bool HitTestBasicShapeOrPathClip(nsIFrame
* aFrame
,
34 const gfxPoint
& aPoint
);
36 static Maybe
<Rect
> GetBoundingRectForBasicShapeOrPathClip(
37 nsIFrame
* aFrame
, const StyleClipPath
&);
40 explicit CSSClipPathInstance(nsIFrame
* aFrame
, const StyleClipPath
& aClipPath
)
41 : mTargetFrame(aFrame
), mClipPathStyle(aClipPath
) {}
43 already_AddRefed
<Path
> CreateClipPath(DrawTarget
* aDrawTarget
,
44 const gfxMatrix
& aTransform
);
46 already_AddRefed
<Path
> CreateClipPathCircle(DrawTarget
* aDrawTarget
,
47 const nsRect
& aRefBox
);
49 already_AddRefed
<Path
> CreateClipPathEllipse(DrawTarget
* aDrawTarget
,
50 const nsRect
& aRefBox
);
52 already_AddRefed
<Path
> CreateClipPathPolygon(DrawTarget
* aDrawTarget
,
53 const nsRect
& aRefBox
);
55 already_AddRefed
<Path
> CreateClipPathInset(DrawTarget
* aDrawTarget
,
56 const nsRect
& aRefBox
);
58 already_AddRefed
<Path
> CreateClipPathPath(DrawTarget
* aDrawTarget
);
61 * The frame for the element that is currently being clipped.
63 nsIFrame
* mTargetFrame
;
64 const StyleClipPath
& mClipPathStyle
;
67 } // namespace mozilla
69 #endif // LAYOUT_SVG_CSSCLIPPATHINSTANCE_H_