2017-10-27 17:33:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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 19:24:18 +00:00
|
|
|
|
2012-03-26 11:58:59 +00:00
|
|
|
// Keep in (case-insensitive) order:
|
2014-11-06 09:30:11 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2006-03-09 23:17:49 +00:00
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsGkAtoms.h"
|
2018-03-22 18:20:41 +00:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2019-04-16 07:24:49 +00:00
|
|
|
#include "mozilla/PresShell.h"
|
2017-08-30 13:14:46 +00:00
|
|
|
#include "SVGObserverUtils.h"
|
2005-03-09 19:24:18 +00:00
|
|
|
|
2018-11-12 22:20:52 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2005-03-09 19:24:18 +00:00
|
|
|
// This is a very simple frame whose only purpose is to capture style change
|
2006-11-01 23:02:18 +00:00
|
|
|
// events and propagate them to the parent. Most of the heavy lifting is done
|
2005-03-09 19:24:18 +00:00
|
|
|
// within the nsSVGGradientFrame, which is the parent for this frame
|
|
|
|
|
2016-04-18 07:42:05 +00:00
|
|
|
class nsSVGStopFrame : public nsFrame {
|
2019-04-16 07:24:49 +00:00
|
|
|
friend nsIFrame* NS_NewSVGStopFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 18:20:41 +00:00
|
|
|
ComputedStyle* aStyle);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2007-07-25 09:16:02 +00:00
|
|
|
protected:
|
2019-02-05 16:45:54 +00:00
|
|
|
explicit nsSVGStopFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
|
|
|
: nsFrame(aStyle, aPresContext, kClassID) {
|
2019-05-29 23:50:55 +00:00
|
|
|
AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
|
2012-12-21 10:00:39 +00:00
|
|
|
}
|
2006-03-26 21:30:36 +00:00
|
|
|
|
2007-07-25 09:16:02 +00:00
|
|
|
public:
|
2017-05-26 10:11:11 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsSVGStopFrame)
|
2009-09-12 16:49:24 +00:00
|
|
|
|
2006-03-09 23:17:49 +00:00
|
|
|
// nsIFrame interface:
|
2009-01-19 18:31:34 +00:00
|
|
|
#ifdef DEBUG
|
2014-05-24 22:20:40 +00:00
|
|
|
virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2009-01-19 18:31:34 +00:00
|
|
|
#endif
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) override {}
|
2012-07-20 16:41:29 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
2015-03-21 16:28:04 +00:00
|
|
|
int32_t aModType) override;
|
2006-03-09 23:17:49 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
2018-08-07 22:02:07 +00:00
|
|
|
if (aFlags & eSupportsContainLayoutAndPaint) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-18 07:42:05 +00:00
|
|
|
return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
|
2007-02-24 18:33:33 +00:00
|
|
|
}
|
2005-04-01 19:56:08 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override {
|
2005-04-01 19:56:08 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2005-03-09 19:24:18 +00:00
|
|
|
};
|
|
|
|
|
2005-08-09 15:45:34 +00:00
|
|
|
//----------------------------------------------------------------------
|
2005-03-09 19:24:18 +00:00
|
|
|
// Implementation
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGStopFrame)
|
|
|
|
|
2005-03-09 19:24:18 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods:
|
|
|
|
|
2009-01-19 18:31:34 +00:00
|
|
|
#ifdef DEBUG
|
2014-05-24 22:20:40 +00:00
|
|
|
void nsSVGStopFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) {
|
2015-03-03 11:08:59 +00:00
|
|
|
NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::stop),
|
|
|
|
"Content is not a stop element");
|
2009-01-19 18:31:34 +00:00
|
|
|
|
2016-04-18 07:42:05 +00:00
|
|
|
nsFrame::Init(aContent, aParent, aPrevInFlow);
|
2009-01-19 18:31:34 +00:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult nsSVGStopFrame::AttributeChanged(int32_t aNameSpaceID,
|
2017-10-02 22:05:19 +00:00
|
|
|
nsAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aModType) {
|
2006-03-09 23:17:49 +00:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::offset) {
|
2017-04-30 15:30:08 +00:00
|
|
|
MOZ_ASSERT(
|
|
|
|
GetParent()->IsSVGLinearGradientFrame() ||
|
|
|
|
GetParent()->IsSVGRadialGradientFrame(),
|
2014-11-06 09:30:11 +00:00
|
|
|
"Observers observe the gradient, so that's what we must invalidate");
|
2017-08-30 14:58:31 +00:00
|
|
|
SVGObserverUtils::InvalidateDirectRenderingObservers(GetParent());
|
2008-10-01 00:51:05 +00:00
|
|
|
}
|
2006-03-09 23:17:49 +00:00
|
|
|
|
2016-04-18 07:42:05 +00:00
|
|
|
return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2005-08-09 15:45:34 +00:00
|
|
|
}
|
|
|
|
|
2005-03-09 19:24:18 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Public functions
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2019-04-16 07:24:49 +00:00
|
|
|
nsIFrame* NS_NewSVGStopFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
|
2019-02-05 16:45:54 +00:00
|
|
|
return new (aPresShell) nsSVGStopFrame(aStyle, aPresShell->GetPresContext());
|
2005-03-09 19:24:18 +00:00
|
|
|
}
|