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