2009-01-14 20:38:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
#ifndef NS_SMILTIMEVALUESPEC_H_
|
|
|
|
#define NS_SMILTIMEVALUESPEC_H_
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2010-01-12 12:00:49 -08:00
|
|
|
#include "nsSMILTimeValueSpecParams.h"
|
|
|
|
#include "nsReferencedElement.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2010-08-18 03:20:24 -07:00
|
|
|
#include "nsIDOMEventListener.h"
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
class nsAString;
|
|
|
|
class nsSMILTimeValue;
|
|
|
|
class nsSMILTimedElement;
|
2010-01-12 12:00:49 -08:00
|
|
|
class nsSMILTimeContainer;
|
|
|
|
class nsSMILInstanceTime;
|
|
|
|
class nsSMILInterval;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2014-03-16 23:56:53 -07:00
|
|
|
namespace mozilla {
|
|
|
|
class EventListenerManager;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-01-14 20:38:07 -08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// 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
|
2010-01-12 12:00:49 -08:00
|
|
|
// the documentation in nsSMILTimeValue.h
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-01-12 12:00:49 -08:00
|
|
|
class nsSMILTimeValueSpec
|
2009-01-14 20:38:07 -08:00
|
|
|
{
|
|
|
|
public:
|
2010-08-18 03:20:24 -07:00
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
nsSMILTimeValueSpec(nsSMILTimedElement& aOwner, bool aIsBegin);
|
2010-01-12 12:00:49 -08:00
|
|
|
~nsSMILTimeValueSpec();
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-08-18 03:20:24 -07:00
|
|
|
nsresult SetSpec(const nsAString& aStringSpec, Element* aContextNode);
|
2010-01-12 12:00:49 -08:00
|
|
|
void ResolveReferences(nsIContent* aContextNode);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsEventBased() const;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-03-01 11:31:50 -08:00
|
|
|
void HandleNewInterval(nsSMILInterval& aInterval,
|
2010-01-12 12:00:49 -08:00
|
|
|
const nsSMILTimeContainer* aSrcContainer);
|
2010-08-18 03:20:24 -07:00
|
|
|
void HandleTargetElementChange(Element* aNewTarget);
|
2010-03-01 11:31:50 -08:00
|
|
|
|
|
|
|
// For created nsSMILInstanceTime objects
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DependsOnBegin() const;
|
2010-03-01 11:31:50 -08:00
|
|
|
void HandleChangedInstanceTime(const nsSMILInstanceTime& aBaseTime,
|
|
|
|
const nsSMILTimeContainer* aSrcContainer,
|
|
|
|
nsSMILInstanceTime& aInstanceTimeToUpdate,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aObjectChanged);
|
2010-03-01 11:31:50 -08:00
|
|
|
void HandleDeletedInstanceTime(nsSMILInstanceTime& aInstanceTime);
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-01-12 12:00:49 -08:00
|
|
|
// Cycle-collection support
|
|
|
|
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
|
|
|
|
void Unlink();
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-01-12 12:00:49 -08:00
|
|
|
protected:
|
2010-08-18 03:20:24 -07:00
|
|
|
void UpdateReferencedElement(Element* aFrom, Element* aTo);
|
|
|
|
void UnregisterFromReferencedElement(Element* aElement);
|
|
|
|
nsSMILTimedElement* GetTimedElement(Element* aElement);
|
2011-12-08 13:34:07 -08:00
|
|
|
bool IsWhitelistedEvent();
|
2010-08-18 03:20:24 -07:00
|
|
|
void RegisterEventListener(Element* aElement);
|
|
|
|
void UnregisterEventListener(Element* aElement);
|
2014-03-16 23:56:53 -07:00
|
|
|
mozilla::EventListenerManager* GetEventListenerManager(Element* aElement);
|
2010-08-18 03:20:24 -07:00
|
|
|
void HandleEvent(nsIDOMEvent* aEvent);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool CheckEventDetail(nsIDOMEvent* aEvent);
|
|
|
|
bool CheckRepeatEventDetail(nsIDOMEvent* aEvent);
|
|
|
|
bool CheckAccessKeyEventDetail(nsIDOMEvent* aEvent);
|
2010-01-12 12:00:49 -08:00
|
|
|
nsSMILTimeValue ConvertBetweenTimeContainers(const nsSMILTimeValue& aSrcTime,
|
|
|
|
const nsSMILTimeContainer* aSrcContainer);
|
2011-11-15 11:56:32 -08:00
|
|
|
bool ApplyOffset(nsSMILTimeValue& aTime) const;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-01-12 12:00:49 -08:00
|
|
|
nsSMILTimedElement* mOwner;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsBegin; // Indicates if *we* are a begin spec,
|
2010-01-12 12:00:49 -08:00
|
|
|
// not to be confused with
|
|
|
|
// mParams.mSyncBegin which indicates
|
|
|
|
// if we're synced with the begin of
|
|
|
|
// the target.
|
|
|
|
nsSMILTimeValueSpecParams mParams;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-08-18 03:20:24 -07:00
|
|
|
class TimeReferenceElement : public nsReferencedElement
|
|
|
|
{
|
2010-01-12 12:00:49 -08:00
|
|
|
public:
|
2014-08-08 06:49:39 -07:00
|
|
|
explicit TimeReferenceElement(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) { }
|
2010-08-18 03:20:24 -07:00
|
|
|
void ResetWithElement(Element* aTo) {
|
|
|
|
nsRefPtr<Element> from = get();
|
|
|
|
Unlink();
|
|
|
|
ElementChanged(from, aTo);
|
|
|
|
}
|
2010-01-12 12:00:49 -08:00
|
|
|
|
|
|
|
protected:
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void ElementChanged(Element* aFrom, Element* aTo) MOZ_OVERRIDE
|
2010-08-18 03:20:24 -07:00
|
|
|
{
|
2010-05-14 10:04:51 -07:00
|
|
|
nsReferencedElement::ElementChanged(aFrom, aTo);
|
2010-08-18 03:20:24 -07:00
|
|
|
mSpec->UpdateReferencedElement(aFrom, aTo);
|
2010-01-12 12:00:49 -08:00
|
|
|
}
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual bool IsPersistent() MOZ_OVERRIDE { return true; }
|
2010-01-12 12:00:49 -08:00
|
|
|
private:
|
|
|
|
nsSMILTimeValueSpec* mSpec;
|
|
|
|
};
|
|
|
|
|
2010-08-18 03:20:24 -07:00
|
|
|
TimeReferenceElement mReferencedElement;
|
|
|
|
|
2012-02-02 08:15:18 -08:00
|
|
|
class EventListener MOZ_FINAL : public nsIDOMEventListener
|
2010-08-18 03:20:24 -07:00
|
|
|
{
|
2014-06-23 12:56:07 -07:00
|
|
|
~EventListener() {}
|
2010-08-18 03:20:24 -07:00
|
|
|
public:
|
2014-08-08 06:49:39 -07:00
|
|
|
explicit EventListener(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) { }
|
2010-08-18 03:20:24 -07:00
|
|
|
void Disconnect()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
mSpec = nullptr;
|
2010-08-18 03:20:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsSMILTimeValueSpec* mSpec;
|
|
|
|
};
|
2014-03-17 17:23:03 -07:00
|
|
|
nsRefPtr<EventListener> mEventListener;
|
2010-01-12 12:00:49 -08:00
|
|
|
};
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
#endif // NS_SMILTIMEVALUESPEC_H_
|