tor-browser

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

SVGPaintServerFrame.h (2573B)


      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_SVGPAINTSERVERFRAME_H_
      8 #define LAYOUT_SVG_SVGPAINTSERVERFRAME_H_
      9 
     10 #include "gfxRect.h"
     11 #include "mozilla/Attributes.h"
     12 #include "mozilla/SVGContainerFrame.h"
     13 #include "nsCOMPtr.h"
     14 #include "nsIFrame.h"
     15 #include "nsQueryFrame.h"
     16 
     17 class gfxContext;
     18 class gfxPattern;
     19 
     20 namespace mozilla {
     21 namespace gfx {
     22 class DrawTarget;
     23 }  // namespace gfx
     24 
     25 /**
     26 * RAII class used to temporarily set and remove the
     27 * NS_FRAME_DRAWING_AS_PAINTSERVER frame state bit while a frame is being
     28 * drawn as a paint server.
     29 */
     30 class MOZ_RAII AutoSetRestorePaintServerState {
     31 public:
     32  explicit AutoSetRestorePaintServerState(nsIFrame* aFrame) : mFrame(aFrame) {
     33    mFrame->AddStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
     34  }
     35  ~AutoSetRestorePaintServerState() {
     36    mFrame->RemoveStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
     37  }
     38 
     39 private:
     40  nsIFrame* mFrame;
     41 };
     42 
     43 class SVGPaintServerFrame : public SVGContainerFrame {
     44 protected:
     45  using DrawTarget = gfx::DrawTarget;
     46 
     47  SVGPaintServerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
     48                      ClassID aID)
     49      : SVGContainerFrame(aStyle, aPresContext, aID) {
     50    AddStateBits(NS_FRAME_IS_NONDISPLAY);
     51  }
     52 
     53 public:
     54  using imgDrawingParams = image::imgDrawingParams;
     55 
     56  NS_DECL_ABSTRACT_FRAME(SVGPaintServerFrame)
     57  NS_DECL_QUERYFRAME
     58  NS_DECL_QUERYFRAME_TARGET(SVGPaintServerFrame)
     59 
     60  /**
     61   * Constructs a gfxPattern of the paint server rendering.
     62   *
     63   * @param aContextMatrix The transform matrix that is currently applied to
     64   *   the gfxContext that is being drawn to. This is needed by SVG patterns so
     65   *   that surfaces of the correct size can be created. (SVG gradients are
     66   *   vector based, so it's not used there.)
     67   */
     68  virtual already_AddRefed<gfxPattern> GetPaintServerPattern(
     69      nsIFrame* aSource, const DrawTarget* aDrawTarget,
     70      const gfxMatrix& aContextMatrix,
     71      StyleSVGPaint nsStyleSVG::* aFillOrStroke, float aOpacity,
     72      imgDrawingParams& aImgParams,
     73      const gfxRect* aOverrideBounds = nullptr) = 0;
     74 
     75  // nsIFrame methods:
     76  void BuildDisplayList(nsDisplayListBuilder* aBuilder,
     77                        const nsDisplayListSet& aLists) override {}
     78 };
     79 
     80 }  // namespace mozilla
     81 
     82 #endif  // LAYOUT_SVG_SVGPAINTSERVERFRAME_H_