Changeset 183185 in webkit


Ignore:
Timestamp:
Apr 23, 2015, 8:49:47 AM (11 years ago)
Author:
eric.carlson@apple.com
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.
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r183183 r183185  
     12015-04-23  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Some media tests assert after r183096
     4        https://bugs.webkit.org/show_bug.cgi?id=144098
     5
     6        Reviewed by Darin Adler.
     7
     8        * dom/Document.cpp:
     9        (WebCore::Document::removePlaybackTargetPickerClient): Don't assert if the client has already
     10            been removed from the map. This happens when a media element is removed from the document
     11            before its destructor runs and is not an error.
     12        (WebCore::Document::showPlaybackTargetPicker): It is an error to call this after the client
     13            has been removed from the map so leave the assert in a debug build, but return early
     14            so a release build doesn't crash.
     15        (WebCore::Document::playbackTargetPickerClientStateDidChange): Ditto.
     16        (WebCore::Document::playbackTargetAvailabilityDidChange): Use "auto" for the map iterator variable.
     17        (WebCore::Document::setPlaybackTarget): Ditto.
     18        (WebCore::Document::setShouldPlayToPlaybackTarget): Ditto.
     19        * dom/Document.h: Fix map typedef names.
     20
    1212015-04-23  Andreas Kling  <akling@apple.com>
    222
  • trunk/Source/WebCore/dom/Document.cpp

    r183096 r183185  
    65516551void Document::removePlaybackTargetPickerClient(MediaPlaybackTargetClient& client)
    65526552{
    6553     ASSERT(m_clientToIDMap.contains(&client));
    6554     uint64_t contextId = m_clientToIDMap.get(&client);
    6555     m_idToClientMap.remove(contextId);
    6556     m_clientToIDMap.remove(&client);
     6553    const auto& it = m_clientToIDMap.find(&client);
     6554    if (it == m_clientToIDMap.end())
     6555        return;
     6556
     6557    uint64_t clientId = it->value;
     6558    m_idToClientMap.remove(clientId);
     6559    m_clientToIDMap.remove(it);
    65576560
    65586561    Page* page = this->page();
    65596562    if (!page)
    65606563        return;
    6561     page->removePlaybackTargetPickerClient(contextId);
     6564    page->removePlaybackTargetPickerClient(clientId);
    65626565}
    65636566
     
    65686571        return;
    65696572
    6570     ASSERT(m_clientToIDMap.contains(&client));
    6571     page->showPlaybackTargetPicker(m_clientToIDMap.get(&client), view()->lastKnownMousePosition(), isVideo);
     6573    const auto& it = m_clientToIDMap.find(&client);
     6574    ASSERT(it != m_clientToIDMap.end());
     6575    if (it == m_clientToIDMap.end())
     6576        return;
     6577
     6578    page->showPlaybackTargetPicker(it->value, view()->lastKnownMousePosition(), isVideo);
    65726579}
    65736580
     
    65786585        return;
    65796586
    6580     ASSERT(m_clientToIDMap.contains(&client));
    6581     page->playbackTargetPickerClientStateDidChange(m_clientToIDMap.get(&client), state);
     6587    const auto& it = m_clientToIDMap.find(&client);
     6588    ASSERT(it != m_clientToIDMap.end());
     6589    if (it == m_clientToIDMap.end())
     6590        return;
     6591
     6592    page->playbackTargetPickerClientStateDidChange(it->value, state);
    65826593}
    65836594
    65846595void Document::playbackTargetAvailabilityDidChange(uint64_t clientId, bool available)
    65856596{
    6586     TargetClientToIdMap::iterator it = m_idToClientMap.find(clientId);
     6597    const auto& it = m_idToClientMap.find(clientId);
    65876598    if (it == m_idToClientMap.end())
    65886599        return;
     
    65936604void Document::setPlaybackTarget(uint64_t clientId, Ref<MediaPlaybackTarget>&& target)
    65946605{
    6595     TargetClientToIdMap::iterator it = m_idToClientMap.find(clientId);
     6606    const auto& it = m_idToClientMap.find(clientId);
    65966607    if (it == m_idToClientMap.end())
    65976608        return;
     
    66026613void Document::setShouldPlayToPlaybackTarget(uint64_t clientId, bool shouldPlay)
    66036614{
    6604     TargetClientToIdMap::iterator it = m_idToClientMap.find(clientId);
     6615    const auto& it = m_idToClientMap.find(clientId);
    66056616    if (it == m_idToClientMap.end())
    66066617        return;
  • trunk/Source/WebCore/dom/Document.h

    r183169 r183185  
    16891689
    16901690#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    1691     typedef HashMap<uint64_t, WebCore::MediaPlaybackTargetClient*> TargetClientToIdMap;
    1692     TargetClientToIdMap m_idToClientMap;
    1693     typedef HashMap<WebCore::MediaPlaybackTargetClient*, uint64_t> TargetIdToClientMap;
    1694     TargetIdToClientMap m_clientToIDMap;
     1691    typedef HashMap<uint64_t, WebCore::MediaPlaybackTargetClient*> TargetIdToClientMap;
     1692    TargetIdToClientMap m_idToClientMap;
     1693    typedef HashMap<WebCore::MediaPlaybackTargetClient*, uint64_t> TargetClientToIdMap;
     1694    TargetClientToIdMap m_clientToIDMap;
    16951695#endif
    16961696};
Note: See TracChangeset for help on using the changeset viewer.