Bug 1800263 - Part 1: Tidup, make MarkingState a private enum inside GCMarker r=sfink
[gecko.git] / layout / svg / ISVGDisplayableFrame.h
blob90446561a1576fcf7b5b62a309c1315ff707405d
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_ISVGDISPLAYABLEFRAME_H_
8 #define LAYOUT_SVG_ISVGDISPLAYABLEFRAME_H_
10 #include "gfxMatrix.h"
11 #include "gfxPoint.h"
12 #include "gfxRect.h"
13 #include "nsQueryFrame.h"
14 #include "nsRect.h"
15 #include "mozilla/gfx/MatrixFwd.h"
17 class gfxContext;
18 class nsIFrame;
20 namespace mozilla {
21 class SVGAnimatedLengthList;
22 class SVGAnimatedNumberList;
23 class SVGBBox;
24 class SVGLengthList;
25 class SVGNumberList;
26 class SVGUserUnitList;
28 namespace image {
29 struct imgDrawingParams;
30 } // namespace image
32 /**
33 * This class is used for elements that can be part of a directly displayable
34 * section of a document. This includes SVGGeometryFrame and SVGGFrame.
35 * (Even though the latter doesn't display anything itself, if it contains
36 * SVGGeometryFrame descendants it is can still be part of a displayable
37 * section of a document) This class is not used for elements that can never
38 * display directly, including SVGGradientFrame and SVGPatternFrame. (The
39 * latter may contain displayable content, but it and its content are never
40 * *directly* displayed in a document. It can only end up being displayed by
41 * means of a reference from other content.)
43 * Note specifically that SVG frames that inherit SVGContainerFrame do *not*
44 * implement this class (only those that inherit SVGDisplayContainerFrame
45 * do.)
47 class ISVGDisplayableFrame : public nsQueryFrame {
48 public:
49 using imgDrawingParams = image::imgDrawingParams;
51 NS_DECL_QUERYFRAME_TARGET(ISVGDisplayableFrame)
53 /**
54 * Paint this frame.
56 * SVG is painted using a combination of display lists (trees of
57 * nsDisplayItem built by BuildDisplayList() implementations) and recursive
58 * PaintSVG calls. SVG frames with the NS_FRAME_IS_NONDISPLAY bit set are
59 * always painted using recursive PaintSVG calls since display list painting
60 * would provide no advantages (they wouldn't be retained for invalidation).
61 * Displayed SVG is normally painted via a display list tree created under
62 * SVGOuterSVGFrame::BuildDisplayList, unless the
63 * svg.display-lists.painting.enabled pref has been set to false by the user
64 * in which case it is done via an SVGOuterSVGFrame::PaintSVG() call that
65 * recurses over the entire SVG frame tree. In future we may use PaintSVG()
66 * calls on SVG container frames to avoid display list construction when it
67 * is expensive and unnecessary (see bug 934411).
69 * @param aTransform The transform that has to be multiplied onto the
70 * DrawTarget in order for drawing to be in this frame's SVG user space.
71 * Implementations of this method should avoid multiplying aTransform onto
72 * the DrawTarget when possible and instead just pass a transform down to
73 * their children. This is preferable because changing the transform is
74 * very expensive for certain DrawTarget backends so it is best to minimize
75 * the number of transform changes.
77 * @param aImgParams imagelib parameters that may be used when painting
78 * feImage.
80 * @param aDirtyRect The area being redrawn, in frame offset pixel
81 * coordinates.
83 virtual void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
84 imgDrawingParams& aImgParams,
85 const nsIntRect* aDirtyRect = nullptr) = 0;
87 /**
88 * Returns the frame that should handle pointer events at aPoint. aPoint is
89 * expected to be in the SVG user space of the frame on which this method is
90 * called. The frame returned may be the frame on which this method is
91 * called, any of its descendants or else nullptr.
93 virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) = 0;
95 // Called on SVG child frames (except NS_FRAME_IS_NONDISPLAY frames)
96 // to update and then invalidate their cached bounds. This method is not
97 // called until after the SVGOuterSVGFrame has had its initial reflow
98 // (i.e. once the SVG viewport dimensions are known). It should also only
99 // be called by SVGOuterSVGFrame during its reflow.
100 virtual void ReflowSVG() = 0;
102 // Flags to pass to NotifySVGChange:
104 // TRANSFORM_CHANGED:
105 // the current transform matrix for this frame has changed
106 // COORD_CONTEXT_CHANGED:
107 // the dimensions of this frame's coordinate context has changed (percentage
108 // lengths must be reevaluated)
109 // FULL_ZOOM_CHANGED:
110 // the page's zoom level has changed
111 enum SVGChangedFlags {
112 TRANSFORM_CHANGED = 0x01,
113 COORD_CONTEXT_CHANGED = 0x02,
114 FULL_ZOOM_CHANGED = 0x04
117 * This is called on a frame when there has been a change to one of its
118 * ancestors that might affect the frame too. SVGChangedFlags are passed
119 * to indicate what changed.
121 * Implementations do not need to invalidate, since the caller will
122 * invalidate the entire area of the ancestor that changed. However, they
123 * may need to update their bounds.
125 virtual void NotifySVGChanged(uint32_t aFlags) = 0;
128 * Get this frame's contribution to the rect returned by a GetBBox() call
129 * that occurred either on this element, or on one of its ancestors.
131 * SVG defines an element's bbox to be the element's fill bounds in the
132 * userspace established by that element. By allowing callers to pass in the
133 * transform from the userspace established by this element to the userspace
134 * established by an an ancestor, this method allows callers to obtain this
135 * element's fill bounds in the userspace established by that ancestor
136 * instead. In that case, since we return the bounds in a different userspace
137 * (the ancestor's), the bounds we return are not this element's bbox, but
138 * rather this element's contribution to the bbox of the ancestor.
140 * @param aToBBoxUserspace The transform from the userspace established by
141 * this element to the userspace established by the ancestor on which
142 * getBBox was called. This will be the identity matrix if we are the
143 * element on which getBBox was called.
145 * @param aFlags Flags indicating whether, stroke, for example, should be
146 * included in the bbox calculation.
148 virtual SVGBBox GetBBoxContribution(const gfx::Matrix& aToBBoxUserspace,
149 uint32_t aFlags) = 0;
151 // Are we a container frame?
152 virtual bool IsDisplayContainer() = 0;
155 } // namespace mozilla
157 #endif // LAYOUT_SVG_ISVGDISPLAYABLEFRAME_H_