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 "mozilla/dom/SVGFilters.h"
9 #include "mozilla/PresShell.h"
10 #include "mozilla/SVGObserverUtils.h"
11 #include "nsContainerFrame.h"
12 #include "nsIFrame.h"
13 #include "nsGkAtoms.h"
14
15 nsIFrame* NS_NewSVGFEUnstyledLeafFrame(mozilla::PresShell* aPresShell,
16 mozilla::ComputedStyle* aStyle);
17
18 namespace mozilla {
19
20 class SVGFEUnstyledLeafFrame final : public nsIFrame {
21 friend nsIFrame* ::NS_NewSVGFEUnstyledLeafFrame(
22 mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
23
24 protected:
SVGFEUnstyledLeafFrame(ComputedStyle * aStyle,nsPresContext * aPresContext)25 explicit SVGFEUnstyledLeafFrame(ComputedStyle* aStyle,
26 nsPresContext* aPresContext)
27 : nsIFrame(aStyle, aPresContext, kClassID) {
28 AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
29 }
30
31 public:
NS_DECL_FRAMEARENA_HELPERS(SVGFEUnstyledLeafFrame)32 NS_DECL_FRAMEARENA_HELPERS(SVGFEUnstyledLeafFrame)
33
34 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
35 const nsDisplayListSet& aLists) override {}
36
IsFrameOfType(uint32_t aFlags) const37 virtual bool IsFrameOfType(uint32_t aFlags) const override {
38 if (aFlags & eSupportsContainLayoutAndPaint) {
39 return false;
40 }
41
42 return nsIFrame::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
43 }
44
45 #ifdef DEBUG_FRAME_DUMP
GetFrameName(nsAString & aResult) const46 virtual nsresult GetFrameName(nsAString& aResult) const override {
47 return MakeFrameName(u"SVGFEUnstyledLeaf"_ns, aResult);
48 }
49 #endif
50
51 virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
52 int32_t aModType) override;
53
ComputeCustomOverflow(OverflowAreas & aOverflowAreas)54 virtual bool ComputeCustomOverflow(OverflowAreas& aOverflowAreas) override {
55 // We don't maintain a ink overflow rect
56 return false;
57 }
58 };
59
60 } // namespace mozilla
61
NS_NewSVGFEUnstyledLeafFrame(mozilla::PresShell * aPresShell,mozilla::ComputedStyle * aStyle)62 nsIFrame* NS_NewSVGFEUnstyledLeafFrame(mozilla::PresShell* aPresShell,
63 mozilla::ComputedStyle* aStyle) {
64 return new (aPresShell)
65 mozilla::SVGFEUnstyledLeafFrame(aStyle, aPresShell->GetPresContext());
66 }
67
68 namespace mozilla {
69
NS_IMPL_FRAMEARENA_HELPERS(SVGFEUnstyledLeafFrame)70 NS_IMPL_FRAMEARENA_HELPERS(SVGFEUnstyledLeafFrame)
71
72 nsresult SVGFEUnstyledLeafFrame::AttributeChanged(int32_t aNameSpaceID,
73 nsAtom* aAttribute,
74 int32_t aModType) {
75 auto* element =
76 static_cast<mozilla::dom::SVGFEUnstyledElement*>(GetContent());
77 if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) {
78 MOZ_ASSERT(
79 GetParent()->GetParent()->IsSVGFilterFrame(),
80 "Observers observe the filter, so that's what we must invalidate");
81 SVGObserverUtils::InvalidateDirectRenderingObservers(
82 GetParent()->GetParent());
83 }
84
85 return nsIFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
86 }
87
88 } // namespace mozilla
89