2004-12-09 03:16:15 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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/. */
|
2004-12-09 03:16:15 +00:00
|
|
|
|
|
|
|
#ifndef __NS_SVGMARKERFRAME_H__
|
|
|
|
#define __NS_SVGMARKERFRAME_H__
|
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "gfxMatrix.h"
|
|
|
|
#include "gfxRect.h"
|
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsLiteralString.h"
|
|
|
|
#include "nsQueryFrame.h"
|
2006-06-09 20:40:06 +00:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-03-18 10:32:02 +00:00
|
|
|
#include "nsSVGUtils.h"
|
2004-12-09 03:16:15 +00:00
|
|
|
|
2014-10-31 20:08:54 +00:00
|
|
|
class gfxContext;
|
2013-01-09 23:02:45 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2016-12-18 11:11:47 +00:00
|
|
|
class SVGGeometryFrame;
|
2013-01-09 23:02:45 +00:00
|
|
|
namespace dom {
|
|
|
|
class SVGSVGElement;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-03-20 12:15:55 +00:00
|
|
|
|
2006-06-21 15:42:28 +00:00
|
|
|
struct nsSVGMark;
|
2006-06-02 14:26:28 +00:00
|
|
|
|
2016-04-18 07:26:00 +00:00
|
|
|
class nsSVGMarkerFrame : public nsSVGContainerFrame
|
2006-06-09 20:40:06 +00:00
|
|
|
{
|
2013-09-16 05:06:29 +00:00
|
|
|
friend class nsSVGMarkerAnonChildFrame;
|
2014-05-24 22:20:40 +00:00
|
|
|
friend nsContainerFrame*
|
2009-01-19 18:31:34 +00:00
|
|
|
NS_NewSVGMarkerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-09-07 09:30:51 +00:00
|
|
|
protected:
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit nsSVGMarkerFrame(nsStyleContext* aContext)
|
2016-04-18 07:26:00 +00:00
|
|
|
: nsSVGContainerFrame(aContext)
|
2012-07-30 14:20:58 +00:00
|
|
|
, mMarkedFrame(nullptr)
|
2012-03-10 19:28:06 +00:00
|
|
|
, mInUse(false)
|
|
|
|
, mInUse2(false)
|
|
|
|
{
|
2013-07-12 07:13:07 +00:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-03-10 19:28:06 +00:00
|
|
|
}
|
2004-12-09 03:16:15 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2008-10-10 13:14:05 +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
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
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,
|
2014-02-18 08:36:33 +00:00
|
|
|
nsIAtom* aAttribute,
|
2015-03-21 16:28:04 +00:00
|
|
|
int32_t aModType) override;
|
2006-06-09 20:40:06 +00:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2007-01-30 00:06:41 +00:00
|
|
|
* @see nsGkAtoms::svgMarkerFrame
|
2006-06-09 20:40:06 +00:00
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2006-06-09 20:40:06 +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
|
2006-06-09 20:40:06 +00:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGMarker"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsContainerFrame* GetContentInsertionFrame() override {
|
2013-09-16 05:06:29 +00:00
|
|
|
// Any children must be added to our single anonymous inner frame kid.
|
2016-01-29 14:42:14 +00:00
|
|
|
MOZ_ASSERT(PrincipalChildList().FirstChild() &&
|
|
|
|
PrincipalChildList().FirstChild()->GetType() ==
|
2015-02-09 22:34:50 +00:00
|
|
|
nsGkAtoms::svgMarkerAnonChildFrame,
|
|
|
|
"Where is our anonymous child?");
|
2016-01-29 14:42:14 +00:00
|
|
|
return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
|
2013-09-16 05:06:29 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 20:40:06 +00:00
|
|
|
// nsSVGMarkerFrame methods:
|
2014-10-31 20:08:54 +00:00
|
|
|
nsresult PaintMark(gfxContext& aContext,
|
2014-08-29 19:42:07 +00:00
|
|
|
const gfxMatrix& aToMarkedFrameUserSpace,
|
2016-12-18 11:11:47 +00:00
|
|
|
SVGGeometryFrame *aMarkedFrame,
|
2006-06-09 20:40:06 +00:00
|
|
|
nsSVGMark *aMark,
|
|
|
|
float aStrokeWidth);
|
|
|
|
|
2013-12-30 06:50:17 +00:00
|
|
|
SVGBBox GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags,
|
2016-12-18 11:11:47 +00:00
|
|
|
SVGGeometryFrame *aMarkedFrame,
|
2011-09-30 09:25:37 +00:00
|
|
|
const nsSVGMark *aMark,
|
|
|
|
float aStrokeWidth);
|
2006-06-09 20:40:06 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// stuff needed for callback
|
2016-12-18 11:11:47 +00:00
|
|
|
SVGGeometryFrame *mMarkedFrame;
|
2010-02-18 21:50:59 +00:00
|
|
|
float mStrokeWidth, mX, mY, mAutoAngle;
|
2013-07-12 06:39:38 +00:00
|
|
|
bool mIsStart; // whether the callback is for a marker-start marker
|
2006-06-09 20:40:06 +00:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
2006-06-09 20:40:06 +00:00
|
|
|
|
2006-12-07 09:32:13 +00:00
|
|
|
// A helper class to allow us to paint markers safely. The helper
|
|
|
|
// automatically sets and clears the mInUse flag on the marker frame (to
|
|
|
|
// prevent nasty reference loops) as well as the reference to the marked
|
|
|
|
// frame and its coordinate context. It's easy to mess this up
|
|
|
|
// and break things, so this helper makes the code far more robust.
|
2015-09-03 16:15:23 +00:00
|
|
|
class MOZ_RAII AutoMarkerReferencer
|
2006-12-07 09:32:13 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoMarkerReferencer(nsSVGMarkerFrame *aFrame,
|
2016-12-18 11:11:47 +00:00
|
|
|
SVGGeometryFrame *aMarkedFrame
|
2013-12-26 18:49:49 +00:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
2006-12-07 09:32:13 +00:00
|
|
|
~AutoMarkerReferencer();
|
|
|
|
private:
|
|
|
|
nsSVGMarkerFrame *mFrame;
|
2013-12-26 18:49:49 +00:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
2006-12-07 09:32:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// nsSVGMarkerFrame methods:
|
2013-01-09 23:02:45 +00:00
|
|
|
void SetParentCoordCtxProvider(mozilla::dom::SVGSVGElement *aContext);
|
2006-12-07 09:32:13 +00:00
|
|
|
|
2006-06-09 20:40:06 +00:00
|
|
|
// recursion prevention flag
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInUse;
|
2006-06-09 20:40:06 +00:00
|
|
|
|
|
|
|
// second recursion prevention flag, for GetCanvasTM()
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInUse2;
|
2006-06-09 20:40:06 +00:00
|
|
|
};
|
2005-11-11 14:36:26 +00:00
|
|
|
|
2013-09-16 05:06:29 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsMarkerAnonChildFrame class
|
|
|
|
|
2016-04-18 07:28:03 +00:00
|
|
|
class nsSVGMarkerAnonChildFrame : public nsSVGDisplayContainerFrame
|
2013-09-16 05:06:29 +00:00
|
|
|
{
|
2014-05-24 22:20:40 +00:00
|
|
|
friend nsContainerFrame*
|
2013-09-16 05:06:29 +00:00
|
|
|
NS_NewSVGMarkerAnonChildFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
|
|
|
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit nsSVGMarkerAnonChildFrame(nsStyleContext* aContext)
|
2016-04-18 07:28:03 +00:00
|
|
|
: nsSVGDisplayContainerFrame(aContext)
|
2013-09-16 05:06:29 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
|
|
|
#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;
|
2014-01-05 23:31:14 +00:00
|
|
|
#endif
|
2013-09-16 05:06:29 +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 {
|
2013-09-16 05:06:29 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGMarkerAnonChild"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgMarkerAnonChildFrame
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2013-09-16 05:06:29 +00:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual gfxMatrix GetCanvasTM() override
|
2013-09-16 05:06:29 +00:00
|
|
|
{
|
2014-09-08 11:28:50 +00:00
|
|
|
return static_cast<nsSVGMarkerFrame*>(GetParent())->GetCanvasTM();
|
2013-09-16 05:06:29 +00:00
|
|
|
}
|
|
|
|
};
|
2004-12-09 03:16:15 +00:00
|
|
|
#endif
|