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:
8 #include "mozilla/PresShell.h"
9 #include "mozilla/SVGObserverUtils.h"
10 #include "mozilla/dom/SVGFilters.h"
11 #include "ComputedStyle.h"
12 #include "nsContainerFrame.h"
14 #include "nsGkAtoms.h"
16 using namespace mozilla::dom
;
18 nsIFrame
* NS_NewSVGFELeafFrame(mozilla::PresShell
* aPresShell
,
19 mozilla::ComputedStyle
* aStyle
);
23 * This frame is used by filter primitive elements that don't
24 * have special child elements that provide parameters.
26 class SVGFELeafFrame final
: public nsIFrame
{
27 friend nsIFrame
* ::NS_NewSVGFELeafFrame(mozilla::PresShell
* aPresShell
,
28 ComputedStyle
* aStyle
);
31 explicit SVGFELeafFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
)
32 : nsIFrame(aStyle
, aPresContext
, kClassID
) {
33 AddStateBits(NS_FRAME_SVG_LAYOUT
| NS_FRAME_IS_NONDISPLAY
);
37 NS_DECL_FRAMEARENA_HELPERS(SVGFELeafFrame
)
40 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
41 nsIFrame
* aPrevInFlow
) override
;
44 #ifdef DEBUG_FRAME_DUMP
45 nsresult
GetFrameName(nsAString
& aResult
) const override
{
46 return MakeFrameName(u
"SVGFELeaf"_ns
, aResult
);
50 nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
51 int32_t aModType
) override
;
53 bool ComputeCustomOverflow(OverflowAreas
& aOverflowAreas
) override
{
54 // We don't maintain a ink overflow rect
59 } // namespace mozilla
61 nsIFrame
* NS_NewSVGFELeafFrame(mozilla::PresShell
* aPresShell
,
62 mozilla::ComputedStyle
* aStyle
) {
63 return new (aPresShell
)
64 mozilla::SVGFELeafFrame(aStyle
, aPresShell
->GetPresContext());
69 NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame
)
72 void SVGFELeafFrame::Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
73 nsIFrame
* aPrevInFlow
) {
74 NS_ASSERTION(aContent
->IsSVGFilterPrimitiveElement(),
75 "Trying to construct an SVGFELeafFrame for a "
76 "content element that doesn't support the right interfaces");
78 nsIFrame::Init(aContent
, aParent
, aPrevInFlow
);
82 nsresult
SVGFELeafFrame::AttributeChanged(int32_t aNameSpaceID
,
86 static_cast<mozilla::dom::SVGFilterPrimitiveElement
*>(GetContent());
87 if (element
->AttributeAffectsRendering(aNameSpaceID
, aAttribute
)) {
89 GetParent()->IsSVGFilterFrame(),
90 "Observers observe the filter, so that's what we must invalidate");
91 SVGObserverUtils::InvalidateRenderingObservers(GetParent());
94 return nsIFrame::AttributeChanged(aNameSpaceID
, aAttribute
, aModType
);
97 } // namespace mozilla