2017-10-27 20:33:53 +03: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 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"
|
2020-07-07 01:38:11 +03:00
|
|
|
#include "nsIFrame.h"
|
2006-03-10 02:17:49 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2019-04-16 10:24:49 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
2020-07-07 16:49:30 +03:00
|
|
|
#include "mozilla/SVGObserverUtils.h"
|
2018-11-13 01:20:52 +03:00
|
|
|
|
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
|
2020-07-07 16:49:30 +03:00
|
|
|
// within the SVGGradientFrame, which is the parent for this frame
|
|
|
|
|
|
|
|
nsIFrame* NS_NewSVGStopFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle);
|
2005-03-09 22:24:18 +03:00
|
|
|
|
2020-07-07 16:49:30 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class SVGStopFrame : public nsIFrame {
|
|
|
|
friend nsIFrame* ::NS_NewSVGStopFrame(mozilla::PresShell* aPresShell,
|
|
|
|
ComputedStyle* aStyle);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-07-25 13:16:02 +04:00
|
|
|
protected:
|
2020-07-07 16:49:30 +03:00
|
|
|
explicit SVGStopFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
2020-07-07 01:29:42 +03:00
|
|
|
: nsIFrame(aStyle, aPresContext, kClassID) {
|
2019-05-30 02:50:55 +03:00
|
|
|
AddStateBits(NS_FRAME_SVG_LAYOUT | 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:
|
2020-07-07 16:49:30 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(SVGStopFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
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,
|
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, nsAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
2006-03-10 02:17:49 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
2018-08-08 01:02:07 +03:00
|
|
|
if (aFlags & eSupportsContainLayoutAndPaint) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-07 01:29:42 +03:00
|
|
|
return nsIFrame::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
|
2007-02-24 21:33:33 +03:00
|
|
|
}
|
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(u"SVGStop"_ns, 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
|
|
|
|
|
2020-07-07 16:49:30 +03:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(SVGStopFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2005-03-09 22:24:18 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods:
|
|
|
|
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
2020-07-07 16:49:30 +03:00
|
|
|
void SVGStopFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) {
|
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
|
|
|
|
2020-07-07 01:29:42 +03:00
|
|
|
nsIFrame::Init(aContent, aParent, aPrevInFlow);
|
2009-01-19 21:31:34 +03:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2020-07-07 16:49:30 +03:00
|
|
|
nsresult SVGStopFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
|
|
nsAtom* aAttribute, int32_t aModType) {
|
2006-03-10 02:17:49 +03:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::offset) {
|
2017-04-30 18:30:08 +03:00
|
|
|
MOZ_ASSERT(
|
2020-07-20 21:02:25 +03:00
|
|
|
static_cast<SVGGradientFrame*>(do_QueryFrame(GetParent())),
|
2014-11-06 12:30:11 +03:00
|
|
|
"Observers observe the gradient, so that's what we must invalidate");
|
2017-08-30 17:58:31 +03:00
|
|
|
SVGObserverUtils::InvalidateDirectRenderingObservers(GetParent());
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
2006-03-10 02:17:49 +03:00
|
|
|
|
2020-07-07 01:29:42 +03:00
|
|
|
return nsIFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2005-08-09 19:45:34 +04:00
|
|
|
}
|
|
|
|
|
2020-07-07 16:49:30 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2005-03-09 22:24:18 +03:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Public functions
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2020-07-07 16:49:30 +03:00
|
|
|
nsIFrame* NS_NewSVGStopFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle) {
|
|
|
|
return new (aPresShell)
|
|
|
|
mozilla::SVGStopFrame(aStyle, aPresShell->GetPresContext());
|
2005-03-09 22:24:18 +03:00
|
|
|
}
|