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 "wtf/RefCounted.h" 38 39 namespace WebCore { 40 41 class ExceptionState; 42 43 class TextTrackCue : public RefCounted<TextTrackCue>, public EventTargetWithInlineData { 44 REFCOUNTED_EVENT_TARGET(TextTrackCue); 45 public: 46 static bool isInfiniteOrNonNumber(double value, ExceptionState&); 47 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 const String& id() const { return m_id; } 60 void setId(const String&); 61 62 double startTime() const { return m_startTime; } 63 void setStartTime(double, ExceptionState&); 64 65 double endTime() const { return m_endTime; } 66 void setEndTime(double, ExceptionState&); 67 68 bool pauseOnExit() const { return m_pauseOnExit; } 69 void setPauseOnExit(bool); 70 71 int cueIndex(); 72 void invalidateCueIndex(); 73 74 using EventTarget::dispatchEvent; 75 virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE; 76 77 bool isActive(); 78 void setIsActive(bool); 79 80 virtual void updateDisplay(const IntSize& videoSize, HTMLDivElement& container) = 0; 81 82 // FIXME: Consider refactoring to eliminate or merge the following three members. 83 // https://code.google.com/p/chromium/issues/detail?id=322434 84 virtual void updateDisplayTree(double movieTime) = 0; 85 virtual void removeDisplayTree() = 0; 86 virtual void notifyRegionWhenRemovingDisplayTree(bool notifyRegion) = 0; 87 88 virtual const AtomicString& interfaceName() const OVERRIDE; 89 90 #ifndef NDEBUG 91 virtual String toString() const = 0; 92 #endif 93 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(enter); 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(exit); 96 97 protected: 98 TextTrackCue(double start, double end); 99 100 void cueWillChange(); 101 virtual void cueDidChange(); 102 103 private: 104 String m_id; 105 double m_startTime; 106 double m_endTime; 107 int m_cueIndex; 108 109 TextTrack* m_track; 110 111 bool m_isActive : 1; 112 bool m_pauseOnExit : 1; 113 }; 114 115 } // namespace WebCore 116 117 #endif 118