Backed out changeset 496886cb30a5 (bug 1867152) for bc failures on browser_user_input...
[gecko.git] / layout / svg / CSSClipPathInstance.h
blob2d1e16c62f3081b86449640c2bcaa01b8f81adf1
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"
11 #include "gfxPoint.h"
12 #include "mozilla/gfx/2D.h"
13 #include "nsRect.h"
14 #include "nsStyleStruct.h"
16 class nsIFrame;
17 class gfxContext;
19 namespace mozilla {
21 class MOZ_STACK_CLASS CSSClipPathInstance {
22 using DrawTarget = gfx::DrawTarget;
23 using Path = gfx::Path;
24 using Rect = gfx::Rect;
26 public:
27 static void ApplyBasicShapeOrPathClip(gfxContext& aContext, nsIFrame* aFrame,
28 const gfxMatrix& aTransform);
29 static RefPtr<Path> CreateClipPathForFrame(gfx::DrawTarget* aDt,
30 nsIFrame* aFrame,
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&);
39 private:
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,
59 const nsRect& aRefBox);
61 /**
62 * The frame for the element that is currently being clipped.
64 nsIFrame* mTargetFrame;
65 const StyleClipPath& mClipPathStyle;
68 } // namespace mozilla
70 #endif // LAYOUT_SVG_CSSCLIPPATHINSTANCE_H_