2005-03-09 22:24:18 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-03-09 22:24:18 +03:00
|
|
|
|
2012-03-26 15:58:59 +04:00
|
|
|
// Keep in (case-insensitive) order:
|
2014-11-06 12:30:11 +03:00
|
|
|
#include "nsContainerFrame.h"
|
2006-03-10 02:17:49 +03:00
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsGkAtoms.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsStyleContext.h"
|
2008-10-01 04:51:05 +04:00
|
|
|
#include "nsSVGEffects.h"
|
2005-03-09 22:24:18 +03:00
|
|
|
|
|
|
|
// This is a very simple frame whose only purpose is to capture style change
|
2006-11-02 02:02:18 +03:00
|
|
|
// events and propagate them to the parent. Most of the heavy lifting is done
|
2005-03-09 22:24:18 +03:00
|
|
|
// within the nsSVGGradientFrame, which is the parent for this frame
|
|
|
|
|
2006-02-24 01:52:12 +03:00
|
|
|
typedef nsFrame nsSVGStopFrameBase;
|
2005-03-09 22:24:18 +03:00
|
|
|
|
2006-03-10 02:17:49 +03:00
|
|
|
class nsSVGStopFrame : public nsSVGStopFrameBase
|
2005-03-09 22:24:18 +03:00
|
|
|
{
|
2007-07-25 13:16:02 +04:00
|
|
|
friend nsIFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGStopFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-07-25 13:16:02 +04:00
|
|
|
protected:
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsSVGStopFrame(nsStyleContext* aContext)
|
2012-12-21 14:00:39 +04:00
|
|
|
: nsSVGStopFrameBase(aContext)
|
|
|
|
{
|
2013-07-12 11:13:07 +04:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-12-21 14:00:39 +04:00
|
|
|
}
|
2006-03-27 01:30:36 +04:00
|
|
|
|
2007-07-25 13:16:02 +04:00
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2006-03-10 02:17:49 +03:00
|
|
|
// nsIFrame interface:
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2009-01-19 21:31:34 +03:00
|
|
|
#endif
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override {}
|
2012-07-20 20:41:29 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
2006-03-10 02:17:49 +03:00
|
|
|
|
2005-04-01 23:56:08 +04:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2006-03-10 02:17:49 +03:00
|
|
|
* @see nsGkAtoms::svgStopFrame
|
2005-04-01 23:56:08 +04:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2007-02-24 21:33:33 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override
|
2007-02-24 21:33:33 +03:00
|
|
|
{
|
|
|
|
return nsSVGStopFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
|
|
|
|
}
|
2005-04-01 23:56:08 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override
|
2005-04-01 23:56:08 +04:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2005-03-09 22:24:18 +03:00
|
|
|
};
|
|
|
|
|
2005-08-09 19:45:34 +04:00
|
|
|
//----------------------------------------------------------------------
|
2005-03-09 22:24:18 +03:00
|
|
|
// Implementation
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGStopFrame)
|
|
|
|
|
2005-03-09 22:24:18 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods:
|
|
|
|
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsSVGStopFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2009-01-19 21:31:34 +03:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::stop), "Content is not a stop element");
|
2009-01-19 21:31:34 +03:00
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
nsSVGStopFrameBase::Init(aContent, aParent, aPrevInFlow);
|
2009-01-19 21:31:34 +03:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2005-04-01 23:56:08 +04:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGStopFrame::GetType() const
|
|
|
|
{
|
2006-03-10 02:17:49 +03:00
|
|
|
return nsGkAtoms::svgStopFrame;
|
2005-04-01 23:56:08 +04:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGStopFrame::AttributeChanged(int32_t aNameSpaceID,
|
2006-03-10 02:17:49 +03:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2005-08-09 19:45:34 +04:00
|
|
|
{
|
2006-03-10 02:17:49 +03:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::offset) {
|
2014-11-06 12:30:11 +03:00
|
|
|
MOZ_ASSERT(GetParent()->GetType() == nsGkAtoms::svgLinearGradientFrame ||
|
|
|
|
GetParent()->GetType() == nsGkAtoms::svgRadialGradientFrame,
|
|
|
|
"Observers observe the gradient, so that's what we must invalidate");
|
|
|
|
nsSVGEffects::InvalidateDirectRenderingObservers(GetParent());
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
2006-03-10 02:17:49 +03:00
|
|
|
|
|
|
|
return nsSVGStopFrameBase::AttributeChanged(aNameSpaceID,
|
|
|
|
aAttribute, aModType);
|
2005-08-09 19:45:34 +04:00
|
|
|
}
|
|
|
|
|
2005-03-09 22:24:18 +03:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Public functions
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext)
|
2005-03-09 22:24:18 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsSVGStopFrame(aContext);
|
2005-03-09 22:24:18 +03:00
|
|
|
}
|