Coverage Report

Created: 2018-09-25 14:53

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