Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebKitLegacy / mac / DOM / DOMHTMLMediaElement.mm
1 /*
2  * Copyright (C) 2004-2016 Apple 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 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 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
27 #if ENABLE(VIDEO)
28
29 #import "DOMHTMLMediaElement.h"
30
31 #import "DOMMediaErrorInternal.h"
32 #import "DOMNodeInternal.h"
33 #import "DOMTimeRangesInternal.h"
34 #import "ExceptionHandlers.h"
35 #import <WebCore/HTMLMediaElement.h>
36 #import <WebCore/HTMLNames.h>
37 #import <WebCore/JSExecState.h>
38 #import <WebCore/MediaError.h>
39 #import <WebCore/ThreadCheck.h>
40 #import <WebCore/TimeRanges.h>
41 #import <WebCore/WebScriptObjectPrivate.h>
42 #import <wtf/GetPtr.h>
43 #import <wtf/URL.h>
44
45 #define IMPL static_cast<WebCore::HTMLMediaElement*>(reinterpret_cast<WebCore::Node*>(_internal))
46
47 @implementation DOMHTMLMediaElement
48
49 - (DOMMediaError *)error
50 {
51     WebCore::JSMainThreadNullState state;
52     return kit(WTF::getPtr(IMPL->error()));
53 }
54
55 - (NSString *)src
56 {
57     WebCore::JSMainThreadNullState state;
58     return IMPL->getURLAttribute(WebCore::HTMLNames::srcAttr);
59 }
60
61 - (void)setSrc:(NSString *)newSrc
62 {
63     WebCore::JSMainThreadNullState state;
64     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::srcAttr, newSrc);
65 }
66
67 - (NSString *)currentSrc
68 {
69     WebCore::JSMainThreadNullState state;
70     return IMPL->currentSrc();
71 }
72
73 - (NSString *)crossOrigin
74 {
75     WebCore::JSMainThreadNullState state;
76     return IMPL->crossOrigin();
77 }
78
79 - (void)setCrossOrigin:(NSString *)newCrossOrigin
80 {
81     WebCore::JSMainThreadNullState state;
82     IMPL->setCrossOrigin(newCrossOrigin);
83 }
84
85 - (unsigned short)networkState
86 {
87     WebCore::JSMainThreadNullState state;
88     return IMPL->networkState();
89 }
90
91 - (NSString *)preload
92 {
93     WebCore::JSMainThreadNullState state;
94     return IMPL->preload();
95 }
96
97 - (void)setPreload:(NSString *)newPreload
98 {
99     WebCore::JSMainThreadNullState state;
100     IMPL->setPreload(newPreload);
101 }
102
103 - (DOMTimeRanges *)buffered
104 {
105     WebCore::JSMainThreadNullState state;
106     return kit(WTF::getPtr(IMPL->buffered()));
107 }
108
109 - (unsigned short)readyState
110 {
111     WebCore::JSMainThreadNullState state;
112     return IMPL->readyState();
113 }
114
115 - (BOOL)seeking
116 {
117     WebCore::JSMainThreadNullState state;
118     return IMPL->seeking();
119 }
120
121 - (double)currentTime
122 {
123     WebCore::JSMainThreadNullState state;
124     return IMPL->currentTime();
125 }
126
127 - (void)setCurrentTime:(double)newCurrentTime
128 {
129     WebCore::JSMainThreadNullState state;
130     raiseOnDOMError(IMPL->setCurrentTimeForBindings(newCurrentTime));
131 }
132
133 - (double)duration
134 {
135     WebCore::JSMainThreadNullState state;
136     return IMPL->duration();
137 }
138
139 - (BOOL)paused
140 {
141     WebCore::JSMainThreadNullState state;
142     return IMPL->paused();
143 }
144
145 - (double)defaultPlaybackRate
146 {
147     WebCore::JSMainThreadNullState state;
148     return IMPL->defaultPlaybackRate();
149 }
150
151 - (void)setDefaultPlaybackRate:(double)newDefaultPlaybackRate
152 {
153     WebCore::JSMainThreadNullState state;
154     IMPL->setDefaultPlaybackRate(newDefaultPlaybackRate);
155 }
156
157 - (double)playbackRate
158 {
159     WebCore::JSMainThreadNullState state;
160     return IMPL->playbackRate();
161 }
162
163 - (void)setPlaybackRate:(double)newPlaybackRate
164 {
165     WebCore::JSMainThreadNullState state;
166     IMPL->setPlaybackRate(newPlaybackRate);
167 }
168
169 - (DOMTimeRanges *)played
170 {
171     WebCore::JSMainThreadNullState state;
172     return kit(WTF::getPtr(IMPL->played()));
173 }
174
175 - (DOMTimeRanges *)seekable
176 {
177     WebCore::JSMainThreadNullState state;
178     return kit(WTF::getPtr(IMPL->seekable()));
179 }
180
181 - (BOOL)ended
182 {
183     WebCore::JSMainThreadNullState state;
184     return IMPL->ended();
185 }
186
187 - (BOOL)autoplay
188 {
189     WebCore::JSMainThreadNullState state;
190     return IMPL->hasAttributeWithoutSynchronization(WebCore::HTMLNames::autoplayAttr);
191 }
192
193 - (void)setAutoplay:(BOOL)newAutoplay
194 {
195     WebCore::JSMainThreadNullState state;
196     IMPL->setBooleanAttribute(WebCore::HTMLNames::autoplayAttr, newAutoplay);
197 }
198
199 - (BOOL)loop
200 {
201     WebCore::JSMainThreadNullState state;
202     return IMPL->hasAttributeWithoutSynchronization(WebCore::HTMLNames::loopAttr);
203 }
204
205 - (void)setLoop:(BOOL)newLoop
206 {
207     WebCore::JSMainThreadNullState state;
208     IMPL->setBooleanAttribute(WebCore::HTMLNames::loopAttr, newLoop);
209 }
210
211 - (BOOL)controls
212 {
213     WebCore::JSMainThreadNullState state;
214     return IMPL->controls();
215 }
216
217 - (void)setControls:(BOOL)newControls
218 {
219     WebCore::JSMainThreadNullState state;
220     IMPL->setControls(newControls);
221 }
222
223 - (double)volume
224 {
225     WebCore::JSMainThreadNullState state;
226     return IMPL->volume();
227 }
228
229 - (void)setVolume:(double)newVolume
230 {
231     WebCore::JSMainThreadNullState state;
232     raiseOnDOMError(IMPL->setVolume(newVolume));
233 }
234
235 - (BOOL)muted
236 {
237     WebCore::JSMainThreadNullState state;
238     return IMPL->muted();
239 }
240
241 - (void)setMuted:(BOOL)newMuted
242 {
243     WebCore::JSMainThreadNullState state;
244     IMPL->setMuted(newMuted);
245 }
246
247 - (BOOL)defaultMuted
248 {
249     WebCore::JSMainThreadNullState state;
250     return IMPL->hasAttributeWithoutSynchronization(WebCore::HTMLNames::mutedAttr);
251 }
252
253 - (void)setDefaultMuted:(BOOL)newDefaultMuted
254 {
255     WebCore::JSMainThreadNullState state;
256     IMPL->setBooleanAttribute(WebCore::HTMLNames::mutedAttr, newDefaultMuted);
257 }
258
259 - (BOOL)webkitPreservesPitch
260 {
261     WebCore::JSMainThreadNullState state;
262     return IMPL->webkitPreservesPitch();
263 }
264
265 - (void)setWebkitPreservesPitch:(BOOL)newWebkitPreservesPitch
266 {
267     WebCore::JSMainThreadNullState state;
268     IMPL->setWebkitPreservesPitch(newWebkitPreservesPitch);
269 }
270
271 - (BOOL)webkitHasClosedCaptions
272 {
273     WebCore::JSMainThreadNullState state;
274     return IMPL->webkitHasClosedCaptions();
275 }
276
277 - (BOOL)webkitClosedCaptionsVisible
278 {
279     WebCore::JSMainThreadNullState state;
280     return IMPL->webkitClosedCaptionsVisible();
281 }
282
283 - (void)setWebkitClosedCaptionsVisible:(BOOL)newWebkitClosedCaptionsVisible
284 {
285     WebCore::JSMainThreadNullState state;
286     IMPL->setWebkitClosedCaptionsVisible(newWebkitClosedCaptionsVisible);
287 }
288
289 - (NSString *)mediaGroup
290 {
291     WebCore::JSMainThreadNullState state;
292     return IMPL->getAttribute(WebCore::HTMLNames::mediagroupAttr);
293 }
294
295 - (void)setMediaGroup:(NSString *)newMediaGroup
296 {
297     WebCore::JSMainThreadNullState state;
298     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::mediagroupAttr, newMediaGroup);
299 }
300
301 - (void)load
302 {
303     WebCore::JSMainThreadNullState state;
304     IMPL->load();
305 }
306
307 - (NSString *)canPlayType:(NSString *)type
308 {
309     WebCore::JSMainThreadNullState state;
310     return IMPL->canPlayType(type);
311 }
312
313 - (NSTimeInterval)getStartDate
314 {
315     WebCore::JSMainThreadNullState state;
316     return IMPL->getStartDate();
317 }
318
319 - (void)play
320 {
321     WebCore::JSMainThreadNullState state;
322     IMPL->play();
323 }
324
325 - (void)pause
326 {
327     WebCore::JSMainThreadNullState state;
328     IMPL->pause();
329 }
330
331 - (void)fastSeek:(double)time
332 {
333     WebCore::JSMainThreadNullState state;
334     IMPL->fastSeek(time);
335 }
336
337 @end
338
339 #endif // ENABLE(VIDEO)