layout/svg/nsSVGPathGeometryFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/svg/nsSVGPathGeometryFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,141 @@
     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_SVGPATHGEOMETRYFRAME_H__
    1.10 +#define __NS_SVGPATHGEOMETRYFRAME_H__
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "gfxMatrix.h"
    1.14 +#include "gfxRect.h"
    1.15 +#include "nsFrame.h"
    1.16 +#include "nsISVGChildFrame.h"
    1.17 +#include "nsLiteralString.h"
    1.18 +#include "nsQueryFrame.h"
    1.19 +#include "nsSVGUtils.h"
    1.20 +
    1.21 +class gfxContext;
    1.22 +class nsDisplaySVGPathGeometry;
    1.23 +class nsIAtom;
    1.24 +class nsIFrame;
    1.25 +class nsIPresShell;
    1.26 +class nsRenderingContext;
    1.27 +class nsStyleContext;
    1.28 +class nsSVGMarkerFrame;
    1.29 +class nsSVGMarkerProperty;
    1.30 +
    1.31 +struct nsPoint;
    1.32 +struct nsRect;
    1.33 +struct nsIntRect;
    1.34 +
    1.35 +typedef nsFrame nsSVGPathGeometryFrameBase;
    1.36 +
    1.37 +class nsSVGPathGeometryFrame : public nsSVGPathGeometryFrameBase,
    1.38 +                               public nsISVGChildFrame
    1.39 +{
    1.40 +  friend nsIFrame*
    1.41 +  NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    1.42 +
    1.43 +  friend class nsDisplaySVGPathGeometry;
    1.44 +
    1.45 +protected:
    1.46 +  nsSVGPathGeometryFrame(nsStyleContext* aContext)
    1.47 +    : nsSVGPathGeometryFrameBase(aContext)
    1.48 +  {
    1.49 +     AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_MAY_BE_TRANSFORMED);
    1.50 +  }
    1.51 +
    1.52 +public:
    1.53 +  NS_DECL_QUERYFRAME_TARGET(nsSVGPathGeometryFrame)
    1.54 +  NS_DECL_QUERYFRAME
    1.55 +  NS_DECL_FRAMEARENA_HELPERS
    1.56 +
    1.57 +  // nsIFrame interface:
    1.58 +  virtual void Init(nsIContent* aContent,
    1.59 +                    nsIFrame* aParent,
    1.60 +                    nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
    1.61 +
    1.62 +  virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
    1.63 +  {
    1.64 +    return nsSVGPathGeometryFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGGeometry));
    1.65 +  }
    1.66 +
    1.67 +  virtual nsresult  AttributeChanged(int32_t         aNameSpaceID,
    1.68 +                                     nsIAtom*        aAttribute,
    1.69 +                                     int32_t         aModType) MOZ_OVERRIDE;
    1.70 +
    1.71 +  virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
    1.72 +
    1.73 +  /**
    1.74 +   * Get the "type" of the frame
    1.75 +   *
    1.76 +   * @see nsGkAtoms::svgPathGeometryFrame
    1.77 +   */
    1.78 +  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
    1.79 +
    1.80 +  virtual bool IsSVGTransformed(Matrix *aOwnTransforms = nullptr,
    1.81 +                                Matrix *aFromParentTransforms = nullptr) const MOZ_OVERRIDE;
    1.82 +
    1.83 +#ifdef DEBUG_FRAME_DUMP
    1.84 +  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
    1.85 +  {
    1.86 +    return MakeFrameName(NS_LITERAL_STRING("SVGPathGeometry"), aResult);
    1.87 +  }
    1.88 +#endif
    1.89 +
    1.90 +  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    1.91 +                                const nsRect&           aDirtyRect,
    1.92 +                                const nsDisplayListSet& aLists) MOZ_OVERRIDE;
    1.93 +
    1.94 +  // nsSVGPathGeometryFrame methods
    1.95 +  gfxMatrix GetCanvasTM(uint32_t aFor,
    1.96 +                        nsIFrame* aTransformRoot = nullptr);
    1.97 +protected:
    1.98 +  // nsISVGChildFrame interface:
    1.99 +  virtual nsresult PaintSVG(nsRenderingContext *aContext,
   1.100 +                            const nsIntRect *aDirtyRect,
   1.101 +                            nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
   1.102 +  virtual nsIFrame* GetFrameForPoint(const nsPoint &aPoint) MOZ_OVERRIDE;
   1.103 +  virtual nsRect GetCoveredRegion() MOZ_OVERRIDE;
   1.104 +  virtual void ReflowSVG() MOZ_OVERRIDE;
   1.105 +  virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
   1.106 +  virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
   1.107 +                                      uint32_t aFlags) MOZ_OVERRIDE;
   1.108 +  virtual bool IsDisplayContainer() MOZ_OVERRIDE { return false; }
   1.109 +
   1.110 +  void GeneratePath(gfxContext *aContext, const Matrix &aTransform);
   1.111 +  /**
   1.112 +   * This function returns a set of bit flags indicating which parts of the
   1.113 +   * element (fill, stroke, bounds) should intercept pointer events. It takes
   1.114 +   * into account the type of element and the value of the 'pointer-events'
   1.115 +   * property on the element.
   1.116 +   */
   1.117 +  virtual uint16_t GetHitTestFlags();
   1.118 +private:
   1.119 +  enum { eRenderFill = 1, eRenderStroke = 2 };
   1.120 +  void Render(nsRenderingContext *aContext, uint32_t aRenderComponents,
   1.121 +              nsIFrame* aTransformRoot);
   1.122 +  void PaintMarkers(nsRenderingContext *aContext);
   1.123 +
   1.124 +  struct MarkerProperties {
   1.125 +    nsSVGMarkerProperty* mMarkerStart;
   1.126 +    nsSVGMarkerProperty* mMarkerMid;
   1.127 +    nsSVGMarkerProperty* mMarkerEnd;
   1.128 +
   1.129 +    bool MarkersExist() const {
   1.130 +      return mMarkerStart || mMarkerMid || mMarkerEnd;
   1.131 +    }
   1.132 +
   1.133 +    nsSVGMarkerFrame *GetMarkerStartFrame();
   1.134 +    nsSVGMarkerFrame *GetMarkerMidFrame();
   1.135 +    nsSVGMarkerFrame *GetMarkerEndFrame();
   1.136 +  };
   1.137 +
   1.138 +  /**
   1.139 +   * @param aFrame should be the first continuation
   1.140 +   */
   1.141 +  static MarkerProperties GetMarkerProperties(nsSVGPathGeometryFrame *aFrame);
   1.142 +};
   1.143 +
   1.144 +#endif // __NS_SVGPATHGEOMETRYFRAME_H__

mercurial