Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLMeterElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do cument) 149 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do cument)
150 { 150 {
151 DocumentElementSetMap& map = documentToElementSetMap(); 151 DocumentElementSetMap& map = documentToElementSetMap();
152 HashSet<HTMLMediaElement*> set = map.take(document); 152 HashSet<HTMLMediaElement*> set = map.take(document);
153 set.remove(element); 153 set.remove(element);
154 if (!set.isEmpty()) 154 if (!set.isEmpty())
155 map.add(document, set); 155 map.add(document, set);
156 } 156 }
157 157
158 static void throwExceptionForMediaKeyException(MediaPlayer::MediaKeyException ex ception, ExceptionState& es) 158 static void throwExceptionForMediaKeyException(MediaPlayer::MediaKeyException ex ception, ExceptionState& exceptionState)
159 { 159 {
160 switch (exception) { 160 switch (exception) {
161 case MediaPlayer::NoError: 161 case MediaPlayer::NoError:
162 return; 162 return;
163 case MediaPlayer::InvalidPlayerState: 163 case MediaPlayer::InvalidPlayerState:
164 es.throwUninformativeAndGenericDOMException(InvalidStateError); 164 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
165 return; 165 return;
166 case MediaPlayer::KeySystemNotSupported: 166 case MediaPlayer::KeySystemNotSupported:
167 es.throwUninformativeAndGenericDOMException(NotSupportedError); 167 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro r);
168 return; 168 return;
169 } 169 }
170 170
171 ASSERT_NOT_REACHED(); 171 ASSERT_NOT_REACHED();
172 return; 172 return;
173 } 173 }
174 174
175 class TrackDisplayUpdateScope { 175 class TrackDisplayUpdateScope {
176 public: 176 public:
177 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) 177 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement)
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 1794
1795 void HTMLMediaElement::prepareToPlay() 1795 void HTMLMediaElement::prepareToPlay()
1796 { 1796 {
1797 LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); 1797 LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this);
1798 if (m_havePreparedToPlay) 1798 if (m_havePreparedToPlay)
1799 return; 1799 return;
1800 m_havePreparedToPlay = true; 1800 m_havePreparedToPlay = true;
1801 m_player->prepareToPlay(); 1801 m_player->prepareToPlay();
1802 } 1802 }
1803 1803
1804 void HTMLMediaElement::seek(double time, ExceptionState& es) 1804 void HTMLMediaElement::seek(double time, ExceptionState& exceptionState)
1805 { 1805 {
1806 LOG(Media, "HTMLMediaElement::seek(%f)", time); 1806 LOG(Media, "HTMLMediaElement::seek(%f)", time);
1807 1807
1808 // 4.8.10.9 Seeking 1808 // 4.8.10.9 Seeking
1809 1809
1810 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva lidStateError exception. 1810 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva lidStateError exception.
1811 if (m_readyState == HAVE_NOTHING || !m_player) { 1811 if (m_readyState == HAVE_NOTHING || !m_player) {
1812 es.throwUninformativeAndGenericDOMException(InvalidStateError); 1812 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
1813 return; 1813 return;
1814 } 1814 }
1815 1815
1816 // If the media engine has been told to postpone loading data, let it go ahe ad now. 1816 // If the media engine has been told to postpone loading data, let it go ahe ad now.
1817 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) 1817 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA)
1818 prepareToPlay(); 1818 prepareToPlay();
1819 1819
1820 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. 1820 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set.
1821 refreshCachedTime(); 1821 refreshCachedTime();
1822 double now = currentTime(); 1822 double now = currentTime();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); 1968 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta);
1969 #endif 1969 #endif
1970 return m_cachedTime; 1970 return m_cachedTime;
1971 } 1971 }
1972 1972
1973 refreshCachedTime(); 1973 refreshCachedTime();
1974 1974
1975 return m_cachedTime; 1975 return m_cachedTime;
1976 } 1976 }
1977 1977
1978 void HTMLMediaElement::setCurrentTime(double time, ExceptionState& es) 1978 void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat e)
1979 { 1979 {
1980 if (m_mediaController) { 1980 if (m_mediaController) {
1981 es.throwUninformativeAndGenericDOMException(InvalidStateError); 1981 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
1982 return; 1982 return;
1983 } 1983 }
1984 seek(time, es); 1984 seek(time, exceptionState);
1985 } 1985 }
1986 1986
1987 double HTMLMediaElement::duration() const 1987 double HTMLMediaElement::duration() const
1988 { 1988 {
1989 if (!m_player || m_readyState < HAVE_METADATA) 1989 if (!m_player || m_readyState < HAVE_METADATA)
1990 return numeric_limits<double>::quiet_NaN(); 1990 return numeric_limits<double>::quiet_NaN();
1991 1991
1992 // FIXME: Refactor so m_duration is kept current (in both MSE and 1992 // FIXME: Refactor so m_duration is kept current (in both MSE and
1993 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> 1993 // non-MSE cases) once we have transitioned from HAVE_NOTHING ->
1994 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE 1994 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 2160
2161 void HTMLMediaElement::closeMediaSource() 2161 void HTMLMediaElement::closeMediaSource()
2162 { 2162 {
2163 if (!m_mediaSource) 2163 if (!m_mediaSource)
2164 return; 2164 return;
2165 2165
2166 m_mediaSource->close(); 2166 m_mediaSource->close();
2167 m_mediaSource = 0; 2167 m_mediaSource = 0;
2168 } 2168 }
2169 2169
2170 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef Ptr<Uint8Array> initData, ExceptionState& es) 2170 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef Ptr<Uint8Array> initData, ExceptionState& exceptionState)
2171 { 2171 {
2172 if (keySystem.isEmpty()) { 2172 if (keySystem.isEmpty()) {
2173 es.throwUninformativeAndGenericDOMException(SyntaxError); 2173 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
2174 return; 2174 return;
2175 } 2175 }
2176 2176
2177 if (!m_player) { 2177 if (!m_player) {
2178 es.throwUninformativeAndGenericDOMException(InvalidStateError); 2178 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
2179 return; 2179 return;
2180 } 2180 }
2181 2181
2182 const unsigned char* initDataPointer = 0; 2182 const unsigned char* initDataPointer = 0;
2183 unsigned initDataLength = 0; 2183 unsigned initDataLength = 0;
2184 if (initData) { 2184 if (initData) {
2185 initDataPointer = initData->data(); 2185 initDataPointer = initData->data();
2186 initDataLength = initData->length(); 2186 initDataLength = initData->length();
2187 } 2187 }
2188 2188
2189 MediaPlayer::MediaKeyException result = m_player->generateKeyRequest(keySyst em, initDataPointer, initDataLength); 2189 MediaPlayer::MediaKeyException result = m_player->generateKeyRequest(keySyst em, initDataPointer, initDataLength);
2190 throwExceptionForMediaKeyException(result, es); 2190 throwExceptionForMediaKeyException(result, exceptionState);
2191 } 2191 }
2192 2192
2193 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, Excepti onState& es) 2193 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, Excepti onState& exceptionState)
2194 { 2194 {
2195 webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), es); 2195 webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), exceptionState);
2196 } 2196 }
2197 2197
2198 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr ay> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionStat e& es) 2198 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr ay> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionStat e& exceptionState)
2199 { 2199 {
2200 if (keySystem.isEmpty()) { 2200 if (keySystem.isEmpty()) {
2201 es.throwUninformativeAndGenericDOMException(SyntaxError); 2201 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
2202 return; 2202 return;
2203 } 2203 }
2204 2204
2205 if (!key) { 2205 if (!key) {
2206 es.throwUninformativeAndGenericDOMException(SyntaxError); 2206 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
2207 return; 2207 return;
2208 } 2208 }
2209 2209
2210 if (!key->length()) { 2210 if (!key->length()) {
2211 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 2211 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
2212 return; 2212 return;
2213 } 2213 }
2214 2214
2215 if (!m_player) { 2215 if (!m_player) {
2216 es.throwUninformativeAndGenericDOMException(InvalidStateError); 2216 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
2217 return; 2217 return;
2218 } 2218 }
2219 2219
2220 const unsigned char* initDataPointer = 0; 2220 const unsigned char* initDataPointer = 0;
2221 unsigned initDataLength = 0; 2221 unsigned initDataLength = 0;
2222 if (initData) { 2222 if (initData) {
2223 initDataPointer = initData->data(); 2223 initDataPointer = initData->data();
2224 initDataLength = initData->length(); 2224 initDataLength = initData->length();
2225 } 2225 }
2226 2226
2227 MediaPlayer::MediaKeyException result = m_player->addKey(keySystem, key->dat a(), key->length(), initDataPointer, initDataLength, sessionId); 2227 MediaPlayer::MediaKeyException result = m_player->addKey(keySystem, key->dat a(), key->length(), initDataPointer, initDataLength, sessionId);
2228 throwExceptionForMediaKeyException(result, es); 2228 throwExceptionForMediaKeyException(result, exceptionState);
2229 } 2229 }
2230 2230
2231 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr ay> key, ExceptionState& es) 2231 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr ay> key, ExceptionState& exceptionState)
2232 { 2232 {
2233 webkitAddKey(keySystem, key, Uint8Array::create(0), String(), es); 2233 webkitAddKey(keySystem, key, Uint8Array::create(0), String(), exceptionState );
2234 } 2234 }
2235 2235
2236 void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const Str ing& sessionId, ExceptionState& es) 2236 void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const Str ing& sessionId, ExceptionState& exceptionState)
2237 { 2237 {
2238 if (keySystem.isEmpty()) { 2238 if (keySystem.isEmpty()) {
2239 es.throwUninformativeAndGenericDOMException(SyntaxError); 2239 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
2240 return; 2240 return;
2241 } 2241 }
2242 2242
2243 if (!m_player) { 2243 if (!m_player) {
2244 es.throwUninformativeAndGenericDOMException(InvalidStateError); 2244 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
2245 return; 2245 return;
2246 } 2246 }
2247 2247
2248 MediaPlayer::MediaKeyException result = m_player->cancelKeyRequest(keySystem , sessionId); 2248 MediaPlayer::MediaKeyException result = m_player->cancelKeyRequest(keySystem , sessionId);
2249 throwExceptionForMediaKeyException(result, es); 2249 throwExceptionForMediaKeyException(result, exceptionState);
2250 } 2250 }
2251 2251
2252 bool HTMLMediaElement::loop() const 2252 bool HTMLMediaElement::loop() const
2253 { 2253 {
2254 return fastHasAttribute(loopAttr); 2254 return fastHasAttribute(loopAttr);
2255 } 2255 }
2256 2256
2257 void HTMLMediaElement::setLoop(bool b) 2257 void HTMLMediaElement::setLoop(bool b)
2258 { 2258 {
2259 LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b)); 2259 LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b));
(...skipping 19 matching lines...) Expand all
2279 { 2279 {
2280 LOG(Media, "HTMLMediaElement::setControls(%s)", boolString(b)); 2280 LOG(Media, "HTMLMediaElement::setControls(%s)", boolString(b));
2281 setBooleanAttribute(controlsAttr, b); 2281 setBooleanAttribute(controlsAttr, b);
2282 } 2282 }
2283 2283
2284 double HTMLMediaElement::volume() const 2284 double HTMLMediaElement::volume() const
2285 { 2285 {
2286 return m_volume; 2286 return m_volume;
2287 } 2287 }
2288 2288
2289 void HTMLMediaElement::setVolume(double vol, ExceptionState& es) 2289 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState)
2290 { 2290 {
2291 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); 2291 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol);
2292 2292
2293 if (vol < 0.0f || vol > 1.0f) { 2293 if (vol < 0.0f || vol > 1.0f) {
2294 es.throwUninformativeAndGenericDOMException(IndexSizeError); 2294 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
2295 return; 2295 return;
2296 } 2296 }
2297 2297
2298 if (m_volume != vol) { 2298 if (m_volume != vol) {
2299 m_volume = vol; 2299 m_volume = vol;
2300 updateVolume(); 2300 updateVolume();
2301 scheduleEvent(EventTypeNames::volumechange); 2301 scheduleEvent(EventTypeNames::volumechange);
2302 } 2302 }
2303 } 2303 }
2304 2304
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 2526
2527 TrackDisplayUpdateScope scope(this); 2527 TrackDisplayUpdateScope scope(this);
2528 for (int i = m_textTracks->length() - 1; i >= 0; --i) { 2528 for (int i = m_textTracks->length() - 1; i >= 0; --i) {
2529 TextTrack* track = m_textTracks->item(i); 2529 TextTrack* track = m_textTracks->item(i);
2530 2530
2531 if (track->trackType() == TextTrack::InBand) 2531 if (track->trackType() == TextTrack::InBand)
2532 removeTrack(track); 2532 removeTrack(track);
2533 } 2533 }
2534 } 2534 }
2535 2535
2536 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const S tring& label, const String& language, ExceptionState& es) 2536 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const S tring& label, const String& language, ExceptionState& exceptionState)
2537 { 2537 {
2538 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); 2538 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled());
2539 2539
2540 // 4.8.10.12.4 Text track API 2540 // 4.8.10.12.4 Text track API
2541 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: 2541 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps:
2542 2542
2543 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps 2543 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps
2544 if (!TextTrack::isValidKindKeyword(kind)) { 2544 if (!TextTrack::isValidKindKeyword(kind)) {
2545 es.throwUninformativeAndGenericDOMException(SyntaxError); 2545 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
2546 return 0; 2546 return 0;
2547 } 2547 }
2548 2548
2549 // 2. If the label argument was omitted, let label be the empty string. 2549 // 2. If the label argument was omitted, let label be the empty string.
2550 // 3. If the language argument was omitted, let language be the empty string . 2550 // 3. If the language argument was omitted, let language be the empty string .
2551 // 4. Create a new TextTrack object. 2551 // 4. Create a new TextTrack object.
2552 2552
2553 // 5. Create a new text track corresponding to the new object, and set its t ext track kind to kind, its text 2553 // 5. Create a new text track corresponding to the new object, and set its t ext track kind to kind, its text
2554 // track label to label, its text track language to language... 2554 // track label to label, its text track language to language...
2555 RefPtr<TextTrack> textTrack = TextTrack::create(document(), this, kind, labe l, language); 2555 RefPtr<TextTrack> textTrack = TextTrack::create(document(), this, kind, labe l, language);
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after
3869 { 3869 {
3870 scheduleLayerUpdate(); 3870 scheduleLayerUpdate();
3871 } 3871 }
3872 3872
3873 bool HTMLMediaElement::isInteractiveContent() const 3873 bool HTMLMediaElement::isInteractiveContent() const
3874 { 3874 {
3875 return fastHasAttribute(controlsAttr); 3875 return fastHasAttribute(controlsAttr);
3876 } 3876 }
3877 3877
3878 } 3878 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLMeterElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698