dom/smil/nsSMILTimeValueSpec.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef NS_SMILTIMEVALUESPEC_H_
michael@0 7 #define NS_SMILTIMEVALUESPEC_H_
michael@0 8
michael@0 9 #include "mozilla/Attributes.h"
michael@0 10 #include "nsSMILTimeValueSpecParams.h"
michael@0 11 #include "nsReferencedElement.h"
michael@0 12 #include "nsAutoPtr.h"
michael@0 13 #include "nsIDOMEventListener.h"
michael@0 14
michael@0 15 class nsAString;
michael@0 16 class nsSMILTimeValue;
michael@0 17 class nsSMILTimedElement;
michael@0 18 class nsSMILTimeContainer;
michael@0 19 class nsSMILInstanceTime;
michael@0 20 class nsSMILInterval;
michael@0 21
michael@0 22 namespace mozilla {
michael@0 23 class EventListenerManager;
michael@0 24 } // namespace mozilla
michael@0 25
michael@0 26 //----------------------------------------------------------------------
michael@0 27 // nsSMILTimeValueSpec class
michael@0 28 //
michael@0 29 // An individual element of a 'begin' or 'end' attribute, e.g. '5s', 'a.end'.
michael@0 30 // This class handles the parsing of such specifications and performs the
michael@0 31 // necessary event handling (for event, repeat, and accesskey specifications)
michael@0 32 // and synchronisation (for syncbase specifications).
michael@0 33 //
michael@0 34 // For an overview of how this class is related to other SMIL time classes see
michael@0 35 // the documentation in nsSMILTimeValue.h
michael@0 36
michael@0 37 class nsSMILTimeValueSpec
michael@0 38 {
michael@0 39 public:
michael@0 40 typedef mozilla::dom::Element Element;
michael@0 41
michael@0 42 nsSMILTimeValueSpec(nsSMILTimedElement& aOwner, bool aIsBegin);
michael@0 43 ~nsSMILTimeValueSpec();
michael@0 44
michael@0 45 nsresult SetSpec(const nsAString& aStringSpec, Element* aContextNode);
michael@0 46 void ResolveReferences(nsIContent* aContextNode);
michael@0 47 bool IsEventBased() const;
michael@0 48
michael@0 49 void HandleNewInterval(nsSMILInterval& aInterval,
michael@0 50 const nsSMILTimeContainer* aSrcContainer);
michael@0 51 void HandleTargetElementChange(Element* aNewTarget);
michael@0 52
michael@0 53 // For created nsSMILInstanceTime objects
michael@0 54 bool DependsOnBegin() const;
michael@0 55 void HandleChangedInstanceTime(const nsSMILInstanceTime& aBaseTime,
michael@0 56 const nsSMILTimeContainer* aSrcContainer,
michael@0 57 nsSMILInstanceTime& aInstanceTimeToUpdate,
michael@0 58 bool aObjectChanged);
michael@0 59 void HandleDeletedInstanceTime(nsSMILInstanceTime& aInstanceTime);
michael@0 60
michael@0 61 // Cycle-collection support
michael@0 62 void Traverse(nsCycleCollectionTraversalCallback* aCallback);
michael@0 63 void Unlink();
michael@0 64
michael@0 65 protected:
michael@0 66 void UpdateReferencedElement(Element* aFrom, Element* aTo);
michael@0 67 void UnregisterFromReferencedElement(Element* aElement);
michael@0 68 nsSMILTimedElement* GetTimedElement(Element* aElement);
michael@0 69 bool IsWhitelistedEvent();
michael@0 70 void RegisterEventListener(Element* aElement);
michael@0 71 void UnregisterEventListener(Element* aElement);
michael@0 72 mozilla::EventListenerManager* GetEventListenerManager(Element* aElement);
michael@0 73 void HandleEvent(nsIDOMEvent* aEvent);
michael@0 74 bool CheckEventDetail(nsIDOMEvent* aEvent);
michael@0 75 bool CheckRepeatEventDetail(nsIDOMEvent* aEvent);
michael@0 76 bool CheckAccessKeyEventDetail(nsIDOMEvent* aEvent);
michael@0 77 nsSMILTimeValue ConvertBetweenTimeContainers(const nsSMILTimeValue& aSrcTime,
michael@0 78 const nsSMILTimeContainer* aSrcContainer);
michael@0 79 bool ApplyOffset(nsSMILTimeValue& aTime) const;
michael@0 80
michael@0 81 nsSMILTimedElement* mOwner;
michael@0 82 bool mIsBegin; // Indicates if *we* are a begin spec,
michael@0 83 // not to be confused with
michael@0 84 // mParams.mSyncBegin which indicates
michael@0 85 // if we're synced with the begin of
michael@0 86 // the target.
michael@0 87 nsSMILTimeValueSpecParams mParams;
michael@0 88
michael@0 89 class TimeReferenceElement : public nsReferencedElement
michael@0 90 {
michael@0 91 public:
michael@0 92 TimeReferenceElement(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) { }
michael@0 93 void ResetWithElement(Element* aTo) {
michael@0 94 nsRefPtr<Element> from = get();
michael@0 95 Unlink();
michael@0 96 ElementChanged(from, aTo);
michael@0 97 }
michael@0 98
michael@0 99 protected:
michael@0 100 virtual void ElementChanged(Element* aFrom, Element* aTo) MOZ_OVERRIDE
michael@0 101 {
michael@0 102 nsReferencedElement::ElementChanged(aFrom, aTo);
michael@0 103 mSpec->UpdateReferencedElement(aFrom, aTo);
michael@0 104 }
michael@0 105 virtual bool IsPersistent() MOZ_OVERRIDE { return true; }
michael@0 106 private:
michael@0 107 nsSMILTimeValueSpec* mSpec;
michael@0 108 };
michael@0 109
michael@0 110 TimeReferenceElement mReferencedElement;
michael@0 111
michael@0 112 class EventListener MOZ_FINAL : public nsIDOMEventListener
michael@0 113 {
michael@0 114 public:
michael@0 115 EventListener(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) { }
michael@0 116 void Disconnect()
michael@0 117 {
michael@0 118 mSpec = nullptr;
michael@0 119 }
michael@0 120
michael@0 121 NS_DECL_ISUPPORTS
michael@0 122 NS_DECL_NSIDOMEVENTLISTENER
michael@0 123
michael@0 124 private:
michael@0 125 nsSMILTimeValueSpec* mSpec;
michael@0 126 };
michael@0 127 nsRefPtr<EventListener> mEventListener;
michael@0 128 };
michael@0 129
michael@0 130 #endif // NS_SMILTIMEVALUESPEC_H_

mercurial