Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/svg/nsSVGAFrame.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 "gfxMatrix.h"
9
#include "mozilla/dom/SVGAElement.h"
10
#include "mozilla/dom/MutationEventBinding.h"
11
#include "nsAutoPtr.h"
12
#include "nsSVGContainerFrame.h"
13
#include "nsSVGIntegrationUtils.h"
14
#include "nsSVGUtils.h"
15
#include "SVGLengthList.h"
16
17
using namespace mozilla;
18
19
class nsSVGAFrame final : public nsSVGDisplayContainerFrame
20
{
21
  friend nsIFrame*
22
  NS_NewSVGAFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
23
protected:
24
  explicit nsSVGAFrame(ComputedStyle* aStyle)
25
    : nsSVGDisplayContainerFrame(aStyle, kClassID)
26
0
  {}
27
28
public:
29
  NS_DECL_FRAMEARENA_HELPERS(nsSVGAFrame)
30
31
#ifdef DEBUG
32
  virtual void Init(nsIContent*       aContent,
33
                    nsContainerFrame* aParent,
34
                    nsIFrame*         aPrevInFlow) override;
35
#endif
36
37
  // nsIFrame:
38
  virtual nsresult  AttributeChanged(int32_t         aNameSpaceID,
39
                                     nsAtom*        aAttribute,
40
                                     int32_t         aModType) override;
41
42
#ifdef DEBUG_FRAME_DUMP
43
  virtual nsresult GetFrameName(nsAString& aResult) const override
44
  {
45
    return MakeFrameName(NS_LITERAL_STRING("SVGA"), aResult);
46
  }
47
#endif
48
};
49
50
//----------------------------------------------------------------------
51
// Implementation
52
53
nsIFrame*
54
NS_NewSVGAFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
55
0
{
56
0
  return new (aPresShell) nsSVGAFrame(aStyle);
57
0
}
58
59
NS_IMPL_FRAMEARENA_HELPERS(nsSVGAFrame)
60
61
//----------------------------------------------------------------------
62
// nsIFrame methods
63
#ifdef DEBUG
64
void
65
nsSVGAFrame::Init(nsIContent*       aContent,
66
                  nsContainerFrame* aParent,
67
                  nsIFrame*         aPrevInFlow)
68
{
69
  NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::a),
70
               "Trying to construct an SVGAFrame for a "
71
               "content element that doesn't support the right interfaces");
72
73
  nsSVGDisplayContainerFrame::Init(aContent, aParent, aPrevInFlow);
74
}
75
#endif /* DEBUG */
76
77
nsresult
78
nsSVGAFrame::AttributeChanged(int32_t         aNameSpaceID,
79
                              nsAtom*        aAttribute,
80
                              int32_t         aModType)
81
0
{
82
0
  if (aNameSpaceID == kNameSpaceID_None &&
83
0
      aAttribute == nsGkAtoms::transform) {
84
0
    // We don't invalidate for transform changes (the layers code does that).
85
0
    // Also note that SVGTransformableElement::GetAttributeChangeHint will
86
0
    // return nsChangeHint_UpdateOverflow for "transform" attribute changes
87
0
    // and cause DoApplyRenderingChangeToTree to make the SchedulePaint call.
88
0
    NotifySVGChanged(TRANSFORM_CHANGED);
89
0
  }
90
0
91
0
  // Currently our SMIL implementation does not modify the DOM attributes. Once
92
0
  // we implement the SVG 2 SMIL behaviour this can be removed
93
0
  // SVGAElement::SetAttr/UnsetAttr's ResetLinkState() call will be sufficient.
94
0
  if (aModType == dom::MutationEvent_Binding::SMIL &&
95
0
      aAttribute == nsGkAtoms::href &&
96
0
      (aNameSpaceID == kNameSpaceID_None ||
97
0
       aNameSpaceID == kNameSpaceID_XLink)) {
98
0
99
0
    dom::SVGAElement* content = static_cast<dom::SVGAElement*>(GetContent());
100
0
101
0
    // SMIL may change whether an <a> element is a link, in which case we will
102
0
    // need to update the link state.
103
0
    content->ResetLinkState(true, content->ElementHasHref());
104
0
  }
105
0
106
0
 return NS_OK;
107
0
}