Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/svg/SVGFELeafFrame.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 "SVGObserverUtils.h"
12
#include "nsSVGFilters.h"
13
14
/*
15
 * This frame is used by filter primitive elements that don't
16
 * have special child elements that provide parameters.
17
 */
18
class SVGFELeafFrame final : public nsFrame
19
{
20
  friend nsIFrame*
21
  NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
22
protected:
23
  explicit SVGFELeafFrame(ComputedStyle* aStyle)
24
    : nsFrame(aStyle, kClassID)
25
0
  {
26
0
    AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
27
0
  }
28
29
public:
30
  NS_DECL_FRAMEARENA_HELPERS(SVGFELeafFrame)
31
32
#ifdef DEBUG
33
  virtual void Init(nsIContent*       aContent,
34
                    nsContainerFrame* aParent,
35
                    nsIFrame*         aPrevInFlow) override;
36
#endif
37
38
  virtual bool IsFrameOfType(uint32_t aFlags) const override
39
0
  {
40
0
    if (aFlags & eSupportsContainLayoutAndPaint) {
41
0
      return false;
42
0
    }
43
0
44
0
    return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
45
0
  }
46
47
#ifdef DEBUG_FRAME_DUMP
48
  virtual nsresult GetFrameName(nsAString& aResult) const override
49
  {
50
    return MakeFrameName(NS_LITERAL_STRING("SVGFELeaf"), aResult);
51
  }
52
#endif
53
54
  virtual nsresult AttributeChanged(int32_t  aNameSpaceID,
55
                                    nsAtom* aAttribute,
56
                                    int32_t  aModType) override;
57
58
0
  virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
59
0
    // We don't maintain a visual overflow rect
60
0
    return false;
61
0
  }
62
};
63
64
nsIFrame*
65
NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
66
0
{
67
0
  return new (aPresShell) SVGFELeafFrame(aStyle);
68
0
}
69
70
NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame)
71
72
#ifdef DEBUG
73
void
74
SVGFELeafFrame::Init(nsIContent*       aContent,
75
                     nsContainerFrame* aParent,
76
                     nsIFrame*         aPrevInFlow)
77
{
78
  NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER),
79
               "Trying to construct an SVGFELeafFrame for a "
80
               "content element that doesn't support the right interfaces");
81
82
  nsFrame::Init(aContent, aParent, aPrevInFlow);
83
}
84
#endif /* DEBUG */
85
86
nsresult
87
SVGFELeafFrame::AttributeChanged(int32_t  aNameSpaceID,
88
                                 nsAtom* aAttribute,
89
                                 int32_t  aModType)
90
0
{
91
0
  nsSVGFE *element = static_cast<nsSVGFE*>(GetContent());
92
0
  if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) {
93
0
    MOZ_ASSERT(GetParent()->IsSVGFilterFrame(),
94
0
               "Observers observe the filter, so that's what we must invalidate");
95
0
    SVGObserverUtils::InvalidateDirectRenderingObservers(GetParent());
96
0
  }
97
0
98
0
  return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
99
0
}