gecko/dom/smil/nsSMILTimeValueSpec.h
Nathan Froyd e4e2da55c9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi
2015-10-18 01:24:48 -04:00

133 lines
4.6 KiB
C++

/* -*- 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 http://mozilla.org/MPL/2.0/. */
#ifndef NS_SMILTIMEVALUESPEC_H_
#define NS_SMILTIMEVALUESPEC_H_
#include "mozilla/Attributes.h"
#include "nsSMILTimeValueSpecParams.h"
#include "nsReferencedElement.h"
#include "nsAutoPtr.h"
#include "nsIDOMEventListener.h"
class nsAString;
class nsSMILTimeValue;
class nsSMILTimedElement;
class nsSMILTimeContainer;
class nsSMILInstanceTime;
class nsSMILInterval;
namespace mozilla {
class EventListenerManager;
} // namespace mozilla
//----------------------------------------------------------------------
// nsSMILTimeValueSpec class
//
// An individual element of a 'begin' or 'end' attribute, e.g. '5s', 'a.end'.
// This class handles the parsing of such specifications and performs the
// necessary event handling (for event, repeat, and accesskey specifications)
// and synchronisation (for syncbase specifications).
//
// For an overview of how this class is related to other SMIL time classes see
// the documentation in nsSMILTimeValue.h
class nsSMILTimeValueSpec
{
public:
typedef mozilla::dom::Element Element;
nsSMILTimeValueSpec(nsSMILTimedElement& aOwner, bool aIsBegin);
~nsSMILTimeValueSpec();
nsresult SetSpec(const nsAString& aStringSpec, Element* aContextNode);
void ResolveReferences(nsIContent* aContextNode);
bool IsEventBased() const;
void HandleNewInterval(nsSMILInterval& aInterval,
const nsSMILTimeContainer* aSrcContainer);
void HandleTargetElementChange(Element* aNewTarget);
// For created nsSMILInstanceTime objects
bool DependsOnBegin() const;
void HandleChangedInstanceTime(const nsSMILInstanceTime& aBaseTime,
const nsSMILTimeContainer* aSrcContainer,
nsSMILInstanceTime& aInstanceTimeToUpdate,
bool aObjectChanged);
void HandleDeletedInstanceTime(nsSMILInstanceTime& aInstanceTime);
// Cycle-collection support
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
void Unlink();
protected:
void UpdateReferencedElement(Element* aFrom, Element* aTo);
void UnregisterFromReferencedElement(Element* aElement);
nsSMILTimedElement* GetTimedElement(Element* aElement);
bool IsWhitelistedEvent();
void RegisterEventListener(Element* aElement);
void UnregisterEventListener(Element* aElement);
mozilla::EventListenerManager* GetEventListenerManager(Element* aElement);
void HandleEvent(nsIDOMEvent* aEvent);
bool CheckEventDetail(nsIDOMEvent* aEvent);
bool CheckRepeatEventDetail(nsIDOMEvent* aEvent);
bool CheckAccessKeyEventDetail(nsIDOMEvent* aEvent);
nsSMILTimeValue ConvertBetweenTimeContainers(const nsSMILTimeValue& aSrcTime,
const nsSMILTimeContainer* aSrcContainer);
bool ApplyOffset(nsSMILTimeValue& aTime) const;
nsSMILTimedElement* mOwner;
bool mIsBegin; // Indicates if *we* are a begin spec,
// not to be confused with
// mParams.mSyncBegin which indicates
// if we're synced with the begin of
// the target.
nsSMILTimeValueSpecParams mParams;
class TimeReferenceElement : public nsReferencedElement
{
public:
explicit TimeReferenceElement(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) { }
void ResetWithElement(Element* aTo) {
RefPtr<Element> from = get();
Unlink();
ElementChanged(from, aTo);
}
protected:
virtual void ElementChanged(Element* aFrom, Element* aTo) override
{
nsReferencedElement::ElementChanged(aFrom, aTo);
mSpec->UpdateReferencedElement(aFrom, aTo);
}
virtual bool IsPersistent() override { return true; }
private:
nsSMILTimeValueSpec* mSpec;
};
TimeReferenceElement mReferencedElement;
class EventListener final : public nsIDOMEventListener
{
~EventListener() {}
public:
explicit EventListener(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) { }
void Disconnect()
{
mSpec = nullptr;
}
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
private:
nsSMILTimeValueSpec* mSpec;
};
RefPtr<EventListener> mEventListener;
};
#endif // NS_SMILTIMEVALUESPEC_H_