Title: [183185] trunk/Source/WebCore
- Revision
- 183185
- Author
- [email protected]
- Date
- 2015-04-23 08:49:47 -0700 (Thu, 23 Apr 2015)
Log Message
Some media tests assert after r183096
https://bugs.webkit.org/show_bug.cgi?id=144098
Reviewed by Darin Adler.
* dom/Document.cpp:
(WebCore::Document::removePlaybackTargetPickerClient): Don't assert if the client has already
been removed from the map. This happens when a media element is removed from the document
before its destructor runs and is not an error.
(WebCore::Document::showPlaybackTargetPicker): It is an error to call this after the client
has been removed from the map so leave the assert in a debug build, but return early
so a release build doesn't crash.
(WebCore::Document::playbackTargetPickerClientStateDidChange): Ditto.
(WebCore::Document::playbackTargetAvailabilityDidChange): Use "auto" for the map iterator variable.
(WebCore::Document::setPlaybackTarget): Ditto.
(WebCore::Document::setShouldPlayToPlaybackTarget): Ditto.
* dom/Document.h: Fix map typedef names.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (183184 => 183185)
--- trunk/Source/WebCore/ChangeLog 2015-04-23 09:43:36 UTC (rev 183184)
+++ trunk/Source/WebCore/ChangeLog 2015-04-23 15:49:47 UTC (rev 183185)
@@ -1,3 +1,23 @@
+2015-04-23 Eric Carlson <[email protected]>
+
+ Some media tests assert after r183096
+ https://bugs.webkit.org/show_bug.cgi?id=144098
+
+ Reviewed by Darin Adler.
+
+ * dom/Document.cpp:
+ (WebCore::Document::removePlaybackTargetPickerClient): Don't assert if the client has already
+ been removed from the map. This happens when a media element is removed from the document
+ before its destructor runs and is not an error.
+ (WebCore::Document::showPlaybackTargetPicker): It is an error to call this after the client
+ has been removed from the map so leave the assert in a debug build, but return early
+ so a release build doesn't crash.
+ (WebCore::Document::playbackTargetPickerClientStateDidChange): Ditto.
+ (WebCore::Document::playbackTargetAvailabilityDidChange): Use "auto" for the map iterator variable.
+ (WebCore::Document::setPlaybackTarget): Ditto.
+ (WebCore::Document::setShouldPlayToPlaybackTarget): Ditto.
+ * dom/Document.h: Fix map typedef names.
+
2015-04-23 Andreas Kling <[email protected]>
DOM nodes should be allocated with fastMalloc().
Modified: trunk/Source/WebCore/dom/Document.cpp (183184 => 183185)
--- trunk/Source/WebCore/dom/Document.cpp 2015-04-23 09:43:36 UTC (rev 183184)
+++ trunk/Source/WebCore/dom/Document.cpp 2015-04-23 15:49:47 UTC (rev 183185)
@@ -6550,15 +6550,18 @@
void Document::removePlaybackTargetPickerClient(MediaPlaybackTargetClient& client)
{
- ASSERT(m_clientToIDMap.contains(&client));
- uint64_t contextId = m_clientToIDMap.get(&client);
- m_idToClientMap.remove(contextId);
- m_clientToIDMap.remove(&client);
+ const auto& it = m_clientToIDMap.find(&client);
+ if (it == m_clientToIDMap.end())
+ return;
+ uint64_t clientId = it->value;
+ m_idToClientMap.remove(clientId);
+ m_clientToIDMap.remove(it);
+
Page* page = this->page();
if (!page)
return;
- page->removePlaybackTargetPickerClient(contextId);
+ page->removePlaybackTargetPickerClient(clientId);
}
void Document::showPlaybackTargetPicker(MediaPlaybackTargetClient& client, bool isVideo)
@@ -6567,8 +6570,12 @@
if (!page)
return;
- ASSERT(m_clientToIDMap.contains(&client));
- page->showPlaybackTargetPicker(m_clientToIDMap.get(&client), view()->lastKnownMousePosition(), isVideo);
+ const auto& it = m_clientToIDMap.find(&client);
+ ASSERT(it != m_clientToIDMap.end());
+ if (it == m_clientToIDMap.end())
+ return;
+
+ page->showPlaybackTargetPicker(it->value, view()->lastKnownMousePosition(), isVideo);
}
void Document::playbackTargetPickerClientStateDidChange(MediaPlaybackTargetClient& client, MediaProducer::MediaStateFlags state)
@@ -6577,13 +6584,17 @@
if (!page)
return;
- ASSERT(m_clientToIDMap.contains(&client));
- page->playbackTargetPickerClientStateDidChange(m_clientToIDMap.get(&client), state);
+ const auto& it = m_clientToIDMap.find(&client);
+ ASSERT(it != m_clientToIDMap.end());
+ if (it == m_clientToIDMap.end())
+ return;
+
+ page->playbackTargetPickerClientStateDidChange(it->value, state);
}
void Document::playbackTargetAvailabilityDidChange(uint64_t clientId, bool available)
{
- TargetClientToIdMap::iterator it = m_idToClientMap.find(clientId);
+ const auto& it = m_idToClientMap.find(clientId);
if (it == m_idToClientMap.end())
return;
@@ -6592,7 +6603,7 @@
void Document::setPlaybackTarget(uint64_t clientId, Ref<MediaPlaybackTarget>&& target)
{
- TargetClientToIdMap::iterator it = m_idToClientMap.find(clientId);
+ const auto& it = m_idToClientMap.find(clientId);
if (it == m_idToClientMap.end())
return;
@@ -6601,7 +6612,7 @@
void Document::setShouldPlayToPlaybackTarget(uint64_t clientId, bool shouldPlay)
{
- TargetClientToIdMap::iterator it = m_idToClientMap.find(clientId);
+ const auto& it = m_idToClientMap.find(clientId);
if (it == m_idToClientMap.end())
return;
Modified: trunk/Source/WebCore/dom/Document.h (183184 => 183185)
--- trunk/Source/WebCore/dom/Document.h 2015-04-23 09:43:36 UTC (rev 183184)
+++ trunk/Source/WebCore/dom/Document.h 2015-04-23 15:49:47 UTC (rev 183185)
@@ -1688,10 +1688,10 @@
MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
- typedef HashMap<uint64_t, WebCore::MediaPlaybackTargetClient*> TargetClientToIdMap;
- TargetClientToIdMap m_idToClientMap;
- typedef HashMap<WebCore::MediaPlaybackTargetClient*, uint64_t> TargetIdToClientMap;
- TargetIdToClientMap m_clientToIDMap;
+ typedef HashMap<uint64_t, WebCore::MediaPlaybackTargetClient*> TargetIdToClientMap;
+ TargetIdToClientMap m_idToClientMap;
+ typedef HashMap<WebCore::MediaPlaybackTargetClient*, uint64_t> TargetClientToIdMap;
+ TargetClientToIdMap m_clientToIDMap;
#endif
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes