Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef __NS_ISVGCHILDFRAME_H__
7 : #define __NS_ISVGCHILDFRAME_H__
8 :
9 : #include "gfxMatrix.h"
10 : #include "gfxRect.h"
11 : #include "nsQueryFrame.h"
12 : #include "mozilla/gfx/MatrixFwd.h"
13 :
14 : class gfxContext;
15 : class nsIFrame;
16 : class SVGBBox;
17 :
18 : struct nsRect;
19 :
20 : namespace mozilla {
21 : class SVGAnimatedLengthList;
22 : class SVGAnimatedNumberList;
23 : class SVGLengthList;
24 : class SVGNumberList;
25 : class SVGUserUnitList;
26 :
27 : } // namespace mozilla
28 :
29 : /**
30 : * This class is used for elements that can be part of a directly displayable
31 : * section of a document. This includes SVGGeometryFrame and nsSVGGframe.
32 : * (Even though the latter doesn't display anything itself, if it contains
33 : * SVGGeometryFrame descendants it is can still be part of a displayable
34 : * section of a document) This class is not used for elements that can never
35 : * display directly, including nsSVGGradientFrame and nsSVGPatternFrame. (The
36 : * latter may contain displayable content, but it and its content are never
37 : * *directly* displayed in a document. It can only end up being displayed by
38 : * means of a reference from other content.)
39 : *
40 : * Note specifically that SVG frames that inherit nsSVGContainerFrame do *not*
41 : * implement this class (only those that inherit nsSVGDisplayContainerFrame
42 : * do.)
43 : */
44 153 : class nsSVGDisplayableFrame : public nsQueryFrame
45 : {
46 : public:
47 : typedef mozilla::SVGAnimatedNumberList SVGAnimatedNumberList;
48 : typedef mozilla::SVGNumberList SVGNumberList;
49 : typedef mozilla::SVGAnimatedLengthList SVGAnimatedLengthList;
50 : typedef mozilla::SVGLengthList SVGLengthList;
51 : typedef mozilla::SVGUserUnitList SVGUserUnitList;
52 : typedef mozilla::image::imgDrawingParams imgDrawingParams;
53 :
54 : NS_DECL_QUERYFRAME_TARGET(nsSVGDisplayableFrame)
55 :
56 : /**
57 : * Paint this frame.
58 : *
59 : * SVG is painted using a combination of display lists (trees of
60 : * nsDisplayItem built by BuildDisplayList() implementations) and recursive
61 : * PaintSVG calls. SVG frames with the NS_FRAME_IS_NONDISPLAY bit set are
62 : * always painted using recursive PaintSVG calls since display list painting
63 : * would provide no advantages (they wouldn't be retained for invalidation).
64 : * Displayed SVG is normally painted via a display list tree created under
65 : * nsSVGOuterSVGFrame::BuildDisplayList, unless the
66 : * svg.display-lists.painting.enabled pref has been set to false by the user
67 : * in which case it is done via an nsSVGOuterSVGFrame::PaintSVG() call that
68 : * recurses over the entire SVG frame tree. In future we may use PaintSVG()
69 : * calls on SVG container frames to avoid display list construction when it
70 : * is expensive and unnecessary (see bug 934411).
71 : *
72 : * @param aTransform The transform that has to be multiplied onto the
73 : * DrawTarget in order for drawing to be in this frame's SVG user space.
74 : * Implementations of this method should avoid multiplying aTransform onto
75 : * the DrawTarget when possible and instead just pass a transform down to
76 : * their children. This is preferable because changing the transform is
77 : * very expensive for certain DrawTarget backends so it is best to minimize
78 : * the number of transform changes.
79 : *
80 : * @param aImgParams imagelib parameters that may be used when painting
81 : * feImage.
82 : *
83 : * @param aDirtyRect The area being redrawn, in frame offset pixel
84 : * coordinates.
85 : */
86 : virtual void PaintSVG(gfxContext& aContext,
87 : const gfxMatrix& aTransform,
88 : imgDrawingParams& aImgParams,
89 : const nsIntRect* aDirtyRect = nullptr) = 0;
90 :
91 : /**
92 : * Returns the frame that should handle pointer events at aPoint. aPoint is
93 : * expected to be in the SVG user space of the frame on which this method is
94 : * called. The frame returned may be the frame on which this method is
95 : * called, any of its descendants or else nullptr.
96 : */
97 : virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) = 0;
98 :
99 : // Called on SVG child frames (except NS_FRAME_IS_NONDISPLAY frames)
100 : // to update and then invalidate their cached bounds. This method is not
101 : // called until after the nsSVGOuterSVGFrame has had its initial reflow
102 : // (i.e. once the SVG viewport dimensions are known). It should also only
103 : // be called by nsSVGOuterSVGFrame during its reflow.
104 : virtual void ReflowSVG()=0;
105 :
106 : // Flags to pass to NotifySVGChange:
107 : //
108 : // DO_NOT_NOTIFY_RENDERING_OBSERVERS - this should only be used when
109 : // updating the descendant frames of a clipPath,
110 : // mask, pattern or marker frame (or other similar
111 : // NS_FRAME_IS_NONDISPLAY frame) immediately
112 : // prior to painting that frame's descendants.
113 : // TRANSFORM_CHANGED - the current transform matrix for this frame has changed
114 : // COORD_CONTEXT_CHANGED - the dimensions of this frame's coordinate context has
115 : // changed (percentage lengths must be reevaluated)
116 : enum SVGChangedFlags {
117 : TRANSFORM_CHANGED = 0x01,
118 : COORD_CONTEXT_CHANGED = 0x02,
119 : FULL_ZOOM_CHANGED = 0x04
120 : };
121 : /**
122 : * This is called on a frame when there has been a change to one of its
123 : * ancestors that might affect the frame too. SVGChangedFlags are passed
124 : * to indicate what changed.
125 : *
126 : * Implementations do not need to invalidate, since the caller will
127 : * invalidate the entire area of the ancestor that changed. However, they
128 : * may need to update their bounds.
129 : */
130 : virtual void NotifySVGChanged(uint32_t aFlags)=0;
131 :
132 : /**
133 : * Get this frame's contribution to the rect returned by a GetBBox() call
134 : * that occurred either on this element, or on one of its ancestors.
135 : *
136 : * SVG defines an element's bbox to be the element's fill bounds in the
137 : * userspace established by that element. By allowing callers to pass in the
138 : * transform from the userspace established by this element to the userspace
139 : * established by an an ancestor, this method allows callers to obtain this
140 : * element's fill bounds in the userspace established by that ancestor
141 : * instead. In that case, since we return the bounds in a different userspace
142 : * (the ancestor's), the bounds we return are not this element's bbox, but
143 : * rather this element's contribution to the bbox of the ancestor.
144 : *
145 : * @param aToBBoxUserspace The transform from the userspace established by
146 : * this element to the userspace established by the ancestor on which
147 : * getBBox was called. This will be the identity matrix if we are the
148 : * element on which getBBox was called.
149 : *
150 : * @param aFlags Flags indicating whether, stroke, for example, should be
151 : * included in the bbox calculation.
152 : */
153 : virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
154 : uint32_t aFlags) = 0;
155 :
156 : // Are we a container frame?
157 : virtual bool IsDisplayContainer()=0;
158 : };
159 :
160 : #endif // __NS_ISVGCHILDFRAME_H__
161 :
|