author Fernando Jiménez <>
Sat, 07 Jun 2014 19:30:19 +0200
changeset 206648 e3dc24f425734635f3f6d663d2339c4234027d86
parent 204053 18214a2cfdb3eea37354959ab6fae5b97bc4a1ee
child 207422 f89e20f3ad3a2a7efa8c39039f6929f7991015c8
permissions -rw-r--r--
Bug 988469 - MSISDN verification API for privileged apps. Part 4: Mobile ID service. r=markh, jedp

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */


#include "mozilla/Attributes.h"
#include "gfxPattern.h"
#include "gfxMatrix.h"
#include "nsSVGContainerFrame.h"
#include "nsSVGUtils.h"

class gfxContext;
class nsRenderingContext;

typedef nsSVGContainerFrame nsSVGMaskFrameBase;

class nsSVGMaskFrame : public nsSVGMaskFrameBase
  friend nsIFrame*
  NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
  nsSVGMaskFrame(nsStyleContext* aContext)
    : nsSVGMaskFrameBase(aContext)
    , mInUse(false)


  // nsSVGMaskFrame method:
  already_AddRefed<gfxPattern> ComputeMaskAlpha(nsRenderingContext *aContext,
                                                nsIFrame* aParent,
                                                const gfxMatrix &aMatrix,
                                                float aOpacity = 1.0f);

  virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
                                    nsIAtom*        aAttribute,
                                    int32_t         aModType) MOZ_OVERRIDE;

#ifdef DEBUG
  virtual void Init(nsIContent*       aContent,
                    nsContainerFrame* aParent,
                    nsIFrame*         aPrevInFlow) MOZ_OVERRIDE;

  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                const nsRect&           aDirtyRect,
                                const nsDisplayListSet& aLists) MOZ_OVERRIDE {}

   * Get the "type" of the frame
   * @see nsGkAtoms::svgMaskFrame
  virtual nsIAtom* GetType() const MOZ_OVERRIDE;

  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
    return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult);

  // A helper class to allow us to paint masks safely. The helper
  // automatically sets and clears the mInUse flag on the mask frame
  // (to prevent nasty reference loops). It's easy to mess this up
  // and break things, so this helper makes the code far more robust.
  class MOZ_STACK_CLASS AutoMaskReferencer
    AutoMaskReferencer(nsSVGMaskFrame *aFrame
       : mFrame(aFrame) {
      NS_ASSERTION(!mFrame->mInUse, "reference loop!");
      mFrame->mInUse = true;
    ~AutoMaskReferencer() {
      mFrame->mInUse = false;
    nsSVGMaskFrame *mFrame;

  nsIFrame *mMaskParent;
  nsAutoPtr<gfxMatrix> mMaskParentMatrix;
  // recursion prevention flag
  bool mInUse;

  // nsSVGContainerFrame methods:
  virtual gfxMatrix GetCanvasTM(uint32_t aFor,
                                nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;