Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/svg/nsSVGStopFrame.cpp
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
// Keep in (case-insensitive) order:
8
#include "nsContainerFrame.h"
9
#include "nsFrame.h"
10
#include "nsGkAtoms.h"
11
#include "mozilla/ComputedStyle.h"
12
#include "SVGObserverUtils.h"
13
14
// This is a very simple frame whose only purpose is to capture style change
15
// events and propagate them to the parent.  Most of the heavy lifting is done
16
// within the nsSVGGradientFrame, which is the parent for this frame
17
18
class nsSVGStopFrame : public nsFrame
19
{
20
  friend nsIFrame*
21
  NS_NewSVGStopFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
22
protected:
23
  explicit nsSVGStopFrame(ComputedStyle* aStyle)
24
    : nsFrame(aStyle, kClassID)
25
0
  {
26
0
    AddStateBits(NS_FRAME_IS_NONDISPLAY);
27
0
  }
28
29
public:
30
  NS_DECL_FRAMEARENA_HELPERS(nsSVGStopFrame)
31
32
  // nsIFrame interface:
33
#ifdef DEBUG
34
  virtual void Init(nsIContent*       aContent,
35
                    nsContainerFrame* aParent,
36
                    nsIFrame*         aPrevInFlow) override;
37
#endif
38
39
  void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
40
0
                        const nsDisplayListSet& aLists) override {}
41
42
  virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
43
                                    nsAtom*        aAttribute,
44
                                    int32_t         aModType) override;
45
46
  virtual bool IsFrameOfType(uint32_t aFlags) const override
47
0
  {
48
0
    if (aFlags & eSupportsContainLayoutAndPaint) {
49
0
      return false;
50
0
    }
51
0
52
0
    return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
53
0
  }
54
55
#ifdef DEBUG_FRAME_DUMP
56
  virtual nsresult GetFrameName(nsAString& aResult) const override
57
  {
58
    return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
59
  }
60
#endif
61
};
62
63
//----------------------------------------------------------------------
64
// Implementation
65
66
NS_IMPL_FRAMEARENA_HELPERS(nsSVGStopFrame)
67
68
//----------------------------------------------------------------------
69
// nsIFrame methods:
70
71
#ifdef DEBUG
72
void
73
nsSVGStopFrame::Init(nsIContent*       aContent,
74
                     nsContainerFrame* aParent,
75
                     nsIFrame*         aPrevInFlow)
76
{
77
  NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::stop), "Content is not a stop element");
78
79
  nsFrame::Init(aContent, aParent, aPrevInFlow);
80
}
81
#endif /* DEBUG */
82
83
nsresult
84
nsSVGStopFrame::AttributeChanged(int32_t         aNameSpaceID,
85
                                 nsAtom*        aAttribute,
86
                                 int32_t         aModType)
87
0
{
88
0
  if (aNameSpaceID == kNameSpaceID_None &&
89
0
      aAttribute == nsGkAtoms::offset) {
90
0
    MOZ_ASSERT(GetParent()->IsSVGLinearGradientFrame() ||
91
0
               GetParent()->IsSVGRadialGradientFrame(),
92
0
               "Observers observe the gradient, so that's what we must invalidate");
93
0
    SVGObserverUtils::InvalidateDirectRenderingObservers(GetParent());
94
0
  }
95
0
96
0
  return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
97
0
}
98
99
// -------------------------------------------------------------------------
100
// Public functions
101
// -------------------------------------------------------------------------
102
103
nsIFrame* NS_NewSVGStopFrame(nsIPresShell*   aPresShell,
104
                             ComputedStyle* aStyle)
105
0
{
106
0
  return new (aPresShell) nsSVGStopFrame(aStyle);
107
0
}