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 "nsContainerFrame.h"
10 #include "nsGkAtoms.h"
11 #include "mozilla/ComputedStyle.h"
12 #include "mozilla/PresShell.h"
13 #include "mozilla/SVGGradientFrame.h"
14 #include "mozilla/SVGObserverUtils.h"
16 // This is a very simple frame whose only purpose is to capture style change
17 // events and propagate them to the parent. Most of the heavy lifting is done
18 // within the SVGGradientFrame, which is the parent for this frame
20 nsIFrame
* NS_NewSVGStopFrame(mozilla::PresShell
* aPresShell
,
21 mozilla::ComputedStyle
* aStyle
);
25 class SVGStopFrame
: public nsIFrame
{
26 friend nsIFrame
* ::NS_NewSVGStopFrame(mozilla::PresShell
* aPresShell
,
27 ComputedStyle
* aStyle
);
30 explicit SVGStopFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
)
31 : nsIFrame(aStyle
, aPresContext
, kClassID
) {
32 AddStateBits(NS_FRAME_SVG_LAYOUT
| NS_FRAME_IS_NONDISPLAY
);
36 NS_DECL_FRAMEARENA_HELPERS(SVGStopFrame
)
38 // nsIFrame interface:
40 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
41 nsIFrame
* aPrevInFlow
) override
;
44 void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
45 const nsDisplayListSet
& aLists
) override
{}
47 nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
48 int32_t aModType
) override
;
50 #ifdef DEBUG_FRAME_DUMP
51 nsresult
GetFrameName(nsAString
& aResult
) const override
{
52 return MakeFrameName(u
"SVGStop"_ns
, aResult
);
57 //----------------------------------------------------------------------
60 NS_IMPL_FRAMEARENA_HELPERS(SVGStopFrame
)
62 //----------------------------------------------------------------------
66 void SVGStopFrame::Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
67 nsIFrame
* aPrevInFlow
) {
68 NS_ASSERTION(aContent
->IsSVGElement(nsGkAtoms::stop
),
69 "Content is not a stop element");
71 nsIFrame::Init(aContent
, aParent
, aPrevInFlow
);
75 nsresult
SVGStopFrame::AttributeChanged(int32_t aNameSpaceID
,
76 nsAtom
* aAttribute
, int32_t aModType
) {
77 if (aNameSpaceID
== kNameSpaceID_None
&& aAttribute
== nsGkAtoms::offset
) {
79 static_cast<SVGGradientFrame
*>(do_QueryFrame(GetParent())),
80 "Observers observe the gradient, so that's what we must invalidate");
81 SVGObserverUtils::InvalidateRenderingObservers(GetParent());
84 return nsIFrame::AttributeChanged(aNameSpaceID
, aAttribute
, aModType
);
87 } // namespace mozilla
89 // -------------------------------------------------------------------------
91 // -------------------------------------------------------------------------
93 nsIFrame
* NS_NewSVGStopFrame(mozilla::PresShell
* aPresShell
,
94 mozilla::ComputedStyle
* aStyle
) {
95 return new (aPresShell
)
96 mozilla::SVGStopFrame(aStyle
, aPresShell
->GetPresContext());