Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : // Keep in (case-insensitive) order:
7 : #include "nsContainerFrame.h"
8 : #include "nsGkAtoms.h"
9 : #include "nsIFrame.h"
10 : #include "nsLiteralString.h"
11 : #include "nsSVGEffects.h"
12 : #include "nsSVGFilters.h"
13 :
14 : /*
15 : * This frame is used by filter primitive elements that
16 : * have special child elements that provide parameters.
17 : */
18 0 : class SVGFEContainerFrame : public nsContainerFrame
19 : {
20 : friend nsIFrame*
21 : NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
22 : protected:
23 0 : explicit SVGFEContainerFrame(nsStyleContext* aContext)
24 0 : : nsContainerFrame(aContext, kClassID)
25 : {
26 0 : AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
27 0 : }
28 :
29 : public:
30 0 : NS_DECL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
31 :
32 0 : virtual bool IsFrameOfType(uint32_t aFlags) const override
33 : {
34 0 : return nsContainerFrame::IsFrameOfType(
35 0 : aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer));
36 : }
37 :
38 : #ifdef DEBUG_FRAME_DUMP
39 0 : virtual nsresult GetFrameName(nsAString& aResult) const override
40 : {
41 0 : return MakeFrameName(NS_LITERAL_STRING("SVGFEContainer"), aResult);
42 : }
43 : #endif
44 :
45 : #ifdef DEBUG
46 : virtual void Init(nsIContent* aContent,
47 : nsContainerFrame* aParent,
48 : nsIFrame* aPrevInFlow) override;
49 : #endif
50 :
51 : virtual nsresult AttributeChanged(int32_t aNameSpaceID,
52 : nsIAtom* aAttribute,
53 : int32_t aModType) override;
54 :
55 0 : virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
56 : // We don't maintain a visual overflow rect
57 0 : return false;
58 : }
59 : };
60 :
61 : nsIFrame*
62 0 : NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
63 : {
64 0 : return new (aPresShell) SVGFEContainerFrame(aContext);
65 : }
66 :
67 0 : NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
68 :
69 : #ifdef DEBUG
70 : void
71 0 : SVGFEContainerFrame::Init(nsIContent* aContent,
72 : nsContainerFrame* aParent,
73 : nsIFrame* aPrevInFlow)
74 : {
75 0 : NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER),
76 : "Trying to construct an SVGFEContainerFrame for a "
77 : "content element that doesn't support the right interfaces");
78 :
79 0 : nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
80 0 : }
81 : #endif /* DEBUG */
82 :
83 : nsresult
84 0 : SVGFEContainerFrame::AttributeChanged(int32_t aNameSpaceID,
85 : nsIAtom* aAttribute,
86 : int32_t aModType)
87 : {
88 0 : nsSVGFE *element = static_cast<nsSVGFE*>(mContent);
89 0 : if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) {
90 0 : MOZ_ASSERT(GetParent()->IsSVGFilterFrame(),
91 : "Observers observe the filter, so that's what we must invalidate");
92 0 : nsSVGEffects::InvalidateDirectRenderingObservers(GetParent());
93 : }
94 :
95 0 : return nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
96 : }
|