Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/svg/nsSVGMaskFrame.h
Line
Count
Source (jump to first uncovered line)
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 __NS_SVGMASKFRAME_H__
8
#define __NS_SVGMASKFRAME_H__
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/gfx/2D.h"
12
#include "mozilla/RefPtr.h"
13
#include "gfxPattern.h"
14
#include "gfxMatrix.h"
15
#include "nsSVGContainerFrame.h"
16
#include "nsSVGUtils.h"
17
18
class gfxContext;
19
20
class nsSVGMaskFrame final : public nsSVGContainerFrame
21
{
22
  friend nsIFrame*
23
  NS_NewSVGMaskFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
24
25
  typedef mozilla::gfx::Matrix Matrix;
26
  typedef mozilla::gfx::SourceSurface SourceSurface;
27
  typedef mozilla::image::imgDrawingParams imgDrawingParams;
28
29
protected:
30
  explicit nsSVGMaskFrame(ComputedStyle* aStyle)
31
    : nsSVGContainerFrame(aStyle, kClassID)
32
    , mInUse(false)
33
0
  {
34
0
    AddStateBits(NS_FRAME_IS_NONDISPLAY);
35
0
  }
36
37
public:
38
  NS_DECL_FRAMEARENA_HELPERS(nsSVGMaskFrame)
39
40
  struct MaskParams {
41
    gfxContext* ctx;
42
    nsIFrame* maskedFrame;
43
    const gfxMatrix& toUserSpace;
44
    float opacity;
45
    Matrix* maskTransform;
46
    uint8_t maskMode;
47
    imgDrawingParams& imgParams;
48
49
    explicit MaskParams(gfxContext* aCtx, nsIFrame* aMaskedFrame,
50
                        const gfxMatrix& aToUserSpace, float aOpacity,
51
                        Matrix* aMaskTransform, uint8_t aMaskMode,
52
                        imgDrawingParams& aImgParams)
53
    : ctx(aCtx), maskedFrame(aMaskedFrame), toUserSpace(aToUserSpace),
54
      opacity(aOpacity), maskTransform(aMaskTransform), maskMode(aMaskMode),
55
      imgParams(aImgParams)
56
0
    { }
57
  };
58
59
  // nsSVGMaskFrame method:
60
61
  /**
62
   * Generate a mask surface for the target frame.
63
   *
64
   * The return surface can be null, it's the caller's responsibility to
65
   * null-check before dereferencing.
66
   */
67
  already_AddRefed<SourceSurface>
68
  GetMaskForMaskedFrame(MaskParams& aParams);
69
70
  gfxRect
71
  GetMaskArea(nsIFrame* aMaskedFrame);
72
73
  virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
74
                                    nsAtom*        aAttribute,
75
                                    int32_t         aModType) override;
76
77
#ifdef DEBUG
78
  virtual void Init(nsIContent*       aContent,
79
                    nsContainerFrame* aParent,
80
                    nsIFrame*         aPrevInFlow) override;
81
#endif
82
83
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
84
0
                                const nsDisplayListSet& aLists) override {}
85
86
#ifdef DEBUG_FRAME_DUMP
87
  virtual nsresult GetFrameName(nsAString& aResult) const override
88
  {
89
    return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult);
90
  }
91
#endif
92
93
private:
94
  /**
95
   * If the mask element transforms its children due to
96
   * maskContentUnits="objectBoundingBox" being set on it, this function
97
   * returns the resulting transform.
98
   */
99
  gfxMatrix GetMaskTransform(nsIFrame* aMaskedFrame);
100
101
  gfxMatrix mMatrixForChildren;
102
  // recursion prevention flag
103
  bool mInUse;
104
105
  // nsSVGContainerFrame methods:
106
  virtual gfxMatrix GetCanvasTM() override;
107
};
108
109
#endif