/work/obj-fuzz/dist/include/mozilla/dom/HTMLTrackElement.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_HTMLTrackElement_h |
8 | | #define mozilla_dom_HTMLTrackElement_h |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "mozilla/dom/HTMLMediaElement.h" |
12 | | #include "mozilla/dom/TextTrack.h" |
13 | | #include "nsCycleCollectionParticipant.h" |
14 | | #include "nsGenericHTMLElement.h" |
15 | | #include "nsGkAtoms.h" |
16 | | #include "nsIHttpChannel.h" |
17 | | |
18 | | class nsIContent; |
19 | | class nsIDocument; |
20 | | |
21 | | namespace mozilla { |
22 | | namespace dom { |
23 | | |
24 | | class WebVTTListener; |
25 | | class WindowDestroyObserver; |
26 | | |
27 | | class HTMLTrackElement final : public nsGenericHTMLElement |
28 | | { |
29 | | public: |
30 | | explicit HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); |
31 | | |
32 | | // nsISupports |
33 | | NS_DECL_ISUPPORTS_INHERITED |
34 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTrackElement, |
35 | | nsGenericHTMLElement) |
36 | | |
37 | | // HTMLTrackElement WebIDL |
38 | | void GetKind(DOMString& aKind) const; |
39 | | void SetKind(const nsAString& aKind, ErrorResult& aError) |
40 | 0 | { |
41 | 0 | SetHTMLAttr(nsGkAtoms::kind, aKind, aError); |
42 | 0 | } |
43 | | |
44 | | void GetSrc(DOMString& aSrc) const |
45 | 0 | { |
46 | 0 | GetHTMLURIAttr(nsGkAtoms::src, aSrc); |
47 | 0 | } |
48 | | |
49 | | void SetSrc(const nsAString& aSrc, ErrorResult& aError); |
50 | | |
51 | | void GetSrclang(DOMString& aSrclang) const |
52 | 0 | { |
53 | 0 | GetHTMLAttr(nsGkAtoms::srclang, aSrclang); |
54 | 0 | } |
55 | | void GetSrclang(nsAString& aSrclang) const |
56 | 0 | { |
57 | 0 | GetHTMLAttr(nsGkAtoms::srclang, aSrclang); |
58 | 0 | } |
59 | | void SetSrclang(const nsAString& aSrclang, ErrorResult& aError) |
60 | 0 | { |
61 | 0 | SetHTMLAttr(nsGkAtoms::srclang, aSrclang, aError); |
62 | 0 | } |
63 | | |
64 | | void GetLabel(DOMString& aLabel) const |
65 | 0 | { |
66 | 0 | GetHTMLAttr(nsGkAtoms::label, aLabel); |
67 | 0 | } |
68 | | void GetLabel(nsAString& aLabel) const |
69 | 0 | { |
70 | 0 | GetHTMLAttr(nsGkAtoms::label, aLabel); |
71 | 0 | } |
72 | | void SetLabel(const nsAString& aLabel, ErrorResult& aError) |
73 | 0 | { |
74 | 0 | SetHTMLAttr(nsGkAtoms::label, aLabel, aError); |
75 | 0 | } |
76 | | |
77 | | bool Default() const |
78 | 0 | { |
79 | 0 | return GetBoolAttr(nsGkAtoms::_default); |
80 | 0 | } |
81 | | void SetDefault(bool aDefault, ErrorResult& aError) |
82 | 0 | { |
83 | 0 | SetHTMLBoolAttr(nsGkAtoms::_default, aDefault, aError); |
84 | 0 | } |
85 | | |
86 | | uint16_t ReadyState() const; |
87 | | void SetReadyState(uint16_t aReadyState); |
88 | | |
89 | | TextTrack* GetTrack(); |
90 | | |
91 | | virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; |
92 | | |
93 | | // Override ParseAttribute() to convert kind strings to enum values. |
94 | | virtual bool ParseAttribute(int32_t aNamespaceID, |
95 | | nsAtom* aAttribute, |
96 | | const nsAString& aValue, |
97 | | nsIPrincipal* aMaybeScriptedPrincipal, |
98 | | nsAttrValue& aResult) override; |
99 | | |
100 | | // Override BindToTree() so that we can trigger a load when we become |
101 | | // the child of a media element. |
102 | | virtual nsresult BindToTree(nsIDocument* aDocument, |
103 | | nsIContent* aParent, |
104 | | nsIContent* aBindingParent) override; |
105 | | virtual void UnbindFromTree(bool aDeep, bool aNullParent) override; |
106 | | |
107 | | void DispatchTrackRunnable(const nsString& aEventName); |
108 | | void DispatchTrustedEvent(const nsAString& aName); |
109 | | |
110 | | void DropChannel(); |
111 | | |
112 | | void NotifyShutdown(); |
113 | | |
114 | | protected: |
115 | | virtual ~HTMLTrackElement(); |
116 | | |
117 | | virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
118 | | void OnChannelRedirect(nsIChannel* aChannel, nsIChannel* aNewChannel, |
119 | | uint32_t aFlags); |
120 | | // Open a new channel to the HTMLTrackElement's src attribute and call |
121 | | // mListener's LoadResource(). |
122 | | void LoadResource(); |
123 | | |
124 | | friend class TextTrackCue; |
125 | | friend class WebVTTListener; |
126 | | |
127 | | RefPtr<TextTrack> mTrack; |
128 | | nsCOMPtr<nsIChannel> mChannel; |
129 | | RefPtr<HTMLMediaElement> mMediaParent; |
130 | | RefPtr<WebVTTListener> mListener; |
131 | | |
132 | | void CreateTextTrack(); |
133 | | |
134 | | private: |
135 | | void DispatchLoadResource(); |
136 | | bool mLoadResourceDispatched; |
137 | | |
138 | | RefPtr<WindowDestroyObserver> mWindowDestroyObserver; |
139 | | }; |
140 | | |
141 | | } // namespace dom |
142 | | } // namespace mozilla |
143 | | |
144 | | #endif // mozilla_dom_HTMLTrackElement_h |