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

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

Issue 244493002: Oilpan: add transition types to track interface objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 6 years, 8 months 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
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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 HTMLMediaElement::~HTMLMediaElement() 301 HTMLMediaElement::~HTMLMediaElement()
302 { 302 {
303 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); 303 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement");
304 304
305 m_asyncEventQueue->close(); 305 m_asyncEventQueue->close();
306 306
307 setShouldDelayLoadEvent(false); 307 setShouldDelayLoadEvent(false);
308 308
309 if (m_textTracks) 309 if (m_textTracks)
Mads Ager (chromium) 2014/04/22 10:33:25 m_textTracks is another garbage collected object.
310 m_textTracks->clearOwner(); 310 m_textTracks->dispose();
311 311
312 if (m_mediaController) { 312 if (m_mediaController) {
313 m_mediaController->removeMediaElement(this); 313 m_mediaController->removeMediaElement(this);
314 m_mediaController = nullptr; 314 m_mediaController = nullptr;
315 } 315 }
316 316
317 closeMediaSource(); 317 closeMediaSource();
318 318
319 removeElementFromDocumentMap(this, &document()); 319 removeElementFromDocumentMap(this, &document());
320 320
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 1254
1255 void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* c ues) 1255 void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* c ues)
1256 { 1256 {
1257 WTF_LOG(Media, "HTMLMediaElement::textTrackRemoveCues"); 1257 WTF_LOG(Media, "HTMLMediaElement::textTrackRemoveCues");
1258 1258
1259 TrackDisplayUpdateScope scope(this); 1259 TrackDisplayUpdateScope scope(this);
1260 for (size_t i = 0; i < cues->length(); ++i) 1260 for (size_t i = 0; i < cues->length(); ++i)
1261 textTrackRemoveCue(cues->item(i)->track(), cues->item(i)); 1261 textTrackRemoveCue(cues->item(i)->track(), cues->item(i));
1262 } 1262 }
1263 1263
1264 void HTMLMediaElement::textTrackAddCue(TextTrack* track, PassRefPtr<TextTrackCue > cue) 1264 void HTMLMediaElement::textTrackAddCue(TextTrack* track, PassRefPtrWillBeRawPtr< TextTrackCue> cue)
1265 { 1265 {
1266 if (track->mode() == TextTrack::disabledKeyword()) 1266 if (track->mode() == TextTrack::disabledKeyword())
1267 return; 1267 return;
1268 1268
1269 // Negative duration cues need be treated in the interval tree as 1269 // Negative duration cues need be treated in the interval tree as
1270 // zero-length cues. 1270 // zero-length cues.
1271 double endTime = max(cue->startTime(), cue->endTime()); 1271 double endTime = max(cue->startTime(), cue->endTime());
1272 1272
1273 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c ue.get()); 1273 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c ue.get());
1274 if (!m_cueTree.contains(interval)) 1274 if (!m_cueTree.contains(interval))
1275 m_cueTree.add(interval); 1275 m_cueTree.add(interval);
1276 updateActiveTextTrackCues(currentTime()); 1276 updateActiveTextTrackCues(currentTime());
1277 } 1277 }
1278 1278
1279 void HTMLMediaElement::textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue> c ue) 1279 void HTMLMediaElement::textTrackRemoveCue(TextTrack*, PassRefPtrWillBeRawPtr<Tex tTrackCue> cue)
1280 { 1280 {
1281 // Negative duration cues need to be treated in the interval tree as 1281 // Negative duration cues need to be treated in the interval tree as
1282 // zero-length cues. 1282 // zero-length cues.
1283 double endTime = max(cue->startTime(), cue->endTime()); 1283 double endTime = max(cue->startTime(), cue->endTime());
1284 1284
1285 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c ue.get()); 1285 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c ue.get());
1286 m_cueTree.remove(interval); 1286 m_cueTree.remove(interval);
1287 1287
1288 // Since the cue will be removed from the media element and likely the 1288 // Since the cue will be removed from the media element and likely the
1289 // TextTrack might also be destructed, notifying the region of the cue 1289 // TextTrack might also be destructed, notifying the region of the cue
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 2289
2290 void HTMLMediaElement::forgetResourceSpecificTracks() 2290 void HTMLMediaElement::forgetResourceSpecificTracks()
2291 { 2291 {
2292 if (m_textTracks) { 2292 if (m_textTracks) {
2293 TrackDisplayUpdateScope scope(this); 2293 TrackDisplayUpdateScope scope(this);
2294 m_textTracks->removeAllInbandTracks(); 2294 m_textTracks->removeAllInbandTracks();
2295 closeCaptionTracksChanged(); 2295 closeCaptionTracksChanged();
2296 } 2296 }
2297 } 2297 }
2298 2298
2299 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) 2299 PassRefPtrWillBeRawPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicStr ing& kind, const AtomicString& label, const AtomicString& language, ExceptionSta te& exceptionState)
2300 { 2300 {
2301 // 4.8.10.12.4 Text track API 2301 // 4.8.10.12.4 Text track API
2302 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: 2302 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps:
2303 2303
2304 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps 2304 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps
2305 if (!TextTrack::isValidKindKeyword(kind)) { 2305 if (!TextTrack::isValidKindKeyword(kind)) {
2306 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid."); 2306 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid.");
2307 return nullptr; 2307 return nullptr;
2308 } 2308 }
2309 2309
2310 // 2. If the label argument was omitted, let label be the empty string. 2310 // 2. If the label argument was omitted, let label be the empty string.
2311 // 3. If the language argument was omitted, let language be the empty string . 2311 // 3. If the language argument was omitted, let language be the empty string .
2312 // 4. Create a new TextTrack object. 2312 // 4. Create a new TextTrack object.
2313 2313
2314 // 5. Create a new text track corresponding to the new object, and set its t ext track kind to kind, its text 2314 // 5. Create a new text track corresponding to the new object, and set its t ext track kind to kind, its text
2315 // track label to label, its text track language to language... 2315 // track label to label, its text track language to language...
2316 RefPtr<TextTrack> textTrack = TextTrack::create(document(), kind, label, lan guage); 2316 RefPtrWillBeRawPtr<TextTrack> textTrack = TextTrack::create(document(), kind , label, language);
2317 2317
2318 // Note, due to side effects when changing track parameters, we have to 2318 // Note, due to side effects when changing track parameters, we have to
2319 // first append the track to the text track list. 2319 // first append the track to the text track list.
2320 2320
2321 // 6. Add the new text track to the media element's list of text tracks. 2321 // 6. Add the new text track to the media element's list of text tracks.
2322 addTextTrack(textTrack.get()); 2322 addTextTrack(textTrack.get());
2323 2323
2324 // ... its text track readiness state to the text track loaded state ... 2324 // ... its text track readiness state to the text track loaded state ...
2325 textTrack->setReadinessState(TextTrack::Loaded); 2325 textTrack->setReadinessState(TextTrack::Loaded);
2326 2326
(...skipping 10 matching lines...) Expand all
2337 2337
2338 return m_textTracks.get(); 2338 return m_textTracks.get();
2339 } 2339 }
2340 2340
2341 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) 2341 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement)
2342 { 2342 {
2343 // 4.8.10.12.3 Sourcing out-of-band text tracks 2343 // 4.8.10.12.3 Sourcing out-of-band text tracks
2344 // When a track element's parent element changes and the new parent is a med ia element, 2344 // When a track element's parent element changes and the new parent is a med ia element,
2345 // then the user agent must add the track element's corresponding text track to the 2345 // then the user agent must add the track element's corresponding text track to the
2346 // media element's list of text tracks ... [continues in TextTrackList::appe nd] 2346 // media element's list of text tracks ... [continues in TextTrackList::appe nd]
2347 RefPtr<TextTrack> textTrack = trackElement->track(); 2347 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2348 if (!textTrack) 2348 if (!textTrack)
2349 return; 2349 return;
2350 2350
2351 addTextTrack(textTrack.get()); 2351 addTextTrack(textTrack.get());
2352 2352
2353 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2353 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks
2354 // in the markup have been added. 2354 // in the markup have been added.
2355 if (isFinishedParsingChildren()) 2355 if (isFinishedParsingChildren())
2356 scheduleDelayedAction(LoadTextTrackResource); 2356 scheduleDelayedAction(LoadTextTrackResource);
2357 2357
2358 if (hasMediaControls()) 2358 if (hasMediaControls())
2359 mediaControls()->closedCaptionTracksChanged(); 2359 mediaControls()->closedCaptionTracksChanged();
2360 } 2360 }
2361 2361
2362 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) 2362 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2363 { 2363 {
2364 #if !LOG_DISABLED 2364 #if !LOG_DISABLED
2365 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2365 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2366 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement - 'src' is %s", urlF orLoggingMedia(url).utf8().data()); 2366 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement - 'src' is %s", urlF orLoggingMedia(url).utf8().data());
2367 #endif 2367 #endif
2368 2368
2369 RefPtr<TextTrack> textTrack = trackElement->track(); 2369 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2370 if (!textTrack) 2370 if (!textTrack)
2371 return; 2371 return;
2372 2372
2373 textTrack->setHasBeenConfigured(false); 2373 textTrack->setHasBeenConfigured(false);
2374 2374
2375 if (!m_textTracks) 2375 if (!m_textTracks)
2376 return; 2376 return;
2377 2377
2378 // 4.8.10.12.3 Sourcing out-of-band text tracks 2378 // 4.8.10.12.3 Sourcing out-of-band text tracks
2379 // When a track element's parent element changes and the old parent was a me dia element, 2379 // When a track element's parent element changes and the old parent was a me dia element,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 2421
2422 void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group) 2422 void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
2423 { 2423 {
2424 ASSERT(group.tracks.size()); 2424 ASSERT(group.tracks.size());
2425 2425
2426 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackGroup(%d)", group.kind); 2426 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackGroup(%d)", group.kind);
2427 2427
2428 Settings* settings = document().settings(); 2428 Settings* settings = document().settings();
2429 2429
2430 // First, find the track in the group that should be enabled (if any). 2430 // First, find the track in the group that should be enabled (if any).
2431 Vector<RefPtr<TextTrack> > currentlyEnabledTracks; 2431 WillBeHeapVector<RefPtrWillBeMember<TextTrack> > currentlyEnabledTracks;
2432 RefPtr<TextTrack> trackToEnable; 2432 RefPtrWillBeRawPtr<TextTrack> trackToEnable = nullptr;
2433 RefPtr<TextTrack> defaultTrack; 2433 RefPtrWillBeRawPtr<TextTrack> defaultTrack = nullptr;
2434 RefPtr<TextTrack> fallbackTrack; 2434 RefPtrWillBeRawPtr<TextTrack> fallbackTrack = nullptr;
2435 int highestTrackScore = 0; 2435 int highestTrackScore = 0;
2436 for (size_t i = 0; i < group.tracks.size(); ++i) { 2436 for (size_t i = 0; i < group.tracks.size(); ++i) {
2437 RefPtr<TextTrack> textTrack = group.tracks[i]; 2437 RefPtrWillBeRawPtr<TextTrack> textTrack = group.tracks[i];
2438 2438
2439 if (m_processingPreferenceChange && textTrack->mode() == TextTrack::show ingKeyword()) 2439 if (m_processingPreferenceChange && textTrack->mode() == TextTrack::show ingKeyword())
2440 currentlyEnabledTracks.append(textTrack); 2440 currentlyEnabledTracks.append(textTrack);
2441 2441
2442 int trackScore = textTrackSelectionScore(*textTrack, settings); 2442 int trackScore = textTrackSelectionScore(*textTrack, settings);
2443 if (trackScore) { 2443 if (trackScore) {
2444 // * If the text track kind is { [subtitles or captions] [descriptio ns] } and the user has indicated an interest in having a 2444 // * If the text track kind is { [subtitles or captions] [descriptio ns] } and the user has indicated an interest in having a
2445 // track with this text track kind, text track language, and text tr ack label enabled, and there is no 2445 // track with this text track kind, text track language, and text tr ack label enabled, and there is no
2446 // other text track in the media element's list of text tracks with a text track kind of either subtitles 2446 // other text track in the media element's list of text tracks with a text track kind of either subtitles
2447 // or captions whose text track mode is showing 2447 // or captions whose text track mode is showing
(...skipping 25 matching lines...) Expand all
2473 // If no track matches the user's preferred language and non was marked 'def ault', enable the first track 2473 // If no track matches the user's preferred language and non was marked 'def ault', enable the first track
2474 // because the user has explicitly stated a preference for this kind of trac k. 2474 // because the user has explicitly stated a preference for this kind of trac k.
2475 if (!fallbackTrack && m_closedCaptionsVisible && group.kind == TrackGroup::C aptionsAndSubtitles) 2475 if (!fallbackTrack && m_closedCaptionsVisible && group.kind == TrackGroup::C aptionsAndSubtitles)
2476 fallbackTrack = group.tracks[0]; 2476 fallbackTrack = group.tracks[0];
2477 2477
2478 if (!trackToEnable && fallbackTrack) 2478 if (!trackToEnable && fallbackTrack)
2479 trackToEnable = fallbackTrack; 2479 trackToEnable = fallbackTrack;
2480 2480
2481 if (currentlyEnabledTracks.size()) { 2481 if (currentlyEnabledTracks.size()) {
2482 for (size_t i = 0; i < currentlyEnabledTracks.size(); ++i) { 2482 for (size_t i = 0; i < currentlyEnabledTracks.size(); ++i) {
2483 RefPtr<TextTrack> textTrack = currentlyEnabledTracks[i]; 2483 RefPtrWillBeRawPtr<TextTrack> textTrack = currentlyEnabledTracks[i];
2484 if (textTrack != trackToEnable) 2484 if (textTrack != trackToEnable)
2485 textTrack->setMode(TextTrack::disabledKeyword()); 2485 textTrack->setMode(TextTrack::disabledKeyword());
2486 } 2486 }
2487 } 2487 }
2488 2488
2489 if (trackToEnable) 2489 if (trackToEnable)
2490 trackToEnable->setMode(TextTrack::showingKeyword()); 2490 trackToEnable->setMode(TextTrack::showingKeyword());
2491 } 2491 }
2492 2492
2493 void HTMLMediaElement::configureTextTracks() 2493 void HTMLMediaElement::configureTextTracks()
2494 { 2494 {
2495 TrackGroup captionAndSubtitleTracks(TrackGroup::CaptionsAndSubtitles); 2495 TrackGroup captionAndSubtitleTracks(TrackGroup::CaptionsAndSubtitles);
2496 TrackGroup descriptionTracks(TrackGroup::Description); 2496 TrackGroup descriptionTracks(TrackGroup::Description);
2497 TrackGroup chapterTracks(TrackGroup::Chapter); 2497 TrackGroup chapterTracks(TrackGroup::Chapter);
2498 TrackGroup metadataTracks(TrackGroup::Metadata); 2498 TrackGroup metadataTracks(TrackGroup::Metadata);
2499 TrackGroup otherTracks(TrackGroup::Other); 2499 TrackGroup otherTracks(TrackGroup::Other);
2500 2500
2501 if (!m_textTracks) 2501 if (!m_textTracks)
2502 return; 2502 return;
2503 2503
2504 for (size_t i = 0; i < m_textTracks->length(); ++i) { 2504 for (size_t i = 0; i < m_textTracks->length(); ++i) {
2505 RefPtr<TextTrack> textTrack = m_textTracks->item(i); 2505 RefPtrWillBeRawPtr<TextTrack> textTrack = m_textTracks->item(i);
2506 if (!textTrack) 2506 if (!textTrack)
2507 continue; 2507 continue;
2508 2508
2509 String kind = textTrack->kind(); 2509 String kind = textTrack->kind();
2510 TrackGroup* currentGroup; 2510 TrackGroup* currentGroup;
2511 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword()) 2511 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword())
2512 currentGroup = &captionAndSubtitleTracks; 2512 currentGroup = &captionAndSubtitleTracks;
2513 else if (kind == TextTrack::descriptionsKeyword()) 2513 else if (kind == TextTrack::descriptionsKeyword())
2514 currentGroup = &descriptionTracks; 2514 currentGroup = &descriptionTracks;
2515 else if (kind == TextTrack::chaptersKeyword()) 2515 else if (kind == TextTrack::chaptersKeyword())
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 { 3384 {
3385 if (!m_textTracks) 3385 if (!m_textTracks)
3386 return; 3386 return;
3387 3387
3388 // Mark all tracks as not "configured" so that configureTextTracks() 3388 // Mark all tracks as not "configured" so that configureTextTracks()
3389 // will reconsider which tracks to display in light of new user preferences 3389 // will reconsider which tracks to display in light of new user preferences
3390 // (e.g. default tracks should not be displayed if the user has turned off 3390 // (e.g. default tracks should not be displayed if the user has turned off
3391 // captions and non-default tracks should be displayed based on language 3391 // captions and non-default tracks should be displayed based on language
3392 // preferences if the user has turned captions on). 3392 // preferences if the user has turned captions on).
3393 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 3393 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
3394 RefPtr<TextTrack> textTrack = m_textTracks->item(i); 3394 RefPtrWillBeRawPtr<TextTrack> textTrack = m_textTracks->item(i);
3395 String kind = textTrack->kind(); 3395 String kind = textTrack->kind();
3396 3396
3397 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword()) 3397 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword())
3398 textTrack->setHasBeenConfigured(false); 3398 textTrack->setHasBeenConfigured(false);
3399 } 3399 }
3400 configureTextTracks(); 3400 configureTextTracks();
3401 } 3401 }
3402 3402
3403 bool HTMLMediaElement::willRespondToMouseClickEvents() 3403 bool HTMLMediaElement::willRespondToMouseClickEvents()
3404 { 3404 {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 return fastHasAttribute(controlsAttr); 3642 return fastHasAttribute(controlsAttr);
3643 } 3643 }
3644 3644
3645 void HTMLMediaElement::trace(Visitor* visitor) 3645 void HTMLMediaElement::trace(Visitor* visitor)
3646 { 3646 {
3647 Supplementable<HTMLMediaElement>::trace(visitor); 3647 Supplementable<HTMLMediaElement>::trace(visitor);
3648 HTMLElement::trace(visitor); 3648 HTMLElement::trace(visitor);
3649 } 3649 }
3650 3650
3651 } 3651 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698