| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // fair amount of overhead and logging. | 115 // fair amount of overhead and logging. |
| 116 #define LOG_CACHED_TIME_WARNINGS 0 | 116 #define LOG_CACHED_TIME_WARNINGS 0 |
| 117 #endif | 117 #endif |
| 118 | 118 |
| 119 // URL protocol used to signal that the media source API is being used. | 119 // URL protocol used to signal that the media source API is being used. |
| 120 static const char mediaSourceBlobProtocol[] = "blob"; | 120 static const char mediaSourceBlobProtocol[] = "blob"; |
| 121 | 121 |
| 122 using namespace HTMLNames; | 122 using namespace HTMLNames; |
| 123 using namespace std; | 123 using namespace std; |
| 124 | 124 |
| 125 typedef HashMap<Document*, HashSet<HTMLMediaElement*> > DocumentElementSetMap; | 125 typedef WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > WeakMediaEl
ementSet; |
| 126 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Document>, WeakMediaElementSet>
DocumentElementSetMap; |
| 126 static DocumentElementSetMap& documentToElementSetMap() | 127 static DocumentElementSetMap& documentToElementSetMap() |
| 127 { | 128 { |
| 129 #if ENABLE(OILPAN) |
| 130 DEFINE_STATIC_LOCAL(Persistent<DocumentElementSetMap>, map, (new DocumentEle
mentSetMap())); |
| 131 return *map; |
| 132 #else |
| 128 DEFINE_STATIC_LOCAL(DocumentElementSetMap, map, ()); | 133 DEFINE_STATIC_LOCAL(DocumentElementSetMap, map, ()); |
| 129 return map; | 134 return map; |
| 135 #endif |
| 130 } | 136 } |
| 131 | 137 |
| 132 static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen
t) | 138 static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen
t) |
| 133 { | 139 { |
| 134 DocumentElementSetMap& map = documentToElementSetMap(); | 140 DocumentElementSetMap& map = documentToElementSetMap(); |
| 135 HashSet<HTMLMediaElement*> set = map.take(document); | 141 WeakMediaElementSet set = map.take(document); |
| 136 set.add(element); | 142 set.add(element); |
| 137 map.add(document, set); | 143 map.add(document, set); |
| 138 } | 144 } |
| 139 | 145 |
| 140 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do
cument) | 146 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do
cument) |
| 141 { | 147 { |
| 142 DocumentElementSetMap& map = documentToElementSetMap(); | 148 DocumentElementSetMap& map = documentToElementSetMap(); |
| 143 HashSet<HTMLMediaElement*> set = map.take(document); | 149 WeakMediaElementSet set = map.take(document); |
| 144 set.remove(element); | 150 set.remove(element); |
| 145 if (!set.isEmpty()) | 151 if (!set.isEmpty()) |
| 146 map.add(document, set); | 152 map.add(document, set); |
| 147 } | 153 } |
| 148 | 154 |
| 149 class TrackDisplayUpdateScope { | 155 class TrackDisplayUpdateScope { |
| 150 public: | 156 public: |
| 151 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) | 157 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) |
| 152 { | 158 { |
| 153 m_mediaElement = mediaElement; | 159 m_mediaElement = mediaElement; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 m_textTracks->clearOwner(); | 317 m_textTracks->clearOwner(); |
| 312 #endif | 318 #endif |
| 313 | 319 |
| 314 if (m_mediaController) { | 320 if (m_mediaController) { |
| 315 m_mediaController->removeMediaElement(this); | 321 m_mediaController->removeMediaElement(this); |
| 316 m_mediaController = nullptr; | 322 m_mediaController = nullptr; |
| 317 } | 323 } |
| 318 | 324 |
| 319 closeMediaSource(); | 325 closeMediaSource(); |
| 320 | 326 |
| 327 #if !ENABLE(OILPAN) |
| 321 removeElementFromDocumentMap(this, &document()); | 328 removeElementFromDocumentMap(this, &document()); |
| 329 #endif |
| 322 | 330 |
| 323 // Destroying the player may cause a resource load to be canceled, | 331 // Destroying the player may cause a resource load to be canceled, |
| 324 // which could result in userCancelledLoad() being called back. | 332 // which could result in userCancelledLoad() being called back. |
| 325 // Setting m_completelyLoaded ensures that such a call will not cause | 333 // Setting m_completelyLoaded ensures that such a call will not cause |
| 326 // us to dispatch an abort event, which would result in a crash. | 334 // us to dispatch an abort event, which would result in a crash. |
| 327 // See http://crbug.com/233654 for more details. | 335 // See http://crbug.com/233654 for more details. |
| 328 m_completelyLoaded = true; | 336 m_completelyLoaded = true; |
| 329 | 337 |
| 338 // With Oilpan load events on the Document are always delayed during |
| 339 // sweeping so we don't need to explicitly increment and decrement |
| 340 // load event delay counts. |
| 341 #if !ENABLE(OILPAN) |
| 330 // Destroying the player may cause a resource load to be canceled, | 342 // Destroying the player may cause a resource load to be canceled, |
| 331 // which could result in Document::dispatchWindowLoadEvent() being | 343 // which could result in Document::dispatchWindowLoadEvent() being |
| 332 // called via ResourceFetch::didLoadResource() then | 344 // called via ResourceFetch::didLoadResource() then |
| 333 // FrameLoader::loadDone(). To prevent load event dispatching during | 345 // FrameLoader::loadDone(). To prevent load event dispatching during |
| 334 // object destruction, we use Document::incrementLoadEventDelayCount(). | 346 // object destruction, we use Document::incrementLoadEventDelayCount(). |
| 335 // See http://crbug.com/275223 for more details. | 347 // See http://crbug.com/275223 for more details. |
| 336 document().incrementLoadEventDelayCount(); | 348 document().incrementLoadEventDelayCount(); |
| 349 #endif |
| 337 | 350 |
| 338 clearMediaPlayerAndAudioSourceProviderClient(); | 351 clearMediaPlayerAndAudioSourceProviderClient(); |
| 339 | 352 |
| 353 #if !ENABLE(OILPAN) |
| 340 document().decrementLoadEventDelayCount(); | 354 document().decrementLoadEventDelayCount(); |
| 355 #endif |
| 341 } | 356 } |
| 342 | 357 |
| 343 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 358 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
| 344 { | 359 { |
| 345 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); | 360 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); |
| 346 | 361 |
| 347 if (m_shouldDelayLoadEvent) { | 362 if (m_shouldDelayLoadEvent) { |
| 348 document().incrementLoadEventDelayCount(); | 363 document().incrementLoadEventDelayCount(); |
| 349 // Note: Keeping the load event delay count increment on oldDocument tha
t was added | 364 // Note: Keeping the load event delay count increment on oldDocument tha
t was added |
| 350 // when m_shouldDelayLoadEvent was set so that destruction of m_player c
an not | 365 // when m_shouldDelayLoadEvent was set so that destruction of m_player c
an not |
| (...skipping 3106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3457 // 1. Let m [this] be the media element in question. | 3472 // 1. Let m [this] be the media element in question. |
| 3458 // 2. Let m have no current media controller, if it currently has one. | 3473 // 2. Let m have no current media controller, if it currently has one. |
| 3459 setControllerInternal(nullptr); | 3474 setControllerInternal(nullptr); |
| 3460 | 3475 |
| 3461 // 3. If m's mediagroup attribute is being removed, then abort these steps. | 3476 // 3. If m's mediagroup attribute is being removed, then abort these steps. |
| 3462 if (group.isNull() || group.isEmpty()) | 3477 if (group.isNull() || group.isEmpty()) |
| 3463 return; | 3478 return; |
| 3464 | 3479 |
| 3465 // 4. If there is another media element whose Document is the same as m's Do
cument (even if one or both | 3480 // 4. If there is another media element whose Document is the same as m's Do
cument (even if one or both |
| 3466 // of these elements are not actually in the Document), | 3481 // of these elements are not actually in the Document), |
| 3467 HashSet<HTMLMediaElement*> elements = documentToElementSetMap().get(&documen
t()); | 3482 WeakMediaElementSet elements = documentToElementSetMap().get(&document()); |
| 3468 for (HashSet<HTMLMediaElement*>::iterator i = elements.begin(); i != element
s.end(); ++i) { | 3483 for (WeakMediaElementSet::iterator i = elements.begin(); i != elements.end()
; ++i) { |
| 3469 if (*i == this) | 3484 if (*i == this) |
| 3470 continue; | 3485 continue; |
| 3471 | 3486 |
| 3472 // and which also has a mediagroup attribute, and whose mediagroup attri
bute has the same value as | 3487 // and which also has a mediagroup attribute, and whose mediagroup attri
bute has the same value as |
| 3473 // the new value of m's mediagroup attribute, | 3488 // the new value of m's mediagroup attribute, |
| 3474 if ((*i)->mediaGroup() == group) { | 3489 if ((*i)->mediaGroup() == group) { |
| 3475 // then let controller be that media element's current media contro
ller. | 3490 // then let controller be that media element's current media contro
ller. |
| 3476 setControllerInternal((*i)->controller()); | 3491 setControllerInternal((*i)->controller()); |
| 3477 return; | 3492 return; |
| 3478 } | 3493 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3619 | 3634 |
| 3620 void HTMLMediaElement::trace(Visitor* visitor) | 3635 void HTMLMediaElement::trace(Visitor* visitor) |
| 3621 { | 3636 { |
| 3622 visitor->trace(m_textTracks); | 3637 visitor->trace(m_textTracks); |
| 3623 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3638 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
| 3624 Supplementable<HTMLMediaElement>::trace(visitor); | 3639 Supplementable<HTMLMediaElement>::trace(visitor); |
| 3625 HTMLElement::trace(visitor); | 3640 HTMLElement::trace(visitor); |
| 3626 } | 3641 } |
| 3627 | 3642 |
| 3628 } | 3643 } |
| OLD | NEW |