tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CSSClipPathInstance.h (2705B)


      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/. */
      6 
      7 #ifndef LAYOUT_SVG_CSSCLIPPATHINSTANCE_H_
      8 #define LAYOUT_SVG_CSSCLIPPATHINSTANCE_H_
      9 
     10 #include "gfxMatrix.h"
     11 #include "gfxPoint.h"
     12 #include "mozilla/gfx/2D.h"
     13 #include "nsRect.h"
     14 #include "nsStyleStruct.h"
     15 
     16 class nsIFrame;
     17 class gfxContext;
     18 
     19 namespace mozilla {
     20 
     21 class MOZ_STACK_CLASS CSSClipPathInstance {
     22  using DrawTarget = gfx::DrawTarget;
     23  using Path = gfx::Path;
     24  using Rect = gfx::Rect;
     25 
     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);
     35 
     36  static Maybe<Rect> GetBoundingRectForBasicShapeOrPathClip(
     37      nsIFrame* aFrame, const StyleClipPath&);
     38 
     39 private:
     40  explicit CSSClipPathInstance(nsIFrame* aFrame, const StyleClipPath& aClipPath)
     41      : mTargetFrame(aFrame), mClipPathStyle(aClipPath) {}
     42 
     43  already_AddRefed<Path> CreateClipPath(DrawTarget* aDrawTarget,
     44                                        const gfxMatrix& aTransform);
     45 
     46  already_AddRefed<Path> CreateClipPathCircle(DrawTarget* aDrawTarget,
     47                                              const nsRect& aRefBox);
     48 
     49  already_AddRefed<Path> CreateClipPathEllipse(DrawTarget* aDrawTarget,
     50                                               const nsRect& aRefBox);
     51 
     52  already_AddRefed<Path> CreateClipPathPolygon(DrawTarget* aDrawTarget,
     53                                               const nsRect& aRefBox);
     54 
     55  already_AddRefed<Path> CreateClipPathInset(DrawTarget* aDrawTarget,
     56                                             const nsRect& aRefBox);
     57 
     58  already_AddRefed<Path> CreateClipPathPath(DrawTarget* aDrawTarget,
     59                                            const nsRect& aRefBox);
     60 
     61  already_AddRefed<Path> CreateClipPathShape(DrawTarget* aDrawTarget,
     62                                             const nsRect& aRefBox);
     63 
     64  /**
     65   * The frame for the element that is currently being clipped.
     66   */
     67  nsIFrame* mTargetFrame;
     68  const StyleClipPath& mClipPathStyle;
     69 };
     70 
     71 }  // namespace mozilla
     72 
     73 #endif  // LAYOUT_SVG_CSSCLIPPATHINSTANCE_H_