Backed out changeset 2960ea3e50ca (bug 1881157) for causing crashtest assertion failu...
[gecko.git] / layout / svg / SVGFELeafFrame.cpp
blob2cf2cdf14f431a37b0a7f49e90fb398745526d05
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"
13 #include "nsIFrame.h"
14 #include "nsGkAtoms.h"
16 using namespace mozilla::dom;
18 nsIFrame* NS_NewSVGFELeafFrame(mozilla::PresShell* aPresShell,
19 mozilla::ComputedStyle* aStyle);
20 namespace mozilla {
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);
30 protected:
31 explicit SVGFELeafFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
32 : nsIFrame(aStyle, aPresContext, kClassID) {
33 AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
36 public:
37 NS_DECL_FRAMEARENA_HELPERS(SVGFELeafFrame)
39 #ifdef DEBUG
40 void Init(nsIContent* aContent, nsContainerFrame* aParent,
41 nsIFrame* aPrevInFlow) override;
42 #endif
44 #ifdef DEBUG_FRAME_DUMP
45 nsresult GetFrameName(nsAString& aResult) const override {
46 return MakeFrameName(u"SVGFELeaf"_ns, aResult);
48 #endif
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
55 return false;
59 } // namespace mozilla
61 nsIFrame* NS_NewSVGFELeafFrame(mozilla::PresShell* aPresShell,
62 mozilla::ComputedStyle* aStyle) {
63 return new (aPresShell)
64 mozilla::SVGFELeafFrame(aStyle, aPresShell->GetPresContext());
67 namespace mozilla {
69 NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame)
71 #ifdef DEBUG
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);
80 #endif /* DEBUG */
82 nsresult SVGFELeafFrame::AttributeChanged(int32_t aNameSpaceID,
83 nsAtom* aAttribute,
84 int32_t aModType) {
85 auto* element =
86 static_cast<mozilla::dom::SVGFilterPrimitiveElement*>(GetContent());
87 if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) {
88 MOZ_ASSERT(
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