2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef HTMLTrackElement_h
27 #define HTMLTrackElement_h
29 #if ENABLE(VIDEO_TRACK)
31 #include "HTMLElement.h"
32 #include "LoadableTextTrack.h"
36 class HTMLMediaElement;
38 class HTMLTrackElement : public HTMLElement, public TextTrackClient {
40 static PassRefPtr<HTMLTrackElement> create(const QualifiedName&, Document*);
43 void setSrc(const String&);
46 void setKind(const String&);
48 String srclang() const;
49 void setSrclang(const String&);
52 void setLabel(const String&);
54 bool isDefault() const;
55 void setIsDefault(bool);
57 enum ReadyState { NONE = 0, LOADING = 1, LOADED = 2, TRACK_ERROR = 3 };
58 ReadyState readyState() const { return m_readyState; }
63 virtual bool canLoadUrl(LoadableTextTrack*, const KURL&);
64 virtual void didCompleteLoad(LoadableTextTrack*, bool /* loadingFailed */);
66 void setReadyState(ReadyState);
69 HTMLTrackElement(const QualifiedName&, Document*);
70 virtual ~HTMLTrackElement();
72 virtual void parseMappedAttribute(Attribute*);
73 virtual void attributeChanged(Attribute*, bool preserveDecls);
75 virtual void insertedIntoTree(bool);
76 virtual void willRemove();
77 virtual bool isURLAttribute(Attribute*) const;
80 virtual String itemValueText() const OVERRIDE;
81 virtual void setItemValueText(const String&, ExceptionCode&) OVERRIDE;
84 HTMLMediaElement* mediaElement() const;
87 virtual void textTrackModeChanged(TextTrack*);
88 virtual void textTrackKindChanged(TextTrack*);
89 virtual void textTrackAddCues(TextTrack*, const TextTrackCueList*);
90 virtual void textTrackRemoveCues(TextTrack*, const TextTrackCueList*);
91 virtual void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>);
92 virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>);
94 LoadableTextTrack* ensureTrack();
96 HTMLTrackElement::ReadyState m_readyState;
97 RefPtr<LoadableTextTrack> m_track;