layout/svg/nsSVGMarkerFrame.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef __NS_SVGMARKERFRAME_H__
michael@0 7 #define __NS_SVGMARKERFRAME_H__
michael@0 8
michael@0 9 #include "mozilla/Attributes.h"
michael@0 10 #include "gfxMatrix.h"
michael@0 11 #include "gfxRect.h"
michael@0 12 #include "nsFrame.h"
michael@0 13 #include "nsLiteralString.h"
michael@0 14 #include "nsQueryFrame.h"
michael@0 15 #include "nsSVGContainerFrame.h"
michael@0 16 #include "nsSVGUtils.h"
michael@0 17
michael@0 18 class nsIAtom;
michael@0 19 class nsIContent;
michael@0 20 class nsIFrame;
michael@0 21 class nsIPresShell;
michael@0 22 class nsRenderingContext;
michael@0 23 class nsStyleContext;
michael@0 24 class nsSVGPathGeometryFrame;
michael@0 25
michael@0 26 namespace mozilla {
michael@0 27 namespace dom {
michael@0 28 class SVGSVGElement;
michael@0 29 }
michael@0 30 }
michael@0 31
michael@0 32 struct nsSVGMark;
michael@0 33
michael@0 34 typedef nsSVGContainerFrame nsSVGMarkerFrameBase;
michael@0 35
michael@0 36 class nsSVGMarkerFrame : public nsSVGMarkerFrameBase
michael@0 37 {
michael@0 38 friend class nsSVGMarkerAnonChildFrame;
michael@0 39 friend nsIFrame*
michael@0 40 NS_NewSVGMarkerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 41 protected:
michael@0 42 nsSVGMarkerFrame(nsStyleContext* aContext)
michael@0 43 : nsSVGMarkerFrameBase(aContext)
michael@0 44 , mMarkedFrame(nullptr)
michael@0 45 , mInUse(false)
michael@0 46 , mInUse2(false)
michael@0 47 {
michael@0 48 AddStateBits(NS_FRAME_IS_NONDISPLAY);
michael@0 49 }
michael@0 50
michael@0 51 public:
michael@0 52 NS_DECL_FRAMEARENA_HELPERS
michael@0 53
michael@0 54 // nsIFrame interface:
michael@0 55 #ifdef DEBUG
michael@0 56 virtual void Init(nsIContent* aContent,
michael@0 57 nsIFrame* aParent,
michael@0 58 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
michael@0 59 #endif
michael@0 60
michael@0 61 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 62 const nsRect& aDirtyRect,
michael@0 63 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
michael@0 64
michael@0 65 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
michael@0 66 nsIAtom* aAttribute,
michael@0 67 int32_t aModType) MOZ_OVERRIDE;
michael@0 68 /**
michael@0 69 * Get the "type" of the frame
michael@0 70 *
michael@0 71 * @see nsGkAtoms::svgMarkerFrame
michael@0 72 */
michael@0 73 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
michael@0 74
michael@0 75 #ifdef DEBUG_FRAME_DUMP
michael@0 76 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
michael@0 77 {
michael@0 78 return MakeFrameName(NS_LITERAL_STRING("SVGMarker"), aResult);
michael@0 79 }
michael@0 80 #endif
michael@0 81
michael@0 82 virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE {
michael@0 83 // Any children must be added to our single anonymous inner frame kid.
michael@0 84 NS_ABORT_IF_FALSE(GetFirstPrincipalChild() &&
michael@0 85 GetFirstPrincipalChild()->GetType() ==
michael@0 86 nsGkAtoms::svgMarkerAnonChildFrame,
michael@0 87 "Where is our anonymous child?");
michael@0 88 return GetFirstPrincipalChild()->GetContentInsertionFrame();
michael@0 89 }
michael@0 90
michael@0 91 // nsSVGMarkerFrame methods:
michael@0 92 nsresult PaintMark(nsRenderingContext *aContext,
michael@0 93 nsSVGPathGeometryFrame *aMarkedFrame,
michael@0 94 nsSVGMark *aMark,
michael@0 95 float aStrokeWidth);
michael@0 96
michael@0 97 SVGBBox GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
michael@0 98 uint32_t aFlags,
michael@0 99 nsSVGPathGeometryFrame *aMarkedFrame,
michael@0 100 const nsSVGMark *aMark,
michael@0 101 float aStrokeWidth);
michael@0 102
michael@0 103 private:
michael@0 104 // stuff needed for callback
michael@0 105 nsSVGPathGeometryFrame *mMarkedFrame;
michael@0 106 float mStrokeWidth, mX, mY, mAutoAngle;
michael@0 107 bool mIsStart; // whether the callback is for a marker-start marker
michael@0 108
michael@0 109 // nsSVGContainerFrame methods:
michael@0 110 virtual gfxMatrix GetCanvasTM(uint32_t aFor,
michael@0 111 nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
michael@0 112
michael@0 113 // A helper class to allow us to paint markers safely. The helper
michael@0 114 // automatically sets and clears the mInUse flag on the marker frame (to
michael@0 115 // prevent nasty reference loops) as well as the reference to the marked
michael@0 116 // frame and its coordinate context. It's easy to mess this up
michael@0 117 // and break things, so this helper makes the code far more robust.
michael@0 118 class MOZ_STACK_CLASS AutoMarkerReferencer
michael@0 119 {
michael@0 120 public:
michael@0 121 AutoMarkerReferencer(nsSVGMarkerFrame *aFrame,
michael@0 122 nsSVGPathGeometryFrame *aMarkedFrame
michael@0 123 MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
michael@0 124 ~AutoMarkerReferencer();
michael@0 125 private:
michael@0 126 nsSVGMarkerFrame *mFrame;
michael@0 127 MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
michael@0 128 };
michael@0 129
michael@0 130 // nsSVGMarkerFrame methods:
michael@0 131 void SetParentCoordCtxProvider(mozilla::dom::SVGSVGElement *aContext);
michael@0 132
michael@0 133 // recursion prevention flag
michael@0 134 bool mInUse;
michael@0 135
michael@0 136 // second recursion prevention flag, for GetCanvasTM()
michael@0 137 bool mInUse2;
michael@0 138 };
michael@0 139
michael@0 140 ////////////////////////////////////////////////////////////////////////
michael@0 141 // nsMarkerAnonChildFrame class
michael@0 142
michael@0 143 typedef nsSVGDisplayContainerFrame nsSVGMarkerAnonChildFrameBase;
michael@0 144
michael@0 145 /**
michael@0 146 */
michael@0 147 class nsSVGMarkerAnonChildFrame
michael@0 148 : public nsSVGMarkerAnonChildFrameBase
michael@0 149 {
michael@0 150 friend nsIFrame*
michael@0 151 NS_NewSVGMarkerAnonChildFrame(nsIPresShell* aPresShell,
michael@0 152 nsStyleContext* aContext);
michael@0 153
michael@0 154 nsSVGMarkerAnonChildFrame(nsStyleContext* aContext)
michael@0 155 : nsSVGMarkerAnonChildFrameBase(aContext)
michael@0 156 {}
michael@0 157
michael@0 158 public:
michael@0 159 NS_DECL_FRAMEARENA_HELPERS
michael@0 160
michael@0 161 #ifdef DEBUG
michael@0 162 virtual void Init(nsIContent* aContent,
michael@0 163 nsIFrame* aParent,
michael@0 164 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
michael@0 165 #endif
michael@0 166
michael@0 167 #ifdef DEBUG_FRAME_DUMP
michael@0 168 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE {
michael@0 169 return MakeFrameName(NS_LITERAL_STRING("SVGMarkerAnonChild"), aResult);
michael@0 170 }
michael@0 171 #endif
michael@0 172
michael@0 173 /**
michael@0 174 * Get the "type" of the frame
michael@0 175 *
michael@0 176 * @see nsGkAtoms::svgMarkerAnonChildFrame
michael@0 177 */
michael@0 178 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
michael@0 179
michael@0 180 // nsSVGContainerFrame methods:
michael@0 181 virtual gfxMatrix GetCanvasTM(uint32_t aFor,
michael@0 182 nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE
michael@0 183 {
michael@0 184 nsSVGMarkerFrame* marker = static_cast<nsSVGMarkerFrame*>(mParent);
michael@0 185 return marker->GetCanvasTM(aFor, aTransformRoot);
michael@0 186 }
michael@0 187 };
michael@0 188 #endif

mercurial