2015-05-03 22:32:37 +03:00
|
|
|
/* -*- 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
|
2013-03-20 07:20:38 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
#ifndef mozilla_dom_SVGAnimatedTransformList_h
|
|
|
|
#define mozilla_dom_SVGAnimatedTransformList_h
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsSVGElement.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class DOMSVGTransformList;
|
2013-04-15 02:56:34 +04:00
|
|
|
class nsSVGAnimatedTransformList;
|
|
|
|
|
|
|
|
namespace dom {
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
/**
|
2013-04-15 02:56:34 +04:00
|
|
|
* Class SVGAnimatedTransformList
|
2013-03-20 07:20:38 +04:00
|
|
|
*
|
|
|
|
* This class is used to create the DOM tearoff objects that wrap internal
|
2013-04-15 02:56:34 +04:00
|
|
|
* nsSVGAnimatedTransformList objects.
|
2013-03-20 07:20:38 +04:00
|
|
|
*
|
|
|
|
* See the architecture comment in DOMSVGAnimatedLengthList.h (that's
|
|
|
|
* LENGTH list). The comment for that class largly applies to this one too
|
|
|
|
* and will go a long way to helping you understand the architecture here.
|
|
|
|
*
|
|
|
|
* This class is strongly intertwined with DOMSVGTransformList and
|
|
|
|
* DOMSVGTransform.
|
|
|
|
* Our DOMSVGTransformList base and anim vals are friends and take care of
|
|
|
|
* nulling out our pointers to them when they die (making our pointers to them
|
|
|
|
* true weak refs).
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class SVGAnimatedTransformList final : public nsWrapperCache
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
2013-04-15 02:56:34 +04:00
|
|
|
friend class mozilla::DOMSVGTransformList;
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
public:
|
2013-04-15 02:56:34 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(SVGAnimatedTransformList)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(SVGAnimatedTransformList)
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
/**
|
2013-04-15 02:56:34 +04:00
|
|
|
* Factory method to create and return a SVGAnimatedTransformList wrapper
|
|
|
|
* for a given internal nsSVGAnimatedTransformList object. The factory takes
|
2013-03-20 07:20:38 +04:00
|
|
|
* care of caching the object that it returns so that the same object can be
|
2013-04-15 02:56:34 +04:00
|
|
|
* returned for the given nsSVGAnimatedTransformList each time it is requested.
|
2013-03-20 07:20:38 +04:00
|
|
|
* The cached object is only removed from the cache when it is destroyed due
|
|
|
|
* to there being no more references to it or to any of its descendant
|
|
|
|
* objects. If that happens, any subsequent call requesting the DOM wrapper
|
2013-04-15 02:56:34 +04:00
|
|
|
* for the nsSVGAnimatedTransformList will naturally result in a new
|
|
|
|
* SVGAnimatedTransformList being returned.
|
2013-03-20 07:20:38 +04:00
|
|
|
*/
|
2013-04-15 02:56:34 +04:00
|
|
|
static already_AddRefed<SVGAnimatedTransformList>
|
|
|
|
GetDOMWrapper(nsSVGAnimatedTransformList *aList, nsSVGElement *aElement);
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
/**
|
2013-04-15 02:56:34 +04:00
|
|
|
* This method returns the SVGAnimatedTransformList wrapper for an internal
|
|
|
|
* nsSVGAnimatedTransformList object if it currently has a wrapper. If it does
|
2013-03-20 07:20:38 +04:00
|
|
|
* not, then nullptr is returned.
|
|
|
|
*/
|
2013-04-15 02:56:34 +04:00
|
|
|
static SVGAnimatedTransformList*
|
|
|
|
GetDOMWrapperIfExists(nsSVGAnimatedTransformList *aList);
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by internal code to notify us when we need to sync the length of
|
|
|
|
* our baseVal DOM list with its internal list. This is called just prior to
|
|
|
|
* the length of the internal baseVal list being changed so that any DOM list
|
|
|
|
* items that need to be removed from the DOM list can first get their values
|
|
|
|
* from their internal counterpart.
|
|
|
|
*
|
|
|
|
* The only time this method could fail is on OOM when trying to increase the
|
|
|
|
* length of the DOM list. If that happens then this method simply clears the
|
|
|
|
* list and returns. Callers just proceed as normal, and we simply accept
|
|
|
|
* that the DOM list will be empty (until successfully set to a new value).
|
|
|
|
*/
|
|
|
|
void InternalBaseValListWillChangeLengthTo(uint32_t aNewLength);
|
|
|
|
void InternalAnimValListWillChangeLengthTo(uint32_t aNewLength);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if our attribute is animating (in which case our animVal is
|
|
|
|
* not simply a mirror of our baseVal).
|
|
|
|
*/
|
|
|
|
bool IsAnimating() const;
|
|
|
|
|
|
|
|
// WebIDL
|
|
|
|
nsSVGElement* GetParentObject() const { return mElement; }
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-03-20 07:20:38 +04:00
|
|
|
// These aren't weak refs because mBaseVal and mAnimVal are weak
|
|
|
|
already_AddRefed<DOMSVGTransformList> BaseVal();
|
|
|
|
already_AddRefed<DOMSVGTransformList> AnimVal();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Only our static GetDOMWrapper() factory method may create objects of our
|
|
|
|
* type.
|
|
|
|
*/
|
2013-04-15 02:56:34 +04:00
|
|
|
explicit SVGAnimatedTransformList(nsSVGElement *aElement)
|
2013-03-20 07:20:38 +04:00
|
|
|
: mBaseVal(nullptr)
|
|
|
|
, mAnimVal(nullptr)
|
|
|
|
, mElement(aElement)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
~SVGAnimatedTransformList();
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
/// Get a reference to this DOM wrapper object's internal counterpart.
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList& InternalAList();
|
|
|
|
const nsSVGAnimatedTransformList& InternalAList() const;
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
// Weak refs to our DOMSVGTransformList baseVal/animVal objects. These objects
|
|
|
|
// are friends and take care of clearing these pointers when they die, making
|
|
|
|
// these true weak references.
|
|
|
|
DOMSVGTransformList *mBaseVal;
|
|
|
|
DOMSVGTransformList *mAnimVal;
|
|
|
|
|
|
|
|
// Strong ref to our element to keep it alive. We hold this not only for
|
|
|
|
// ourself, but also for our base/animVal and all of their items.
|
|
|
|
nsRefPtr<nsSVGElement> mElement;
|
|
|
|
};
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
} // namespace dom
|
2013-03-20 07:20:38 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
#endif // mozilla_dom_SVGAnimatedTransformList_h
|