no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / svg / SVGPatternFrame.h
blobbfc9d1862a7637b0515637e9f62d12273eb9d000
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 LAYOUT_SVG_SVGPATTERNFRAME_H_
8 #define LAYOUT_SVG_SVGPATTERNFRAME_H_
10 #include "mozilla/Attributes.h"
11 #include "gfxMatrix.h"
12 #include "mozilla/gfx/2D.h"
13 #include "mozilla/RefPtr.h"
14 #include "mozilla/SVGPaintServerFrame.h"
15 #include "mozilla/UniquePtr.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 nsIFrame* NS_NewSVGPatternFrame(mozilla::PresShell* aPresShell,
29 mozilla::ComputedStyle* aStyle);
31 namespace mozilla {
33 class SVGPatternFrame final : public SVGPaintServerFrame {
34 using SourceSurface = gfx::SourceSurface;
36 public:
37 NS_DECL_FRAMEARENA_HELPERS(SVGPatternFrame)
38 NS_DECL_QUERYFRAME
40 friend nsIFrame* ::NS_NewSVGPatternFrame(mozilla::PresShell* aPresShell,
41 ComputedStyle* aStyle);
43 explicit SVGPatternFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
45 // SVGPaintServerFrame methods:
46 already_AddRefed<gfxPattern> GetPaintServerPattern(
47 nsIFrame* aSource, const DrawTarget* aDrawTarget,
48 const gfxMatrix& aContextMatrix, StyleSVGPaint nsStyleSVG::*aFillOrStroke,
49 float aGraphicOpacity, imgDrawingParams& aImgParams,
50 const gfxRect* aOverrideBounds) override;
52 public:
53 // SVGContainerFrame methods:
54 gfxMatrix GetCanvasTM() override;
56 // nsIFrame interface:
57 nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
58 int32_t aModType) override;
60 #ifdef DEBUG
61 void Init(nsIContent* aContent, nsContainerFrame* aParent,
62 nsIFrame* aPrevInFlow) override;
63 #endif
65 #ifdef DEBUG_FRAME_DUMP
66 nsresult GetFrameName(nsAString& aResult) const override {
67 return MakeFrameName(u"SVGPattern"_ns, aResult);
69 #endif // DEBUG
71 protected:
72 /**
73 * Parses this frame's href and - if it references another pattern - returns
74 * it. It also makes this frame a rendering observer of the specified ID.
76 SVGPatternFrame* GetReferencedPattern();
78 // Accessors to lookup pattern attributes
79 uint16_t GetEnumValue(uint32_t aIndex, nsIContent* aDefault);
80 uint16_t GetEnumValue(uint32_t aIndex) {
81 return GetEnumValue(aIndex, mContent);
83 SVGAnimatedTransformList* GetPatternTransformList(nsIContent* aDefault);
84 gfxMatrix GetPatternTransform();
85 const SVGAnimatedViewBox& GetViewBox(nsIContent* aDefault);
86 const SVGAnimatedViewBox& GetViewBox() { return GetViewBox(mContent); }
87 const SVGAnimatedPreserveAspectRatio& GetPreserveAspectRatio(
88 nsIContent* aDefault);
89 const SVGAnimatedPreserveAspectRatio& GetPreserveAspectRatio() {
90 return GetPreserveAspectRatio(mContent);
92 const SVGAnimatedLength* GetLengthValue(uint32_t aIndex,
93 nsIContent* aDefault);
94 const SVGAnimatedLength* GetLengthValue(uint32_t aIndex) {
95 return GetLengthValue(aIndex, mContent);
98 void PaintChildren(DrawTarget* aDrawTarget,
99 SVGPatternFrame* aPatternWithChildren, nsIFrame* aSource,
100 float aGraphicOpacity, imgDrawingParams& aImgParams);
102 already_AddRefed<SourceSurface> PaintPattern(
103 const DrawTarget* aDrawTarget, Matrix* patternMatrix,
104 const Matrix& aContextMatrix, nsIFrame* aSource,
105 StyleSVGPaint nsStyleSVG::*aFillOrStroke, float aGraphicOpacity,
106 const gfxRect* aOverrideBounds, imgDrawingParams& aImgParams);
109 * A <pattern> element may reference another <pattern> element using
110 * xlink:href and, if it doesn't have any child content of its own, then it
111 * will "inherit" the children of the referenced pattern (which may itself be
112 * inheriting its children if it references another <pattern>). This
113 * function returns this SVGPatternFrame or the first pattern along the
114 * reference chain (if there is one) to have children.
116 SVGPatternFrame* GetPatternWithChildren();
118 gfxRect GetPatternRect(uint16_t aPatternUnits, const gfxRect& bbox,
119 const Matrix& aTargetCTM, nsIFrame* aTarget);
120 gfxMatrix ConstructCTM(const SVGAnimatedViewBox& aViewBox,
121 uint16_t aPatternContentUnits, uint16_t aPatternUnits,
122 const gfxRect& callerBBox, const Matrix& callerCTM,
123 nsIFrame* aTarget);
125 private:
126 // this is a *temporary* reference to the frame of the element currently
127 // referencing our pattern. This must be temporary because different
128 // referencing frames will all reference this one frame
129 SVGGeometryFrame* mSource;
130 UniquePtr<gfxMatrix> mCTM;
132 protected:
133 // This flag is used to detect loops in xlink:href processing
134 bool mLoopFlag;
135 bool mNoHRefURI;
138 } // namespace mozilla
140 #endif // LAYOUT_SVG_SVGPATTERNFRAME_H_