michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __NS_ISVGCHILDFRAME_H__ michael@0: #define __NS_ISVGCHILDFRAME_H__ michael@0: michael@0: #include "gfxRect.h" michael@0: #include "nsQueryFrame.h" michael@0: michael@0: class nsIFrame; michael@0: class nsRenderingContext; michael@0: michael@0: struct nsPoint; michael@0: class SVGBBox; michael@0: struct nsRect; michael@0: struct nsIntRect; michael@0: michael@0: namespace mozilla { michael@0: class SVGAnimatedLengthList; michael@0: class SVGAnimatedNumberList; michael@0: class SVGLengthList; michael@0: class SVGNumberList; michael@0: class SVGUserUnitList; michael@0: michael@0: namespace gfx { michael@0: class Matrix; michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * This class is not particularly well named. It is inherited by some, but michael@0: * not all SVG frame classes that can be descendants of an michael@0: * nsSVGOuterSVGFrame in the frame tree. Note specifically that SVG container michael@0: * frames that do not inherit nsSVGDisplayContainerFrame do not inherit this michael@0: * class (so that's classes that only inherit nsSVGContainerFrame). michael@0: */ michael@0: class nsISVGChildFrame : public nsQueryFrame michael@0: { michael@0: public: michael@0: typedef mozilla::SVGAnimatedNumberList SVGAnimatedNumberList; michael@0: typedef mozilla::SVGNumberList SVGNumberList; michael@0: typedef mozilla::SVGAnimatedLengthList SVGAnimatedLengthList; michael@0: typedef mozilla::SVGLengthList SVGLengthList; michael@0: typedef mozilla::SVGUserUnitList SVGUserUnitList; michael@0: michael@0: NS_DECL_QUERYFRAME_TARGET(nsISVGChildFrame) michael@0: michael@0: // Paint this frame. michael@0: // aDirtyRect is the area being redrawn, in frame offset pixel coordinates. michael@0: // aTransformRoot (if non-null) is the frame at which we stop looking up michael@0: // transforms, when painting content that is part of an SVG glyph. (See michael@0: // bug 875329.) michael@0: // For normal SVG graphics using display-list rendering, any transforms on michael@0: // the element or its parents will have already been set up in the context michael@0: // before PaintSVG is called. When painting SVG glyphs, this is not the case, michael@0: // so the element's full transform needs to be applied; but we don't want to michael@0: // apply transforms from outside the actual glyph element, so we need to know michael@0: // how far up the ancestor chain to go. michael@0: virtual nsresult PaintSVG(nsRenderingContext* aContext, michael@0: const nsIntRect *aDirtyRect, michael@0: nsIFrame* aTransformRoot = nullptr) = 0; michael@0: michael@0: // Check if this frame or children contain the given point, michael@0: // specified in app units relative to the origin of the outer michael@0: // svg frame (origin ill-defined in the case of borders - bug michael@0: // 290770). See bug 290852 for foreignObject complications. michael@0: virtual nsIFrame* GetFrameForPoint(const nsPoint &aPoint)=0; michael@0: michael@0: // Get bounds in our nsSVGOuterSVGFrame's coordinates space (in app units) michael@0: virtual nsRect GetCoveredRegion()=0; michael@0: michael@0: // Called on SVG child frames (except NS_FRAME_IS_NONDISPLAY frames) michael@0: // to update and then invalidate their cached bounds. This method is not michael@0: // called until after the nsSVGOuterSVGFrame has had its initial reflow michael@0: // (i.e. once the SVG viewport dimensions are known). It should also only michael@0: // be called by nsSVGOuterSVGFrame during its reflow. michael@0: virtual void ReflowSVG()=0; michael@0: michael@0: /** michael@0: * Flags used to specify to GetCanvasTM what it's being called for so that it michael@0: * knows how far up the tree the "canvas" is. When display lists are being michael@0: * used for painting or hit-testing of SVG, the "canvas" is simply user michael@0: * space. michael@0: */ michael@0: enum RequestingCanvasTMFor { michael@0: FOR_PAINTING = 1, michael@0: FOR_HIT_TESTING, michael@0: FOR_OUTERSVG_TM michael@0: }; michael@0: michael@0: // Flags to pass to NotifySVGChange: michael@0: // michael@0: // DO_NOT_NOTIFY_RENDERING_OBSERVERS - this should only be used when michael@0: // updating the descendant frames of a clipPath, michael@0: // mask, pattern or marker frame (or other similar michael@0: // NS_FRAME_IS_NONDISPLAY frame) immediately michael@0: // prior to painting that frame's descendants. michael@0: // TRANSFORM_CHANGED - the current transform matrix for this frame has changed michael@0: // COORD_CONTEXT_CHANGED - the dimensions of this frame's coordinate context has michael@0: // changed (percentage lengths must be reevaluated) michael@0: enum SVGChangedFlags { michael@0: TRANSFORM_CHANGED = 0x01, michael@0: COORD_CONTEXT_CHANGED = 0x02, michael@0: FULL_ZOOM_CHANGED = 0x04 michael@0: }; michael@0: /** michael@0: * This is called on a frame when there has been a change to one of its michael@0: * ancestors that might affect the frame too. SVGChangedFlags are passed michael@0: * to indicate what changed. michael@0: * michael@0: * Implementations do not need to invalidate, since the caller will michael@0: * invalidate the entire area of the ancestor that changed. However, they michael@0: * may need to update their bounds. michael@0: */ michael@0: virtual void NotifySVGChanged(uint32_t aFlags)=0; michael@0: michael@0: /** michael@0: * Get this frame's contribution to the rect returned by a GetBBox() call michael@0: * that occurred either on this element, or on one of its ancestors. michael@0: * michael@0: * SVG defines an element's bbox to be the element's fill bounds in the michael@0: * userspace established by that element. By allowing callers to pass in the michael@0: * transform from the userspace established by this element to the userspace michael@0: * established by an an ancestor, this method allows callers to obtain this michael@0: * element's fill bounds in the userspace established by that ancestor michael@0: * instead. In that case, since we return the bounds in a different userspace michael@0: * (the ancestor's), the bounds we return are not this element's bbox, but michael@0: * rather this element's contribution to the bbox of the ancestor. michael@0: * michael@0: * @param aToBBoxUserspace The transform from the userspace established by michael@0: * this element to the userspace established by the ancestor on which michael@0: * getBBox was called. This will be the identity matrix if we are the michael@0: * element on which getBBox was called. michael@0: * michael@0: * @param aFlags Flags indicating whether, stroke, for example, should be michael@0: * included in the bbox calculation. michael@0: */ michael@0: virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace, michael@0: uint32_t aFlags) = 0; michael@0: michael@0: // Are we a container frame? michael@0: virtual bool IsDisplayContainer()=0; michael@0: }; michael@0: michael@0: #endif // __NS_ISVGCHILDFRAME_H__ michael@0: