tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebCore / html / HTMLTrackElement.h
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
31 #include "HTMLElement.h"
32 #include "LoadableTextTrack.h"
33
34 namespace WebCore {
35
36 class HTMLMediaElement;
37
38 class HTMLTrackElement : public HTMLElement, public TextTrackClient {
39 public:
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() const { return m_readyState; }
59
60     TextTrack* track();
61     
62     void scheduleLoad();
63     virtual bool canLoadUrl(LoadableTextTrack*, const KURL&);
64     virtual void didCompleteLoad(LoadableTextTrack*, bool /* loadingFailed */);
65     
66     void setReadyState(ReadyState);
67
68 private:
69     HTMLTrackElement(const QualifiedName&, Document*);
70     virtual ~HTMLTrackElement();
71
72     virtual void parseMappedAttribute(Attribute*);
73     virtual void attributeChanged(Attribute*, bool preserveDecls);
74
75     virtual void insertedIntoTree(bool);
76     virtual void willRemove();
77     virtual bool isURLAttribute(Attribute*) const;
78
79 #if ENABLE(MICRODATA)
80     virtual String itemValueText() const OVERRIDE;
81     virtual void setItemValueText(const String&, ExceptionCode&) OVERRIDE;
82 #endif
83
84     HTMLMediaElement* mediaElement() const;
85
86     // TextTrackClient
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>);
93
94     LoadableTextTrack* ensureTrack();
95
96     HTMLTrackElement::ReadyState m_readyState;
97     RefPtr<LoadableTextTrack> m_track;
98 };
99
100 }
101
102 #endif
103 #endif