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.)

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

mercurial