Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / track / TextTrackCue.h
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 RefCountedWillBeRefCountedGarbageCollected<TextTrackCue>, public EventTargetWithInlineData {
45     REFCOUNTED_EVENT_TARGET(TextTrackCue);
46     WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TextTrackCue);
47 public:
48     static const AtomicString& cueShadowPseudoId()
49     {
50         DEFINE_STATIC_LOCAL(const AtomicString, cue, ("cue", AtomicString::ConstructFromLiteral));
51         return cue;
52     }
53
54     virtual ~TextTrackCue() { }
55
56     TextTrack* track() const;
57     void setTrack(TextTrack*);
58
59     Node* owner() const;
60
61     const AtomicString& id() const { return m_id; }
62     void setId(const AtomicString&);
63
64     double startTime() const { return m_startTime; }
65     void setStartTime(double);
66
67     double endTime() const { return m_endTime; }
68     void setEndTime(double);
69
70     bool pauseOnExit() const { return m_pauseOnExit; }
71     void setPauseOnExit(bool);
72
73     int cueIndex();
74     void invalidateCueIndex();
75
76     using EventTarget::dispatchEvent;
77     virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE;
78
79     bool isActive();
80     void setIsActive(bool);
81
82     virtual void updateDisplay(const IntSize& videoSize, HTMLDivElement& container) = 0;
83
84     // FIXME: Consider refactoring to eliminate or merge the following three members.
85     // https://code.google.com/p/chromium/issues/detail?id=322434
86     virtual void updateDisplayTree(double movieTime) = 0;
87     virtual void removeDisplayTree() = 0;
88     virtual void notifyRegionWhenRemovingDisplayTree(bool notifyRegion) = 0;
89
90     virtual const AtomicString& interfaceName() const OVERRIDE;
91
92 #ifndef NDEBUG
93     virtual String toString() const = 0;
94 #endif
95
96     DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
97     DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
98
99     virtual void trace(Visitor*) OVERRIDE;
100
101 protected:
102     TextTrackCue(double start, double end);
103
104     void cueWillChange();
105     virtual void cueDidChange();
106
107 private:
108     AtomicString m_id;
109     double m_startTime;
110     double m_endTime;
111     int m_cueIndex;
112
113     RawPtrWillBeMember<TextTrack> m_track;
114
115     bool m_isActive : 1;
116     bool m_pauseOnExit : 1;
117 };
118
119 } // namespace blink
120
121 #endif