Bug 1692937 [wpt PR 27636] - new parameter --include-file for wptrunner, a=testonly
[gecko.git] / layout / svg / SVGFEContainerFrame.cpp
bloba8ee89dc2131f8b7397b2295162d4ae222ce05fa
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"
13 #include "nsIFrame.h"
14 #include "nsLiteralString.h"
16 nsIFrame* NS_NewSVGFEContainerFrame(mozilla::PresShell* aPresShell,
17 mozilla::ComputedStyle* aStyle);
19 namespace mozilla {
22 * This frame is used by filter primitive elements that
23 * have special child elements that provide parameters.
25 class SVGFEContainerFrame final : public nsContainerFrame {
26 friend nsIFrame* ::NS_NewSVGFEContainerFrame(mozilla::PresShell* aPresShell,
27 ComputedStyle* aStyle);
29 protected:
30 explicit SVGFEContainerFrame(ComputedStyle* aStyle,
31 nsPresContext* aPresContext)
32 : nsContainerFrame(aStyle, aPresContext, kClassID) {
33 AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
36 public:
37 NS_DECL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
39 virtual bool IsFrameOfType(uint32_t aFlags) const override {
40 if (aFlags & eSupportsContainLayoutAndPaint) {
41 return false;
44 return nsContainerFrame::IsFrameOfType(
45 aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer));
48 #ifdef DEBUG_FRAME_DUMP
49 virtual nsresult GetFrameName(nsAString& aResult) const override {
50 return MakeFrameName(u"SVGFEContainer"_ns, aResult);
52 #endif
54 #ifdef DEBUG
55 virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
56 nsIFrame* aPrevInFlow) override;
57 #endif
59 virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
60 int32_t aModType) override;
62 virtual bool ComputeCustomOverflow(OverflowAreas& aOverflowAreas) override {
63 // We don't maintain a ink overflow rect
64 return false;
68 } // namespace mozilla
70 nsIFrame* NS_NewSVGFEContainerFrame(mozilla::PresShell* aPresShell,
71 mozilla::ComputedStyle* aStyle) {
72 return new (aPresShell)
73 mozilla::SVGFEContainerFrame(aStyle, aPresShell->GetPresContext());
76 namespace mozilla {
78 NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
80 #ifdef DEBUG
81 void SVGFEContainerFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
82 nsIFrame* aPrevInFlow) {
83 nsCOMPtr<SVGFE> filterPrimitive = do_QueryInterface(aContent);
84 NS_ASSERTION(filterPrimitive,
85 "Trying to construct an SVGFEContainerFrame for a "
86 "content element that doesn't support the right interfaces");
88 nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
90 #endif /* DEBUG */
92 nsresult SVGFEContainerFrame::AttributeChanged(int32_t aNameSpaceID,
93 nsAtom* aAttribute,
94 int32_t aModType) {
95 dom::SVGFE* element = static_cast<dom::SVGFE*>(GetContent());
96 if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) {
97 MOZ_ASSERT(
98 GetParent()->IsSVGFilterFrame(),
99 "Observers observe the filter, so that's what we must invalidate");
100 SVGObserverUtils::InvalidateDirectRenderingObservers(GetParent());
103 return nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
106 } // namespace mozilla