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/. */
|
2004-12-09 06:16:15 +03:00
|
|
|
|
|
|
|
#ifndef __NS_SVGMARKERFRAME_H__
|
|
|
|
#define __NS_SVGMARKERFRAME_H__
|
|
|
|
|
2013-05-29 23:37:49 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2020-07-09 04:33:33 +03:00
|
|
|
#include "mozilla/SVGContainerFrame.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
#include "gfxMatrix.h"
|
|
|
|
#include "gfxRect.h"
|
2020-07-07 01:38:11 +03:00
|
|
|
#include "nsIFrame.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
#include "nsLiteralString.h"
|
|
|
|
#include "nsQueryFrame.h"
|
2012-03-18 14:32:02 +04:00
|
|
|
#include "nsSVGUtils.h"
|
2004-12-09 06:16:15 +03:00
|
|
|
|
2014-10-31 23:08:54 +03:00
|
|
|
class gfxContext;
|
2013-01-10 03:02:45 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2019-01-26 16:01:31 +03:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
class PresShell;
|
2016-12-18 14:11:47 +03:00
|
|
|
class SVGGeometryFrame;
|
2019-01-26 16:01:31 +03:00
|
|
|
|
|
|
|
struct SVGMark;
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
namespace dom {
|
2017-10-10 09:58:34 +03:00
|
|
|
class SVGViewportElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-03-20 16:15:55 +04:00
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
nsContainerFrame* NS_NewSVGMarkerFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle);
|
|
|
|
nsContainerFrame* NS_NewSVGMarkerAnonChildFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle);
|
2017-05-18 23:03:41 +03:00
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
class SVGMarkerFrame final : public SVGContainerFrame {
|
2020-06-27 08:39:42 +03:00
|
|
|
typedef image::imgDrawingParams imgDrawingParams;
|
|
|
|
|
|
|
|
friend class SVGMarkerAnonChildFrame;
|
|
|
|
friend nsContainerFrame* ::NS_NewSVGMarkerFrame(
|
|
|
|
mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-09-07 13:30:51 +04:00
|
|
|
protected:
|
2020-06-27 08:39:42 +03:00
|
|
|
explicit SVGMarkerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
2020-07-09 04:33:33 +03:00
|
|
|
: SVGContainerFrame(aStyle, aPresContext, kClassID),
|
2012-07-30 18:20:58 +04:00
|
|
|
mMarkedFrame(nullptr),
|
2012-03-10 23:28:06 +04:00
|
|
|
mInUse(false),
|
|
|
|
mInUse2(false) {
|
2013-07-12 11:13:07 +04:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-03-10 23:28:06 +04:00
|
|
|
}
|
2004-12-09 06:16:15 +03:00
|
|
|
|
2007-09-07 13:30:51 +04:00
|
|
|
public:
|
2020-06-27 08:39:42 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(SVGMarkerFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2008-10-10 17:14:05 +04: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
|
|
|
virtual 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-06-10 00:40:06 +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 {
|
2020-07-01 11:29:29 +03:00
|
|
|
return MakeFrameName(u"SVGMarker"_ns, aResult);
|
2006-06-10 00:40:06 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsContainerFrame* GetContentInsertionFrame() override {
|
2013-09-16 09:06:29 +04:00
|
|
|
// Any children must be added to our single anonymous inner frame kid.
|
2016-01-29 17:42:14 +03:00
|
|
|
MOZ_ASSERT(
|
|
|
|
PrincipalChildList().FirstChild() &&
|
2017-04-30 18:30:08 +03:00
|
|
|
PrincipalChildList().FirstChild()->IsSVGMarkerAnonChildFrame(),
|
2015-02-10 01:34:50 +03:00
|
|
|
"Where is our anonymous child?");
|
2016-01-29 17:42:14 +03:00
|
|
|
return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
|
2013-09-16 09:06:29 +04:00
|
|
|
}
|
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
// SVGMarkerFrame methods:
|
2017-05-18 23:03:41 +03:00
|
|
|
void PaintMark(gfxContext& aContext, const gfxMatrix& aToMarkedFrameUserSpace,
|
2020-06-27 08:39:42 +03:00
|
|
|
SVGGeometryFrame* aMarkedFrame, const SVGMark& aMark,
|
2019-01-26 16:01:31 +03:00
|
|
|
float aStrokeWidth, imgDrawingParams& aImgParams);
|
2006-06-10 00:40:06 +04:00
|
|
|
|
2017-06-08 08:17:07 +03:00
|
|
|
SVGBBox GetMarkBBoxContribution(const Matrix& aToBBoxUserspace,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags,
|
2020-06-27 08:39:42 +03:00
|
|
|
SVGGeometryFrame* aMarkedFrame,
|
2019-01-26 16:01:31 +03:00
|
|
|
const SVGMark& aMark, float aStrokeWidth);
|
2006-06-10 00:40:06 +04:00
|
|
|
|
2017-06-16 12:22:33 +03:00
|
|
|
// Return our anonymous box child.
|
|
|
|
void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
|
2017-03-15 21:00:44 +03:00
|
|
|
|
2006-06-10 00:40:06 +04:00
|
|
|
private:
|
|
|
|
// stuff needed for callback
|
2020-06-27 08:39:42 +03:00
|
|
|
SVGGeometryFrame* mMarkedFrame;
|
2017-06-08 08:17:07 +03:00
|
|
|
Matrix mMarkerTM;
|
2006-06-10 00:40:06 +04:00
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
// SVGContainerFrame methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
2006-06-10 00:40:06 +04:00
|
|
|
|
2006-12-07 12:32:13 +03: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 19:15:23 +03:00
|
|
|
class MOZ_RAII AutoMarkerReferencer {
|
2006-12-07 12:32:13 +03:00
|
|
|
public:
|
2020-06-27 08:39:42 +03:00
|
|
|
AutoMarkerReferencer(SVGMarkerFrame* aFrame,
|
|
|
|
SVGGeometryFrame* aMarkedFrame
|
2013-12-26 22:49:49 +04:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
2006-12-07 12:32:13 +03:00
|
|
|
~AutoMarkerReferencer();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-12-07 12:32:13 +03:00
|
|
|
private:
|
2020-06-27 08:39:42 +03:00
|
|
|
SVGMarkerFrame* mFrame;
|
2013-12-26 22:49:49 +04:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
2006-12-07 12:32:13 +03:00
|
|
|
};
|
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
// SVGMarkerFrame methods:
|
|
|
|
void SetParentCoordCtxProvider(dom::SVGViewportElement* aContext);
|
2006-12-07 12:32:13 +03:00
|
|
|
|
2006-06-10 00:40:06 +04:00
|
|
|
// recursion prevention flag
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInUse;
|
2006-06-10 00:40:06 +04:00
|
|
|
|
|
|
|
// second recursion prevention flag, for GetCanvasTM()
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInUse2;
|
2006-06-10 00:40:06 +04:00
|
|
|
};
|
2005-11-11 17:36:26 +03:00
|
|
|
|
2013-09-16 09:06:29 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsMarkerAnonChildFrame class
|
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
class SVGMarkerAnonChildFrame final : public SVGDisplayContainerFrame {
|
2020-06-27 08:39:42 +03:00
|
|
|
friend nsContainerFrame* ::NS_NewSVGMarkerAnonChildFrame(
|
2019-04-16 10:24:49 +03:00
|
|
|
mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
|
2013-09-16 09:06:29 +04:00
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
explicit SVGMarkerAnonChildFrame(ComputedStyle* aStyle,
|
|
|
|
nsPresContext* aPresContext)
|
2020-07-09 04:33:33 +03:00
|
|
|
: SVGDisplayContainerFrame(aStyle, aPresContext, kClassID) {}
|
2013-09-16 09:06:29 +04:00
|
|
|
|
|
|
|
public:
|
2020-06-27 08:39:42 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(SVGMarkerAnonChildFrame)
|
2013-09-16 09:06:29 +04: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;
|
2014-01-06 03:31:14 +04:00
|
|
|
#endif
|
2013-09-16 09:06:29 +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 {
|
2020-07-01 11:29:29 +03:00
|
|
|
return MakeFrameName(u"SVGMarkerAnonChild"_ns, aResult);
|
2013-09-16 09:06:29 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
// SVGContainerFrame methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfxMatrix GetCanvasTM() override {
|
2020-06-27 08:39:42 +03:00
|
|
|
return static_cast<SVGMarkerFrame*>(GetParent())->GetCanvasTM();
|
2013-09-16 09:06:29 +04:00
|
|
|
}
|
|
|
|
};
|
2020-06-27 08:39:42 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|
2004-12-09 06:16:15 +03:00
|
|
|
#endif
|