author Nathan Froyd <>
Wed, 07 Oct 2015 15:05:02 -0400
changeset 301510 1f51d1614b9a58e41dd3a1bf2dc6aad34dbb2170
parent 285938 91d6e262b662a0b4e47358665e222d3927337af9
child 301514 91d4539e00cecb658604e021675a923c60ef3235
permissions -rw-r--r--
Bug 1207245 - part 3 - switch all uses of mozilla::RefPtr<T> to nsRefPtr<T>; r=ehsan This commit was generated using the following script, executed at the top level of a typical source code checkout. # Don't modify select files in mfbt/ because it's not worth trying to # tease out the dependencies currently. # # Don't modify anything in media/gmp-clearkey/0.1/ because those files # use their own RefPtr, defined in their own RefCounted.h. find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ grep -v 'mfbt/RefPtr.h' | \ grep -v 'mfbt/nsRefPtr.h' | \ grep -v 'mfbt/RefCounted.h' | \ grep -v 'media/gmp-clearkey/0.1/' | \ xargs perl -p -i -e ' s/mozilla::RefPtr/nsRefPtr/g; # handle declarations in headers s/\bRefPtr</nsRefPtr</g; # handle local variables in functions s#mozilla/RefPtr.h#mozilla/nsRefPtr.h#; # handle #includes s#mfbt/RefPtr.h#mfbt/nsRefPtr.h#; # handle strange #includes ' # |using mozilla::RefPtr;| is OK; |using nsRefPtr;| is invalid syntax. find . -name '*.cpp' -o -name '*.mm' | xargs sed -i -e '/using nsRefPtr/d' # RefPtr.h used |byRef| for dealing with COM-style outparams. # nsRefPtr.h uses |getter_AddRefs|. # Fixup that mismatch. find . -name '*.cpp' | \ xargs perl -p -i -e 's/byRef/getter_AddRefs/g'

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/gfx/2D.h"
#include "mozilla/nsRefPtr.h"
#include "nsAutoPtr.h"
#include "nsSMILAnimationFunction.h"
#include "nsTArray.h"
#include "SVGMotionSMILType.h"  // for RotateType

class nsAttrValue;
class nsIAtom;
class nsIContent;
class nsISMILAttr;
class nsSMILValue;

namespace mozilla {

namespace dom {
class SVGMPathElement;
} // namespace dom

// SVGMotionSMILAnimationFunction
// Subclass of nsSMILAnimationFunction to support a few extra features offered
// by the <animateMotion> element.
class SVGMotionSMILAnimationFunction final : public nsSMILAnimationFunction
  typedef mozilla::gfx::Path Path;

  virtual bool SetAttr(nsIAtom* aAttribute,
                       const nsAString& aValue,
                       nsAttrValue& aResult,
                       nsresult* aParseResult = nullptr) override;
  virtual bool UnsetAttr(nsIAtom* aAttribute) override;

  // Method to allow our owner-element to signal us when our <mpath>
  // has changed or been added/removed.  When that happens, we need to
  // mark ourselves as changed so we'll get recomposed, and mark our path data
  // as stale so it'll get regenerated (regardless of mPathSourceType, since
  // <mpath> trumps all the other sources of path data)
  void MpathChanged() { mIsPathStale = mHasChanged = true; }

  enum PathSourceType {
    // NOTE: Ordering matters here. Higher-priority path-descriptors should
    // have higher enumerated values
    ePathSourceType_None,      // uninitialized or not applicable
    ePathSourceType_ByAttr,    // by or from-by animation
    ePathSourceType_ToAttr,    // to or from-to animation

  virtual nsSMILCalcMode GetCalcMode() const override;
  virtual nsresult GetValues(const nsISMILAttr& aSMILAttr,
                             nsSMILValueArray& aResult) override;
  virtual void CheckValueListDependentAttrs(uint32_t aNumValues) override;

  virtual bool IsToAnimation() const override;

  void     CheckKeyPoints();
  nsresult SetKeyPoints(const nsAString& aKeyPoints, nsAttrValue& aResult);
  void     UnsetKeyPoints();
  nsresult SetRotate(const nsAString& aRotate, nsAttrValue& aResult);
  void     UnsetRotate();

  // Helpers for GetValues
  void     MarkStaleIfAttributeAffectsPath(nsIAtom* aAttribute);
  void     RebuildPathAndVertices(const nsIContent* aContextElem);
  void     RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem);
  void     RebuildPathAndVerticesFromPathAttr();
  void     RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem);
  bool     GenerateValuesForPathAndPoints(Path* aPath,
                                          bool aIsKeyPoints,
                                          FallibleTArray<double>& aPointDistances,
                                          nsSMILValueArray& aResult);

  // Members
  // -------
  FallibleTArray<double>     mKeyPoints; // parsed from "keyPoints" attribute.

  RotateType                 mRotateType;  // auto, auto-reverse, or explicit.
  float                      mRotateAngle; // the angle value, if explicit.

  PathSourceType             mPathSourceType; // source of our Path.
  nsRefPtr<Path>               mPath;           // representation of motion path.
  FallibleTArray<double>     mPathVertices; // distances of vertices along path.

  bool                       mIsPathStale;

} // namespace mozilla