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 "nsFrame.h"
9 : #include "nsGkAtoms.h"
10 : #include "nsSVGEffects.h"
11 : #include "nsSVGFilters.h"
12 :
13 : /*
14 : * This frame is used by filter primitive elements that don't
15 : * have special child elements that provide parameters.
16 : */
17 0 : class SVGFELeafFrame final : public nsFrame
18 : {
19 : friend nsIFrame*
20 : NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
21 : protected:
22 0 : explicit SVGFELeafFrame(nsStyleContext* aContext)
23 0 : : nsFrame(aContext, kClassID)
24 : {
25 0 : AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
26 0 : }
27 :
28 : public:
29 0 : NS_DECL_FRAMEARENA_HELPERS(SVGFELeafFrame)
30 :
31 : #ifdef DEBUG
32 : virtual void Init(nsIContent* aContent,
33 : nsContainerFrame* aParent,
34 : nsIFrame* aPrevInFlow) override;
35 : #endif
36 :
37 0 : virtual bool IsFrameOfType(uint32_t aFlags) const override
38 : {
39 0 : return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
40 : }
41 :
42 : #ifdef DEBUG_FRAME_DUMP
43 0 : virtual nsresult GetFrameName(nsAString& aResult) const override
44 : {
45 0 : return MakeFrameName(NS_LITERAL_STRING("SVGFELeaf"), aResult);
46 : }
47 : #endif
48 :
49 : virtual nsresult AttributeChanged(int32_t aNameSpaceID,
50 : nsIAtom* aAttribute,
51 : int32_t aModType) override;
52 :
53 0 : virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
54 : // We don't maintain a visual overflow rect
55 0 : return false;
56 : }
57 : };
58 :
59 : nsIFrame*
60 0 : NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
61 : {
62 0 : return new (aPresShell) SVGFELeafFrame(aContext);
63 : }
64 :
65 0 : NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame)
66 :
67 : #ifdef DEBUG
68 : void
69 0 : SVGFELeafFrame::Init(nsIContent* aContent,
70 : nsContainerFrame* aParent,
71 : nsIFrame* aPrevInFlow)
72 : {
73 0 : NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER),
74 : "Trying to construct an SVGFELeafFrame for a "
75 : "content element that doesn't support the right interfaces");
76 :
77 0 : nsFrame::Init(aContent, aParent, aPrevInFlow);
78 0 : }
79 : #endif /* DEBUG */
80 :
81 : nsresult
82 0 : SVGFELeafFrame::AttributeChanged(int32_t aNameSpaceID,
83 : nsIAtom* aAttribute,
84 : int32_t aModType)
85 : {
86 0 : nsSVGFE *element = static_cast<nsSVGFE*>(mContent);
87 0 : if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) {
88 0 : MOZ_ASSERT(GetParent()->IsSVGFilterFrame(),
89 : "Observers observe the filter, so that's what we must invalidate");
90 0 : nsSVGEffects::InvalidateDirectRenderingObservers(GetParent());
91 : }
92 :
93 0 : return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
94 : }
|