2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef __NS_SVGMARKERFRAME_H__
|
|
|
|
#define __NS_SVGMARKERFRAME_H__
|
|
|
|
|
2013-05-29 12:37:49 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "gfxMatrix.h"
|
|
|
|
#include "gfxRect.h"
|
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsLiteralString.h"
|
|
|
|
#include "nsQueryFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-03-18 03:32:02 -07:00
|
|
|
#include "nsSVGUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-02 00:28:59 -08:00
|
|
|
class nsRenderingContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsSVGPathGeometryFrame;
|
2013-01-09 15:02:45 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class SVGSVGElement;
|
|
|
|
}
|
|
|
|
}
|
2012-03-20 05:15:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
struct nsSVGMark;
|
|
|
|
|
|
|
|
typedef nsSVGContainerFrame nsSVGMarkerFrameBase;
|
|
|
|
|
|
|
|
class nsSVGMarkerFrame : public nsSVGMarkerFrameBase
|
|
|
|
{
|
2013-09-15 22:06:29 -07:00
|
|
|
friend class nsSVGMarkerAnonChildFrame;
|
2014-05-24 15:20:40 -07:00
|
|
|
friend nsContainerFrame*
|
2009-01-19 10:31:34 -08:00
|
|
|
NS_NewSVGMarkerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-09-07 02:30:51 -07:00
|
|
|
protected:
|
2012-03-10 11:28:06 -08:00
|
|
|
nsSVGMarkerFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGMarkerFrameBase(aContext)
|
2012-07-30 07:20:58 -07:00
|
|
|
, mMarkedFrame(nullptr)
|
2012-03-10 11:28:06 -08:00
|
|
|
, mInUse(false)
|
|
|
|
, mInUse2(false)
|
|
|
|
{
|
2013-07-12 00:13:07 -07:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-03-10 11:28:06 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-07 02:30:51 -07:00
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2008-10-10 06:14:05 -07:00
|
|
|
// nsIFrame interface:
|
2009-01-19 10:31:34 -08:00
|
|
|
#ifdef DEBUG
|
2014-05-24 15:20:40 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2009-01-19 10:31:34 -08:00
|
|
|
#endif
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
|
2012-07-20 09:41:29 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgMarkerFrame
|
|
|
|
*/
|
2013-05-29 12:37:49 -07:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGMarker"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-24 15:20:39 -07:00
|
|
|
virtual nsContainerFrame* GetContentInsertionFrame() MOZ_OVERRIDE {
|
2013-09-15 22:06:29 -07:00
|
|
|
// Any children must be added to our single anonymous inner frame kid.
|
|
|
|
NS_ABORT_IF_FALSE(GetFirstPrincipalChild() &&
|
|
|
|
GetFirstPrincipalChild()->GetType() ==
|
|
|
|
nsGkAtoms::svgMarkerAnonChildFrame,
|
|
|
|
"Where is our anonymous child?");
|
|
|
|
return GetFirstPrincipalChild()->GetContentInsertionFrame();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsSVGMarkerFrame methods:
|
2012-03-02 00:28:59 -08:00
|
|
|
nsresult PaintMark(nsRenderingContext *aContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSVGPathGeometryFrame *aMarkedFrame,
|
|
|
|
nsSVGMark *aMark,
|
|
|
|
float aStrokeWidth);
|
|
|
|
|
2013-12-29 22:50:17 -08:00
|
|
|
SVGBBox GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags,
|
2011-09-30 02:25:37 -07:00
|
|
|
nsSVGPathGeometryFrame *aMarkedFrame,
|
|
|
|
const nsSVGMark *aMark,
|
|
|
|
float aStrokeWidth);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// stuff needed for callback
|
|
|
|
nsSVGPathGeometryFrame *mMarkedFrame;
|
2010-02-18 13:50:59 -08:00
|
|
|
float mStrokeWidth, mX, mY, mAutoAngle;
|
2013-07-11 23:39:38 -07:00
|
|
|
bool mIsStart; // whether the callback is for a marker-start marker
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2013-09-11 00:27:45 -07:00
|
|
|
virtual gfxMatrix GetCanvasTM(uint32_t aFor,
|
|
|
|
nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07: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.
|
2013-12-26 10:49:49 -08:00
|
|
|
class MOZ_STACK_CLASS AutoMarkerReferencer
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoMarkerReferencer(nsSVGMarkerFrame *aFrame,
|
2013-12-26 10:49:49 -08:00
|
|
|
nsSVGPathGeometryFrame *aMarkedFrame
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
2007-03-22 10:30:00 -07:00
|
|
|
~AutoMarkerReferencer();
|
|
|
|
private:
|
|
|
|
nsSVGMarkerFrame *mFrame;
|
2013-12-26 10:49:49 -08:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// nsSVGMarkerFrame methods:
|
2013-01-09 15:02:45 -08:00
|
|
|
void SetParentCoordCtxProvider(mozilla::dom::SVGSVGElement *aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// recursion prevention flag
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInUse;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// second recursion prevention flag, for GetCanvasTM()
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInUse2;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2013-09-15 22:06:29 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsMarkerAnonChildFrame class
|
|
|
|
|
|
|
|
typedef nsSVGDisplayContainerFrame nsSVGMarkerAnonChildFrameBase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class nsSVGMarkerAnonChildFrame
|
|
|
|
: public nsSVGMarkerAnonChildFrameBase
|
|
|
|
{
|
2014-05-24 15:20:40 -07:00
|
|
|
friend nsContainerFrame*
|
2013-09-15 22:06:29 -07:00
|
|
|
NS_NewSVGMarkerAnonChildFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
|
|
|
|
|
|
|
nsSVGMarkerAnonChildFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGMarkerAnonChildFrameBase(aContext)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-05-24 15:20:40 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2014-01-05 15:31:14 -08:00
|
|
|
#endif
|
2013-09-15 22:06:29 -07:00
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE {
|
2013-09-15 22:06:29 -07:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGMarkerAnonChild"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgMarkerAnonChildFrame
|
|
|
|
*/
|
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
|
|
|
virtual gfxMatrix GetCanvasTM(uint32_t aFor,
|
|
|
|
nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE
|
|
|
|
{
|
2014-05-24 15:20:41 -07:00
|
|
|
nsSVGMarkerFrame* marker = static_cast<nsSVGMarkerFrame*>(GetParent());
|
2013-09-15 22:06:29 -07:00
|
|
|
return marker->GetCanvasTM(aFor, aTransformRoot);
|
|
|
|
}
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|