Bug 1568157 - Part 5: Move the NodePicker initialization into a getter. r=yulia
[gecko.git] / layout / svg / nsSVGPatternFrame.h
blob7f5a3c78b22430e7af336fea2ec8e853f86c38db
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef __NS_SVGPATTERNFRAME_H__
8 #define __NS_SVGPATTERNFRAME_H__
10 #include "mozilla/Attributes.h"
11 #include "gfxMatrix.h"
12 #include "mozilla/gfx/2D.h"
13 #include "mozilla/RefPtr.h"
14 #include "nsAutoPtr.h"
15 #include "nsSVGPaintServerFrame.h"
17 class nsIFrame;
19 namespace mozilla {
20 class PresShell;
21 class SVGAnimatedLength;
22 class SVGAnimatedPreserveAspectRatio;
23 class SVGAnimatedTransformList;
24 class SVGAnimatedViewBox;
25 class SVGGeometryFrame;
26 } // namespace mozilla
28 class nsSVGPatternFrame final : public nsSVGPaintServerFrame {
29 typedef mozilla::gfx::SourceSurface SourceSurface;
31 public:
32 NS_DECL_FRAMEARENA_HELPERS(nsSVGPatternFrame)
34 friend nsIFrame* NS_NewSVGPatternFrame(mozilla::PresShell* aPresShell,
35 ComputedStyle* aStyle);
37 explicit nsSVGPatternFrame(ComputedStyle* aStyle,
38 nsPresContext* aPresContext);
40 // nsSVGPaintServerFrame methods:
41 virtual already_AddRefed<gfxPattern> GetPaintServerPattern(
42 nsIFrame* aSource, const DrawTarget* aDrawTarget,
43 const gfxMatrix& aContextMatrix,
44 mozilla::StyleSVGPaint nsStyleSVG::*aFillOrStroke, float aGraphicOpacity,
45 imgDrawingParams& aImgParams, const gfxRect* aOverrideBounds) override;
47 public:
48 typedef mozilla::SVGAnimatedPreserveAspectRatio
49 SVGAnimatedPreserveAspectRatio;
51 // nsSVGContainerFrame methods:
52 virtual gfxMatrix GetCanvasTM() override;
54 // nsIFrame interface:
55 virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
56 int32_t aModType) override;
58 #ifdef DEBUG
59 virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
60 nsIFrame* aPrevInFlow) override;
61 #endif
63 #ifdef DEBUG_FRAME_DUMP
64 virtual nsresult GetFrameName(nsAString& aResult) const override {
65 return MakeFrameName(NS_LITERAL_STRING("SVGPattern"), aResult);
67 #endif // DEBUG
69 protected:
70 /**
71 * Parses this frame's href and - if it references another pattern - returns
72 * it. It also makes this frame a rendering observer of the specified ID.
74 nsSVGPatternFrame* GetReferencedPattern();
76 // Accessors to lookup pattern attributes
77 uint16_t GetEnumValue(uint32_t aIndex, nsIContent* aDefault);
78 uint16_t GetEnumValue(uint32_t aIndex) {
79 return GetEnumValue(aIndex, mContent);
81 mozilla::SVGAnimatedTransformList* GetPatternTransformList(
82 nsIContent* aDefault);
83 gfxMatrix GetPatternTransform();
84 const SVGAnimatedViewBox& GetViewBox(nsIContent* aDefault);
85 const SVGAnimatedViewBox& GetViewBox() { return GetViewBox(mContent); }
86 const SVGAnimatedPreserveAspectRatio& GetPreserveAspectRatio(
87 nsIContent* aDefault);
88 const SVGAnimatedPreserveAspectRatio& GetPreserveAspectRatio() {
89 return GetPreserveAspectRatio(mContent);
91 const SVGAnimatedLength* GetLengthValue(uint32_t aIndex,
92 nsIContent* aDefault);
93 const SVGAnimatedLength* GetLengthValue(uint32_t aIndex) {
94 return GetLengthValue(aIndex, mContent);
97 already_AddRefed<SourceSurface> PaintPattern(
98 const DrawTarget* aDrawTarget, Matrix* patternMatrix,
99 const Matrix& aContextMatrix, nsIFrame* aSource,
100 mozilla::StyleSVGPaint nsStyleSVG::*aFillOrStroke, float aGraphicOpacity,
101 const gfxRect* aOverrideBounds, imgDrawingParams& aImgParams);
104 * A <pattern> element may reference another <pattern> element using
105 * xlink:href and, if it doesn't have any child content of its own, then it
106 * will "inherit" the children of the referenced pattern (which may itself be
107 * inheriting its children if it references another <pattern>). This
108 * function returns this nsSVGPatternFrame or the first pattern along the
109 * reference chain (if there is one) to have children.
111 nsSVGPatternFrame* GetPatternWithChildren();
113 gfxRect GetPatternRect(uint16_t aPatternUnits, const gfxRect& bbox,
114 const Matrix& aTargetCTM, nsIFrame* aTarget);
115 gfxMatrix ConstructCTM(const SVGAnimatedViewBox& aViewBox,
116 uint16_t aPatternContentUnits, uint16_t aPatternUnits,
117 const gfxRect& callerBBox, const Matrix& callerCTM,
118 nsIFrame* aTarget);
120 private:
121 // this is a *temporary* reference to the frame of the element currently
122 // referencing our pattern. This must be temporary because different
123 // referencing frames will all reference this one frame
124 mozilla::SVGGeometryFrame* mSource;
125 nsAutoPtr<gfxMatrix> mCTM;
127 protected:
128 // This flag is used to detect loops in xlink:href processing
129 bool mLoopFlag;
130 bool mNoHRefURI;
133 #endif