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_SMILTIMEDELEMENT_H_
|
|
|
|
#define NS_SMILTIMEDELEMENT_H_
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
#include "mozilla/EventForwards.h"
|
2014-05-08 02:05:37 +04:00
|
|
|
#include "mozilla/Move.h"
|
2019-01-02 10:21:13 +03:00
|
|
|
#include "mozilla/SMILMilestone.h"
|
2019-01-22 10:28:40 +03:00
|
|
|
#include "mozilla/SMILInstanceTime.h"
|
2019-01-21 16:08:12 +03:00
|
|
|
#include "mozilla/SMILInterval.h"
|
|
|
|
#include "mozilla/SMILRepeatCount.h"
|
2019-01-22 10:28:40 +03:00
|
|
|
#include "mozilla/SMILTimeValueSpec.h"
|
2019-01-23 16:48:08 +03:00
|
|
|
#include "mozilla/SMILTypes.h"
|
2018-04-16 18:15:56 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
#include "nsTArray.h"
|
2010-01-12 23:00:49 +03:00
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsAttrValue.h"
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
class nsAtom;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
namespace mozilla {
|
2019-01-22 10:28:40 +03:00
|
|
|
|
2018-12-31 14:54:22 +03:00
|
|
|
class SMILAnimationFunction;
|
2019-01-02 10:21:13 +03:00
|
|
|
class SMILTimeContainer;
|
2019-01-22 10:28:40 +03:00
|
|
|
class SMILTimeValue;
|
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
namespace dom {
|
|
|
|
class SVGAnimationElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2013-03-19 07:18:45 +04:00
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
//----------------------------------------------------------------------
|
2019-01-01 12:16:21 +03:00
|
|
|
// SMILTimedElement
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-01 12:16:21 +03:00
|
|
|
class SMILTimedElement {
|
2009-01-15 07:38:07 +03:00
|
|
|
public:
|
2019-01-01 12:16:21 +03:00
|
|
|
SMILTimedElement();
|
|
|
|
~SMILTimedElement();
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-08-18 14:20:24 +04:00
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2010-01-12 23:00:49 +03:00
|
|
|
/*
|
|
|
|
* Sets the owning animation element which this class uses to convert between
|
|
|
|
* container times and to register timebase elements.
|
|
|
|
*/
|
2013-03-19 07:18:45 +04:00
|
|
|
void SetAnimationElement(mozilla::dom::SVGAnimationElement* aElement);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the time container with which this timed element is associated or
|
2012-07-30 18:20:58 +04:00
|
|
|
* nullptr if it is not associated with a time container.
|
2010-01-12 23:00:49 +03:00
|
|
|
*/
|
2019-01-02 10:21:13 +03:00
|
|
|
SMILTimeContainer* GetTimeContainer();
|
2010-01-12 23:00:49 +03:00
|
|
|
|
2010-08-18 14:20:24 +04:00
|
|
|
/*
|
|
|
|
* Returns the element targeted by the animation element. Needed for
|
|
|
|
* registering event listeners against the appropriate element.
|
|
|
|
*/
|
2018-08-28 12:06:08 +03:00
|
|
|
Element* GetTargetElement();
|
2010-08-18 14:20:24 +04:00
|
|
|
|
2009-07-15 22:33:31 +04:00
|
|
|
/**
|
2018-04-27 06:37:34 +03:00
|
|
|
* Methods for supporting the ElementTimeControl interface.
|
2009-01-15 07:38:07 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2010-01-12 23:00:49 +03:00
|
|
|
* Adds a new begin instance time at the current container time plus or minus
|
|
|
|
* the specified offset.
|
2009-01-15 07:38:07 +03:00
|
|
|
*
|
|
|
|
* @param aOffsetSeconds A real number specifying the number of seconds to add
|
|
|
|
* to the current container time.
|
|
|
|
* @return NS_OK if the operation succeeeded, or an error code otherwise.
|
|
|
|
*/
|
2010-01-12 23:00:49 +03:00
|
|
|
nsresult BeginElementAt(double aOffsetSeconds);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
/*
|
2010-01-12 23:00:49 +03:00
|
|
|
* Adds a new end instance time at the current container time plus or minus
|
|
|
|
* the specified offset.
|
2009-01-15 07:38:07 +03:00
|
|
|
*
|
|
|
|
* @param aOffsetSeconds A real number specifying the number of seconds to add
|
|
|
|
* to the current container time.
|
|
|
|
* @return NS_OK if the operation succeeeded, or an error code otherwise.
|
|
|
|
*/
|
2010-01-12 23:00:49 +03:00
|
|
|
nsresult EndElementAt(double aOffsetSeconds);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2009-07-15 22:33:31 +04:00
|
|
|
/**
|
2009-01-19 12:10:53 +03:00
|
|
|
* Methods for supporting the nsSVGAnimationElement interface.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2009-10-13 03:14:08 +04:00
|
|
|
* According to SVG 1.1 SE this returns
|
2009-01-19 12:10:53 +03:00
|
|
|
*
|
2009-10-13 03:14:08 +04:00
|
|
|
* the begin time, in seconds, for this animation element's current
|
|
|
|
* interval, if it exists, regardless of whether the interval has begun yet.
|
2009-01-19 12:10:53 +03:00
|
|
|
*
|
2009-10-13 03:14:08 +04:00
|
|
|
* @return the start time as defined above in milliseconds or an unresolved
|
|
|
|
* time if there is no current interval.
|
2009-01-19 12:10:53 +03:00
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILTimeValue GetStartTime() const;
|
2009-01-19 12:10:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the simple duration of this element.
|
|
|
|
*
|
|
|
|
* @return the simple duration in milliseconds or INDEFINITE.
|
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILTimeValue GetSimpleDuration() const { return mSimpleDur; }
|
2009-01-19 12:10:53 +03:00
|
|
|
|
2012-05-17 13:56:57 +04:00
|
|
|
/**
|
|
|
|
* Methods for supporting hyperlinking
|
|
|
|
*/
|
|
|
|
|
2009-07-15 22:33:31 +04:00
|
|
|
/**
|
2009-01-19 12:10:53 +03:00
|
|
|
* Internal SMIL methods
|
|
|
|
*/
|
|
|
|
|
2012-05-17 13:56:57 +04:00
|
|
|
/**
|
|
|
|
* Returns the time to seek the document to when this element is targetted by
|
|
|
|
* a hyperlink.
|
|
|
|
*
|
|
|
|
* The behavior is defined here:
|
|
|
|
* http://www.w3.org/TR/smil-animation/#HyperlinkSemantics
|
|
|
|
*
|
|
|
|
* It is very similar to GetStartTime() with the exception that when the
|
|
|
|
* element is not active, the begin time of the *first* interval is returned.
|
|
|
|
*
|
|
|
|
* @return the time to seek the documen to in milliseconds or an unresolved
|
|
|
|
* time if there is no resolved interval.
|
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILTimeValue GetHyperlinkTime() const;
|
2012-05-17 13:56:57 +04:00
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
/**
|
|
|
|
* Adds an instance time object this element's list of instance times.
|
|
|
|
* These instance times are used when creating intervals.
|
|
|
|
*
|
2019-01-22 10:28:40 +03:00
|
|
|
* This method is typically called by an SMILTimeValueSpec.
|
2009-01-15 07:38:07 +03:00
|
|
|
*
|
2010-01-12 23:00:49 +03:00
|
|
|
* @param aInstanceTime The time to add, expressed in container time.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aIsBegin true if the time to be added represents a begin
|
|
|
|
* time or false if it represents an end time.
|
2009-01-15 07:38:07 +03:00
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
void AddInstanceTime(SMILInstanceTime* aInstanceTime, bool aIsBegin);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Requests this element update the given instance time.
|
|
|
|
*
|
2019-01-22 10:28:40 +03:00
|
|
|
* This method is typically called by a child SMILTimeValueSpec.
|
2010-01-12 23:00:49 +03:00
|
|
|
*
|
|
|
|
* @param aInstanceTime The instance time to update.
|
|
|
|
* @param aUpdatedTime The time to update aInstanceTime with.
|
|
|
|
* @param aDependentTime The instance time upon which aInstanceTime should be
|
|
|
|
* based.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aIsBegin true if the time to be updated represents a begin
|
|
|
|
* instance time or false if it represents an end
|
2010-01-12 23:00:49 +03:00
|
|
|
* instance time.
|
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
void UpdateInstanceTime(SMILInstanceTime* aInstanceTime,
|
|
|
|
SMILTimeValue& aUpdatedTime, bool aIsBegin);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
|
|
|
/**
|
2010-05-21 04:18:29 +04:00
|
|
|
* Removes an instance time object from this element's list of instance times.
|
2010-01-12 23:00:49 +03:00
|
|
|
*
|
2019-01-22 10:28:40 +03:00
|
|
|
* This method is typically called by a child SMILTimeValueSpec.
|
2010-01-12 23:00:49 +03:00
|
|
|
*
|
|
|
|
* @param aInstanceTime The instance time to remove.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aIsBegin true if the time to be removed represents a begin
|
|
|
|
* time or false if it represents an end time.
|
2010-01-12 23:00:49 +03:00
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
void RemoveInstanceTime(SMILInstanceTime* aInstanceTime, bool aIsBegin);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-03-01 22:31:50 +03:00
|
|
|
/**
|
|
|
|
* Removes all the instance times associated with the given
|
2019-01-22 10:28:40 +03:00
|
|
|
* SMILTimeValueSpec object. Used when an ID assignment changes and hence
|
2010-03-01 22:31:50 +03:00
|
|
|
* all the previously associated instance times become invalid.
|
|
|
|
*
|
2019-01-22 10:28:40 +03:00
|
|
|
* @param aSpec The SMILTimeValueSpec object whose created
|
|
|
|
* SMILInstanceTime's should be removed.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aIsBegin true if the times to be removed represent begin
|
|
|
|
* times or false if they are end times.
|
2010-03-01 22:31:50 +03:00
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
void RemoveInstanceTimesForCreator(const SMILTimeValueSpec* aSpec,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsBegin);
|
2010-03-01 22:31:50 +03:00
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
/**
|
|
|
|
* Sets the object that will be called by this timed element each time it is
|
|
|
|
* sampled.
|
|
|
|
*
|
|
|
|
* In Schmitz's model it is possible to associate several time clients with
|
|
|
|
* a timed element but for now we only allow one.
|
|
|
|
*
|
|
|
|
* @param aClient The time client to associate. Any previous time client
|
|
|
|
* will be disassociated and no longer sampled. Setting this
|
2012-07-30 18:20:58 +04:00
|
|
|
* to nullptr will simply disassociate the previous client,
|
2009-01-15 07:38:07 +03:00
|
|
|
* if any.
|
|
|
|
*/
|
2018-12-31 14:54:22 +03:00
|
|
|
void SetTimeClient(SMILAnimationFunction* aClient);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
/**
|
2010-01-12 23:00:49 +03:00
|
|
|
* Samples the object at the given container time. Timing intervals are
|
|
|
|
* updated and if this element is active at the given time the associated time
|
|
|
|
* client will be sampled with the appropriate simple time.
|
2009-01-15 07:38:07 +03:00
|
|
|
*
|
2010-01-12 23:00:49 +03:00
|
|
|
* @param aContainerTime The container time at which to sample.
|
2009-01-15 07:38:07 +03:00
|
|
|
*/
|
2019-01-25 06:24:01 +03:00
|
|
|
void SampleAt(SMILTime aContainerTime);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs a special sample for the end of an interval. Such a sample should
|
|
|
|
* only advance the timed element (and any dependent elements) to the waiting
|
|
|
|
* or postactive state. It should not cause a transition to the active state.
|
|
|
|
* Transition to the active state is only performed on a regular SampleAt.
|
|
|
|
*
|
|
|
|
* This allows all interval ends at a given time to be processed first and
|
|
|
|
* hence the new interval can be established based on full information of the
|
|
|
|
* available instance times.
|
|
|
|
*
|
|
|
|
* @param aContainerTime The container time at which to sample.
|
|
|
|
*/
|
2019-01-25 06:24:01 +03:00
|
|
|
void SampleEndAt(SMILTime aContainerTime);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
/**
|
2010-01-12 23:00:49 +03:00
|
|
|
* Informs the timed element that its time container has changed time
|
|
|
|
* relative to document time. The timed element therefore needs to update its
|
|
|
|
* dependent elements (which may belong to a different time container) so they
|
|
|
|
* can re-resolve their times.
|
2009-01-15 07:38:07 +03:00
|
|
|
*/
|
2010-01-12 23:00:49 +03:00
|
|
|
void HandleContainerTimeChange();
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-07-03 09:52:51 +04:00
|
|
|
/**
|
|
|
|
* Resets this timed element's accumulated times and intervals back to start
|
|
|
|
* up state.
|
|
|
|
*
|
|
|
|
* This is used for backwards seeking where rather than accumulating
|
|
|
|
* historical timing state and winding it back, we reset the element and seek
|
|
|
|
* forwards.
|
|
|
|
*/
|
|
|
|
void Rewind();
|
|
|
|
|
2014-05-28 09:13:31 +04:00
|
|
|
/**
|
|
|
|
* Marks this element as disabled or not. If the element is disabled, it
|
|
|
|
* will ignore any future samples and discard any accumulated timing state.
|
|
|
|
*
|
|
|
|
* This is used by SVG to "turn off" timed elements when the associated
|
|
|
|
* animation element has failing conditional processing tests.
|
|
|
|
*
|
|
|
|
* Returns true if the disabled state of the timed element was changed
|
|
|
|
* as a result of this call (i.e. it was not a redundant call).
|
|
|
|
*/
|
|
|
|
bool SetIsDisabled(bool aIsDisabled);
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
/**
|
|
|
|
* Attempts to set an attribute on this timed element.
|
|
|
|
*
|
|
|
|
* @param aAttribute The name of the attribute to set. The namespace of this
|
|
|
|
* attribute is not specified as it is checked by the host
|
|
|
|
* element. Only attributes in the namespace defined for
|
|
|
|
* SMIL attributes in the host language are passed to the
|
|
|
|
* timed element.
|
|
|
|
* @param aValue The attribute value.
|
|
|
|
* @param aResult The nsAttrValue object that may be used for storing the
|
|
|
|
* parsed result.
|
2018-08-28 12:06:08 +03:00
|
|
|
* @param aContextElement The element to use for context when resolving
|
|
|
|
* references to other elements.
|
2009-01-15 07:38:07 +03:00
|
|
|
* @param[out] aParseResult The result of parsing the attribute. Will be set
|
|
|
|
* to NS_OK if parsing is successful.
|
|
|
|
*
|
2011-10-17 18:59:28 +04:00
|
|
|
* @return true if the given attribute is a timing attribute, false
|
2009-01-15 07:38:07 +03:00
|
|
|
* otherwise.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
bool SetAttr(nsAtom* aAttribute, const nsAString& aValue,
|
2018-08-28 12:06:08 +03:00
|
|
|
nsAttrValue& aResult, Element& aContextElement,
|
|
|
|
nsresult* aParseResult = nullptr);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to unset an attribute on this timed element.
|
|
|
|
*
|
|
|
|
* @param aAttribute The name of the attribute to set. As with SetAttr the
|
|
|
|
* namespace of the attribute is not specified (see
|
|
|
|
* SetAttr).
|
|
|
|
*
|
2011-10-17 18:59:28 +04:00
|
|
|
* @return true if the given attribute is a timing attribute, false
|
2009-01-15 07:38:07 +03:00
|
|
|
* otherwise.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
bool UnsetAttr(nsAtom* aAttribute);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-01-12 23:00:49 +03:00
|
|
|
/**
|
2010-01-12 23:00:49 +03:00
|
|
|
* Adds a syncbase dependency to the list of dependents that will be notified
|
|
|
|
* when this timed element creates, deletes, or updates its current interval.
|
|
|
|
*
|
2019-01-22 10:28:40 +03:00
|
|
|
* @param aDependent The SMILTimeValueSpec object to notify. A raw pointer
|
2010-01-12 23:00:49 +03:00
|
|
|
* to this object will be stored. Therefore it is necessary
|
|
|
|
* for the object to be explicitly unregistered (with
|
|
|
|
* RemoveDependent) when it is destroyed.
|
2010-01-12 23:00:49 +03:00
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
void AddDependent(SMILTimeValueSpec& aDependent);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a syncbase dependency from the list of dependents that are notified
|
|
|
|
* when the current interval is modified.
|
|
|
|
*
|
2019-01-22 10:28:40 +03:00
|
|
|
* @param aDependent The SMILTimeValueSpec object to unregister.
|
2010-01-12 23:00:49 +03:00
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
void RemoveDependent(SMILTimeValueSpec& aDependent);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if this timed element is dependent on the given timed element's
|
|
|
|
* begin time for the interval currently in effect. Whilst the element is in
|
|
|
|
* the active state this is the current interval and in the postactive or
|
|
|
|
* waiting state this is the previous interval if one exists. In all other
|
|
|
|
* cases the element is not considered a time dependent of any other element.
|
|
|
|
*
|
|
|
|
* @param aOther The potential syncbase element.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @return true if this timed element's begin time for the currently
|
|
|
|
* effective interval is directly or indirectly derived from aOther, false
|
2010-01-12 23:00:49 +03:00
|
|
|
* otherwise.
|
|
|
|
*/
|
2019-01-01 12:16:21 +03:00
|
|
|
bool IsTimeDependent(const SMILTimedElement& aOther) const;
|
2010-01-12 23:00:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the timed element has been bound to the document so that
|
|
|
|
* references from this timed element to other elements can be resolved.
|
|
|
|
*
|
2018-08-28 12:06:08 +03:00
|
|
|
* @param aContextElement The element which provides the necessary context for
|
|
|
|
* resolving references. This is typically the element
|
|
|
|
* in the host language that owns this timed element.
|
2010-01-12 23:00:49 +03:00
|
|
|
*/
|
2018-08-28 12:06:08 +03:00
|
|
|
void BindToTree(Element& aContextElement);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
2010-08-18 14:20:24 +04:00
|
|
|
/**
|
|
|
|
* Called when the target of the animation has changed so that event
|
|
|
|
* registrations can be updated.
|
|
|
|
*/
|
2018-08-28 12:06:08 +03:00
|
|
|
void HandleTargetElementChange(Element* aNewTarget);
|
2010-08-18 14:20:24 +04:00
|
|
|
|
2010-01-12 23:00:49 +03:00
|
|
|
/**
|
|
|
|
* Called when the timed element has been removed from a document so that
|
|
|
|
* references to other elements can be broken.
|
|
|
|
*/
|
|
|
|
void DissolveReferences() { Unlink(); }
|
|
|
|
|
|
|
|
// Cycle collection
|
|
|
|
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
|
|
|
|
void Unlink();
|
2010-01-12 23:00:49 +03:00
|
|
|
|
2019-01-22 10:28:40 +03:00
|
|
|
typedef bool (*RemovalTestFunction)(SMILInstanceTime* aInstance);
|
2010-08-18 14:20:24 +04:00
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
protected:
|
2010-01-12 23:00:49 +03:00
|
|
|
// Typedefs
|
2019-01-22 10:28:40 +03:00
|
|
|
typedef nsTArray<UniquePtr<SMILTimeValueSpec>> TimeValueSpecList;
|
|
|
|
typedef nsTArray<RefPtr<SMILInstanceTime>> InstanceTimeList;
|
2019-01-21 16:08:12 +03:00
|
|
|
typedef nsTArray<UniquePtr<SMILInterval>> IntervalList;
|
2019-01-22 10:28:40 +03:00
|
|
|
typedef nsPtrHashKey<SMILTimeValueSpec> TimeValueSpecPtrKey;
|
2010-01-12 23:00:49 +03:00
|
|
|
typedef nsTHashtable<TimeValueSpecPtrKey> TimeValueSpecHashSet;
|
2010-01-12 23:00:49 +03:00
|
|
|
|
|
|
|
// Helper classes
|
|
|
|
class InstanceTimeComparator {
|
|
|
|
public:
|
2019-01-22 10:28:40 +03:00
|
|
|
bool Equals(const SMILInstanceTime* aElem1,
|
|
|
|
const SMILInstanceTime* aElem2) const;
|
|
|
|
bool LessThan(const SMILInstanceTime* aElem1,
|
|
|
|
const SMILInstanceTime* aElem2) const;
|
2010-01-12 23:00:49 +03:00
|
|
|
};
|
|
|
|
|
2010-07-03 09:52:50 +04:00
|
|
|
// Templated helper functions
|
|
|
|
template <class TestFunctor>
|
|
|
|
void RemoveInstanceTimes(InstanceTimeList& aArray, TestFunctor& aTest);
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
//
|
|
|
|
// Implementation helpers
|
|
|
|
//
|
|
|
|
|
2010-01-12 23:00:49 +03:00
|
|
|
nsresult SetBeginSpec(const nsAString& aBeginSpec, Element& aContextElement,
|
2010-08-18 14:20:24 +04:00
|
|
|
RemovalTestFunction aRemove);
|
2010-01-12 23:00:49 +03:00
|
|
|
nsresult SetEndSpec(const nsAString& aEndSpec, Element& aContextElement,
|
2010-08-18 14:20:24 +04:00
|
|
|
RemovalTestFunction aRemove);
|
2009-01-15 07:38:07 +03:00
|
|
|
nsresult SetSimpleDuration(const nsAString& aDurSpec);
|
|
|
|
nsresult SetMin(const nsAString& aMinSpec);
|
|
|
|
nsresult SetMax(const nsAString& aMaxSpec);
|
|
|
|
nsresult SetRestart(const nsAString& aRestartSpec);
|
|
|
|
nsresult SetRepeatCount(const nsAString& aRepeatCountSpec);
|
|
|
|
nsresult SetRepeatDur(const nsAString& aRepeatDurSpec);
|
|
|
|
nsresult SetFillMode(const nsAString& aFillModeSpec);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-08-18 14:20:24 +04:00
|
|
|
void UnsetBeginSpec(RemovalTestFunction aRemove);
|
|
|
|
void UnsetEndSpec(RemovalTestFunction aRemove);
|
2009-01-15 07:38:07 +03:00
|
|
|
void UnsetSimpleDuration();
|
|
|
|
void UnsetMin();
|
|
|
|
void UnsetMax();
|
|
|
|
void UnsetRestart();
|
|
|
|
void UnsetRepeatCount();
|
|
|
|
void UnsetRepeatDur();
|
|
|
|
void UnsetFillMode();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-01-12 23:00:49 +03:00
|
|
|
nsresult SetBeginOrEndSpec(const nsAString& aSpec, Element& aContextElement,
|
2010-08-18 14:20:24 +04:00
|
|
|
bool aIsBegin, RemovalTestFunction aRemove);
|
|
|
|
void ClearSpecs(TimeValueSpecList& aSpecs, InstanceTimeList& aInstances,
|
|
|
|
RemovalTestFunction aRemove);
|
2011-07-25 21:45:49 +04:00
|
|
|
void ClearIntervals();
|
2019-01-25 06:24:01 +03:00
|
|
|
void DoSampleAt(SMILTime aContainerTime, bool aEndOnly);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-07-03 09:52:50 +04:00
|
|
|
/**
|
|
|
|
* Helper function to check for an early end and, if necessary, update the
|
|
|
|
* current interval accordingly.
|
|
|
|
*
|
|
|
|
* See SMIL 3.0, section 5.4.5, Element life cycle, "Active Time - Playing an
|
|
|
|
* interval" for a description of ending early.
|
|
|
|
*
|
|
|
|
* @param aSampleTime The current sample time. Early ends should only be
|
|
|
|
* applied at the last possible moment (i.e. if they are at
|
|
|
|
* or before the current sample time) and only if the
|
|
|
|
* current interval is not already ending.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @return true if the end time of the current interval was updated,
|
|
|
|
* false otherwise.
|
2010-07-03 09:52:50 +04:00
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
bool ApplyEarlyEnd(const SMILTimeValue& aSampleTime);
|
2010-07-03 09:52:50 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears certain state in response to the element restarting.
|
|
|
|
*
|
|
|
|
* This state is described in SMIL 3.0, section 5.4.3, Resetting element state
|
|
|
|
*/
|
|
|
|
void Reset();
|
|
|
|
|
2014-05-28 09:13:31 +04:00
|
|
|
/**
|
|
|
|
* Clears all accumulated timing state except for those instance times for
|
|
|
|
* which aRemove does not return true.
|
|
|
|
*
|
|
|
|
* Unlike the Reset method which only clears instance times, this clears the
|
|
|
|
* element's state, intervals (including current interval), and tells the
|
|
|
|
* client animation function to stop applying a result. In effect, it returns
|
|
|
|
* the element to its initial state but preserves any instance times excluded
|
|
|
|
* by the passed-in function.
|
|
|
|
*/
|
|
|
|
void ClearTimingState(RemovalTestFunction aRemove);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recreates timing state by re-applying begin/end attributes specified on
|
|
|
|
* the associated animation element.
|
|
|
|
*
|
|
|
|
* Note that this does not completely restore the information cleared by
|
|
|
|
* ClearTimingState since it leaves the element in the startup state.
|
|
|
|
* The element state will be updated on the next sample.
|
|
|
|
*/
|
|
|
|
void RebuildTimingState(RemovalTestFunction aRemove);
|
|
|
|
|
2010-07-03 09:52:51 +04:00
|
|
|
/**
|
|
|
|
* Completes a seek operation by sending appropriate events and, in the case
|
|
|
|
* of a backwards seek, updating the state of timing information that was
|
|
|
|
* previously considered historical.
|
|
|
|
*/
|
|
|
|
void DoPostSeek();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unmarks instance times that were previously preserved because they were
|
|
|
|
* considered important historical milestones but are no longer such because
|
|
|
|
* a backwards seek has been performed.
|
|
|
|
*/
|
|
|
|
void UnpreserveInstanceTimes(InstanceTimeList& aList);
|
|
|
|
|
2010-07-03 09:52:50 +04:00
|
|
|
/**
|
|
|
|
* Helper function to iterate through this element's accumulated timing
|
2019-01-25 06:24:01 +03:00
|
|
|
* information (specifically old SMILIntervals and SMILTimeInstanceTimes)
|
2010-07-03 09:52:50 +04:00
|
|
|
* and discard items that are no longer needed or exceed some threshold of
|
|
|
|
* accumulated state.
|
|
|
|
*/
|
|
|
|
void FilterHistory();
|
|
|
|
|
2019-01-21 16:08:12 +03:00
|
|
|
// Helper functions for FilterHistory to clear old SMILIntervals and
|
2019-01-22 10:28:40 +03:00
|
|
|
// SMILInstanceTimes respectively.
|
2010-07-03 09:52:50 +04:00
|
|
|
void FilterIntervals();
|
|
|
|
void FilterInstanceTimes(InstanceTimeList& aList);
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
/**
|
2010-01-12 23:00:49 +03:00
|
|
|
* Calculates the next acceptable interval for this element after the
|
|
|
|
* specified interval, or, if no previous interval is specified, it will be
|
|
|
|
* the first interval with an end time after t=0.
|
2009-01-15 07:38:07 +03:00
|
|
|
*
|
|
|
|
* @see SMILANIM 3.6.8
|
2010-01-12 23:00:49 +03:00
|
|
|
*
|
|
|
|
* @param aPrevInterval The previous interval used. If supplied, the first
|
|
|
|
* interval that begins after aPrevInterval will be
|
2012-07-30 18:20:58 +04:00
|
|
|
* returned. May be nullptr.
|
2011-06-22 05:12:35 +04:00
|
|
|
* @param aReplacedInterval The interval that is being updated (if any). This
|
|
|
|
* used to ensure we don't return interval endpoints
|
2012-07-30 18:20:58 +04:00
|
|
|
* that are dependent on themselves. May be nullptr.
|
2010-01-12 23:00:49 +03:00
|
|
|
* @param aFixedBeginTime The time to use for the start of the interval. This
|
|
|
|
* is used when only the endpoint of the interval
|
|
|
|
* should be updated such as when the animation is in
|
2012-07-30 18:20:58 +04:00
|
|
|
* the ACTIVE state. May be nullptr.
|
2010-01-12 23:00:49 +03:00
|
|
|
* @param[out] aResult The next interval. Will be unchanged if no suitable
|
2011-10-17 18:59:28 +04:00
|
|
|
* interval was found (in which case false will be
|
2011-03-28 03:10:33 +04:00
|
|
|
* returned).
|
2011-10-17 18:59:28 +04:00
|
|
|
* @return true if a suitable interval was found, false otherwise.
|
2009-01-15 07:38:07 +03:00
|
|
|
*/
|
2019-01-21 16:08:12 +03:00
|
|
|
bool GetNextInterval(const SMILInterval* aPrevInterval,
|
|
|
|
const SMILInterval* aReplacedInterval,
|
2019-01-22 10:28:40 +03:00
|
|
|
const SMILInstanceTime* aFixedBeginTime,
|
2019-01-21 16:08:12 +03:00
|
|
|
SMILInterval& aResult) const;
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILInstanceTime* GetNextGreater(const InstanceTimeList& aList,
|
|
|
|
const SMILTimeValue& aBase,
|
|
|
|
int32_t& aPosition) const;
|
|
|
|
SMILInstanceTime* GetNextGreaterOrEqual(const InstanceTimeList& aList,
|
|
|
|
const SMILTimeValue& aBase,
|
|
|
|
int32_t& aPosition) const;
|
|
|
|
SMILTimeValue CalcActiveEnd(const SMILTimeValue& aBegin,
|
|
|
|
const SMILTimeValue& aEnd) const;
|
|
|
|
SMILTimeValue GetRepeatDuration() const;
|
|
|
|
SMILTimeValue ApplyMinAndMax(const SMILTimeValue& aDuration) const;
|
2019-01-25 06:24:01 +03:00
|
|
|
SMILTime ActiveTimeToSimpleTime(SMILTime aActiveTime,
|
|
|
|
uint32_t& aRepeatIteration);
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILInstanceTime* CheckForEarlyEnd(const SMILTimeValue& aContainerTime) const;
|
2011-09-29 10:19:26 +04:00
|
|
|
void UpdateCurrentInterval(bool aForceChangeNotice = false);
|
2019-01-25 06:24:01 +03:00
|
|
|
void SampleSimpleTime(SMILTime aActiveTime);
|
2009-01-15 07:38:07 +03:00
|
|
|
void SampleFillValue();
|
2019-01-25 06:24:01 +03:00
|
|
|
nsresult AddInstanceTimeFromCurrentTime(SMILTime aCurrentTime,
|
2011-09-29 10:19:26 +04:00
|
|
|
double aOffsetSeconds, bool aIsBegin);
|
2010-01-12 23:00:49 +03:00
|
|
|
void RegisterMilestone();
|
2019-01-02 10:21:13 +03:00
|
|
|
bool GetNextMilestone(SMILMilestone& aNextMilestone) const;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2011-06-15 04:16:57 +04:00
|
|
|
// Notification methods. Note that these notifications can result in nested
|
|
|
|
// calls to this same object. Therefore,
|
|
|
|
// (i) we should not perform notification until this object is in
|
|
|
|
// a consistent state to receive callbacks, and
|
|
|
|
// (ii) after calling these methods we must assume that the state of the
|
|
|
|
// element may have changed.
|
2010-01-12 23:00:49 +03:00
|
|
|
void NotifyNewInterval();
|
2019-01-21 16:08:12 +03:00
|
|
|
void NotifyChangedInterval(SMILInterval* aInterval, bool aBeginObjectChanged,
|
|
|
|
bool aEndObjectChanged);
|
2011-06-15 04:16:57 +04:00
|
|
|
|
2019-01-01 12:16:21 +03:00
|
|
|
void FireTimeEventAsync(EventMessage aMsg, int32_t aDetail);
|
2019-01-22 10:28:40 +03:00
|
|
|
const SMILInstanceTime* GetEffectiveBeginInstance() const;
|
2019-01-21 16:08:12 +03:00
|
|
|
const SMILInterval* GetPreviousInterval() const;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasPlayed() const { return !mOldIntervals.IsEmpty(); }
|
2013-12-13 08:41:52 +04:00
|
|
|
bool HasClientInFillRange() const;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool EndHasEventConditions() const;
|
2019-01-22 10:28:40 +03:00
|
|
|
bool AreEndTimesDependentOn(const SMILInstanceTime* aBase) const;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-10-13 04:20:12 +04:00
|
|
|
// Reset the current interval by first passing ownership to a temporary
|
|
|
|
// variable so that if Unlink() results in us receiving a callback,
|
2012-07-30 18:20:58 +04:00
|
|
|
// mCurrentInterval will be nullptr and we will be in a consistent state.
|
2010-10-13 04:20:12 +04:00
|
|
|
void ResetCurrentInterval() {
|
|
|
|
if (mCurrentInterval) {
|
|
|
|
// Transfer ownership to temp var. (This sets mCurrentInterval to null.)
|
2018-05-30 22:15:35 +03:00
|
|
|
auto interval = std::move(mCurrentInterval);
|
2010-10-13 04:20:12 +04:00
|
|
|
interval->Unlink();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
//
|
|
|
|
// Members
|
|
|
|
//
|
2013-03-19 07:18:45 +04:00
|
|
|
mozilla::dom::SVGAnimationElement* mAnimationElement; // [weak] won't outlive
|
|
|
|
// owner
|
2010-01-12 23:00:49 +03:00
|
|
|
TimeValueSpecList mBeginSpecs; // [strong]
|
|
|
|
TimeValueSpecList mEndSpecs; // [strong]
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILTimeValue mSimpleDur;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-21 16:08:12 +03:00
|
|
|
SMILRepeatCount mRepeatCount;
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILTimeValue mRepeatDur;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILTimeValue mMin;
|
|
|
|
SMILTimeValue mMax;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
enum SMILFillMode : uint8_t { FILL_REMOVE, FILL_FREEZE };
|
|
|
|
SMILFillMode mFillMode;
|
2017-07-01 12:55:27 +03:00
|
|
|
static const nsAttrValue::EnumTable sFillModeTable[];
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
enum SMILRestartMode : uint8_t {
|
2009-01-15 07:38:07 +03:00
|
|
|
RESTART_ALWAYS,
|
|
|
|
RESTART_WHENNOTACTIVE,
|
|
|
|
RESTART_NEVER
|
|
|
|
};
|
2019-01-25 06:24:01 +03:00
|
|
|
SMILRestartMode mRestartMode;
|
2017-07-01 12:55:27 +03:00
|
|
|
static const nsAttrValue::EnumTable sRestartModeTable[];
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-01-12 23:00:49 +03:00
|
|
|
InstanceTimeList mBeginInstances;
|
|
|
|
InstanceTimeList mEndInstances;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mInstanceSerialIndex;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2018-12-31 14:54:22 +03:00
|
|
|
SMILAnimationFunction* mClient;
|
2019-01-21 16:08:12 +03:00
|
|
|
UniquePtr<SMILInterval> mCurrentInterval;
|
2010-03-01 22:31:50 +03:00
|
|
|
IntervalList mOldIntervals;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mCurrentRepeatIteration;
|
2019-01-02 10:21:13 +03:00
|
|
|
SMILMilestone mPrevRegisteredMilestone;
|
|
|
|
static const SMILMilestone sMaxMilestone;
|
2012-08-22 19:56:38 +04:00
|
|
|
static const uint8_t sMaxNumIntervals;
|
|
|
|
static const uint8_t sMaxNumInstanceTimes;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-05-21 04:18:29 +04:00
|
|
|
// Set of dependent time value specs to be notified when establishing a new
|
|
|
|
// current interval. Change notifications and delete notifications are handled
|
|
|
|
// by the interval.
|
2010-01-12 23:00:49 +03:00
|
|
|
//
|
2019-01-22 10:28:40 +03:00
|
|
|
// [weak] The SMILTimeValueSpec objects register themselves and unregister
|
2010-01-12 23:00:49 +03:00
|
|
|
// on destruction. Likewise, we notify them when we are destroyed.
|
2010-01-12 23:00:49 +03:00
|
|
|
TimeValueSpecHashSet mTimeDependents;
|
2010-01-12 23:00:49 +03:00
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
/**
|
|
|
|
* The state of the element in its life-cycle. These states are based on the
|
|
|
|
* element life-cycle described in SMILANIM 3.6.8
|
|
|
|
*/
|
2019-01-25 06:24:01 +03:00
|
|
|
enum SMILElementState {
|
2009-01-15 07:38:07 +03:00
|
|
|
STATE_STARTUP,
|
|
|
|
STATE_WAITING,
|
|
|
|
STATE_ACTIVE,
|
|
|
|
STATE_POSTACTIVE
|
|
|
|
};
|
2019-01-25 06:24:01 +03:00
|
|
|
SMILElementState mElementState;
|
2010-07-03 09:52:51 +04:00
|
|
|
|
2019-01-25 06:24:01 +03:00
|
|
|
enum SMILSeekState {
|
2010-07-03 09:52:51 +04:00
|
|
|
SEEK_NOT_SEEKING,
|
|
|
|
SEEK_FORWARD_FROM_ACTIVE,
|
|
|
|
SEEK_FORWARD_FROM_INACTIVE,
|
|
|
|
SEEK_BACKWARD_FROM_ACTIVE,
|
|
|
|
SEEK_BACKWARD_FROM_INACTIVE
|
|
|
|
};
|
2019-01-25 06:24:01 +03:00
|
|
|
SMILSeekState mSeekState;
|
2011-07-02 07:37:10 +04:00
|
|
|
|
|
|
|
// Used to batch updates to the timing model
|
|
|
|
class AutoIntervalUpdateBatcher;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDeferIntervalUpdates;
|
2012-02-02 03:58:58 +04:00
|
|
|
bool mDoDeferredUpdate; // Set if an update to the current interval was
|
|
|
|
// requested while mDeferIntervalUpdates was set
|
2014-05-28 09:13:31 +04:00
|
|
|
bool mIsDisabled;
|
2011-07-02 07:37:47 +04:00
|
|
|
|
2013-12-13 08:41:56 +04:00
|
|
|
// Stack-based helper class to call UpdateCurrentInterval when it is destroyed
|
|
|
|
class AutoIntervalUpdater;
|
|
|
|
|
2011-07-02 07:37:47 +04:00
|
|
|
// Recursion depth checking
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mDeleteCount;
|
|
|
|
uint8_t mUpdateIntervalRecursionDepth;
|
|
|
|
static const uint8_t sMaxUpdateIntervalRecursionDepth;
|
2009-01-15 07:38:07 +03:00
|
|
|
};
|
|
|
|
|
2019-01-01 12:16:21 +03:00
|
|
|
inline void ImplCycleCollectionUnlink(SMILTimedElement& aField) {
|
2014-09-10 14:18:58 +04:00
|
|
|
aField.Unlink();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void ImplCycleCollectionTraverse(
|
2019-01-01 12:16:21 +03:00
|
|
|
nsCycleCollectionTraversalCallback& aCallback, SMILTimedElement& aField,
|
2014-09-10 14:18:58 +04:00
|
|
|
const char* aName, uint32_t aFlags = 0) {
|
|
|
|
aField.Traverse(&aCallback);
|
|
|
|
}
|
|
|
|
|
2019-01-01 12:16:21 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
#endif // NS_SMILTIMEDELEMENT_H_
|