layout/svg/nsSVGPatternFrame.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_SVGPATTERNFRAME_H__
michael@0 7 #define __NS_SVGPATTERNFRAME_H__
michael@0 8
michael@0 9 #include "mozilla/Attributes.h"
michael@0 10 #include "gfxMatrix.h"
michael@0 11 #include "mozilla/gfx/2D.h"
michael@0 12 #include "nsSVGPaintServerFrame.h"
michael@0 13
michael@0 14 class gfxASurface;
michael@0 15 class gfxContext;
michael@0 16 class nsIFrame;
michael@0 17 class nsSVGElement;
michael@0 18 class nsSVGLength2;
michael@0 19 class nsSVGPathGeometryFrame;
michael@0 20 class nsSVGViewBox;
michael@0 21
michael@0 22 namespace mozilla {
michael@0 23 class SVGAnimatedPreserveAspectRatio;
michael@0 24 class nsSVGAnimatedTransformList;
michael@0 25 } // namespace mozilla
michael@0 26
michael@0 27 typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
michael@0 28
michael@0 29 /**
michael@0 30 * Patterns can refer to other patterns. We create an nsSVGPaintingProperty
michael@0 31 * with property type nsGkAtoms::href to track the referenced pattern.
michael@0 32 */
michael@0 33 class nsSVGPatternFrame : public nsSVGPatternFrameBase
michael@0 34 {
michael@0 35 public:
michael@0 36 NS_DECL_FRAMEARENA_HELPERS
michael@0 37
michael@0 38 friend nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell,
michael@0 39 nsStyleContext* aContext);
michael@0 40
michael@0 41 nsSVGPatternFrame(nsStyleContext* aContext);
michael@0 42
michael@0 43 // nsSVGPaintServerFrame methods:
michael@0 44 virtual already_AddRefed<gfxPattern>
michael@0 45 GetPaintServerPattern(nsIFrame *aSource,
michael@0 46 const gfxMatrix& aContextMatrix,
michael@0 47 nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
michael@0 48 float aOpacity,
michael@0 49 const gfxRect *aOverrideBounds) MOZ_OVERRIDE;
michael@0 50
michael@0 51 public:
michael@0 52 typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
michael@0 53
michael@0 54 // nsSVGContainerFrame methods:
michael@0 55 virtual gfxMatrix GetCanvasTM(uint32_t aFor,
michael@0 56 nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
michael@0 57
michael@0 58 // nsIFrame interface:
michael@0 59 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
michael@0 60 nsIAtom* aAttribute,
michael@0 61 int32_t aModType) MOZ_OVERRIDE;
michael@0 62
michael@0 63 #ifdef DEBUG
michael@0 64 virtual void Init(nsIContent* aContent,
michael@0 65 nsIFrame* aParent,
michael@0 66 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
michael@0 67 #endif
michael@0 68
michael@0 69 /**
michael@0 70 * Get the "type" of the frame
michael@0 71 *
michael@0 72 * @see nsGkAtoms::svgPatternFrame
michael@0 73 */
michael@0 74 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
michael@0 75
michael@0 76 #ifdef DEBUG_FRAME_DUMP
michael@0 77 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
michael@0 78 {
michael@0 79 return MakeFrameName(NS_LITERAL_STRING("SVGPattern"), aResult);
michael@0 80 }
michael@0 81 #endif // DEBUG
michael@0 82
michael@0 83 protected:
michael@0 84 // Internal methods for handling referenced patterns
michael@0 85 class AutoPatternReferencer;
michael@0 86 nsSVGPatternFrame* GetReferencedPattern();
michael@0 87 nsSVGPatternFrame* GetReferencedPatternIfNotInUse();
michael@0 88
michael@0 89 // Accessors to lookup pattern attributes
michael@0 90 uint16_t GetEnumValue(uint32_t aIndex, nsIContent *aDefault);
michael@0 91 uint16_t GetEnumValue(uint32_t aIndex)
michael@0 92 {
michael@0 93 return GetEnumValue(aIndex, mContent);
michael@0 94 }
michael@0 95 mozilla::nsSVGAnimatedTransformList* GetPatternTransformList(
michael@0 96 nsIContent* aDefault);
michael@0 97 gfxMatrix GetPatternTransform();
michael@0 98 const nsSVGViewBox &GetViewBox(nsIContent *aDefault);
michael@0 99 const nsSVGViewBox &GetViewBox() { return GetViewBox(mContent); }
michael@0 100 const SVGAnimatedPreserveAspectRatio &GetPreserveAspectRatio(
michael@0 101 nsIContent *aDefault);
michael@0 102 const SVGAnimatedPreserveAspectRatio &GetPreserveAspectRatio()
michael@0 103 {
michael@0 104 return GetPreserveAspectRatio(mContent);
michael@0 105 }
michael@0 106 const nsSVGLength2 *GetLengthValue(uint32_t aIndex, nsIContent *aDefault);
michael@0 107 const nsSVGLength2 *GetLengthValue(uint32_t aIndex)
michael@0 108 {
michael@0 109 return GetLengthValue(aIndex, mContent);
michael@0 110 }
michael@0 111
michael@0 112 nsresult PaintPattern(gfxASurface **surface,
michael@0 113 gfxMatrix *patternMatrix,
michael@0 114 const gfxMatrix &aContextMatrix,
michael@0 115 nsIFrame *aSource,
michael@0 116 nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
michael@0 117 float aGraphicOpacity,
michael@0 118 const gfxRect *aOverrideBounds);
michael@0 119 nsIFrame* GetPatternFirstChild();
michael@0 120 gfxRect GetPatternRect(uint16_t aPatternUnits,
michael@0 121 const gfxRect &bbox,
michael@0 122 const Matrix &callerCTM,
michael@0 123 nsIFrame *aTarget);
michael@0 124 gfxMatrix ConstructCTM(const nsSVGViewBox& aViewBox,
michael@0 125 uint16_t aPatternContentUnits,
michael@0 126 uint16_t aPatternUnits,
michael@0 127 const gfxRect &callerBBox,
michael@0 128 const Matrix &callerCTM,
michael@0 129 nsIFrame *aTarget);
michael@0 130
michael@0 131 private:
michael@0 132 // this is a *temporary* reference to the frame of the element currently
michael@0 133 // referencing our pattern. This must be temporary because different
michael@0 134 // referencing frames will all reference this one frame
michael@0 135 nsSVGPathGeometryFrame *mSource;
michael@0 136 nsAutoPtr<gfxMatrix> mCTM;
michael@0 137
michael@0 138 protected:
michael@0 139 // This flag is used to detect loops in xlink:href processing
michael@0 140 bool mLoopFlag;
michael@0 141 bool mNoHRefURI;
michael@0 142 };
michael@0 143
michael@0 144 #endif

mercurial