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/. */
7 // Keep in (case-insensitive) order:
9 #include "mozilla/PresShell.h"
10 #include "mozilla/SVGContainerFrame.h"
11 #include "mozilla/dom/SVGAElement.h"
12 #include "mozilla/dom/MutationEventBinding.h"
13 #include "SVGLengthList.h"
15 nsIFrame
* NS_NewSVGAFrame(mozilla::PresShell
* aPresShell
,
16 mozilla::ComputedStyle
* aStyle
);
20 class SVGAFrame final
: public SVGDisplayContainerFrame
{
21 friend nsIFrame
* ::NS_NewSVGAFrame(mozilla::PresShell
* aPresShell
,
22 ComputedStyle
* aStyle
);
25 explicit SVGAFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
)
26 : SVGDisplayContainerFrame(aStyle
, aPresContext
, kClassID
) {}
29 NS_DECL_FRAMEARENA_HELPERS(SVGAFrame
)
32 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
33 nsIFrame
* aPrevInFlow
) override
;
37 nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
38 int32_t aModType
) override
;
40 #ifdef DEBUG_FRAME_DUMP
41 nsresult
GetFrameName(nsAString
& aResult
) const override
{
42 return MakeFrameName(u
"SVGA"_ns
, aResult
);
47 } // namespace mozilla
49 //----------------------------------------------------------------------
52 nsIFrame
* NS_NewSVGAFrame(mozilla::PresShell
* aPresShell
,
53 mozilla::ComputedStyle
* aStyle
) {
54 return new (aPresShell
)
55 mozilla::SVGAFrame(aStyle
, aPresShell
->GetPresContext());
60 NS_IMPL_FRAMEARENA_HELPERS(SVGAFrame
)
62 //----------------------------------------------------------------------
65 void SVGAFrame::Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
66 nsIFrame
* aPrevInFlow
) {
67 NS_ASSERTION(aContent
->IsSVGElement(nsGkAtoms::a
),
68 "Trying to construct an SVGAFrame for a "
69 "content element that doesn't support the right interfaces");
71 SVGDisplayContainerFrame::Init(aContent
, aParent
, aPrevInFlow
);
75 nsresult
SVGAFrame::AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
77 if (aNameSpaceID
== kNameSpaceID_None
&& aAttribute
== nsGkAtoms::transform
) {
78 // We don't invalidate for transform changes (the layers code does that).
79 // Also note that SVGTransformableElement::GetAttributeChangeHint will
80 // return nsChangeHint_UpdateOverflow for "transform" attribute changes
81 // and cause DoApplyRenderingChangeToTree to make the SchedulePaint call.
82 NotifySVGChanged(TRANSFORM_CHANGED
);
85 // Currently our SMIL implementation does not modify the DOM attributes. Once
86 // we implement the SVG 2 SMIL behaviour this can be removed
87 // SVGAElement::SetAttr/UnsetAttr's ResetLinkState() call will be sufficient.
88 if (aModType
== dom::MutationEvent_Binding::SMIL
&&
89 aAttribute
== nsGkAtoms::href
&&
90 (aNameSpaceID
== kNameSpaceID_None
||
91 aNameSpaceID
== kNameSpaceID_XLink
)) {
92 auto* content
= static_cast<dom::SVGAElement
*>(GetContent());
94 // SMIL may change whether an <a> element is a link, in which case we will
95 // need to update the link state.
96 content
->ResetLinkState(true, content
->ElementHasHref());
102 } // namespace mozilla