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 "nsContainerFrame.h"
12 #include "nsGkAtoms.h"
14 #include "nsLiteralString.h"
16 using namespace mozilla::dom
;
18 nsIFrame
* NS_NewSVGFEContainerFrame(mozilla::PresShell
* aPresShell
,
19 mozilla::ComputedStyle
* aStyle
);
24 * This frame is used by filter primitive elements that
25 * have special child elements that provide parameters.
27 class SVGFEContainerFrame final
: public nsContainerFrame
{
28 friend nsIFrame
* ::NS_NewSVGFEContainerFrame(mozilla::PresShell
* aPresShell
,
29 ComputedStyle
* aStyle
);
32 explicit SVGFEContainerFrame(ComputedStyle
* aStyle
,
33 nsPresContext
* aPresContext
)
34 : nsContainerFrame(aStyle
, aPresContext
, kClassID
) {
35 AddStateBits(NS_FRAME_SVG_LAYOUT
| NS_FRAME_IS_NONDISPLAY
);
39 NS_DECL_FRAMEARENA_HELPERS(SVGFEContainerFrame
)
41 #ifdef DEBUG_FRAME_DUMP
42 nsresult
GetFrameName(nsAString
& aResult
) const override
{
43 return MakeFrameName(u
"SVGFEContainer"_ns
, aResult
);
48 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
49 nsIFrame
* aPrevInFlow
) override
;
52 nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
53 int32_t aModType
) override
;
55 bool ComputeCustomOverflow(OverflowAreas
& aOverflowAreas
) override
{
56 // We don't maintain a ink overflow rect
61 } // namespace mozilla
63 nsIFrame
* NS_NewSVGFEContainerFrame(mozilla::PresShell
* aPresShell
,
64 mozilla::ComputedStyle
* aStyle
) {
65 return new (aPresShell
)
66 mozilla::SVGFEContainerFrame(aStyle
, aPresShell
->GetPresContext());
71 NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame
)
74 void SVGFEContainerFrame::Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
75 nsIFrame
* aPrevInFlow
) {
76 NS_ASSERTION(aContent
->IsSVGFilterPrimitiveElement(),
77 "Trying to construct an SVGFEContainerFrame for a "
78 "content element that doesn't support the right interfaces");
80 nsContainerFrame::Init(aContent
, aParent
, aPrevInFlow
);
84 nsresult
SVGFEContainerFrame::AttributeChanged(int32_t aNameSpaceID
,
87 dom::SVGFilterPrimitiveElement
* element
=
88 static_cast<dom::SVGFilterPrimitiveElement
*>(GetContent());
89 if (element
->AttributeAffectsRendering(aNameSpaceID
, aAttribute
)) {
91 GetParent()->IsSVGFilterFrame(),
92 "Observers observe the filter, so that's what we must invalidate");
93 SVGObserverUtils::InvalidateRenderingObservers(GetParent());
96 return nsContainerFrame::AttributeChanged(aNameSpaceID
, aAttribute
, aModType
);
99 } // namespace mozilla