• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 Google Inc.  All rights reserved.
3  * Copyright (C) 2012, 2013 Apple Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *     * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef TextTrackCue_h
33 #define TextTrackCue_h
34 
35 #include "core/events/EventTarget.h"
36 #include "core/html/HTMLDivElement.h"
37 #include "platform/heap/Handle.h"
38 #include "wtf/RefCounted.h"
39 
40 namespace blink {
41 
42 class ExceptionState;
43 
44 class TextTrackCue : public RefCountedWillBeGarbageCollectedFinalized<TextTrackCue>, public EventTargetWithInlineData {
45     DEFINE_WRAPPERTYPEINFO();
46     REFCOUNTED_EVENT_TARGET(TextTrackCue);
47     WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TextTrackCue);
48 public:
cueShadowPseudoId()49     static const AtomicString& cueShadowPseudoId()
50     {
51         DEFINE_STATIC_LOCAL(const AtomicString, cue, ("cue", AtomicString::ConstructFromLiteral));
52         return cue;
53     }
54 
~TextTrackCue()55     virtual ~TextTrackCue() { }
56 
57     TextTrack* track() const;
58     void setTrack(TextTrack*);
59 
60     Node* owner() const;
61 
id()62     const AtomicString& id() const { return m_id; }
63     void setId(const AtomicString&);
64 
startTime()65     double startTime() const { return m_startTime; }
66     void setStartTime(double);
67 
endTime()68     double endTime() const { return m_endTime; }
69     void setEndTime(double);
70 
pauseOnExit()71     bool pauseOnExit() const { return m_pauseOnExit; }
72     void setPauseOnExit(bool);
73 
74     int cueIndex();
75     void invalidateCueIndex();
76 
77     using EventTarget::dispatchEvent;
78     virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE;
79 
80     bool isActive();
81     void setIsActive(bool);
82 
83     virtual void updateDisplay(const IntSize& videoSize, HTMLDivElement& container) = 0;
84 
85     // FIXME: Consider refactoring to eliminate or merge the following three members.
86     // https://code.google.com/p/chromium/issues/detail?id=322434
87     virtual void updateDisplayTree(double movieTime) = 0;
88     virtual void removeDisplayTree() = 0;
89     virtual void notifyRegionWhenRemovingDisplayTree(bool notifyRegion) = 0;
90 
91     virtual const AtomicString& interfaceName() const OVERRIDE;
92 
93 #ifndef NDEBUG
94     virtual String toString() const = 0;
95 #endif
96 
97     DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
98     DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
99 
100     virtual void trace(Visitor*) OVERRIDE;
101 
102 protected:
103     TextTrackCue(double start, double end);
104 
105     void cueWillChange();
106     virtual void cueDidChange();
107 
108 private:
109     AtomicString m_id;
110     double m_startTime;
111     double m_endTime;
112     int m_cueIndex;
113 
114     RawPtrWillBeMember<TextTrack> m_track;
115 
116     bool m_isActive : 1;
117     bool m_pauseOnExit : 1;
118 };
119 
120 } // namespace blink
121 
122 #endif // TextTrackCue_h
123