| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (!set.isEmpty()) | 152 if (!set.isEmpty()) |
| 153 map.add(document, set); | 153 map.add(document, set); |
| 154 } | 154 } |
| 155 | 155 |
| 156 static void throwExceptionForMediaKeyException(MediaPlayer::MediaKeyException ex
ception, ExceptionState& es) | 156 static void throwExceptionForMediaKeyException(MediaPlayer::MediaKeyException ex
ception, ExceptionState& es) |
| 157 { | 157 { |
| 158 switch (exception) { | 158 switch (exception) { |
| 159 case MediaPlayer::NoError: | 159 case MediaPlayer::NoError: |
| 160 return; | 160 return; |
| 161 case MediaPlayer::InvalidPlayerState: | 161 case MediaPlayer::InvalidPlayerState: |
| 162 es.throwDOMException(InvalidStateError); | 162 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 163 return; | 163 return; |
| 164 case MediaPlayer::KeySystemNotSupported: | 164 case MediaPlayer::KeySystemNotSupported: |
| 165 es.throwDOMException(NotSupportedError); | 165 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 ASSERT_NOT_REACHED(); | 169 ASSERT_NOT_REACHED(); |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 | 172 |
| 173 class TrackDisplayUpdateScope { | 173 class TrackDisplayUpdateScope { |
| 174 public: | 174 public: |
| 175 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) | 175 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) |
| (...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1841 } | 1841 } |
| 1842 | 1842 |
| 1843 void HTMLMediaElement::seek(double time, ExceptionState& es) | 1843 void HTMLMediaElement::seek(double time, ExceptionState& es) |
| 1844 { | 1844 { |
| 1845 LOG(Media, "HTMLMediaElement::seek(%f)", time); | 1845 LOG(Media, "HTMLMediaElement::seek(%f)", time); |
| 1846 | 1846 |
| 1847 // 4.8.10.9 Seeking | 1847 // 4.8.10.9 Seeking |
| 1848 | 1848 |
| 1849 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva
lidStateError exception. | 1849 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva
lidStateError exception. |
| 1850 if (m_readyState == HAVE_NOTHING || !m_player) { | 1850 if (m_readyState == HAVE_NOTHING || !m_player) { |
| 1851 es.throwDOMException(InvalidStateError); | 1851 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 1852 return; | 1852 return; |
| 1853 } | 1853 } |
| 1854 | 1854 |
| 1855 // If the media engine has been told to postpone loading data, let it go ahe
ad now. | 1855 // If the media engine has been told to postpone loading data, let it go ahe
ad now. |
| 1856 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) | 1856 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) |
| 1857 prepareToPlay(); | 1857 prepareToPlay(); |
| 1858 | 1858 |
| 1859 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. | 1859 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. |
| 1860 refreshCachedTime(); | 1860 refreshCachedTime(); |
| 1861 double now = currentTime(); | 1861 double now = currentTime(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 } | 2010 } |
| 2011 | 2011 |
| 2012 refreshCachedTime(); | 2012 refreshCachedTime(); |
| 2013 | 2013 |
| 2014 return m_cachedTime; | 2014 return m_cachedTime; |
| 2015 } | 2015 } |
| 2016 | 2016 |
| 2017 void HTMLMediaElement::setCurrentTime(double time, ExceptionState& es) | 2017 void HTMLMediaElement::setCurrentTime(double time, ExceptionState& es) |
| 2018 { | 2018 { |
| 2019 if (m_mediaController) { | 2019 if (m_mediaController) { |
| 2020 es.throwDOMException(InvalidStateError); | 2020 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 2021 return; | 2021 return; |
| 2022 } | 2022 } |
| 2023 seek(time, es); | 2023 seek(time, es); |
| 2024 } | 2024 } |
| 2025 | 2025 |
| 2026 double HTMLMediaElement::startTime() const | 2026 double HTMLMediaElement::startTime() const |
| 2027 { | 2027 { |
| 2028 return 0; | 2028 return 0; |
| 2029 } | 2029 } |
| 2030 | 2030 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 if (!m_mediaSource) | 2244 if (!m_mediaSource) |
| 2245 return; | 2245 return; |
| 2246 | 2246 |
| 2247 m_mediaSource->close(); | 2247 m_mediaSource->close(); |
| 2248 m_mediaSource = 0; | 2248 m_mediaSource = 0; |
| 2249 } | 2249 } |
| 2250 | 2250 |
| 2251 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef
Ptr<Uint8Array> initData, ExceptionState& es) | 2251 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef
Ptr<Uint8Array> initData, ExceptionState& es) |
| 2252 { | 2252 { |
| 2253 if (keySystem.isEmpty()) { | 2253 if (keySystem.isEmpty()) { |
| 2254 es.throwDOMException(SyntaxError); | 2254 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 2255 return; | 2255 return; |
| 2256 } | 2256 } |
| 2257 | 2257 |
| 2258 if (!m_player) { | 2258 if (!m_player) { |
| 2259 es.throwDOMException(InvalidStateError); | 2259 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 2260 return; | 2260 return; |
| 2261 } | 2261 } |
| 2262 | 2262 |
| 2263 const unsigned char* initDataPointer = 0; | 2263 const unsigned char* initDataPointer = 0; |
| 2264 unsigned initDataLength = 0; | 2264 unsigned initDataLength = 0; |
| 2265 if (initData) { | 2265 if (initData) { |
| 2266 initDataPointer = initData->data(); | 2266 initDataPointer = initData->data(); |
| 2267 initDataLength = initData->length(); | 2267 initDataLength = initData->length(); |
| 2268 } | 2268 } |
| 2269 | 2269 |
| 2270 MediaPlayer::MediaKeyException result = m_player->generateKeyRequest(keySyst
em, initDataPointer, initDataLength); | 2270 MediaPlayer::MediaKeyException result = m_player->generateKeyRequest(keySyst
em, initDataPointer, initDataLength); |
| 2271 throwExceptionForMediaKeyException(result, es); | 2271 throwExceptionForMediaKeyException(result, es); |
| 2272 } | 2272 } |
| 2273 | 2273 |
| 2274 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, Excepti
onState& es) | 2274 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, Excepti
onState& es) |
| 2275 { | 2275 { |
| 2276 webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), es); | 2276 webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), es); |
| 2277 } | 2277 } |
| 2278 | 2278 |
| 2279 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionStat
e& es) | 2279 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionStat
e& es) |
| 2280 { | 2280 { |
| 2281 if (keySystem.isEmpty()) { | 2281 if (keySystem.isEmpty()) { |
| 2282 es.throwDOMException(SyntaxError); | 2282 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 2283 return; | 2283 return; |
| 2284 } | 2284 } |
| 2285 | 2285 |
| 2286 if (!key) { | 2286 if (!key) { |
| 2287 es.throwDOMException(SyntaxError); | 2287 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 2288 return; | 2288 return; |
| 2289 } | 2289 } |
| 2290 | 2290 |
| 2291 if (!key->length()) { | 2291 if (!key->length()) { |
| 2292 es.throwDOMException(TypeMismatchError); | 2292 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 2293 return; | 2293 return; |
| 2294 } | 2294 } |
| 2295 | 2295 |
| 2296 if (!m_player) { | 2296 if (!m_player) { |
| 2297 es.throwDOMException(InvalidStateError); | 2297 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 2298 return; | 2298 return; |
| 2299 } | 2299 } |
| 2300 | 2300 |
| 2301 const unsigned char* initDataPointer = 0; | 2301 const unsigned char* initDataPointer = 0; |
| 2302 unsigned initDataLength = 0; | 2302 unsigned initDataLength = 0; |
| 2303 if (initData) { | 2303 if (initData) { |
| 2304 initDataPointer = initData->data(); | 2304 initDataPointer = initData->data(); |
| 2305 initDataLength = initData->length(); | 2305 initDataLength = initData->length(); |
| 2306 } | 2306 } |
| 2307 | 2307 |
| 2308 MediaPlayer::MediaKeyException result = m_player->addKey(keySystem, key->dat
a(), key->length(), initDataPointer, initDataLength, sessionId); | 2308 MediaPlayer::MediaKeyException result = m_player->addKey(keySystem, key->dat
a(), key->length(), initDataPointer, initDataLength, sessionId); |
| 2309 throwExceptionForMediaKeyException(result, es); | 2309 throwExceptionForMediaKeyException(result, es); |
| 2310 } | 2310 } |
| 2311 | 2311 |
| 2312 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, ExceptionState& es) | 2312 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, ExceptionState& es) |
| 2313 { | 2313 { |
| 2314 webkitAddKey(keySystem, key, Uint8Array::create(0), String(), es); | 2314 webkitAddKey(keySystem, key, Uint8Array::create(0), String(), es); |
| 2315 } | 2315 } |
| 2316 | 2316 |
| 2317 void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const Str
ing& sessionId, ExceptionState& es) | 2317 void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const Str
ing& sessionId, ExceptionState& es) |
| 2318 { | 2318 { |
| 2319 if (keySystem.isEmpty()) { | 2319 if (keySystem.isEmpty()) { |
| 2320 es.throwDOMException(SyntaxError); | 2320 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 2321 return; | 2321 return; |
| 2322 } | 2322 } |
| 2323 | 2323 |
| 2324 if (!m_player) { | 2324 if (!m_player) { |
| 2325 es.throwDOMException(InvalidStateError); | 2325 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 2326 return; | 2326 return; |
| 2327 } | 2327 } |
| 2328 | 2328 |
| 2329 MediaPlayer::MediaKeyException result = m_player->cancelKeyRequest(keySystem
, sessionId); | 2329 MediaPlayer::MediaKeyException result = m_player->cancelKeyRequest(keySystem
, sessionId); |
| 2330 throwExceptionForMediaKeyException(result, es); | 2330 throwExceptionForMediaKeyException(result, es); |
| 2331 } | 2331 } |
| 2332 | 2332 |
| 2333 bool HTMLMediaElement::loop() const | 2333 bool HTMLMediaElement::loop() const |
| 2334 { | 2334 { |
| 2335 return fastHasAttribute(loopAttr); | 2335 return fastHasAttribute(loopAttr); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2365 double HTMLMediaElement::volume() const | 2365 double HTMLMediaElement::volume() const |
| 2366 { | 2366 { |
| 2367 return m_volume; | 2367 return m_volume; |
| 2368 } | 2368 } |
| 2369 | 2369 |
| 2370 void HTMLMediaElement::setVolume(double vol, ExceptionState& es) | 2370 void HTMLMediaElement::setVolume(double vol, ExceptionState& es) |
| 2371 { | 2371 { |
| 2372 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); | 2372 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); |
| 2373 | 2373 |
| 2374 if (vol < 0.0f || vol > 1.0f) { | 2374 if (vol < 0.0f || vol > 1.0f) { |
| 2375 es.throwDOMException(IndexSizeError); | 2375 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 2376 return; | 2376 return; |
| 2377 } | 2377 } |
| 2378 | 2378 |
| 2379 if (m_volume != vol) { | 2379 if (m_volume != vol) { |
| 2380 m_volume = vol; | 2380 m_volume = vol; |
| 2381 updateVolume(); | 2381 updateVolume(); |
| 2382 scheduleEvent(eventNames().volumechangeEvent); | 2382 scheduleEvent(eventNames().volumechangeEvent); |
| 2383 } | 2383 } |
| 2384 } | 2384 } |
| 2385 | 2385 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2617 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const S
tring& label, const String& language, ExceptionState& es) | 2617 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const S
tring& label, const String& language, ExceptionState& es) |
| 2618 { | 2618 { |
| 2619 if (!RuntimeEnabledFeatures::videoTrackEnabled()) | 2619 if (!RuntimeEnabledFeatures::videoTrackEnabled()) |
| 2620 return 0; | 2620 return 0; |
| 2621 | 2621 |
| 2622 // 4.8.10.12.4 Text track API | 2622 // 4.8.10.12.4 Text track API |
| 2623 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: | 2623 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: |
| 2624 | 2624 |
| 2625 // 1. If kind is not one of the following strings, then throw a SyntaxError
exception and abort these steps | 2625 // 1. If kind is not one of the following strings, then throw a SyntaxError
exception and abort these steps |
| 2626 if (!TextTrack::isValidKindKeyword(kind)) { | 2626 if (!TextTrack::isValidKindKeyword(kind)) { |
| 2627 es.throwDOMException(SyntaxError); | 2627 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 2628 return 0; | 2628 return 0; |
| 2629 } | 2629 } |
| 2630 | 2630 |
| 2631 // 2. If the label argument was omitted, let label be the empty string. | 2631 // 2. If the label argument was omitted, let label be the empty string. |
| 2632 // 3. If the language argument was omitted, let language be the empty string
. | 2632 // 3. If the language argument was omitted, let language be the empty string
. |
| 2633 // 4. Create a new TextTrack object. | 2633 // 4. Create a new TextTrack object. |
| 2634 | 2634 |
| 2635 // 5. Create a new text track corresponding to the new object, and set its t
ext track kind to kind, its text | 2635 // 5. Create a new text track corresponding to the new object, and set its t
ext track kind to kind, its text |
| 2636 // track label to label, its text track language to language... | 2636 // track label to label, its text track language to language... |
| 2637 RefPtr<TextTrack> textTrack = TextTrack::create(ActiveDOMObject::scriptExecu
tionContext(), this, kind, label, language); | 2637 RefPtr<TextTrack> textTrack = TextTrack::create(ActiveDOMObject::scriptExecu
tionContext(), this, kind, label, language); |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4002 { | 4002 { |
| 4003 m_restrictions = NoRestrictions; | 4003 m_restrictions = NoRestrictions; |
| 4004 } | 4004 } |
| 4005 | 4005 |
| 4006 void HTMLMediaElement::mediaPlayerScheduleLayerUpdate() | 4006 void HTMLMediaElement::mediaPlayerScheduleLayerUpdate() |
| 4007 { | 4007 { |
| 4008 scheduleLayerUpdate(); | 4008 scheduleLayerUpdate(); |
| 4009 } | 4009 } |
| 4010 | 4010 |
| 4011 } | 4011 } |
| OLD | NEW |