layout/svg/nsISVGChildFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/svg/nsISVGChildFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,148 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef __NS_ISVGCHILDFRAME_H__
    1.10 +#define __NS_ISVGCHILDFRAME_H__
    1.11 +
    1.12 +#include "gfxRect.h"
    1.13 +#include "nsQueryFrame.h"
    1.14 +
    1.15 +class nsIFrame;
    1.16 +class nsRenderingContext;
    1.17 +
    1.18 +struct nsPoint;
    1.19 +class SVGBBox;
    1.20 +struct nsRect;
    1.21 +struct nsIntRect;
    1.22 +
    1.23 +namespace mozilla {
    1.24 +class SVGAnimatedLengthList;
    1.25 +class SVGAnimatedNumberList;
    1.26 +class SVGLengthList;
    1.27 +class SVGNumberList;
    1.28 +class SVGUserUnitList;
    1.29 +
    1.30 +namespace gfx {
    1.31 +class Matrix;
    1.32 +}
    1.33 +}
    1.34 +
    1.35 +/**
    1.36 + * This class is not particularly well named. It is inherited by some, but
    1.37 + * not all SVG frame classes that can be descendants of an
    1.38 + * nsSVGOuterSVGFrame in the frame tree. Note specifically that SVG container
    1.39 + * frames that do not inherit nsSVGDisplayContainerFrame do not inherit this
    1.40 + * class (so that's classes that only inherit nsSVGContainerFrame).
    1.41 + */
    1.42 +class nsISVGChildFrame : public nsQueryFrame
    1.43 +{
    1.44 +public:
    1.45 +  typedef mozilla::SVGAnimatedNumberList SVGAnimatedNumberList;
    1.46 +  typedef mozilla::SVGNumberList SVGNumberList;
    1.47 +  typedef mozilla::SVGAnimatedLengthList SVGAnimatedLengthList;
    1.48 +  typedef mozilla::SVGLengthList SVGLengthList;
    1.49 +  typedef mozilla::SVGUserUnitList SVGUserUnitList;
    1.50 +
    1.51 +  NS_DECL_QUERYFRAME_TARGET(nsISVGChildFrame)
    1.52 +
    1.53 +  // Paint this frame.
    1.54 +  // aDirtyRect is the area being redrawn, in frame offset pixel coordinates.
    1.55 +  // aTransformRoot (if non-null) is the frame at which we stop looking up
    1.56 +  // transforms, when painting content that is part of an SVG glyph. (See
    1.57 +  // bug 875329.)
    1.58 +  // For normal SVG graphics using display-list rendering, any transforms on
    1.59 +  // the element or its parents will have already been set up in the context
    1.60 +  // before PaintSVG is called. When painting SVG glyphs, this is not the case,
    1.61 +  // so the element's full transform needs to be applied; but we don't want to
    1.62 +  // apply transforms from outside the actual glyph element, so we need to know
    1.63 +  // how far up the ancestor chain to go.
    1.64 +  virtual nsresult PaintSVG(nsRenderingContext* aContext,
    1.65 +                            const nsIntRect *aDirtyRect,
    1.66 +                            nsIFrame* aTransformRoot = nullptr) = 0;
    1.67 +
    1.68 +  // Check if this frame or children contain the given point,
    1.69 +  // specified in app units relative to the origin of the outer
    1.70 +  // svg frame (origin ill-defined in the case of borders - bug
    1.71 +  // 290770).  See bug 290852 for foreignObject complications.
    1.72 +  virtual nsIFrame* GetFrameForPoint(const nsPoint &aPoint)=0;
    1.73 +
    1.74 +  // Get bounds in our nsSVGOuterSVGFrame's coordinates space (in app units)
    1.75 +  virtual nsRect GetCoveredRegion()=0;
    1.76 +
    1.77 +  // Called on SVG child frames (except NS_FRAME_IS_NONDISPLAY frames)
    1.78 +  // to update and then invalidate their cached bounds. This method is not
    1.79 +  // called until after the nsSVGOuterSVGFrame has had its initial reflow
    1.80 +  // (i.e. once the SVG viewport dimensions are known). It should also only
    1.81 +  // be called by nsSVGOuterSVGFrame during its reflow.
    1.82 +  virtual void ReflowSVG()=0;
    1.83 +
    1.84 +  /**
    1.85 +   * Flags used to specify to GetCanvasTM what it's being called for so that it
    1.86 +   * knows how far up the tree the "canvas" is. When display lists are being
    1.87 +   * used for painting or hit-testing of SVG, the "canvas" is simply user
    1.88 +   * space.
    1.89 +   */
    1.90 +  enum RequestingCanvasTMFor {
    1.91 +    FOR_PAINTING = 1,
    1.92 +    FOR_HIT_TESTING,
    1.93 +    FOR_OUTERSVG_TM
    1.94 +  };
    1.95 +
    1.96 +  // Flags to pass to NotifySVGChange:
    1.97 +  //
    1.98 +  // DO_NOT_NOTIFY_RENDERING_OBSERVERS - this should only be used when
    1.99 +  //                           updating the descendant frames of a clipPath,
   1.100 +  //                           mask, pattern or marker frame (or other similar
   1.101 +  //                           NS_FRAME_IS_NONDISPLAY frame) immediately
   1.102 +  //                           prior to painting that frame's descendants.
   1.103 +  // TRANSFORM_CHANGED     - the current transform matrix for this frame has changed
   1.104 +  // COORD_CONTEXT_CHANGED - the dimensions of this frame's coordinate context has
   1.105 +  //                           changed (percentage lengths must be reevaluated)
   1.106 +  enum SVGChangedFlags {
   1.107 +    TRANSFORM_CHANGED     = 0x01,
   1.108 +    COORD_CONTEXT_CHANGED = 0x02,
   1.109 +    FULL_ZOOM_CHANGED     = 0x04
   1.110 +  };
   1.111 +  /**
   1.112 +   * This is called on a frame when there has been a change to one of its
   1.113 +   * ancestors that might affect the frame too. SVGChangedFlags are passed
   1.114 +   * to indicate what changed.
   1.115 +   *
   1.116 +   * Implementations do not need to invalidate, since the caller will 
   1.117 +   * invalidate the entire area of the ancestor that changed. However, they
   1.118 +   * may need to update their bounds.
   1.119 +   */
   1.120 +  virtual void NotifySVGChanged(uint32_t aFlags)=0;
   1.121 +
   1.122 +  /**
   1.123 +   * Get this frame's contribution to the rect returned by a GetBBox() call
   1.124 +   * that occurred either on this element, or on one of its ancestors.
   1.125 +   *
   1.126 +   * SVG defines an element's bbox to be the element's fill bounds in the
   1.127 +   * userspace established by that element. By allowing callers to pass in the
   1.128 +   * transform from the userspace established by this element to the userspace
   1.129 +   * established by an an ancestor, this method allows callers to obtain this
   1.130 +   * element's fill bounds in the userspace established by that ancestor
   1.131 +   * instead. In that case, since we return the bounds in a different userspace
   1.132 +   * (the ancestor's), the bounds we return are not this element's bbox, but
   1.133 +   * rather this element's contribution to the bbox of the ancestor.
   1.134 +   *
   1.135 +   * @param aToBBoxUserspace The transform from the userspace established by
   1.136 +   *   this element to the userspace established by the ancestor on which
   1.137 +   *   getBBox was called. This will be the identity matrix if we are the
   1.138 +   *   element on which getBBox was called.
   1.139 +   *
   1.140 +   * @param aFlags Flags indicating whether, stroke, for example, should be
   1.141 +   *   included in the bbox calculation.
   1.142 +   */
   1.143 +  virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
   1.144 +                                      uint32_t aFlags) = 0;
   1.145 +
   1.146 +  // Are we a container frame?
   1.147 +  virtual bool IsDisplayContainer()=0;
   1.148 +};
   1.149 +
   1.150 +#endif // __NS_ISVGCHILDFRAME_H__
   1.151 +

mercurial