no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / layout / svg / ISVGDisplayableFrame.h
blobf29a51b6aa510b2383c18e68323d9b863396478f
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, In future we may use a PaintSVG() call
63 * that recurses over the entire SVG frame tree on SVG container frames to
64 * avoid display list construction when it is expensive and unnecessary (see
65 * bug 934411).
67 * @param aTransform The transform that has to be multiplied onto the
68 * DrawTarget in order for drawing to be in this frame's SVG user space.
69 * Implementations of this method should avoid multiplying aTransform onto
70 * the DrawTarget when possible and instead just pass a transform down to
71 * their children. This is preferable because changing the transform is
72 * very expensive for certain DrawTarget backends so it is best to minimize
73 * the number of transform changes.
75 * @param aImgParams imagelib parameters that may be used when painting
76 * feImage.
78 virtual void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
79 imgDrawingParams& aImgParams) = 0;
81 /**
82 * Returns the frame that should handle pointer events at aPoint. aPoint is
83 * expected to be in the SVG user space of the frame on which this method is
84 * called. The frame returned may be the frame on which this method is
85 * called, any of its descendants or else nullptr.
87 virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) = 0;
89 // Called on SVG child frames (except NS_FRAME_IS_NONDISPLAY frames)
90 // to update and then invalidate their cached bounds. This method is not
91 // called until after the SVGOuterSVGFrame has had its initial reflow
92 // (i.e. once the SVG viewport dimensions are known). It should also only
93 // be called by SVGOuterSVGFrame during its reflow.
94 virtual void ReflowSVG() = 0;
96 // Flags to pass to NotifySVGChange:
98 // TRANSFORM_CHANGED:
99 // the current transform matrix for this frame has changed
100 // COORD_CONTEXT_CHANGED:
101 // the dimensions of this frame's coordinate context has changed (percentage
102 // lengths must be reevaluated)
103 // FULL_ZOOM_CHANGED:
104 // the page's zoom level has changed
105 enum SVGChangedFlags {
106 TRANSFORM_CHANGED = 0x01,
107 COORD_CONTEXT_CHANGED = 0x02,
108 FULL_ZOOM_CHANGED = 0x04
111 * This is called on a frame when there has been a change to one of its
112 * ancestors that might affect the frame too. SVGChangedFlags are passed
113 * to indicate what changed.
115 * Implementations do not need to invalidate, since the caller will
116 * invalidate the entire area of the ancestor that changed. However, they
117 * may need to update their bounds.
119 virtual void NotifySVGChanged(uint32_t aFlags) = 0;
122 * Get this frame's contribution to the rect returned by a GetBBox() call
123 * that occurred either on this element, or on one of its ancestors.
125 * SVG defines an element's bbox to be the element's fill bounds in the
126 * userspace established by that element. By allowing callers to pass in the
127 * transform from the userspace established by this element to the userspace
128 * established by an an ancestor, this method allows callers to obtain this
129 * element's fill bounds in the userspace established by that ancestor
130 * instead. In that case, since we return the bounds in a different userspace
131 * (the ancestor's), the bounds we return are not this element's bbox, but
132 * rather this element's contribution to the bbox of the ancestor.
134 * @param aToBBoxUserspace The transform from the userspace established by
135 * this element to the userspace established by the ancestor on which
136 * getBBox was called. This will be the identity matrix if we are the
137 * element on which getBBox was called.
139 * @param aFlags Flags indicating whether, stroke, for example, should be
140 * included in the bbox calculation.
142 virtual SVGBBox GetBBoxContribution(const gfx::Matrix& aToBBoxUserspace,
143 uint32_t aFlags) = 0;
145 // Are we a container frame?
146 virtual bool IsDisplayContainer() = 0;
149 } // namespace mozilla
151 #endif // LAYOUT_SVG_ISVGDISPLAYABLEFRAME_H_