1/* 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef HTMLTrackElement_h 27#define HTMLTrackElement_h 28 29#if ENABLE(VIDEO_TRACK) 30#include "HTMLElement.h" 31#include "LoadableTextTrack.h" 32#include "TextTrack.h" 33 34namespace WebCore { 35 36class HTMLMediaElement; 37 38class HTMLTrackElement FINAL : public HTMLElement, public TextTrackClient { 39public: 40 static PassRefPtr<HTMLTrackElement> create(const QualifiedName&, Document*); 41 42 KURL src() const; 43 void setSrc(const String&); 44 45 String kind(); 46 void setKind(const String&); 47 48 String srclang() const; 49 void setSrclang(const String&); 50 51 String label() const; 52 void setLabel(const String&); 53 54 bool isDefault() const; 55 void setIsDefault(bool); 56 57 enum ReadyState { NONE = 0, LOADING = 1, LOADED = 2, TRACK_ERROR = 3 }; 58 ReadyState readyState(); 59 void setReadyState(ReadyState); 60 61 TextTrack* track(); 62 63 void scheduleLoad(); 64 65 enum LoadStatus { Failure, Success }; 66 virtual void didCompleteLoad(LoadableTextTrack*, LoadStatus); 67 68 const AtomicString& mediaElementCrossOriginAttribute() const; 69 70private: 71 HTMLTrackElement(const QualifiedName&, Document*); 72 virtual ~HTMLTrackElement(); 73 74 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 75 76 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 77 78 virtual void removedFrom(ContainerNode*) OVERRIDE; 79 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 80 81 void loadTimerFired(Timer<HTMLTrackElement>*); 82 83#if ENABLE(MICRODATA) 84 virtual String itemValueText() const OVERRIDE; 85 virtual void setItemValueText(const String&, ExceptionCode&) OVERRIDE; 86#endif 87 88 HTMLMediaElement* mediaElement() const; 89 90 // TextTrackClient 91 virtual void textTrackModeChanged(TextTrack*); 92 virtual void textTrackKindChanged(TextTrack*); 93 virtual void textTrackAddCues(TextTrack*, const TextTrackCueList*); 94 virtual void textTrackRemoveCues(TextTrack*, const TextTrackCueList*); 95 virtual void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>); 96 virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>); 97 98 LoadableTextTrack* ensureTrack(); 99 virtual bool canLoadUrl(const KURL&); 100 101 RefPtr<LoadableTextTrack> m_track; 102 Timer<HTMLTrackElement> m_loadTimer; 103}; 104 105} 106 107#endif 108#endif 109