layout/svg/nsSVGClipPathFrame.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef __NS_SVGCLIPPATHFRAME_H__
     7 #define __NS_SVGCLIPPATHFRAME_H__
     9 #include "mozilla/Attributes.h"
    10 #include "gfxMatrix.h"
    11 #include "nsSVGContainerFrame.h"
    12 #include "nsSVGUtils.h"
    14 class nsRenderingContext;
    15 class nsISVGChildFrame;
    17 typedef nsSVGContainerFrame nsSVGClipPathFrameBase;
    19 class nsSVGClipPathFrame : public nsSVGClipPathFrameBase
    20 {
    21   friend nsIFrame*
    22   NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    23 protected:
    24   nsSVGClipPathFrame(nsStyleContext* aContext)
    25     : nsSVGClipPathFrameBase(aContext)
    26     , mInUse(false)
    27   {
    28     AddStateBits(NS_FRAME_IS_NONDISPLAY);
    29   }
    31 public:
    32   NS_DECL_FRAMEARENA_HELPERS
    34   // nsIFrame methods:
    35   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    36                                 const nsRect&           aDirtyRect,
    37                                 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
    39   // nsSVGClipPathFrame methods:
    40   nsresult ClipPaint(nsRenderingContext* aContext,
    41                      nsIFrame* aParent,
    42                      const gfxMatrix &aMatrix);
    44   bool ClipHitTest(nsIFrame* aParent,
    45                      const gfxMatrix &aMatrix,
    46                      const nsPoint &aPoint);
    48   // Check if this clipPath is made up of more than one geometry object.
    49   // If so, the clipping API in cairo isn't enough and we need to use
    50   // mask based clipping.
    51   bool IsTrivial(nsISVGChildFrame **aSingleChild = nullptr);
    53   bool IsValid();
    55   // nsIFrame interface:
    56   virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
    57                                     nsIAtom*        aAttribute,
    58                                     int32_t         aModType) MOZ_OVERRIDE;
    60   virtual void Init(nsIContent*      aContent,
    61                     nsIFrame*        aParent,
    62                     nsIFrame*        aPrevInFlow) MOZ_OVERRIDE;
    64   /**
    65    * Get the "type" of the frame
    66    *
    67    * @see nsGkAtoms::svgClipPathFrame
    68    */
    69   virtual nsIAtom* GetType() const MOZ_OVERRIDE;
    71 #ifdef DEBUG_FRAME_DUMP
    72   virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
    73   {
    74     return MakeFrameName(NS_LITERAL_STRING("SVGClipPath"), aResult);
    75   }
    76 #endif
    78  private:
    79   // A helper class to allow us to paint clip paths safely. The helper
    80   // automatically sets and clears the mInUse flag on the clip path frame
    81   // (to prevent nasty reference loops). It's easy to mess this up
    82   // and break things, so this helper makes the code far more robust.
    83   class MOZ_STACK_CLASS AutoClipPathReferencer
    84   {
    85   public:
    86     AutoClipPathReferencer(nsSVGClipPathFrame *aFrame
    87                            MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
    88        : mFrame(aFrame) {
    89       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
    90       NS_ASSERTION(!mFrame->mInUse, "reference loop!");
    91       mFrame->mInUse = true;
    92     }
    93     ~AutoClipPathReferencer() {
    94       mFrame->mInUse = false;
    95     }
    96   private:
    97     nsSVGClipPathFrame *mFrame;
    98     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
    99   };
   101   nsIFrame *mClipParent;
   102   nsAutoPtr<gfxMatrix> mClipParentMatrix;
   103   // recursion prevention flag
   104   bool mInUse;
   106   // nsSVGContainerFrame methods:
   107   virtual gfxMatrix GetCanvasTM(uint32_t aFor,
   108                                 nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
   109 };
   111 #endif

mercurial