<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205365] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205365">205365</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2016-09-02 13:06:52 -0700 (Fri, 02 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Refactor WebPlaybackSessionModelMediaElement to be client based.
https://bugs.webkit.org/show_bug.cgi?id=159580

Reviewed by Eric Carlson.

Source/WebCore:

Add client callback interfaces to both WebPlaybackSessionModel and WebVideoFullscreenModel, where each object
can have multiple clients, and so the object will both store current values and also notify those clients
when the values change. After this change, there is no need to have the models know about their associated
interfaces explicitly.

* platform/cocoa/WebPlaybackSessionInterface.h:
* platform/cocoa/WebPlaybackSessionModel.h:
(WebCore::WebPlaybackSessionModelClient::~WebPlaybackSessionModelClient):
(WebCore::WebPlaybackSessionModelClient::durationChanged):
(WebCore::WebPlaybackSessionModelClient::currentTimeChanged):
(WebCore::WebPlaybackSessionModelClient::bufferedTimeChanged):
(WebCore::WebPlaybackSessionModelClient::rateChanged):
(WebCore::WebPlaybackSessionModelClient::seekableRangesChanged):
(WebCore::WebPlaybackSessionModelClient::canPlayFastReverseChanged):
(WebCore::WebPlaybackSessionModelClient::audioMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionModelClient::legibleMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionModelClient::externalPlaybackChanged):
(WebCore::WebPlaybackSessionModelClient::wirelessVideoPlaybackDisabledChanged):
* platform/cocoa/WebPlaybackSessionModelMediaElement.h:
* platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
(WebPlaybackSessionModelMediaElement::setMediaElement):
(WebPlaybackSessionModelMediaElement::updateForEventName):
(WebPlaybackSessionModelMediaElement::addClient):
(WebPlaybackSessionModelMediaElement::removeClient):
(WebPlaybackSessionModelMediaElement::updateLegibleOptions):
(WebPlaybackSessionModelMediaElement::observedEventNames):
(WebPlaybackSessionModelMediaElement::eventNameAll):
(WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions):
(WebPlaybackSessionModelMediaElement::audioMediaSelectedIndex):
(WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex):
(WebPlaybackSessionModelMediaElement::externalPlaybackEnabled):
(WebPlaybackSessionModelMediaElement::externalPlaybackTargetType):
(WebPlaybackSessionModelMediaElement::externalPlaybackLocalizedDeviceName):
(WebPlaybackSessionModelMediaElement::wirelessVideoPlaybackDisabled):
(WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface): Deleted.
* platform/cocoa/WebVideoFullscreenInterface.h:
* platform/cocoa/WebVideoFullscreenModel.h:
(WebCore::WebVideoFullscreenModelClient::~WebVideoFullscreenModelClient):
* platform/cocoa/WebVideoFullscreenModelVideoElement.h:
(WebCore::WebVideoFullscreenModelVideoElement::create):
(WebCore::WebVideoFullscreenModelVideoElement::playbackSessionModel): Deleted.
* platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement):
(WebVideoFullscreenModelVideoElement::setVideoElement):
(WebVideoFullscreenModelVideoElement::updateForEventName):
(WebVideoFullscreenModelVideoElement::addClient):
(WebVideoFullscreenModelVideoElement::removeClient):
(WebVideoFullscreenModelVideoElement::setHasVideo):
(WebVideoFullscreenModelVideoElement::setVideoDimensions):
(WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface): Deleted.
* platform/ios/WebAVPlayerController.h:
* platform/ios/WebAVPlayerController.mm:
(-[WebAVPlayerController resetState]): Deleted.
* platform/ios/WebPlaybackSessionInterfaceAVKit.h:
(WebCore::WebPlaybackSessionInterfaceAVKitClient::~WebPlaybackSessionInterfaceAVKitClient): Deleted.
* platform/ios/WebPlaybackSessionInterfaceAVKit.mm:
(WebCore::WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit):
(WebCore::WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit):
(WebCore::WebPlaybackSessionInterfaceAVKit::resetMediaState):
(WebCore::WebPlaybackSessionInterfaceAVKit::durationChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::currentTimeChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::bufferedTimeChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::rateChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::seekableRangesChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::canPlayFastReverseChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::audioMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::legibleMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::externalPlaybackChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabledChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::invalidate):
(WebCore::WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setDuration): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setCurrentTime): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setBufferedTime): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setRate): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setSeekableRanges): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setExternalPlayback): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled): Deleted.
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(WebVideoFullscreenControllerContext::didSetupFullscreen):
(WebVideoFullscreenControllerContext::didExitFullscreen):
(WebVideoFullscreenControllerContext::didCleanupFullscreen):
(WebVideoFullscreenControllerContext::durationChanged):
(WebVideoFullscreenControllerContext::currentTimeChanged):
(WebVideoFullscreenControllerContext::bufferedTimeChanged):
(WebVideoFullscreenControllerContext::rateChanged):
(WebVideoFullscreenControllerContext::hasVideoChanged):
(WebVideoFullscreenControllerContext::videoDimensionsChanged):
(WebVideoFullscreenControllerContext::seekableRangesChanged):
(WebVideoFullscreenControllerContext::canPlayFastReverseChanged):
(WebVideoFullscreenControllerContext::audioMediaSelectionOptionsChanged):
(WebVideoFullscreenControllerContext::legibleMediaSelectionOptionsChanged):
(WebVideoFullscreenControllerContext::externalPlaybackChanged):
(WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabledChanged):
(WebVideoFullscreenControllerContext::addClient):
(WebVideoFullscreenControllerContext::removeClient):
(WebVideoFullscreenControllerContext::requestFullscreenMode):
(WebVideoFullscreenControllerContext::setVideoLayerFrame):
(WebVideoFullscreenControllerContext::setVideoLayerGravity):
(WebVideoFullscreenControllerContext::fullscreenModeChanged):
(WebVideoFullscreenControllerContext::isVisible):
(WebVideoFullscreenControllerContext::hasVideo):
(WebVideoFullscreenControllerContext::videoDimensions):
(WebVideoFullscreenControllerContext::play):
(WebVideoFullscreenControllerContext::pause):
(WebVideoFullscreenControllerContext::togglePlayState):
(WebVideoFullscreenControllerContext::beginScrubbing):
(WebVideoFullscreenControllerContext::endScrubbing):
(WebVideoFullscreenControllerContext::seekToTime):
(WebVideoFullscreenControllerContext::fastSeek):
(WebVideoFullscreenControllerContext::beginScanningForward):
(WebVideoFullscreenControllerContext::beginScanningBackward):
(WebVideoFullscreenControllerContext::endScanning):
(WebVideoFullscreenControllerContext::selectAudioMediaOption):
(WebVideoFullscreenControllerContext::selectLegibleMediaOption):
(WebVideoFullscreenControllerContext::duration):
(WebVideoFullscreenControllerContext::currentTime):
(WebVideoFullscreenControllerContext::bufferedTime):
(WebVideoFullscreenControllerContext::isPlaying):
(WebVideoFullscreenControllerContext::playbackRate):
(WebVideoFullscreenControllerContext::seekableRanges):
(WebVideoFullscreenControllerContext::canPlayFastReverse):
(WebVideoFullscreenControllerContext::audioMediaSelectionOptions):
(WebVideoFullscreenControllerContext::audioMediaSelectedIndex):
(WebVideoFullscreenControllerContext::legibleMediaSelectionOptions):
(WebVideoFullscreenControllerContext::legibleMediaSelectedIndex):
(WebVideoFullscreenControllerContext::externalPlaybackEnabled):
(WebVideoFullscreenControllerContext::externalPlaybackTargetType):
(WebVideoFullscreenControllerContext::externalPlaybackLocalizedDeviceName):
(WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabled):
(WebVideoFullscreenControllerContext::setUpFullscreen):
(WebVideoFullscreenControllerContext::exitFullscreen):
(WebVideoFullscreenControllerContext::requestHideAndExitFullscreen):
(WebVideoFullscreenControllerContext::resetMediaState): Deleted.
(WebVideoFullscreenControllerContext::setDuration): Deleted.
(WebVideoFullscreenControllerContext::setCurrentTime): Deleted.
(WebVideoFullscreenControllerContext::setBufferedTime): Deleted.
(WebVideoFullscreenControllerContext::setRate): Deleted.
(WebVideoFullscreenControllerContext::setVideoDimensions): Deleted.
(WebVideoFullscreenControllerContext::setSeekableRanges): Deleted.
(WebVideoFullscreenControllerContext::setCanPlayFastReverse): Deleted.
(WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions): Deleted.
(WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions): Deleted.
(WebVideoFullscreenControllerContext::setExternalPlayback): Deleted.
(WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled): Deleted.
(WebVideoFullscreenSessionModel::play): Deleted.
(WebVideoFullscreenSessionModel::pause): Deleted.
(WebVideoFullscreenSessionModel::togglePlayState): Deleted.
(WebVideoFullscreenSessionModel::beginScrubbing): Deleted.
(WebVideoFullscreenSessionModel::endScrubbing): Deleted.
(WebVideoFullscreenSessionModel::seekToTime): Deleted.
(WebVideoFullscreenSessionModel::fastSeek): Deleted.
(WebVideoFullscreenSessionModel::beginScanningForward): Deleted.
(WebVideoFullscreenSessionModel::beginScanningBackward): Deleted.
(WebVideoFullscreenSessionModel::endScanning): Deleted.
(WebVideoFullscreenSessionModel::selectAudioMediaOption): Deleted.
(WebVideoFullscreenSessionModel::selectLegibleMediaOption): Deleted.
* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit):
(WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel):
(WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenChangeObserver):
(WebVideoFullscreenInterfaceAVKit::hasVideoChanged):
(WebVideoFullscreenInterfaceAVKit::videoDimensionsChanged):
(WebVideoFullscreenInterfaceAVKit::externalPlaybackChanged):
(WebVideoFullscreenInterfaceAVKit::resetMediaState): Deleted.
(WebVideoFullscreenInterfaceAVKit::setDuration): Deleted.
(WebVideoFullscreenInterfaceAVKit::setCurrentTime): Deleted.
(WebVideoFullscreenInterfaceAVKit::setBufferedTime): Deleted.
(WebVideoFullscreenInterfaceAVKit::setRate): Deleted.
(WebVideoFullscreenInterfaceAVKit::setVideoDimensions): Deleted.
(WebVideoFullscreenInterfaceAVKit::setSeekableRanges): Deleted.
(WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse): Deleted.
(WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions): Deleted.
(WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions): Deleted.
(WebVideoFullscreenInterfaceAVKit::setExternalPlayback): Deleted.
(WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged): Deleted.
(WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled): Deleted.
(WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled): Deleted.
* platform/mac/WebPlaybackSessionInterfaceMac.h:
(WebCore::WebPlaybackSessionInterfaceMacClient::~WebPlaybackSessionInterfaceMacClient): Deleted.
* platform/mac/WebPlaybackSessionInterfaceMac.mm:
(WebCore::WebPlaybackSessionInterfaceMac::create):
(WebCore::WebPlaybackSessionInterfaceMac::WebPlaybackSessionInterfaceMac):
(WebCore::WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac):
(WebCore::WebPlaybackSessionInterfaceMac::durationChanged):
(WebCore::WebPlaybackSessionInterfaceMac::currentTimeChanged):
(WebCore::WebPlaybackSessionInterfaceMac::rateChanged):
(WebCore::WebPlaybackSessionInterfaceMac::seekableRangesChanged):
(WebCore::WebPlaybackSessionInterfaceMac::audioMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionInterfaceMac::legibleMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionInterfaceMac::invalidate):
(WebCore::WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setClient): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setDuration): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setCurrentTime): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setRate): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setSeekableRanges): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions): Deleted.
* platform/mac/WebVideoFullscreenInterfaceMac.h:
* platform/mac/WebVideoFullscreenInterfaceMac.mm:
(WebCore::WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac):
(WebCore::WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac):
(WebCore::WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel):
(WebCore::WebVideoFullscreenInterfaceMac::externalPlaybackChanged):
(WebCore::WebVideoFullscreenInterfaceMac::hasVideoChanged):
(WebCore::WebVideoFullscreenInterfaceMac::videoDimensionsChanged):
(WebCore::WebVideoFullscreenInterfaceMac::setDuration): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setCurrentTime): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setRate): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setSeekableRanges): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setExternalPlayback): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setVideoDimensions): Deleted.

Source/WebKit/mac:

No longer necessary to tell the models and interfaces about each other.

* WebView/WebView.mm:
(-[WebView _setUpPlaybackControlsManagerForMediaElement:]):
(-[WebView _clearPlaybackControlsManager]):

Source/WebKit2:

Adopt the changes made in the WebPlaybackSessionModel,Interface and WebVideoFullscreenModel,Interface
in the WebPlaybackSessionManager,Proxy classes.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]): Deleted.
* UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h:
* UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm:
(WebKit::WebPlaybackSessionModelContext::addClient):
(WebKit::WebPlaybackSessionModelContext::removeClient):
(WebKit::WebPlaybackSessionModelContext::setDuration):
(WebKit::WebPlaybackSessionModelContext::setCurrentTime):
(WebKit::WebPlaybackSessionModelContext::setBufferedTime):
(WebKit::WebPlaybackSessionModelContext::setRate):
(WebKit::WebPlaybackSessionModelContext::setSeekableRanges):
(WebKit::WebPlaybackSessionModelContext::setCanPlayFastReverse):
(WebKit::WebPlaybackSessionModelContext::setAudioMediaSelectionOptions):
(WebKit::WebPlaybackSessionModelContext::setLegibleMediaSelectionOptions):
(WebKit::WebPlaybackSessionModelContext::setExternalPlayback):
(WebKit::WebPlaybackSessionModelContext::setWirelessVideoPlaybackDisabled):
(WebKit::WebPlaybackSessionManagerProxy::createModelAndInterface):
(WebKit::WebPlaybackSessionManagerProxy::removeClientForContext):
(WebKit::WebPlaybackSessionManagerProxy::setCurrentTime):
(WebKit::WebPlaybackSessionManagerProxy::setBufferedTime):
(WebKit::WebPlaybackSessionManagerProxy::setSeekableRangesVector):
(WebKit::WebPlaybackSessionManagerProxy::setCanPlayFastReverse):
(WebKit::WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions):
(WebKit::WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions):
(WebKit::WebPlaybackSessionManagerProxy::setExternalPlaybackProperties):
(WebKit::WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled):
(WebKit::WebPlaybackSessionManagerProxy::setDuration):
(WebKit::WebPlaybackSessionManagerProxy::setRate):
* UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
* UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in:
* UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenModelContext::addClient):
(WebKit::WebVideoFullscreenModelContext::removeClient):
(WebKit::WebVideoFullscreenManagerProxy::setHasVideo):
(WebKit::WebVideoFullscreenManagerProxy::setVideoDimensions):
* WebProcess/cocoa/WebPlaybackSessionManager.h:
* WebProcess/cocoa/WebPlaybackSessionManager.mm:
(WebKit::WebPlaybackSessionInterfaceContext::durationChanged):
(WebKit::WebPlaybackSessionInterfaceContext::currentTimeChanged):
(WebKit::WebPlaybackSessionInterfaceContext::bufferedTimeChanged):
(WebKit::WebPlaybackSessionInterfaceContext::rateChanged):
(WebKit::WebPlaybackSessionInterfaceContext::seekableRangesChanged):
(WebKit::WebPlaybackSessionInterfaceContext::canPlayFastReverseChanged):
(WebKit::WebPlaybackSessionInterfaceContext::audioMediaSelectionOptionsChanged):
(WebKit::WebPlaybackSessionInterfaceContext::legibleMediaSelectionOptionsChanged):
(WebKit::WebPlaybackSessionInterfaceContext::externalPlaybackChanged):
(WebKit::WebPlaybackSessionInterfaceContext::wirelessVideoPlaybackDisabledChanged):
(WebKit::WebPlaybackSessionManager::~WebPlaybackSessionManager):
(WebKit::WebPlaybackSessionManager::createModelAndInterface):
(WebKit::WebPlaybackSessionManager::removeContext):
(WebKit::WebPlaybackSessionManager::durationChanged):
(WebKit::WebPlaybackSessionManager::currentTimeChanged):
(WebKit::WebPlaybackSessionManager::bufferedTimeChanged):
(WebKit::WebPlaybackSessionManager::rateChanged):
(WebKit::WebPlaybackSessionManager::seekableRangesChanged):
(WebKit::WebPlaybackSessionManager::canPlayFastReverseChanged):
(WebKit::WebPlaybackSessionManager::audioMediaSelectionOptionsChanged):
(WebKit::WebPlaybackSessionManager::legibleMediaSelectionOptionsChanged):
(WebKit::WebPlaybackSessionManager::externalPlaybackChanged):
(WebKit::WebPlaybackSessionManager::wirelessVideoPlaybackDisabledChanged):
(WebKit::WebPlaybackSessionInterfaceContext::setDuration): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setCurrentTime): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setBufferedTime): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setRate): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setSeekableRanges): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setCanPlayFastReverse): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setAudioMediaSelectionOptions): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setLegibleMediaSelectionOptions): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setExternalPlayback): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setWirelessVideoPlaybackDisabled): Deleted.
(WebKit::WebPlaybackSessionManager::setDuration): Deleted.
(WebKit::WebPlaybackSessionManager::setCurrentTime): Deleted.
(WebKit::WebPlaybackSessionManager::setBufferedTime): Deleted.
(WebKit::WebPlaybackSessionManager::setRate): Deleted.
(WebKit::WebPlaybackSessionManager::setSeekableRanges): Deleted.
(WebKit::WebPlaybackSessionManager::setCanPlayFastReverse): Deleted.
(WebKit::WebPlaybackSessionManager::setAudioMediaSelectionOptions): Deleted.
(WebKit::WebPlaybackSessionManager::setLegibleMediaSelectionOptions): Deleted.
(WebKit::WebPlaybackSessionManager::setExternalPlayback): Deleted.
(WebKit::WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled): Deleted.
* WebProcess/cocoa/WebVideoFullscreenManager.h:
(WebKit::WebVideoFullscreenInterfaceContext::create):
* WebProcess/cocoa/WebVideoFullscreenManager.mm:
(WebKit::WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext):
(WebKit::WebVideoFullscreenInterfaceContext::hasVideoChanged):
(WebKit::WebVideoFullscreenInterfaceContext::videoDimensionsChanged):
(WebKit::WebVideoFullscreenManager::~WebVideoFullscreenManager):
(WebKit::WebVideoFullscreenManager::createModelAndInterface):
(WebKit::WebVideoFullscreenManager::removeContext):
(WebKit::WebVideoFullscreenManager::hasVideoChanged):
(WebKit::WebVideoFullscreenManager::videoDimensionsChanged):
(WebKit::WebVideoFullscreenInterfaceContext::resetMediaState): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setDuration): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setCurrentTime): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setBufferedTime): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setRate): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setVideoDimensions): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setSeekableRanges): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setCanPlayFastReverse): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setExternalPlayback): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled): Deleted.
(WebKit::WebVideoFullscreenManager::setVideoDimensions): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebPlaybackSessionInterfaceh">trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelh">trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementh">trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementmm">trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebVideoFullscreenInterfaceh">trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelh">trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelVideoElementh">trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelVideoElementmm">trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebAVPlayerControllerh">trunk/Source/WebCore/platform/ios/WebAVPlayerController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebAVPlayerControllermm">trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebPlaybackSessionInterfaceAVKith">trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebPlaybackSessionInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMach">trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMacmm">trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMach">trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMacmm">trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxyh">trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymm">trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxyh">trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymessagesin">trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymm">trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagerh">trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermm">trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagerh">trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagermm">trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/ChangeLog        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -1,3 +1,231 @@
</span><ins>+2016-07-08  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Refactor WebPlaybackSessionModelMediaElement to be client based.
+        https://bugs.webkit.org/show_bug.cgi?id=159580
+
+        Reviewed by Eric Carlson.
+
+        Add client callback interfaces to both WebPlaybackSessionModel and WebVideoFullscreenModel, where each object
+        can have multiple clients, and so the object will both store current values and also notify those clients
+        when the values change. After this change, there is no need to have the models know about their associated
+        interfaces explicitly.
+
+        * platform/cocoa/WebPlaybackSessionInterface.h:
+        * platform/cocoa/WebPlaybackSessionModel.h:
+        (WebCore::WebPlaybackSessionModelClient::~WebPlaybackSessionModelClient):
+        (WebCore::WebPlaybackSessionModelClient::durationChanged):
+        (WebCore::WebPlaybackSessionModelClient::currentTimeChanged):
+        (WebCore::WebPlaybackSessionModelClient::bufferedTimeChanged):
+        (WebCore::WebPlaybackSessionModelClient::rateChanged):
+        (WebCore::WebPlaybackSessionModelClient::seekableRangesChanged):
+        (WebCore::WebPlaybackSessionModelClient::canPlayFastReverseChanged):
+        (WebCore::WebPlaybackSessionModelClient::audioMediaSelectionOptionsChanged):
+        (WebCore::WebPlaybackSessionModelClient::legibleMediaSelectionOptionsChanged):
+        (WebCore::WebPlaybackSessionModelClient::externalPlaybackChanged):
+        (WebCore::WebPlaybackSessionModelClient::wirelessVideoPlaybackDisabledChanged):
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.h:
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
+        (WebPlaybackSessionModelMediaElement::setMediaElement):
+        (WebPlaybackSessionModelMediaElement::updateForEventName):
+        (WebPlaybackSessionModelMediaElement::addClient):
+        (WebPlaybackSessionModelMediaElement::removeClient):
+        (WebPlaybackSessionModelMediaElement::updateLegibleOptions):
+        (WebPlaybackSessionModelMediaElement::observedEventNames):
+        (WebPlaybackSessionModelMediaElement::eventNameAll):
+        (WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions):
+        (WebPlaybackSessionModelMediaElement::audioMediaSelectedIndex):
+        (WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex):
+        (WebPlaybackSessionModelMediaElement::externalPlaybackEnabled):
+        (WebPlaybackSessionModelMediaElement::externalPlaybackTargetType):
+        (WebPlaybackSessionModelMediaElement::externalPlaybackLocalizedDeviceName):
+        (WebPlaybackSessionModelMediaElement::wirelessVideoPlaybackDisabled):
+        (WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface): Deleted.
+        * platform/cocoa/WebVideoFullscreenInterface.h:
+        * platform/cocoa/WebVideoFullscreenModel.h:
+        (WebCore::WebVideoFullscreenModelClient::~WebVideoFullscreenModelClient):
+        * platform/cocoa/WebVideoFullscreenModelVideoElement.h:
+        (WebCore::WebVideoFullscreenModelVideoElement::create):
+        (WebCore::WebVideoFullscreenModelVideoElement::playbackSessionModel): Deleted.
+        * platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
+        (WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement):
+        (WebVideoFullscreenModelVideoElement::setVideoElement):
+        (WebVideoFullscreenModelVideoElement::updateForEventName):
+        (WebVideoFullscreenModelVideoElement::addClient):
+        (WebVideoFullscreenModelVideoElement::removeClient):
+        (WebVideoFullscreenModelVideoElement::setHasVideo):
+        (WebVideoFullscreenModelVideoElement::setVideoDimensions):
+        (WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface): Deleted.
+        * platform/ios/WebAVPlayerController.h:
+        * platform/ios/WebAVPlayerController.mm:
+        (-[WebAVPlayerController resetState]): Deleted.
+        * platform/ios/WebPlaybackSessionInterfaceAVKit.h:
+        (WebCore::WebPlaybackSessionInterfaceAVKitClient::~WebPlaybackSessionInterfaceAVKitClient): Deleted.
+        * platform/ios/WebPlaybackSessionInterfaceAVKit.mm:
+        (WebCore::WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::resetMediaState):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::durationChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::currentTimeChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::bufferedTimeChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::rateChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::seekableRangesChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::canPlayFastReverseChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::audioMediaSelectionOptionsChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::legibleMediaSelectionOptionsChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::externalPlaybackChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabledChanged):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::invalidate):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setDuration): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setCurrentTime): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setBufferedTime): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setRate): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setSeekableRanges): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setExternalPlayback): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled): Deleted.
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (WebVideoFullscreenControllerContext::didSetupFullscreen):
+        (WebVideoFullscreenControllerContext::didExitFullscreen):
+        (WebVideoFullscreenControllerContext::didCleanupFullscreen):
+        (WebVideoFullscreenControllerContext::durationChanged):
+        (WebVideoFullscreenControllerContext::currentTimeChanged):
+        (WebVideoFullscreenControllerContext::bufferedTimeChanged):
+        (WebVideoFullscreenControllerContext::rateChanged):
+        (WebVideoFullscreenControllerContext::hasVideoChanged):
+        (WebVideoFullscreenControllerContext::videoDimensionsChanged):
+        (WebVideoFullscreenControllerContext::seekableRangesChanged):
+        (WebVideoFullscreenControllerContext::canPlayFastReverseChanged):
+        (WebVideoFullscreenControllerContext::audioMediaSelectionOptionsChanged):
+        (WebVideoFullscreenControllerContext::legibleMediaSelectionOptionsChanged):
+        (WebVideoFullscreenControllerContext::externalPlaybackChanged):
+        (WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabledChanged):
+        (WebVideoFullscreenControllerContext::addClient):
+        (WebVideoFullscreenControllerContext::removeClient):
+        (WebVideoFullscreenControllerContext::requestFullscreenMode):
+        (WebVideoFullscreenControllerContext::setVideoLayerFrame):
+        (WebVideoFullscreenControllerContext::setVideoLayerGravity):
+        (WebVideoFullscreenControllerContext::fullscreenModeChanged):
+        (WebVideoFullscreenControllerContext::isVisible):
+        (WebVideoFullscreenControllerContext::hasVideo):
+        (WebVideoFullscreenControllerContext::videoDimensions):
+        (WebVideoFullscreenControllerContext::play):
+        (WebVideoFullscreenControllerContext::pause):
+        (WebVideoFullscreenControllerContext::togglePlayState):
+        (WebVideoFullscreenControllerContext::beginScrubbing):
+        (WebVideoFullscreenControllerContext::endScrubbing):
+        (WebVideoFullscreenControllerContext::seekToTime):
+        (WebVideoFullscreenControllerContext::fastSeek):
+        (WebVideoFullscreenControllerContext::beginScanningForward):
+        (WebVideoFullscreenControllerContext::beginScanningBackward):
+        (WebVideoFullscreenControllerContext::endScanning):
+        (WebVideoFullscreenControllerContext::selectAudioMediaOption):
+        (WebVideoFullscreenControllerContext::selectLegibleMediaOption):
+        (WebVideoFullscreenControllerContext::duration):
+        (WebVideoFullscreenControllerContext::currentTime):
+        (WebVideoFullscreenControllerContext::bufferedTime):
+        (WebVideoFullscreenControllerContext::isPlaying):
+        (WebVideoFullscreenControllerContext::playbackRate):
+        (WebVideoFullscreenControllerContext::seekableRanges):
+        (WebVideoFullscreenControllerContext::canPlayFastReverse):
+        (WebVideoFullscreenControllerContext::audioMediaSelectionOptions):
+        (WebVideoFullscreenControllerContext::audioMediaSelectedIndex):
+        (WebVideoFullscreenControllerContext::legibleMediaSelectionOptions):
+        (WebVideoFullscreenControllerContext::legibleMediaSelectedIndex):
+        (WebVideoFullscreenControllerContext::externalPlaybackEnabled):
+        (WebVideoFullscreenControllerContext::externalPlaybackTargetType):
+        (WebVideoFullscreenControllerContext::externalPlaybackLocalizedDeviceName):
+        (WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabled):
+        (WebVideoFullscreenControllerContext::setUpFullscreen):
+        (WebVideoFullscreenControllerContext::exitFullscreen):
+        (WebVideoFullscreenControllerContext::requestHideAndExitFullscreen):
+        (WebVideoFullscreenControllerContext::resetMediaState): Deleted.
+        (WebVideoFullscreenControllerContext::setDuration): Deleted.
+        (WebVideoFullscreenControllerContext::setCurrentTime): Deleted.
+        (WebVideoFullscreenControllerContext::setBufferedTime): Deleted.
+        (WebVideoFullscreenControllerContext::setRate): Deleted.
+        (WebVideoFullscreenControllerContext::setVideoDimensions): Deleted.
+        (WebVideoFullscreenControllerContext::setSeekableRanges): Deleted.
+        (WebVideoFullscreenControllerContext::setCanPlayFastReverse): Deleted.
+        (WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions): Deleted.
+        (WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions): Deleted.
+        (WebVideoFullscreenControllerContext::setExternalPlayback): Deleted.
+        (WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled): Deleted.
+        (WebVideoFullscreenSessionModel::play): Deleted.
+        (WebVideoFullscreenSessionModel::pause): Deleted.
+        (WebVideoFullscreenSessionModel::togglePlayState): Deleted.
+        (WebVideoFullscreenSessionModel::beginScrubbing): Deleted.
+        (WebVideoFullscreenSessionModel::endScrubbing): Deleted.
+        (WebVideoFullscreenSessionModel::seekToTime): Deleted.
+        (WebVideoFullscreenSessionModel::fastSeek): Deleted.
+        (WebVideoFullscreenSessionModel::beginScanningForward): Deleted.
+        (WebVideoFullscreenSessionModel::beginScanningBackward): Deleted.
+        (WebVideoFullscreenSessionModel::endScanning): Deleted.
+        (WebVideoFullscreenSessionModel::selectAudioMediaOption): Deleted.
+        (WebVideoFullscreenSessionModel::selectLegibleMediaOption): Deleted.
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit):
+        (WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel):
+        (WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenChangeObserver):
+        (WebVideoFullscreenInterfaceAVKit::hasVideoChanged):
+        (WebVideoFullscreenInterfaceAVKit::videoDimensionsChanged):
+        (WebVideoFullscreenInterfaceAVKit::externalPlaybackChanged):
+        (WebVideoFullscreenInterfaceAVKit::resetMediaState): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setDuration): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setCurrentTime): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setBufferedTime): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setRate): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setVideoDimensions): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setSeekableRanges): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setExternalPlayback): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled): Deleted.
+        * platform/mac/WebPlaybackSessionInterfaceMac.h:
+        (WebCore::WebPlaybackSessionInterfaceMacClient::~WebPlaybackSessionInterfaceMacClient): Deleted.
+        * platform/mac/WebPlaybackSessionInterfaceMac.mm:
+        (WebCore::WebPlaybackSessionInterfaceMac::create):
+        (WebCore::WebPlaybackSessionInterfaceMac::WebPlaybackSessionInterfaceMac):
+        (WebCore::WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac):
+        (WebCore::WebPlaybackSessionInterfaceMac::durationChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::currentTimeChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::rateChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::seekableRangesChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::audioMediaSelectionOptionsChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::legibleMediaSelectionOptionsChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::invalidate):
+        (WebCore::WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceMac::setClient): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceMac::setDuration): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceMac::setCurrentTime): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceMac::setRate): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceMac::setSeekableRanges): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions): Deleted.
+        (WebCore::WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions): Deleted.
+        * platform/mac/WebVideoFullscreenInterfaceMac.h:
+        * platform/mac/WebVideoFullscreenInterfaceMac.mm:
+        (WebCore::WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac):
+        (WebCore::WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac):
+        (WebCore::WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel):
+        (WebCore::WebVideoFullscreenInterfaceMac::externalPlaybackChanged):
+        (WebCore::WebVideoFullscreenInterfaceMac::hasVideoChanged):
+        (WebCore::WebVideoFullscreenInterfaceMac::videoDimensionsChanged):
+        (WebCore::WebVideoFullscreenInterfaceMac::setDuration): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setCurrentTime): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setRate): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setSeekableRanges): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setExternalPlayback): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setVideoDimensions): Deleted.
+
</ins><span class="cx"> 2016-09-02  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r204839): [mac-wk1] LayoutTest webgl/max-active-contexts-webglcontextlost-prevent-default.html is a flaky timeout
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebPlaybackSessionInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -40,20 +40,8 @@
</span><span class="cx"> 
</span><span class="cx"> class WebPlaybackSessionInterface {
</span><span class="cx"> public:
</span><del>-    enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
-
</del><span class="cx">     virtual ~WebPlaybackSessionInterface() { };
</span><span class="cx">     virtual void resetMediaState() = 0;
</span><del>-    virtual void setDuration(double) = 0;
-    virtual void setCurrentTime(double currentTime, double anchorTime) = 0;
-    virtual void setBufferedTime(double) = 0;
-    virtual void setRate(bool isPlaying, float playbackRate) = 0;
-    virtual void setSeekableRanges(const TimeRanges&amp;) = 0;
-    virtual void setCanPlayFastReverse(bool) = 0;
-    virtual void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) = 0;
-    virtual void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) = 0;
-    virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) = 0;
-    virtual void setWirelessVideoPlaybackDisabled(bool) = 0;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -36,9 +36,14 @@
</span><span class="cx"> 
</span><span class="cx"> class TimeRanges;
</span><span class="cx"> 
</span><ins>+class WebPlaybackSessionModelClient;
+
</ins><span class="cx"> class WebPlaybackSessionModel {
</span><span class="cx"> public:
</span><span class="cx">     virtual ~WebPlaybackSessionModel() { };
</span><ins>+    virtual void addClient(WebPlaybackSessionModelClient&amp;) = 0;
+    virtual void removeClient(WebPlaybackSessionModelClient&amp;) = 0;
+
</ins><span class="cx">     virtual void play() = 0;
</span><span class="cx">     virtual void pause() = 0;
</span><span class="cx">     virtual void togglePlayState() = 0;
</span><span class="lines">@@ -52,6 +57,8 @@
</span><span class="cx">     virtual void selectAudioMediaOption(uint64_t index) = 0;
</span><span class="cx">     virtual void selectLegibleMediaOption(uint64_t index) = 0;
</span><span class="cx"> 
</span><ins>+    enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
+
</ins><span class="cx">     virtual double duration() const = 0;
</span><span class="cx">     virtual double currentTime() const = 0;
</span><span class="cx">     virtual double bufferedTime() const = 0;
</span><span class="lines">@@ -59,14 +66,31 @@
</span><span class="cx">     virtual float playbackRate() const = 0;
</span><span class="cx">     virtual Ref&lt;TimeRanges&gt; seekableRanges() const = 0;
</span><span class="cx">     virtual bool canPlayFastReverse() const = 0;
</span><del>-    virtual Vector&lt;WTF::String&gt; audioMediaSelectionOptions() const = 0;
</del><ins>+    virtual Vector&lt;String&gt; audioMediaSelectionOptions() const = 0;
</ins><span class="cx">     virtual uint64_t audioMediaSelectedIndex() const = 0;
</span><del>-    virtual Vector&lt;WTF::String&gt; legibleMediaSelectionOptions() const = 0;
</del><ins>+    virtual Vector&lt;String&gt; legibleMediaSelectionOptions() const = 0;
</ins><span class="cx">     virtual uint64_t legibleMediaSelectedIndex() const = 0;
</span><span class="cx">     virtual bool externalPlaybackEnabled() const = 0;
</span><ins>+    virtual ExternalPlaybackTargetType externalPlaybackTargetType() const = 0;
+    virtual String externalPlaybackLocalizedDeviceName() const = 0;
</ins><span class="cx">     virtual bool wirelessVideoPlaybackDisabled() const = 0;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class WebPlaybackSessionModelClient {
+public:
+    virtual ~WebPlaybackSessionModelClient() { };
+    virtual void durationChanged(double) { }
+    virtual void currentTimeChanged(double /* currentTime */, double /* anchorTime */) { }
+    virtual void bufferedTimeChanged(double) { }
+    virtual void rateChanged(bool /* isPlaying */, float /* playbackRate */) { }
+    virtual void seekableRangesChanged(const TimeRanges&amp;) { }
+    virtual void canPlayFastReverseChanged(bool) { }
+    virtual void audioMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; /* options */, uint64_t /* selectedIndex */) { }
+    virtual void legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; /* options */, uint64_t /* selectedIndex */) { }
+    virtual void externalPlaybackChanged(bool /* enabled */, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp; /* localizedDeviceName */) { }
+    virtual void wirelessVideoPlaybackDisabledChanged(bool) { }
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;EventListener.h&quot;
</span><span class="cx"> #include &quot;HTMLMediaElementEnums.h&quot;
</span><span class="cx"> #include &quot;WebPlaybackSessionModel.h&quot;
</span><ins>+#include &lt;wtf/HashSet.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -46,7 +47,6 @@
</span><span class="cx">         return adoptRef(*new WebPlaybackSessionModelMediaElement());
</span><span class="cx">     }
</span><span class="cx">     WEBCORE_EXPORT virtual ~WebPlaybackSessionModelMediaElement();
</span><del>-    WEBCORE_EXPORT void setWebPlaybackSessionInterface(WebPlaybackSessionInterface*);
</del><span class="cx">     WEBCORE_EXPORT void setMediaElement(HTMLMediaElement*);
</span><span class="cx">     WEBCORE_EXPORT HTMLMediaElement* mediaElement() const { return m_mediaElement.get(); }
</span><span class="cx"> 
</span><span class="lines">@@ -54,6 +54,8 @@
</span><span class="cx">     void updateForEventName(const WTF::AtomicString&amp;);
</span><span class="cx">     bool operator==(const EventListener&amp; rhs) const final { return static_cast&lt;const WebCore::EventListener*&gt;(this) == &amp;rhs; }
</span><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT void addClient(WebPlaybackSessionModelClient&amp;);
+    WEBCORE_EXPORT void removeClient(WebPlaybackSessionModelClient&amp;);
</ins><span class="cx">     WEBCORE_EXPORT void play() final;
</span><span class="cx">     WEBCORE_EXPORT void pause() final;
</span><span class="cx">     WEBCORE_EXPORT void togglePlayState() final;
</span><span class="lines">@@ -79,6 +81,8 @@
</span><span class="cx">     Vector&lt;WTF::String&gt; legibleMediaSelectionOptions() const final;
</span><span class="cx">     uint64_t legibleMediaSelectedIndex() const final;
</span><span class="cx">     bool externalPlaybackEnabled() const final;
</span><ins>+    ExternalPlaybackTargetType externalPlaybackTargetType() const final;
+    String externalPlaybackLocalizedDeviceName() const final;
</ins><span class="cx">     bool wirelessVideoPlaybackDisabled() const final;
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="lines">@@ -90,7 +94,7 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;HTMLMediaElement&gt; m_mediaElement;
</span><span class="cx">     bool m_isListening { false };
</span><del>-    WebPlaybackSessionInterface* m_playbackSessionInterface { nullptr };
</del><ins>+    HashSet&lt;WebPlaybackSessionModelClient*&gt; m_clients;
</ins><span class="cx">     Vector&lt;RefPtr&lt;TextTrack&gt;&gt; m_legibleTracksForMenu;
</span><span class="cx">     Vector&lt;RefPtr&lt;AudioTrack&gt;&gt; m_audioTracksForMenu;
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -56,35 +56,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface(WebPlaybackSessionInterface* interface)
-{
-    if (interface == m_playbackSessionInterface)
-        return;
-
-    m_playbackSessionInterface = interface;
-
-    if (!m_playbackSessionInterface)
-        return;
-
-    m_playbackSessionInterface-&gt;resetMediaState();
-    m_playbackSessionInterface-&gt;setDuration(duration());
-    m_playbackSessionInterface-&gt;setCurrentTime(currentTime(), [[NSProcessInfo processInfo] systemUptime]);
-    m_playbackSessionInterface-&gt;setBufferedTime(bufferedTime());
-    m_playbackSessionInterface-&gt;setRate(isPlaying(), playbackRate());
-    m_playbackSessionInterface-&gt;setSeekableRanges(seekableRanges());
-    m_playbackSessionInterface-&gt;setCanPlayFastReverse(canPlayFastReverse());
-    m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(wirelessVideoPlaybackDisabled());
-    updateLegibleOptions();
-}
-
</del><span class="cx"> void WebPlaybackSessionModelMediaElement::setMediaElement(HTMLMediaElement* mediaElement)
</span><span class="cx"> {
</span><span class="cx">     if (m_mediaElement == mediaElement)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (m_playbackSessionInterface)
-        m_playbackSessionInterface-&gt;resetMediaState();
-
</del><span class="cx">     if (m_mediaElement &amp;&amp; m_isListening) {
</span><span class="cx">         for (auto&amp; eventName : observedEventNames())
</span><span class="cx">             m_mediaElement-&gt;removeEventListener(eventName, *this, false);
</span><span class="lines">@@ -93,17 +69,13 @@
</span><span class="cx"> 
</span><span class="cx">     m_mediaElement = mediaElement;
</span><span class="cx"> 
</span><del>-    if (!m_mediaElement)
-        return;
</del><ins>+    if (m_mediaElement) {
+        for (auto&amp; eventName : observedEventNames())
+            m_mediaElement-&gt;addEventListener(eventName, *this, false);
+        m_isListening = true;
+    }
</ins><span class="cx"> 
</span><del>-    for (auto&amp; eventName : observedEventNames())
-        m_mediaElement-&gt;addEventListener(eventName, *this, false);
-    m_isListening = true;
-
</del><span class="cx">     updateForEventName(eventNameAll());
</span><del>-
-    if (m_playbackSessionInterface)
-        m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(m_mediaElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement));
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionModelMediaElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
</span><span class="lines">@@ -113,7 +85,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionModelMediaElement::updateForEventName(const WTF::AtomicString&amp; eventName)
</span><span class="cx"> {
</span><del>-    if (!m_mediaElement || !m_playbackSessionInterface)
</del><ins>+    if (m_clients.isEmpty())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     bool all = eventName == eventNameAll();
</span><span class="lines">@@ -120,24 +92,39 @@
</span><span class="cx"> 
</span><span class="cx">     if (all
</span><span class="cx">         || eventName == eventNames().durationchangeEvent) {
</span><del>-        m_playbackSessionInterface-&gt;setDuration(m_mediaElement-&gt;duration());
</del><ins>+        double duration = this-&gt;duration();
+        for (auto client : m_clients)
+            client-&gt;durationChanged(duration);
</ins><span class="cx">         // These is no standard event for minFastReverseRateChange; duration change is a reasonable proxy for it.
</span><span class="cx">         // It happens every time a new item becomes ready to play.
</span><del>-        m_playbackSessionInterface-&gt;setCanPlayFastReverse(m_mediaElement-&gt;minFastReverseRate() &lt; 0.0);
</del><ins>+        bool canPlayFastReverse = this-&gt;canPlayFastReverse();
+        for (auto client : m_clients)
+            client-&gt;canPlayFastReverseChanged(canPlayFastReverse);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (all
</span><span class="cx">         || eventName == eventNames().pauseEvent
</span><span class="cx">         || eventName == eventNames().playEvent
</span><del>-        || eventName == eventNames().ratechangeEvent)
-        m_playbackSessionInterface-&gt;setRate(!m_mediaElement-&gt;paused(), m_mediaElement-&gt;playbackRate());
</del><ins>+        || eventName == eventNames().ratechangeEvent) {
+        bool isPlaying = this-&gt;isPlaying();
+        float playbackRate = this-&gt;playbackRate();
+        for (auto client : m_clients)
+            client-&gt;rateChanged(isPlaying, playbackRate);
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (all
</span><span class="cx">         || eventName == eventNames().timeupdateEvent) {
</span><del>-        m_playbackSessionInterface-&gt;setCurrentTime(m_mediaElement-&gt;currentTime(), [[NSProcessInfo processInfo] systemUptime]);
-        m_playbackSessionInterface-&gt;setBufferedTime(m_mediaElement-&gt;maxBufferedTime());
-        // FIXME: 130788 - find a better event to update seekable ranges from.
-        m_playbackSessionInterface-&gt;setSeekableRanges(m_mediaElement-&gt;seekable());
</del><ins>+        auto currentTime = this-&gt;currentTime();
+        auto anchorTime = [[NSProcessInfo processInfo] systemUptime];
+        auto bufferedTime = this-&gt;bufferedTime();
+        auto seekableRanges = this-&gt;seekableRanges();
+
+        for (auto client : m_clients) {
+            client-&gt;currentTimeChanged(currentTime, anchorTime);
+            client-&gt;bufferedTimeChanged(bufferedTime);
+            // FIXME: 130788 - find a better event from which to update seekable ranges.
+            client-&gt;seekableRangesChanged(seekableRanges);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (all
</span><span class="lines">@@ -147,23 +134,30 @@
</span><span class="cx"> 
</span><span class="cx">     if (all
</span><span class="cx">         || eventName == eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent) {
</span><del>-        bool enabled = m_mediaElement-&gt;webkitCurrentPlaybackTargetIsWireless();
-        WebPlaybackSessionInterface::ExternalPlaybackTargetType targetType = WebPlaybackSessionInterface::TargetTypeNone;
-        String localizedDeviceName;
</del><ins>+        bool enabled = externalPlaybackEnabled();
+        ExternalPlaybackTargetType targetType = externalPlaybackTargetType();
+        String localizedDeviceName = externalPlaybackLocalizedDeviceName();
</ins><span class="cx"> 
</span><del>-        if (m_mediaElement-&gt;mediaControlsHost()) {
-            auto type = m_mediaElement-&gt;mediaControlsHost()-&gt;externalDeviceType();
-            if (type == MediaControlsHost::DeviceType::Airplay)
-                targetType = WebPlaybackSessionInterface::TargetTypeAirPlay;
-            else if (type == MediaControlsHost::DeviceType::Tvout)
-                targetType = WebPlaybackSessionInterface::TargetTypeTVOut;
-            localizedDeviceName = m_mediaElement-&gt;mediaControlsHost()-&gt;externalDeviceDisplayName();
</del><ins>+        bool wirelessVideoPlaybackDisabled = this-&gt;wirelessVideoPlaybackDisabled();
+
+        for (auto client : m_clients) {
+            client-&gt;externalPlaybackChanged(enabled, targetType, localizedDeviceName);
+            client-&gt;wirelessVideoPlaybackDisabledChanged(wirelessVideoPlaybackDisabled);
</ins><span class="cx">         }
</span><del>-        m_playbackSessionInterface-&gt;setExternalPlayback(enabled, targetType, localizedDeviceName);
-        m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(m_mediaElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement));
</del><span class="cx">     }
</span><span class="cx"> }
</span><ins>+void WebPlaybackSessionModelMediaElement::addClient(WebPlaybackSessionModelClient&amp; client)
+{
+    ASSERT(!m_clients.contains(&amp;client));
+    m_clients.add(&amp;client);
+}
</ins><span class="cx"> 
</span><ins>+void WebPlaybackSessionModelMediaElement::removeClient(WebPlaybackSessionModelClient&amp; client)
+{
+    ASSERT(m_clients.contains(&amp;client));
+    m_clients.remove(&amp;client);
+}
+
</ins><span class="cx"> void WebPlaybackSessionModelMediaElement::play()
</span><span class="cx"> {
</span><span class="cx">     if (m_mediaElement)
</span><span class="lines">@@ -279,31 +273,37 @@
</span><span class="cx">     else
</span><span class="cx">         m_audioTracksForMenu.clear();
</span><span class="cx"> 
</span><del>-    m_playbackSessionInterface-&gt;setAudioMediaSelectionOptions(audioMediaSelectionOptions(), audioMediaSelectedIndex());
-    m_playbackSessionInterface-&gt;setLegibleMediaSelectionOptions(legibleMediaSelectionOptions(), legibleMediaSelectedIndex());
</del><ins>+    auto audioOptions = audioMediaSelectionOptions();
+    auto audioIndex = audioMediaSelectedIndex();
+    auto legibleOptions = legibleMediaSelectionOptions();
+    auto legibleIndex = legibleMediaSelectedIndex();
+
+    for (auto client : m_clients) {
+        client-&gt;audioMediaSelectionOptionsChanged(audioOptions, audioIndex);
+        client-&gt;legibleMediaSelectionOptionsChanged(legibleOptions, legibleIndex);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-const Vector&lt;AtomicString&gt;&amp;  WebPlaybackSessionModelMediaElement::observedEventNames()
</del><ins>+const Vector&lt;AtomicString&gt;&amp; WebPlaybackSessionModelMediaElement::observedEventNames()
</ins><span class="cx"> {
</span><del>-    static NeverDestroyed&lt;Vector&lt;AtomicString&gt;&gt; sEventNames;
-
-    if (!sEventNames.get().size()) {
-        sEventNames.get().append(eventNames().durationchangeEvent);
-        sEventNames.get().append(eventNames().pauseEvent);
-        sEventNames.get().append(eventNames().playEvent);
-        sEventNames.get().append(eventNames().ratechangeEvent);
-        sEventNames.get().append(eventNames().timeupdateEvent);
-        sEventNames.get().append(eventNames().addtrackEvent);
-        sEventNames.get().append(eventNames().removetrackEvent);
-        sEventNames.get().append(eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent);
-    }
-    return sEventNames.get();
</del><ins>+    // FIXME(157452): Remove the right-hand constructor notation once NeverDestroyed supports initializer_lists.
+    static NeverDestroyed&lt;Vector&lt;AtomicString&gt;&gt; names = Vector&lt;AtomicString&gt;({
+        eventNames().durationchangeEvent,
+        eventNames().pauseEvent,
+        eventNames().playEvent,
+        eventNames().ratechangeEvent,
+        eventNames().timeupdateEvent,
+        eventNames().addtrackEvent,
+        eventNames().removetrackEvent,
+        eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent,
+    });
+    return names.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const AtomicString&amp;  WebPlaybackSessionModelMediaElement::eventNameAll()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed&lt;AtomicString&gt; sEventNameAll = &quot;allEvents&quot;;
-    return sEventNameAll;
</del><ins>+    static NeverDestroyed&lt;AtomicString&gt; eventNameAll(&quot;allEvents&quot;, AtomicString::ConstructFromLiteral);
+    return eventNameAll;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double WebPlaybackSessionModelMediaElement::duration() const
</span><span class="lines">@@ -341,7 +341,7 @@
</span><span class="cx">     return m_mediaElement ? m_mediaElement-&gt;minFastReverseRate() &lt; 0.0 : false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Vector&lt;WTF::String&gt; WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions() const
</del><ins>+Vector&lt;String&gt; WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions() const
</ins><span class="cx"> {
</span><span class="cx">     Vector&lt;String&gt; audioTrackDisplayNames;
</span><span class="cx"> 
</span><span class="lines">@@ -350,8 +350,9 @@
</span><span class="cx"> 
</span><span class="cx">     auto&amp; captionPreferences = m_mediaElement-&gt;document().page()-&gt;group().captionPreferences();
</span><span class="cx"> 
</span><ins>+    audioTrackDisplayNames.reserveInitialCapacity(m_audioTracksForMenu.size());
</ins><span class="cx">     for (auto&amp; audioTrack : m_audioTracksForMenu)
</span><del>-        audioTrackDisplayNames.append(captionPreferences.displayNameForTrack(audioTrack.get()));
</del><ins>+        audioTrackDisplayNames.uncheckedAppend(captionPreferences.displayNameForTrack(audioTrack.get()));
</ins><span class="cx"> 
</span><span class="cx">     return audioTrackDisplayNames;
</span><span class="cx"> }
</span><span class="lines">@@ -362,7 +363,7 @@
</span><span class="cx">         if (m_audioTracksForMenu[index]-&gt;enabled())
</span><span class="cx">             return index;
</span><span class="cx">     }
</span><del>-    return 0;
</del><ins>+    return std::numeric_limits&lt;uint64_t&gt;::max();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Vector&lt;WTF::String&gt; WebPlaybackSessionModelMediaElement::legibleMediaSelectionOptions() const
</span><span class="lines">@@ -382,16 +383,18 @@
</span><span class="cx"> 
</span><span class="cx"> uint64_t WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex() const
</span><span class="cx"> {
</span><del>-    uint64_t selectedIndex = 0;
</del><ins>+    uint64_t selectedIndex = std::numeric_limits&lt;uint64_t&gt;::max();
</ins><span class="cx">     uint64_t offIndex = 0;
</span><span class="cx">     bool trackMenuItemSelected = false;
</span><span class="cx"> 
</span><del>-    if (!m_mediaElement || !m_mediaElement-&gt;mediaControlsHost())
</del><ins>+    auto host = m_mediaElement ? m_mediaElement-&gt;mediaControlsHost() : nullptr;
+
+    if (!host)
</ins><span class="cx">         return selectedIndex;
</span><span class="cx"> 
</span><del>-    AtomicString displayMode = m_mediaElement-&gt;mediaControlsHost()-&gt;captionDisplayMode();
-    TextTrack* offItem = m_mediaElement-&gt;mediaControlsHost()-&gt;captionMenuOffItem();
-    TextTrack* automaticItem = m_mediaElement-&gt;mediaControlsHost()-&gt;captionMenuAutomaticItem();
</del><ins>+    AtomicString displayMode = host-&gt;captionDisplayMode();
+    TextTrack* offItem = host-&gt;captionMenuOffItem();
+    TextTrack* automaticItem = host-&gt;captionMenuAutomaticItem();
</ins><span class="cx"> 
</span><span class="cx">     for (size_t index = 0; index &lt; m_legibleTracksForMenu.size(); index++) {
</span><span class="cx">         auto&amp; track = m_legibleTracksForMenu[index];
</span><span class="lines">@@ -417,12 +420,37 @@
</span><span class="cx"> 
</span><span class="cx"> bool WebPlaybackSessionModelMediaElement::externalPlaybackEnabled() const
</span><span class="cx"> {
</span><del>-    return m_mediaElement ? m_mediaElement-&gt;webkitCurrentPlaybackTargetIsWireless() : false;
</del><ins>+    return m_mediaElement &amp;&amp; m_mediaElement-&gt;webkitCurrentPlaybackTargetIsWireless();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WebPlaybackSessionModel::ExternalPlaybackTargetType WebPlaybackSessionModelMediaElement::externalPlaybackTargetType() const
+{
+    if (!m_mediaElement || !m_mediaElement-&gt;mediaControlsHost())
+        return TargetTypeNone;
+
+    switch (m_mediaElement-&gt;mediaControlsHost()-&gt;externalDeviceType()) {
+    default:
+        ASSERT_NOT_REACHED();
+        return TargetTypeNone;
+    case MediaControlsHost::DeviceType::None:
+        return TargetTypeNone;
+    case MediaControlsHost::DeviceType::Airplay:
+        return TargetTypeAirPlay;
+    case MediaControlsHost::DeviceType::Tvout:
+        return TargetTypeTVOut;
+    }
+}
+
+String WebPlaybackSessionModelMediaElement::externalPlaybackLocalizedDeviceName() const
+{
+    if (m_mediaElement &amp;&amp; m_mediaElement-&gt;mediaControlsHost())
+        return m_mediaElement-&gt;mediaControlsHost()-&gt;externalDeviceDisplayName();
+    return emptyString();
+}
+
</ins><span class="cx"> bool WebPlaybackSessionModelMediaElement::wirelessVideoPlaybackDisabled() const
</span><span class="cx"> {
</span><del>-    return m_mediaElement ? m_mediaElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement) : false;
</del><ins>+    return m_mediaElement &amp;&amp; m_mediaElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebVideoFullscreenInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -36,10 +36,9 @@
</span><span class="cx"> 
</span><span class="cx"> class TimeRanges;
</span><span class="cx"> 
</span><del>-class WebVideoFullscreenInterface : public WebPlaybackSessionInterface {
</del><ins>+class WebVideoFullscreenInterface {
</ins><span class="cx"> public:
</span><span class="cx">     virtual ~WebVideoFullscreenInterface() { };
</span><del>-    virtual void setVideoDimensions(bool hasVideo, float width, float height) = 0;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -35,17 +35,32 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class WebVideoFullscreenModelClient;
+
</ins><span class="cx"> class WebVideoFullscreenModel {
</span><span class="cx"> public:
</span><span class="cx">     virtual ~WebVideoFullscreenModel() { };
</span><ins>+    virtual void addClient(WebVideoFullscreenModelClient&amp;) = 0;
+    virtual void removeClient(WebVideoFullscreenModelClient&amp;)= 0;
+
</ins><span class="cx">     virtual void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) = 0;
</span><span class="cx">     virtual void setVideoLayerFrame(FloatRect) = 0;
</span><span class="cx">     enum VideoGravity { VideoGravityResize, VideoGravityResizeAspect, VideoGravityResizeAspectFill };
</span><span class="cx">     virtual void setVideoLayerGravity(VideoGravity) = 0;
</span><span class="cx">     virtual void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) = 0;
</span><ins>+
</ins><span class="cx">     virtual bool isVisible() const = 0;
</span><ins>+    virtual FloatSize videoDimensions() const = 0;
+    virtual bool hasVideo() const = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class WebVideoFullscreenModelClient {
+public:
+    virtual ~WebVideoFullscreenModelClient() { }
+    virtual void hasVideoChanged(bool) = 0;
+    virtual void videoDimensionsChanged(const FloatSize&amp;) = 0;
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelVideoElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;PlatformLayer.h&quot;
</span><span class="cx"> #include &quot;WebVideoFullscreenModel.h&quot;
</span><span class="cx"> #include &lt;functional&gt;
</span><ins>+#include &lt;wtf/HashSet.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="lines">@@ -44,44 +45,50 @@
</span><span class="cx"> class HTMLVideoElement;
</span><span class="cx"> class TextTrack;
</span><span class="cx"> class WebPlaybackSessionModelMediaElement;
</span><del>-class WebVideoFullscreenInterface;
</del><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenModelVideoElement : public WebVideoFullscreenModel, public EventListener {
</span><span class="cx"> public:
</span><del>-    static RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; create(WebPlaybackSessionModelMediaElement&amp; playbackSessionModel)
</del><ins>+    static RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; create()
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new WebVideoFullscreenModelVideoElement(playbackSessionModel));
</del><ins>+        return adoptRef(*new WebVideoFullscreenModelVideoElement());
</ins><span class="cx">     }
</span><span class="cx">     WEBCORE_EXPORT virtual ~WebVideoFullscreenModelVideoElement();
</span><del>-    WEBCORE_EXPORT void setWebVideoFullscreenInterface(WebVideoFullscreenInterface*);
</del><span class="cx">     WEBCORE_EXPORT void setVideoElement(HTMLVideoElement*);
</span><span class="cx">     WEBCORE_EXPORT HTMLVideoElement* videoElement() const { return m_videoElement.get(); }
</span><span class="cx">     WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, std::function&lt;void()&gt; completionHandler = [] { });
</span><span class="cx">     WEBCORE_EXPORT void waitForPreparedForInlineThen(std::function&lt;void()&gt; completionHandler = [] { });
</span><del>-    WebPlaybackSessionModelMediaElement&amp; playbackSessionModel() { return m_playbackSessionModel; }
</del><span class="cx">     
</span><span class="cx">     WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
</span><span class="cx">     void updateForEventName(const WTF::AtomicString&amp;);
</span><span class="cx">     bool operator==(const EventListener&amp; rhs) const override { return static_cast&lt;const WebCore::EventListener*&gt;(this) == &amp;rhs; }
</span><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT void addClient(WebVideoFullscreenModelClient&amp;) override;
+    WEBCORE_EXPORT void removeClient(WebVideoFullscreenModelClient&amp;) override;
</ins><span class="cx">     WEBCORE_EXPORT void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) override;
</span><span class="cx">     WEBCORE_EXPORT void setVideoLayerFrame(FloatRect) override;
</span><span class="cx">     WEBCORE_EXPORT void setVideoLayerGravity(VideoGravity) override;
</span><span class="cx">     WEBCORE_EXPORT void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) override;
</span><span class="cx">     WEBCORE_EXPORT bool isVisible() const override;
</span><ins>+    WEBCORE_EXPORT FloatSize videoDimensions() const override { return m_videoDimensions; }
+    WEBCORE_EXPORT bool hasVideo() const override { return m_hasVideo; }
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> protected:
</span><del>-    WEBCORE_EXPORT WebVideoFullscreenModelVideoElement(WebPlaybackSessionModelMediaElement&amp;);
</del><ins>+    WEBCORE_EXPORT WebVideoFullscreenModelVideoElement();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    void setHasVideo(bool);
+    void setVideoDimensions(const FloatSize&amp;);
+
</ins><span class="cx">     static const Vector&lt;WTF::AtomicString&gt;&amp; observedEventNames();
</span><span class="cx">     const WTF::AtomicString&amp; eventNameAll();
</span><span class="cx"> 
</span><del>-    Ref&lt;WebPlaybackSessionModelMediaElement&gt; m_playbackSessionModel;
</del><span class="cx">     RefPtr&lt;HTMLVideoElement&gt; m_videoElement;
</span><span class="cx">     RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
</span><span class="cx">     bool m_isListening { false };
</span><del>-    WebVideoFullscreenInterface* m_videoFullscreenInterface { nullptr };
</del><ins>+    HashSet&lt;WebVideoFullscreenModelClient*&gt; m_clients;
+    bool m_hasVideo { false };
+    FloatSize m_videoDimensions;
</ins><span class="cx">     FloatRect m_videoFrame;
</span><span class="cx">     Vector&lt;RefPtr&lt;TextTrack&gt;&gt; m_legibleTracksForMenu;
</span><span class="cx">     Vector&lt;RefPtr&lt;AudioTrack&gt;&gt; m_audioTracksForMenu;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelVideoElementmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -48,9 +48,8 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement(WebPlaybackSessionModelMediaElement&amp; playbackSessionModel)
</del><ins>+WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement()
</ins><span class="cx">     : EventListener(EventListener::CPPEventListenerType)
</span><del>-    , m_playbackSessionModel(playbackSessionModel)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -58,18 +57,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface(WebVideoFullscreenInterface* interface)
-{
-    if (interface == m_videoFullscreenInterface)
-        return;
-
-    m_videoFullscreenInterface = interface;
-    m_playbackSessionModel-&gt;setWebPlaybackSessionInterface(interface);
-
-    if (m_videoFullscreenInterface &amp;&amp; m_videoElement)
-        m_videoFullscreenInterface-&gt;setVideoDimensions(true, m_videoElement-&gt;videoWidth(), m_videoElement-&gt;videoHeight());
-}
-
</del><span class="cx"> void WebVideoFullscreenModelVideoElement::setVideoElement(HTMLVideoElement* videoElement)
</span><span class="cx"> {
</span><span class="cx">     if (m_videoElement == videoElement)
</span><span class="lines">@@ -86,17 +73,13 @@
</span><span class="cx"> 
</span><span class="cx">     m_videoElement = videoElement;
</span><span class="cx"> 
</span><del>-    if (!m_videoElement)
-        return;
</del><ins>+    if (m_videoElement) {
+        for (auto&amp; eventName : observedEventNames())
+            m_videoElement-&gt;addEventListener(eventName, *this, false);
+        m_isListening = true;
+    }
</ins><span class="cx"> 
</span><del>-    for (auto&amp; eventName : observedEventNames())
-        m_videoElement-&gt;addEventListener(eventName, *this, false);
-    m_isListening = true;
-
</del><span class="cx">     updateForEventName(eventNameAll());
</span><del>-
-    if (m_videoFullscreenInterface)
-        m_videoFullscreenInterface-&gt;setVideoDimensions(true, videoElement-&gt;videoWidth(), videoElement-&gt;videoHeight());
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
</span><span class="lines">@@ -106,14 +89,16 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::updateForEventName(const WTF::AtomicString&amp; eventName)
</span><span class="cx"> {
</span><del>-    if (!m_videoElement || !m_videoFullscreenInterface)
</del><ins>+    if (m_clients.isEmpty())
</ins><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     bool all = eventName == eventNameAll();
</span><span class="cx"> 
</span><span class="cx">     if (all
</span><del>-        || eventName == eventNames().resizeEvent)
-        m_videoFullscreenInterface-&gt;setVideoDimensions(true, m_videoElement-&gt;videoWidth(), m_videoElement-&gt;videoHeight());
</del><ins>+        || eventName == eventNames().resizeEvent) {
+        setHasVideo(m_videoElement);
+        setVideoDimensions(m_videoElement ? FloatSize(m_videoElement-&gt;videoWidth(), m_videoElement-&gt;videoHeight()) : FloatSize());
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer(PlatformLayer* videoLayer, std::function&lt;void()&gt; completionHandler)
</span><span class="lines">@@ -199,6 +184,18 @@
</span><span class="cx">         m_videoElement-&gt;fullscreenModeChanged(videoFullscreenMode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenModelVideoElement::addClient(WebVideoFullscreenModelClient&amp; client)
+{
+    ASSERT(!m_clients.contains(&amp;client));
+    m_clients.add(&amp;client);
+}
+
+void WebVideoFullscreenModelVideoElement::removeClient(WebVideoFullscreenModelClient&amp; client)
+{
+    ASSERT(m_clients.contains(&amp;client));
+    m_clients.remove(&amp;client);
+}
+
</ins><span class="cx"> bool WebVideoFullscreenModelVideoElement::isVisible() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_videoElement)
</span><span class="lines">@@ -210,4 +207,26 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenModelVideoElement::setHasVideo(bool hasVideo)
+{
+    if (hasVideo == m_hasVideo)
+        return;
+
+    m_hasVideo = hasVideo;
+
+    for (auto&amp; client : m_clients)
+        client-&gt;hasVideoChanged(m_hasVideo);
+}
+
+void WebVideoFullscreenModelVideoElement::setVideoDimensions(const FloatSize&amp; videoDimensions)
+{
+    if (m_videoDimensions == videoDimensions)
+        return;
+
+    m_videoDimensions = videoDimensions;
+
+    for (auto&amp; client : m_clients)
+        client-&gt;videoDimensionsChanged(m_videoDimensions);
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebAVPlayerControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebAVPlayerController.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebAVPlayerController.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/ios/WebAVPlayerController.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -42,8 +42,6 @@
</span><span class="cx">     BOOL _pictureInPictureInterrupted;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)resetState;
-
</del><span class="cx"> @property (retain) AVPlayerController* playerControllerProxy;
</span><span class="cx"> @property (assign) WebCore::WebPlaybackSessionModel* delegate;
</span><span class="cx"> @property (assign) WebCore::WebPlaybackSessionInterfaceAVKit* playbackSessionInterface;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebAVPlayerControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -74,38 +74,6 @@
</span><span class="cx">     [super dealloc];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)resetState
-{
-    self.contentDuration = 0;
-    self.maxTime = 0;
-    self.contentDurationWithinEndTimes = 0;
-    self.loadedTimeRanges = @[];
-
-    self.canPlay = NO;
-    self.canPause = NO;
-    self.canTogglePlayback = NO;
-    self.hasEnabledAudio = NO;
-    self.canSeek = NO;
-    self.minTime = 0;
-    self.status = AVPlayerControllerStatusUnknown;
-
-    self.timing = nil;
-    self.rate = 0;
-
-    self.hasEnabledVideo = NO;
-    self.contentDimensions = CGSizeMake(0, 0);
-
-    self.seekableTimeRanges = [NSMutableArray array];
-
-    self.canScanBackward = NO;
-
-    self.audioMediaSelectionOptions = nil;
-    self.currentAudioMediaSelectionOption = nil;
-
-    self.legibleMediaSelectionOptions = nil;
-    self.currentLegibleMediaSelectionOption = nil;
-}
-
</del><span class="cx"> - (AVPlayer *)player
</span><span class="cx"> {
</span><span class="cx">     return nil;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebPlaybackSessionInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;HTMLMediaElementEnums.h&quot;
</span><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="cx"> #include &quot;WebPlaybackSessionInterface.h&quot;
</span><ins>+#include &quot;WebPlaybackSessionModel.h&quot;
</ins><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;objc/objc.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="lines">@@ -54,52 +55,43 @@
</span><span class="cx"> class WebPlaybackSessionModel;
</span><span class="cx"> class WebPlaybackSessionChangeObserver;
</span><span class="cx"> 
</span><del>-class WebPlaybackSessionInterfaceAVKitClient {
-public:
-    virtual ~WebPlaybackSessionInterfaceAVKitClient() { }
-
-    virtual void externalPlaybackEnabledChanged(bool) = 0;
-};
-
</del><span class="cx"> class WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit
</span><span class="cx">     : public WebPlaybackSessionInterface
</span><ins>+    , public WebPlaybackSessionModelClient
</ins><span class="cx">     , public RefCounted&lt;WebPlaybackSessionInterfaceAVKit&gt; {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><del>-    static Ref&lt;WebPlaybackSessionInterfaceAVKit&gt; create()
</del><ins>+    static Ref&lt;WebPlaybackSessionInterfaceAVKit&gt; create(WebPlaybackSessionModel&amp; model)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new WebPlaybackSessionInterfaceAVKit());
</del><ins>+        return adoptRef(*new WebPlaybackSessionInterfaceAVKit(model));
</ins><span class="cx">     }
</span><span class="cx">     virtual ~WebPlaybackSessionInterfaceAVKit();
</span><del>-    WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);
</del><span class="cx">     WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; }
</span><del>-    void setClient(WebPlaybackSessionInterfaceAVKitClient* client) { m_client = client; }
</del><span class="cx"> 
</span><ins>+    // WebPlaybackSessionInterface
</ins><span class="cx">     WEBCORE_EXPORT void resetMediaState() override;
</span><del>-    WEBCORE_EXPORT void setDuration(double) override;
-    WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) override;
-    WEBCORE_EXPORT void setBufferedTime(double) override;
-    WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) override;
-    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&amp;) override;
-    WEBCORE_EXPORT void setCanPlayFastReverse(bool) override;
-    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
-    WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
-    WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
-    WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override;
-    bool wirelessVideoPlaybackDisabled() const;
</del><span class="cx"> 
</span><ins>+    // WebPlaybackSessionModelClient
+    WEBCORE_EXPORT void durationChanged(double) override;
+    WEBCORE_EXPORT void currentTimeChanged(double currentTime, double anchorTime) override;
+    WEBCORE_EXPORT void bufferedTimeChanged(double) override;
+    WEBCORE_EXPORT void rateChanged(bool isPlaying, float playbackRate) override;
+    WEBCORE_EXPORT void seekableRangesChanged(const TimeRanges&amp;) override;
+    WEBCORE_EXPORT void canPlayFastReverseChanged(bool) override;
+    WEBCORE_EXPORT void audioMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
+    WEBCORE_EXPORT void legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
+    WEBCORE_EXPORT void externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp; localizedDeviceName) override;
+    WEBCORE_EXPORT void wirelessVideoPlaybackDisabledChanged(bool) override;
+
</ins><span class="cx">     WEBCORE_EXPORT virtual void invalidate();
</span><span class="cx"> 
</span><span class="cx">     WebAVPlayerController *playerController() const { return m_playerController.get(); }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit();
</del><ins>+    WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit(WebPlaybackSessionModel&amp;);
</ins><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;WebAVPlayerController&gt; m_playerController;
</span><span class="cx">     WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
</span><del>-    WebPlaybackSessionInterfaceAVKitClient* m_client { nullptr};
-
-    bool m_wirelessVideoPlaybackDisabled { true };
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebPlaybackSessionInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -47,31 +47,55 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit()
</del><ins>+WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit(WebPlaybackSessionModel&amp; model)
</ins><span class="cx">     : m_playerController(adoptNS([[WebAVPlayerController alloc] init]))
</span><ins>+    , m_playbackSessionModel(&amp;model)
</ins><span class="cx"> {
</span><ins>+    model.addClient(*this);
</ins><span class="cx">     [m_playerController setPlaybackSessionInterface:this];
</span><ins>+    [m_playerController setDelegate:&amp;model];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit()
</span><span class="cx"> {
</span><del>-    WebAVPlayerController* playerController = m_playerController.get();
-    if (playerController &amp;&amp; playerController.externalPlaybackActive)
-        setExternalPlayback(false, TargetTypeNone, &quot;&quot;);
</del><ins>+    [m_playerController setPlaybackSessionInterface:nullptr];
+    [m_playerController setExternalPlaybackActive:false];
+
+    invalidate();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionInterfaceAVKit::resetMediaState()
</span><span class="cx"> {
</span><del>-    [m_playerController resetState];
-}
</del><ins>+    WebAVPlayerController* playerController = m_playerController.get();
</ins><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel(WebPlaybackSessionModel* model)
-{
-    m_playbackSessionModel = model;
-    [m_playerController setDelegate:m_playbackSessionModel];
</del><ins>+    playerController.contentDuration = 0;
+    playerController.maxTime = 0;
+    playerController.contentDurationWithinEndTimes = 0;
+    playerController.loadedTimeRanges = @[];
+
+    playerController.canPlay = NO;
+    playerController.canPause = NO;
+    playerController.canTogglePlayback = NO;
+    playerController.hasEnabledAudio = NO;
+    playerController.canSeek = NO;
+    playerController.minTime = 0;
+    playerController.status = AVPlayerControllerStatusUnknown;
+
+    playerController.timing = nil;
+    playerController.rate = 0;
+
+    playerController.seekableTimeRanges = [NSMutableArray array];
+
+    playerController.canScanBackward = NO;
+
+    playerController.audioMediaSelectionOptions = nil;
+    playerController.currentAudioMediaSelectionOption = nil;
+
+    playerController.legibleMediaSelectionOptions = nil;
+    playerController.currentLegibleMediaSelectionOption = nil;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setDuration(double duration)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::durationChanged(double duration)
</ins><span class="cx"> {
</span><span class="cx">     WebAVPlayerController* playerController = m_playerController.get();
</span><span class="cx"> 
</span><span class="lines">@@ -90,7 +114,7 @@
</span><span class="cx">     playerController.status = AVPlayerControllerStatusReadyToPlay;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setCurrentTime(double currentTime, double anchorTime)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::currentTimeChanged(double currentTime, double anchorTime)
</ins><span class="cx"> {
</span><span class="cx">     NSTimeInterval anchorTimeStamp = ![m_playerController rate] ? NAN : anchorTime;
</span><span class="cx">     AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
</span><span class="lines">@@ -99,7 +123,7 @@
</span><span class="cx">     [m_playerController setTiming:timing];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setBufferedTime(double bufferedTime)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::bufferedTimeChanged(double bufferedTime)
</ins><span class="cx"> {
</span><span class="cx">     WebAVPlayerController* playerController = m_playerController.get();
</span><span class="cx">     double duration = playerController.contentDuration;
</span><span class="lines">@@ -111,12 +135,12 @@
</span><span class="cx">     playerController.loadedTimeRanges = @[@0, @(normalizedBufferedTime)];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setRate(bool isPlaying, float playbackRate)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::rateChanged(bool isPlaying, float playbackRate)
</ins><span class="cx"> {
</span><span class="cx">     [m_playerController setRate:isPlaying ? playbackRate : 0.];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setSeekableRanges(const TimeRanges&amp; timeRanges)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::seekableRangesChanged(const TimeRanges&amp; timeRanges)
</ins><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;NSMutableArray&gt; seekableRanges = adoptNS([[NSMutableArray alloc] init]);
</span><span class="cx">     ExceptionCode exceptionCode;
</span><span class="lines">@@ -132,7 +156,7 @@
</span><span class="cx">     [m_playerController setSeekableTimeRanges:seekableRanges.get()];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse(bool canPlayFastReverse)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::canPlayFastReverseChanged(bool canPlayFastReverse)
</ins><span class="cx"> {
</span><span class="cx">     [m_playerController setCanScanBackward:canPlayFastReverse];
</span><span class="cx"> }
</span><span class="lines">@@ -148,7 +172,7 @@
</span><span class="cx">     return webOptions;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::audioMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
</span><span class="cx">     [m_playerController setAudioMediaSelectionOptions:webOptions.get()];
</span><span class="lines">@@ -156,7 +180,7 @@
</span><span class="cx">         [m_playerController setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
</span><span class="cx">     [m_playerController setLegibleMediaSelectionOptions:webOptions.get()];
</span><span class="lines">@@ -164,12 +188,12 @@
</span><span class="cx">         [m_playerController setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType targetType, const String&amp; localizedDeviceName)
</ins><span class="cx"> {
</span><span class="cx">     AVPlayerControllerExternalPlaybackType externalPlaybackType = AVPlayerControllerExternalPlaybackTypeNone;
</span><del>-    if (targetType == TargetTypeAirPlay)
</del><ins>+    if (targetType == WebPlaybackSessionModel::TargetTypeAirPlay)
</ins><span class="cx">         externalPlaybackType = AVPlayerControllerExternalPlaybackTypeAirPlay;
</span><del>-    else if (targetType == TargetTypeTVOut)
</del><ins>+    else if (targetType == WebPlaybackSessionModel::TargetTypeTVOut)
</ins><span class="cx">         externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut;
</span><span class="cx"> 
</span><span class="cx">     WebAVPlayerController* playerController = m_playerController.get();
</span><span class="lines">@@ -176,24 +200,21 @@
</span><span class="cx">     playerController.externalPlaybackAirPlayDeviceLocalizedName = localizedDeviceName;
</span><span class="cx">     playerController.externalPlaybackType = externalPlaybackType;
</span><span class="cx">     playerController.externalPlaybackActive = enabled;
</span><del>-
-    if (m_client)
-        m_client-&gt;externalPlaybackEnabledChanged(enabled);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled)
</del><ins>+void WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabledChanged(bool disabled)
</ins><span class="cx"> {
</span><span class="cx">     [m_playerController setAllowsExternalPlayback:!disabled];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled() const
</del><ins>+void WebPlaybackSessionInterfaceAVKit::invalidate()
</ins><span class="cx"> {
</span><del>-    return [m_playerController allowsExternalPlayback];
-}
</del><ins>+    if (!m_playbackSessionModel)
+        return;
</ins><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceAVKit::invalidate()
-{
-    m_playbackSessionModel = nil;
</del><ins>+    [m_playerController setDelegate:nullptr];
+    m_playbackSessionModel-&gt;removeClient(*this);
+    m_playbackSessionModel = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -91,7 +91,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenControllerContext;
</span><del>-class WebVideoFullscreenSessionModel;
</del><span class="cx"> 
</span><span class="cx"> @interface WebVideoFullscreenController (delegate)
</span><span class="cx"> -(void)didFinishFullscreen:(WebVideoFullscreenControllerContext*)context;
</span><span class="lines">@@ -100,7 +99,10 @@
</span><span class="cx"> class WebVideoFullscreenControllerContext final
</span><span class="cx">     : private WebVideoFullscreenInterface
</span><span class="cx">     , private WebVideoFullscreenModel
</span><ins>+    , private WebVideoFullscreenModelClient
</ins><span class="cx">     , private WebVideoFullscreenChangeObserver
</span><ins>+    , private WebPlaybackSessionModel
+    , private WebPlaybackSessionModelClient
</ins><span class="cx">     , public ThreadSafeRefCounted&lt;WebVideoFullscreenControllerContext&gt; {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><span class="lines">@@ -115,19 +117,6 @@
</span><span class="cx">     void requestHideAndExitFullscreen();
</span><span class="cx">     void invalidate();
</span><span class="cx"> 
</span><del>-    void play();
-    void pause();
-    void togglePlayState();
-    void beginScrubbing();
-    void endScrubbing();
-    void seekToTime(double);
-    void fastSeek(double time);
-    void beginScanningForward();
-    void beginScanningBackward();
-    void endScanning();
-    void selectAudioMediaOption(uint64_t);
-    void selectLegibleMediaOption(uint64_t);
-
</del><span class="cx"> private:
</span><span class="cx">     WebVideoFullscreenControllerContext() { }
</span><span class="cx"> 
</span><span class="lines">@@ -138,119 +127,84 @@
</span><span class="cx">     void didCleanupFullscreen() override;
</span><span class="cx">     void fullscreenMayReturnToInline() override;
</span><span class="cx"> 
</span><del>-    // WebVideoFullscreenInterface
-    void resetMediaState() override;
-    void setDuration(double) override;
-    void setCurrentTime(double currentTime, double anchorTime) override;
-    void setBufferedTime(double) override;
-    void setRate(bool isPlaying, float playbackRate) override;
-    void setVideoDimensions(bool hasVideo, float width, float height) override;
-    void setSeekableRanges(const TimeRanges&amp;) override;
-    void setCanPlayFastReverse(bool) override;
-    void setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
-    void setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
-    void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String localizedDeviceName) override;
-    void setWirelessVideoPlaybackDisabled(bool) override;
</del><ins>+    // WebVideoFullscreenModelClient
+    void hasVideoChanged(bool) override;
+    void videoDimensionsChanged(const FloatSize&amp;) override;
</ins><span class="cx"> 
</span><ins>+    // WebPlaybackSessionModel
+    void addClient(WebPlaybackSessionModelClient&amp;) override;
+    void removeClient(WebPlaybackSessionModelClient&amp;) override;
+    void play() override;
+    void pause() override;
+    void togglePlayState() override;
+    void beginScrubbing() override;
+    void endScrubbing() override;
+    void seekToTime(double) override;
+    void fastSeek(double time) override;
+    void beginScanningForward() override;
+    void beginScanningBackward() override;
+    void endScanning() override;
+    void selectAudioMediaOption(uint64_t) override;
+    void selectLegibleMediaOption(uint64_t) override;
+    double duration() const override;
+    double currentTime() const override;
+    double bufferedTime() const override;
+    bool isPlaying() const override;
+    float playbackRate() const override;
+    Ref&lt;TimeRanges&gt; seekableRanges() const override;
+    bool canPlayFastReverse() const override;
+    Vector&lt;String&gt; audioMediaSelectionOptions() const override;
+    uint64_t audioMediaSelectedIndex() const override;
+    Vector&lt;String&gt; legibleMediaSelectionOptions() const override;
+    uint64_t legibleMediaSelectedIndex() const override;
+    bool externalPlaybackEnabled() const override;
+    ExternalPlaybackTargetType externalPlaybackTargetType() const override;
+    String externalPlaybackLocalizedDeviceName() const override;
+    bool wirelessVideoPlaybackDisabled() const override;
+
+    // WebPlaybackSessionModelClient
+    void durationChanged(double) override;
+    void currentTimeChanged(double currentTime, double anchorTime) override;
+    void bufferedTimeChanged(double) override;
+    void rateChanged(bool isPlaying, float playbackRate) override;
+    void seekableRangesChanged(const TimeRanges&amp;) override;
+    void canPlayFastReverseChanged(bool) override;
+    void audioMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
+    void legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
+    void externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp; localizedDeviceName) override;
+    void wirelessVideoPlaybackDisabledChanged(bool) override;
+
</ins><span class="cx">     // WebVideoFullscreenModel
</span><ins>+    void addClient(WebVideoFullscreenModelClient&amp;) override;
+    void removeClient(WebVideoFullscreenModelClient&amp;) override;
</ins><span class="cx">     void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) override;
</span><span class="cx">     void setVideoLayerFrame(FloatRect) override;
</span><span class="cx">     void setVideoLayerGravity(WebVideoFullscreenModel::VideoGravity) override;
</span><span class="cx">     void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) override;
</span><span class="cx">     bool isVisible() const override;
</span><ins>+    bool hasVideo() const override;
+    FloatSize videoDimensions() const override;
</ins><span class="cx"> 
</span><ins>+    HashSet&lt;WebPlaybackSessionModelClient*&gt; m_playbackClients;
+    HashSet&lt;WebVideoFullscreenModelClient*&gt; m_fullscreenClients;
</ins><span class="cx">     RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; m_interface;
</span><del>-    RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; m_model;
</del><ins>+    RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; m_fullscreenModel;
+    RefPtr&lt;WebPlaybackSessionModelMediaElement&gt; m_playbackModel;
</ins><span class="cx">     RefPtr&lt;HTMLVideoElement&gt; m_videoElement;
</span><span class="cx">     RetainPtr&lt;UIView&gt; m_videoFullscreenView;
</span><span class="cx">     RetainPtr&lt;WebVideoFullscreenController&gt; m_controller;
</span><del>-    RefPtr&lt;WebVideoFullscreenSessionModel&gt; m_sessionModel;
</del><span class="cx"> };
</span><span class="cx"> 
</span><del>-
-class WebVideoFullscreenSessionModel final: public RefCounted&lt;WebVideoFullscreenSessionModel&gt;, public WebCore::WebPlaybackSessionModel  {
-public:
-    static Ref&lt;WebVideoFullscreenSessionModel&gt; create(WebVideoFullscreenControllerContext&amp; controller)
-    {
-        return adoptRef(*new WebVideoFullscreenSessionModel(controller));
-    }
-    virtual ~WebVideoFullscreenSessionModel() { }
-
-    void invalidate() { m_controller = nullptr; }
-
-    void setDuration(double duration) { m_duration = duration; }
-    void setCurrentTime(double currentTime) { m_currentTime = currentTime; }
-    void setBufferedTime(double bufferedTime) { m_bufferedTime = bufferedTime; }
-    void setIsPlaying(bool isPlaying) { m_isPlaying = isPlaying; }
-    void setPlaybackRate(float playbackRate) { m_playbackRate = playbackRate; }
-    void setSeekableRanges(WebCore::TimeRanges&amp; seekableRanges) { m_seekableRanges = seekableRanges; }
-    void setCanPlayFastReverse(bool canPlayFastReverse) { m_canPlayFastReverse = canPlayFastReverse; }
-    void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; audioMediaSelectionOptions) { m_audioMediaSelectionOptions = audioMediaSelectionOptions; }
-    void setAudioMediaSelectedIndex(uint64_t audioMediaSelectedIndex) { m_audioMediaSelectedIndex = audioMediaSelectedIndex; }
-    void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; legibleMediaSelectionOptions) { m_legibleMediaSelectionOptions = legibleMediaSelectionOptions; }
-    void setLegibleMediaSelectedIndex(uint64_t legibleMediaSelectedIndex) { m_legibleMediaSelectedIndex = legibleMediaSelectedIndex; }
-    void setExternalPlaybackEnabled(bool externalPlaybackEnabled) { m_externalPlaybackEnabled = externalPlaybackEnabled; }
-    void setWirelessVideoPlaybackDisabled(bool wirelessVideoPlaybackDisabled) { m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled; }
-
-private:
-    WebVideoFullscreenSessionModel(WebVideoFullscreenControllerContext&amp; controller)
-        : m_controller(&amp;controller)
-    {
-    }
-
-    void play() final;
-    void pause() final;
-    void togglePlayState() final;
-    void beginScrubbing() final;
-    void endScrubbing() final;
-    void seekToTime(double) final;
-    void fastSeek(double time) final;
-    void beginScanningForward() final;
-    void beginScanningBackward() final;
-    void endScanning() final;
-    void selectAudioMediaOption(uint64_t) final;
-    void selectLegibleMediaOption(uint64_t) final;
-
-    double duration() const final { return m_duration; }
-    double currentTime() const final { return m_currentTime; }
-    double bufferedTime() const final { return m_bufferedTime; }
-    bool isPlaying() const final { return m_isPlaying; }
-    float playbackRate() const final { return m_playbackRate; }
-    Ref&lt;WebCore::TimeRanges&gt; seekableRanges() const final { return m_seekableRanges.copyRef(); }
-    bool canPlayFastReverse() const final { return m_canPlayFastReverse; }
-    Vector&lt;WTF::String&gt; audioMediaSelectionOptions() const final { return m_audioMediaSelectionOptions; }
-    uint64_t audioMediaSelectedIndex() const final { return m_audioMediaSelectedIndex; }
-    Vector&lt;WTF::String&gt; legibleMediaSelectionOptions() const final { return m_legibleMediaSelectionOptions; }
-    uint64_t legibleMediaSelectedIndex() const final { return m_legibleMediaSelectedIndex; }
-    bool externalPlaybackEnabled() const final { return m_externalPlaybackEnabled; }
-    bool wirelessVideoPlaybackDisabled() const final { return m_wirelessVideoPlaybackDisabled; }
-
-    WebVideoFullscreenControllerContext* m_controller;
-    double m_duration { 0 };
-    double m_currentTime { 0 };
-    double m_bufferedTime { 0 };
-    bool m_isPlaying { false };
-    float m_playbackRate { 0 };
-    Ref&lt;WebCore::TimeRanges&gt; m_seekableRanges { WebCore::TimeRanges::create() };
-    bool m_canPlayFastReverse { false };
-    Vector&lt;WTF::String&gt; m_audioMediaSelectionOptions;
-    uint64_t m_audioMediaSelectedIndex { 0 };
-    Vector&lt;WTF::String&gt; m_legibleMediaSelectionOptions;
-    uint64_t m_legibleMediaSelectedIndex { 0 };
-    bool m_externalPlaybackEnabled { false };
-    bool m_wirelessVideoPlaybackDisabled { false };
-};
-
</del><span class="cx"> #pragma mark WebVideoFullscreenChangeObserver
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenControllerContext::didSetupFullscreen()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isUIThread());
</span><ins>+    RetainPtr&lt;CALayer&gt; videoFullscreenLayer = [m_videoFullscreenView layer];
</ins><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><del>-    RetainPtr&lt;CALayer&gt; videoFullscreenLayer = [m_videoFullscreenView layer];
</del><span class="cx">     WebThreadRun([protectedThis, this, videoFullscreenLayer] {
</span><span class="cx">         [videoFullscreenLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)];
</span><del>-        m_model-&gt;setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis, this] {
</del><ins>+        m_fullscreenModel-&gt;setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis, this] {
</ins><span class="cx">             dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
</span><span class="cx">                 m_interface-&gt;enterFullscreen();
</span><span class="cx">             });
</span><span class="lines">@@ -263,7 +217,7 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        m_model-&gt;setVideoFullscreenLayer(nil, [protectedThis, this] {
</del><ins>+        m_fullscreenModel-&gt;setVideoFullscreenLayer(nil, [protectedThis, this] {
</ins><span class="cx">             dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
</span><span class="cx">                 m_interface-&gt;cleanupFullscreen();
</span><span class="cx">             });
</span><span class="lines">@@ -278,16 +232,14 @@
</span><span class="cx">     m_interface-&gt;setWebVideoFullscreenChangeObserver(nullptr);
</span><span class="cx">     m_interface = nullptr;
</span><span class="cx">     m_videoFullscreenView = nil;
</span><del>-    m_sessionModel-&gt;invalidate();
-    m_sessionModel = nullptr;
</del><span class="cx"> 
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        m_model-&gt;setVideoFullscreenLayer(nil);
-        m_model-&gt;setWebVideoFullscreenInterface(nullptr);
-        m_model-&gt;setVideoElement(nullptr);
-        m_model-&gt;playbackSessionModel().setMediaElement(nullptr);
-        m_model = nullptr;
</del><ins>+        m_fullscreenModel-&gt;setVideoFullscreenLayer(nil);
+        m_fullscreenModel-&gt;setVideoElement(nullptr);
+        m_playbackModel-&gt;setMediaElement(nullptr);
+        m_fullscreenModel-&gt;removeClient(*this);
+        m_fullscreenModel = nullptr;
</ins><span class="cx">         m_videoElement = nullptr;
</span><span class="cx"> 
</span><span class="cx">         [m_controller didFinishFullscreen:this];
</span><span class="lines">@@ -306,160 +258,197 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#pragma mark WebVideoFullscreenInterface
</del><ins>+#pragma mark WebPlaybackSessionModelClient
</ins><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::resetMediaState()
</del><ins>+void WebVideoFullscreenControllerContext::durationChanged(double duration)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent() || isMainThread());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
-        if (m_interface)
-            m_interface-&gt;resetMediaState();
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, duration] {
+            protectedThis-&gt;durationChanged(duration);
+        });
+        return;
+    }
+
+    for (auto&amp; client : m_playbackClients)
+        client-&gt;durationChanged(duration);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setDuration(double duration)
</del><ins>+void WebVideoFullscreenControllerContext::currentTimeChanged(double currentTime, double anchorTime)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, duration] {
-        if (m_interface)
-            m_interface-&gt;setDuration(duration);
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, currentTime, anchorTime] {
+            protectedThis-&gt;currentTimeChanged(currentTime, anchorTime);
+        });
+        return;
+    }
+
+    for (auto&amp; client : m_playbackClients)
+        client-&gt;currentTimeChanged(currentTime, anchorTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setCurrentTime(double currentTime, double anchorTime)
</del><ins>+void WebVideoFullscreenControllerContext::bufferedTimeChanged(double bufferedTime)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, currentTime, anchorTime] {
-        if (m_interface)
-            m_interface-&gt;setCurrentTime(currentTime, anchorTime);
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, bufferedTime] {
+            protectedThis-&gt;bufferedTimeChanged(bufferedTime);
+        });
+        return;
+    }
+
+    for (auto&amp; client : m_playbackClients)
+        client-&gt;bufferedTimeChanged(bufferedTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setBufferedTime(double bufferedTime)
</del><ins>+void WebVideoFullscreenControllerContext::rateChanged(bool isPlaying, float playbackRate)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, bufferedTime] {
-        if (m_interface)
-            m_interface-&gt;setBufferedTime(bufferedTime);
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, isPlaying, playbackRate] {
+            protectedThis-&gt;rateChanged(isPlaying, playbackRate);
+        });
+        return;
+    }
+
+    for (auto&amp; client : m_playbackClients)
+        client-&gt;rateChanged(isPlaying, playbackRate);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setRate(bool isPlaying, float playbackRate)
</del><ins>+void WebVideoFullscreenControllerContext::hasVideoChanged(bool hasVideo)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, isPlaying, playbackRate] {
-        if (m_interface)
-            m_interface-&gt;setRate(isPlaying, playbackRate);
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, hasVideo] {
+            protectedThis-&gt;hasVideoChanged(hasVideo);
+        });
+        return;
+    }
+
+    for (auto&amp; client : m_fullscreenClients)
+        client-&gt;hasVideoChanged(hasVideo);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setVideoDimensions(bool hasVideo, float width, float height)
</del><ins>+void WebVideoFullscreenControllerContext::videoDimensionsChanged(const FloatSize&amp; videoDimensions)
</ins><span class="cx"> {
</span><span class="cx">     if (WebThreadIsCurrent()) {
</span><span class="cx">         RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><del>-        dispatch_async(dispatch_get_main_queue(), [protectedThis, this, hasVideo, width, height] {
-            if (m_interface)
-                m_interface-&gt;setVideoDimensions(hasVideo, width, height);
</del><ins>+        dispatch_async(dispatch_get_main_queue(), [protectedThis, videoDimensions = videoDimensions] {
+            protectedThis-&gt;videoDimensionsChanged(videoDimensions);
</ins><span class="cx">         });
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (m_interface)
-        m_interface-&gt;setVideoDimensions(hasVideo, width, height);
</del><ins>+    for (auto&amp; client : m_fullscreenClients)
+        client-&gt;videoDimensionsChanged(videoDimensions);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setSeekableRanges(const TimeRanges&amp; timeRanges)
</del><ins>+void WebVideoFullscreenControllerContext::seekableRangesChanged(const TimeRanges&amp; timeRanges)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    const PlatformTimeRanges&amp; platformTimeRanges = timeRanges.ranges();
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, platformTimeRanges] {
-        if (m_interface)
-            m_interface-&gt;setSeekableRanges(TimeRanges::create(platformTimeRanges));
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, platformTimeRanges = timeRanges.ranges()] {
+            protectedThis-&gt;seekableRangesChanged(TimeRanges::create(platformTimeRanges));
+        });
+        return;
+    }
+
+    for (auto &amp;client : m_playbackClients)
+        client-&gt;seekableRangesChanged(timeRanges);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setCanPlayFastReverse(bool canPlayFastReverse)
</del><ins>+void WebVideoFullscreenControllerContext::canPlayFastReverseChanged(bool canPlayFastReverse)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, canPlayFastReverse] {
-        if (m_interface)
-            m_interface-&gt;setCanPlayFastReverse(canPlayFastReverse);
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, canPlayFastReverse] {
+            protectedThis-&gt;canPlayFastReverseChanged(canPlayFastReverse);
+        });
+        return;
+    }
+
+    for (auto &amp;client : m_playbackClients)
+        client-&gt;canPlayFastReverseChanged(canPlayFastReverse);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebVideoFullscreenControllerContext::audioMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, options = options, selectedIndex] {
+            protectedThis-&gt;audioMediaSelectionOptionsChanged(options, selectedIndex);
+        });
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    RetainPtr&lt;NSMutableArray&gt; optionsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]);
-    for (auto&amp; name : options)
-        [optionsArray addObject:name];
-    
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, optionsArray, selectedIndex] {
-        Vector&lt;String&gt; options;
-        for (NSString *name : optionsArray.get())
-            options.append(name);
-        
-        if (m_interface)
-            m_interface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
-    });
</del><ins>+    for (auto&amp; client : m_playbackClients)
+        client-&gt;audioMediaSelectionOptionsChanged(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebVideoFullscreenControllerContext::legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    
-    RetainPtr&lt;NSMutableArray&gt; optionsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]);
-    for (auto&amp; name : options)
-        [optionsArray addObject:name];
-    
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, optionsArray, selectedIndex] {
-        Vector&lt;String&gt; options;
-        for (NSString *name : optionsArray.get())
-            options.append(name);
-        
-        if (m_interface)
-            m_interface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, options = options, selectedIndex] {
+            protectedThis-&gt;legibleMediaSelectionOptionsChanged(options, selectedIndex);
+        });
+        return;
+    }
+
+    for (auto&amp; client : m_playbackClients)
+        client-&gt;legibleMediaSelectionOptionsChanged(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, String localizedDeviceName)
</del><ins>+void WebVideoFullscreenControllerContext::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType type, const String&amp; localizedDeviceName)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    callOnMainThread([protectedThis = makeRef(*this), this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] {
-        if (m_interface)
-            m_interface-&gt;setExternalPlayback(enabled, type, localizedDeviceName);
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        callOnMainThread([protectedThis = makeRef(*this), this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] {
+            for (auto&amp; client : m_playbackClients)
+                client-&gt;externalPlaybackChanged(enabled, type, localizedDeviceName);
+        });
+        return;
+    }
+
+    for (auto&amp; client : m_playbackClients)
+        client-&gt;externalPlaybackChanged(enabled, type, localizedDeviceName);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled(bool disabled)
</del><ins>+void WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabledChanged(bool disabled)
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, disabled] {
-        if (m_interface)
-            m_interface-&gt;setWirelessVideoPlaybackDisabled(disabled);
-    });
</del><ins>+    if (WebThreadIsCurrent()) {
+        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis, disabled] {
+            protectedThis-&gt;wirelessVideoPlaybackDisabledChanged(disabled);
+        });
+        return;
+    }
+
+    for (auto&amp; client : m_playbackClients)
+        client-&gt;wirelessVideoPlaybackDisabledChanged(disabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #pragma mark WebVideoFullscreenModel
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenControllerContext::addClient(WebVideoFullscreenModelClient&amp; client)
+{
+    ASSERT(!m_fullscreenClients.contains(&amp;client));
+    m_fullscreenClients.add(&amp;client);
+}
+
+void WebVideoFullscreenControllerContext::removeClient(WebVideoFullscreenModelClient&amp; client)
+{
+    ASSERT(m_fullscreenClients.contains(&amp;client));
+    m_fullscreenClients.remove(&amp;client);
+}
+
</ins><span class="cx"> void WebVideoFullscreenControllerContext::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this, mode] {
</span><del>-        if (m_model)
-            m_model-&gt;requestFullscreenMode(mode);
</del><ins>+        if (m_fullscreenModel)
+            m_fullscreenModel-&gt;requestFullscreenMode(mode);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -479,8 +468,8 @@
</span><span class="cx">             
</span><span class="cx">             [videoFullscreenLayer setSublayerTransform:CATransform3DIdentity];
</span><span class="cx">             
</span><del>-            if (m_model)
-                m_model-&gt;setVideoLayerFrame(frame);
</del><ins>+            if (m_fullscreenModel)
+                m_fullscreenModel-&gt;setVideoLayerFrame(frame);
</ins><span class="cx">             [CATransaction commit];
</span><span class="cx">         });
</span><span class="cx">     });
</span><span class="lines">@@ -491,8 +480,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this, videoGravity] {
</span><del>-        if (m_model)
-            m_model-&gt;setVideoLayerGravity(videoGravity);
</del><ins>+        if (m_fullscreenModel)
+            m_fullscreenModel-&gt;setVideoLayerGravity(videoGravity);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -501,8 +490,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this, mode] {
</span><del>-        if (m_model)
-            m_model-&gt;fullscreenModeChanged(mode);
</del><ins>+        if (m_fullscreenModel)
+            m_fullscreenModel-&gt;fullscreenModeChanged(mode);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -509,18 +498,42 @@
</span><span class="cx"> bool WebVideoFullscreenControllerContext::isVisible() const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isUIThread());
</span><del>-    return m_model ? m_model-&gt;isVisible() : false;
</del><ins>+    return m_fullscreenModel ? m_fullscreenModel-&gt;isVisible() : false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-#pragma mark - WebPlaybackSessionModelContext
</del><ins>+bool WebVideoFullscreenControllerContext::hasVideo() const
+{
+    ASSERT(isUIThread());
+    return m_fullscreenModel ? m_fullscreenModel-&gt;hasVideo() : false;
+}
</ins><span class="cx"> 
</span><ins>+FloatSize WebVideoFullscreenControllerContext::videoDimensions() const
+{
+    ASSERT(isUIThread());
+    return m_fullscreenModel ? m_fullscreenModel-&gt;videoDimensions() : FloatSize();
+}
+
+#pragma mark - WebPlaybackSessionModel
+
+void WebVideoFullscreenControllerContext::addClient(WebPlaybackSessionModelClient&amp; client)
+{
+    ASSERT(!m_playbackClients.contains(&amp;client));
+    m_playbackClients.add(&amp;client);
+}
+
+void WebVideoFullscreenControllerContext::removeClient(WebPlaybackSessionModelClient&amp; client)
+{
+    ASSERT(m_playbackClients.contains(&amp;client));
+    m_playbackClients.remove(&amp;client);
+}
+
</ins><span class="cx"> void WebVideoFullscreenControllerContext::play()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().play();
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;play();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -529,8 +542,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().pause();
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;pause();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -539,8 +552,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().togglePlayState();
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;togglePlayState();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -549,8 +562,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().beginScrubbing();
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;beginScrubbing();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -559,8 +572,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().endScrubbing();
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;endScrubbing();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -569,8 +582,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this, time] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().seekToTime(time);
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;seekToTime(time);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -579,8 +592,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this, time] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().fastSeek(time);
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;fastSeek(time);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -589,8 +602,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().beginScanningForward();
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;beginScanningForward();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -599,8 +612,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().beginScanningBackward();
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;beginScanningBackward();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -609,8 +622,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().endScanning();
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;endScanning();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -619,8 +632,8 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this, index] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().selectAudioMediaOption(index);
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;selectAudioMediaOption(index);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -629,145 +642,155 @@
</span><span class="cx">     ASSERT(isUIThread());
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
</span><span class="cx">     WebThreadRun([protectedThis, this, index] {
</span><del>-        if (m_model)
-            m_model-&gt;playbackSessionModel().selectLegibleMediaOption(index);
</del><ins>+        if (m_playbackModel)
+            m_playbackModel-&gt;selectLegibleMediaOption(index);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#pragma mark Other
</del><ins>+double WebVideoFullscreenControllerContext::duration() const
+{
+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;duration() : 0;
+}
</ins><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::setUpFullscreen(HTMLVideoElement&amp; videoElement, UIView *view, HTMLMediaElementEnums::VideoFullscreenMode mode)
</del><ins>+double WebVideoFullscreenControllerContext::currentTime() const
</ins><span class="cx"> {
</span><del>-    ASSERT(isMainThread());
-    RetainPtr&lt;UIView&gt; viewRef = view;
-    m_videoElement = &amp;videoElement;
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;currentTime() : 0;
+}
</ins><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, viewRef, mode] {
-        ASSERT(isUIThread());
</del><ins>+double WebVideoFullscreenControllerContext::bufferedTime() const
+{
+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;bufferedTime() : 0;
+}
</ins><span class="cx"> 
</span><del>-        Ref&lt;WebPlaybackSessionInterfaceAVKit&gt; sessionInterface = WebPlaybackSessionInterfaceAVKit::create();
-        m_interface = WebVideoFullscreenInterfaceAVKit::create(sessionInterface.get());
-
-        m_sessionModel = WebVideoFullscreenSessionModel::create(*this);
-        sessionInterface-&gt;setWebPlaybackSessionModel(m_sessionModel.get());
-
-        m_interface-&gt;setWebVideoFullscreenModel(this);
-        m_interface-&gt;setWebVideoFullscreenChangeObserver(this);
-
-        m_videoFullscreenView = adoptNS([[getUIViewClass() alloc] init]);
-        
-        RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-        WebThreadRun([protectedThis, this, viewRef, mode] {
-            m_model = WebVideoFullscreenModelVideoElement::create(WebPlaybackSessionModelMediaElement::create().get());
-            m_model-&gt;setWebVideoFullscreenInterface(this);
-            m_model-&gt;playbackSessionModel().setMediaElement(m_videoElement.get());
-            m_model-&gt;setVideoElement(m_videoElement.get());
-
-            IntRect videoElementClientRect = elementRectInWindow(m_videoElement.get());
-            FloatRect videoLayerFrame = FloatRect(FloatPoint(), videoElementClientRect.size());
-            m_model-&gt;setVideoLayerFrame(videoLayerFrame);
-            
-            bool allowsPictureInPicture = m_videoElement-&gt;mediaSession().allowsPictureInPicture(*m_videoElement.get());
-            dispatch_async(dispatch_get_main_queue(), [protectedThis, this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] {
-                m_interface-&gt;setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture);
-            });
-        });
-    });
</del><ins>+bool WebVideoFullscreenControllerContext::isPlaying() const
+{
+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;isPlaying() : false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::exitFullscreen()
</del><ins>+float WebVideoFullscreenControllerContext::playbackRate() const
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent() || isMainThread());
-    IntRect clientRect = elementRectInWindow(m_videoElement.get());
-    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, clientRect] {
-        ASSERT(isUIThread());
-        m_interface-&gt;exitFullscreen(clientRect);
-    });
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;playbackRate() : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenControllerContext::requestHideAndExitFullscreen()
</del><ins>+Ref&lt;TimeRanges&gt; WebVideoFullscreenControllerContext::seekableRanges() const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isUIThread());
</span><del>-    m_interface-&gt;requestHideAndExitFullscreen();
</del><ins>+    return m_playbackModel ? m_playbackModel-&gt;seekableRanges() : TimeRanges::create();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-#pragma mark WebPlaybackSessionModel
-
-void WebVideoFullscreenSessionModel::play()
</del><ins>+bool WebVideoFullscreenControllerContext::canPlayFastReverse() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;play();
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;canPlayFastReverse() : false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::pause()
</del><ins>+Vector&lt;String&gt; WebVideoFullscreenControllerContext::audioMediaSelectionOptions() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;pause();
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;audioMediaSelectionOptions() : Vector&lt;String&gt;();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::togglePlayState()
</del><ins>+uint64_t WebVideoFullscreenControllerContext::audioMediaSelectedIndex() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;togglePlayState();
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;audioMediaSelectedIndex() : -1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::beginScrubbing()
</del><ins>+Vector&lt;String&gt; WebVideoFullscreenControllerContext::legibleMediaSelectionOptions() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;beginScrubbing();
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;legibleMediaSelectionOptions() : Vector&lt;String&gt;();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::endScrubbing()
</del><ins>+uint64_t WebVideoFullscreenControllerContext::legibleMediaSelectedIndex() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;endScrubbing();
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;legibleMediaSelectedIndex() : -1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::seekToTime(double time)
</del><ins>+bool WebVideoFullscreenControllerContext::externalPlaybackEnabled() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;seekToTime(time);
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;externalPlaybackEnabled() : false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::fastSeek(double time)
</del><ins>+WebPlaybackSessionModel::ExternalPlaybackTargetType WebVideoFullscreenControllerContext::externalPlaybackTargetType() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;fastSeek(time);
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;externalPlaybackTargetType() : TargetTypeNone;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::beginScanningForward()
</del><ins>+String WebVideoFullscreenControllerContext::externalPlaybackLocalizedDeviceName() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;beginScanningForward();
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;externalPlaybackLocalizedDeviceName() : String();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::beginScanningBackward()
</del><ins>+bool WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabled() const
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;beginScanningBackward();
</del><ins>+    ASSERT(isUIThread());
+    return m_playbackModel ? m_playbackModel-&gt;wirelessVideoPlaybackDisabled() : true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::endScanning()
</del><ins>+#pragma mark Other
+
+void WebVideoFullscreenControllerContext::setUpFullscreen(HTMLVideoElement&amp; videoElement, UIView *view, HTMLMediaElementEnums::VideoFullscreenMode mode)
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;endScanning();
</del><ins>+    ASSERT(isMainThread());
+    RetainPtr&lt;UIView&gt; viewRef = view;
+    m_videoElement = &amp;videoElement;
+    m_playbackModel = WebPlaybackSessionModelMediaElement::create();
+    m_playbackModel-&gt;addClient(*this);
+    m_playbackModel-&gt;setMediaElement(m_videoElement.get());
+
+    m_fullscreenModel = WebVideoFullscreenModelVideoElement::create();
+    m_fullscreenModel-&gt;addClient(*this);
+    m_fullscreenModel-&gt;setVideoElement(m_videoElement.get());
+
+    bool allowsPictureInPicture = m_videoElement-&gt;mediaSession().allowsPictureInPicture(*m_videoElement.get());
+
+    IntRect videoElementClientRect = elementRectInWindow(m_videoElement.get());
+    FloatRect videoLayerFrame = FloatRect(FloatPoint(), videoElementClientRect.size());
+    m_fullscreenModel-&gt;setVideoLayerFrame(videoLayerFrame);
+
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] {
+        ASSERT(isUIThread());
+
+        Ref&lt;WebPlaybackSessionInterfaceAVKit&gt; sessionInterface = WebPlaybackSessionInterfaceAVKit::create(*this);
+        m_interface = WebVideoFullscreenInterfaceAVKit::create(sessionInterface.get());
+        m_interface-&gt;setWebVideoFullscreenChangeObserver(this);
+        m_interface-&gt;setWebVideoFullscreenModel(this);
+        m_interface-&gt;setWebVideoFullscreenChangeObserver(this);
+
+        m_videoFullscreenView = adoptNS([[getUIViewClass() alloc] init]);
+        
+        m_interface-&gt;setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::selectAudioMediaOption(uint64_t optionId)
</del><ins>+void WebVideoFullscreenControllerContext::exitFullscreen()
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;selectAudioMediaOption(optionId);
</del><ins>+    ASSERT(WebThreadIsCurrent() || isMainThread());
+    IntRect clientRect = elementRectInWindow(m_videoElement.get());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; protectedThis(this);
+    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, clientRect] {
+        ASSERT(isUIThread());
+        m_interface-&gt;exitFullscreen(clientRect);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenSessionModel::selectLegibleMediaOption(uint64_t optionId)
</del><ins>+void WebVideoFullscreenControllerContext::requestHideAndExitFullscreen()
</ins><span class="cx"> {
</span><del>-    if (m_controller)
-        m_controller-&gt;selectLegibleMediaOption(optionId);
</del><ins>+    ASSERT(isUIThread());
+    m_interface-&gt;requestHideAndExitFullscreen();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> @implementation WebVideoFullscreenController {
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenControllerContext&gt; _context;
</span><span class="cx">     RefPtr&lt;HTMLVideoElement&gt; _videoElement;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="cx"> #include &quot;WebPlaybackSessionInterfaceAVKit.h&quot;
</span><span class="cx"> #include &quot;WebVideoFullscreenInterface.h&quot;
</span><ins>+#include &quot;WebVideoFullscreenModel.h&quot;
</ins><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;objc/objc.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="lines">@@ -57,12 +58,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class IntRect;
</span><ins>+class FloatSize;
</ins><span class="cx"> class WebVideoFullscreenModel;
</span><span class="cx"> class WebVideoFullscreenChangeObserver;
</span><span class="cx">     
</span><span class="cx"> class WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit final
</span><span class="cx">     : public WebVideoFullscreenInterface
</span><del>-    , public WebPlaybackSessionInterfaceAVKitClient
</del><ins>+    , public WebVideoFullscreenModelClient
+    , public WebPlaybackSessionModelClient
</ins><span class="cx">     , public RefCounted&lt;WebVideoFullscreenInterfaceAVKit&gt; {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><span class="lines">@@ -72,18 +75,13 @@
</span><span class="cx">     WEBCORE_EXPORT void setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver*);
</span><span class="cx">     WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionInterface-&gt;webPlaybackSessionModel(); }
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void resetMediaState() final;
-    WEBCORE_EXPORT void setDuration(double) final;
-    WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) final;
-    WEBCORE_EXPORT void setBufferedTime(double) final;
-    WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) final;
-    WEBCORE_EXPORT void setVideoDimensions(bool hasVideo, float width, float height) final;
-    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&amp;) final;
-    WEBCORE_EXPORT void setCanPlayFastReverse(bool) final;
-    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) final;
-    WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) final;
-    WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) final;
-    WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) final;
</del><ins>+    // WebVideoFullscreenModelClient
+    WEBCORE_EXPORT void hasVideoChanged(bool) final;
+    WEBCORE_EXPORT void videoDimensionsChanged(const FloatSize&amp;) final;
+
+    // WebPlaybackSessionModelClient
+    WEBCORE_EXPORT void externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp; localizedDeviceName) final;
+
</ins><span class="cx">     WEBCORE_EXPORT virtual void setupFullscreen(UIView&amp;, const IntRect&amp; initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
</span><span class="cx">     WEBCORE_EXPORT virtual void enterFullscreen();
</span><span class="cx">     WEBCORE_EXPORT virtual void exitFullscreen(const IntRect&amp; finalRect);
</span><span class="lines">@@ -127,7 +125,6 @@
</span><span class="cx">     void enterPictureInPicture();
</span><span class="cx">     void enterFullscreenStandard();
</span><span class="cx">     void watchdogTimerFired();
</span><del>-    void externalPlaybackEnabledChanged(bool) final;
</del><span class="cx">     WebAVPlayerController *playerController() const;
</span><span class="cx"> 
</span><span class="cx">     Ref&lt;WebPlaybackSessionInterfaceAVKit&gt; m_playbackSessionInterface;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -503,7 +503,9 @@
</span><span class="cx"> {
</span><span class="cx">     WebAVPlayerController* playerController = this-&gt;playerController();
</span><span class="cx">     if (playerController &amp;&amp; playerController.externalPlaybackActive)
</span><del>-        setExternalPlayback(false, TargetTypeNone, &quot;&quot;);
</del><ins>+        externalPlaybackChanged(false, WebPlaybackSessionModel::TargetTypeNone, &quot;&quot;);
+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel-&gt;removeClient(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebAVPlayerController *WebVideoFullscreenInterfaceAVKit::playerController() const
</span><span class="lines">@@ -511,14 +513,18 @@
</span><span class="cx">     return m_playbackSessionInterface-&gt;playerController();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceAVKit::resetMediaState()
</del><ins>+void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
</ins><span class="cx"> {
</span><del>-    m_playbackSessionInterface-&gt;resetMediaState();
-}
</del><ins>+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel-&gt;removeClient(*this);
</ins><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
-{
</del><span class="cx">     m_videoFullscreenModel = model;
</span><ins>+
+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel-&gt;addClient(*this);
+
+    hasVideoChanged(m_videoFullscreenModel ? m_videoFullscreenModel-&gt;hasVideo() : false);
+    videoDimensionsChanged(m_videoFullscreenModel ? m_videoFullscreenModel-&gt;videoDimensions() : FloatSize());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver* observer)
</span><span class="lines">@@ -526,33 +532,17 @@
</span><span class="cx">     m_fullscreenChangeObserver = observer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceAVKit::setDuration(double duration)
</del><ins>+void WebVideoFullscreenInterfaceAVKit::hasVideoChanged(bool hasVideo)
</ins><span class="cx"> {
</span><del>-    m_playbackSessionInterface-&gt;setDuration(duration);
</del><ins>+    [playerController() setHasEnabledVideo:hasVideo];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceAVKit::setCurrentTime(double currentTime, double anchorTime)
</del><ins>+void WebVideoFullscreenInterfaceAVKit::videoDimensionsChanged(const FloatSize&amp; videoDimensions)
</ins><span class="cx"> {
</span><del>-    m_playbackSessionInterface-&gt;setCurrentTime(currentTime, anchorTime);
-}
-
-void WebVideoFullscreenInterfaceAVKit::setBufferedTime(double bufferedTime)
-{
-    m_playbackSessionInterface-&gt;setBufferedTime(bufferedTime);
-}
-
-void WebVideoFullscreenInterfaceAVKit::setRate(bool isPlaying, float playbackRate)
-{
-    m_playbackSessionInterface-&gt;setRate(isPlaying, playbackRate);
-}
-
-void WebVideoFullscreenInterfaceAVKit::setVideoDimensions(bool hasVideo, float width, float height)
-{
</del><span class="cx">     WebAVPlayerLayer *playerLayer = (WebAVPlayerLayer *)[m_playerLayerView playerLayer];
</span><span class="cx"> 
</span><del>-    [playerLayer setVideoDimensions:CGSizeMake(width, height)];
-    [playerController() setHasEnabledVideo:hasVideo];
-    [playerController() setContentDimensions:CGSizeMake(width, height)];
</del><ins>+    [playerLayer setVideoDimensions:videoDimensions];
+    [playerController() setContentDimensions:videoDimensions];
</ins><span class="cx">     [m_playerLayerView setNeedsLayout];
</span><span class="cx"> 
</span><span class="cx">     WebAVPictureInPicturePlayerLayerView *pipView = (WebAVPictureInPicturePlayerLayerView *)[m_playerLayerView pictureInPicturePlayerLayerView];
</span><span class="lines">@@ -561,46 +551,11 @@
</span><span class="cx">     [pipView setNeedsLayout];    
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceAVKit::setSeekableRanges(const TimeRanges&amp; timeRanges)
</del><ins>+void WebVideoFullscreenInterfaceAVKit::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp;)
</ins><span class="cx"> {
</span><del>-    m_playbackSessionInterface-&gt;setSeekableRanges(timeRanges);
-}
-
-void WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse(bool canPlayFastReverse)
-{
-    m_playbackSessionInterface-&gt;setCanPlayFastReverse(canPlayFastReverse);
-}
-
-void WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
-{
-    m_playbackSessionInterface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
-}
-
-void WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
-{
-    m_playbackSessionInterface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
-}
-
-void WebVideoFullscreenInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName)
-{
-    m_playbackSessionInterface-&gt;setExternalPlayback(enabled, targetType, localizedDeviceName);
-}
-
-void WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged(bool enabled)
-{
</del><span class="cx">     [m_playerLayerView setHidden:enabled];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled)
-{
-    m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(disabled);
-}
-
-bool WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled() const
-{
-    return m_playbackSessionInterface-&gt;wirelessVideoPlaybackDisabled();
-}
-
</del><span class="cx"> void WebVideoFullscreenInterfaceAVKit::applicationDidBecomeActive()
</span><span class="cx"> {
</span><span class="cx">     LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::applicationDidBecomeActive(%p)&quot;, this);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;HTMLMediaElementEnums.h&quot;
</span><span class="cx"> #include &quot;WebPlaybackSessionInterface.h&quot;
</span><ins>+#include &quot;WebPlaybackSessionModel.h&quot;
</ins><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -40,38 +41,25 @@
</span><span class="cx"> class IntRect;
</span><span class="cx"> class WebPlaybackSessionModel;
</span><span class="cx"> 
</span><del>-class WebPlaybackSessionInterfaceMacClient {
-public:
-    virtual ~WebPlaybackSessionInterfaceMacClient() { }
-
-    virtual void rateChanged(bool isPlaying, float playbackRate) = 0;
-};
-
</del><span class="cx"> class WEBCORE_EXPORT WebPlaybackSessionInterfaceMac final
</span><span class="cx">     : public WebPlaybackSessionInterface
</span><ins>+    , public WebPlaybackSessionModelClient
</ins><span class="cx">     , public RefCounted&lt;WebPlaybackSessionInterfaceMac&gt; {
</span><span class="cx"> public:
</span><del>-    static Ref&lt;WebPlaybackSessionInterfaceMac&gt; create()
-    {
-        return adoptRef(*new WebPlaybackSessionInterfaceMac());
-    }
</del><ins>+    static Ref&lt;WebPlaybackSessionInterfaceMac&gt; create(WebPlaybackSessionModel&amp;);
</ins><span class="cx">     virtual ~WebPlaybackSessionInterfaceMac();
</span><span class="cx">     WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; }
</span><del>-    WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);
-    WebPlaybackSessionInterfaceMacClient* client() const { return m_client; }
-    void setClient(WebPlaybackSessionInterfaceMacClient*);
</del><span class="cx"> 
</span><ins>+    // WebPlaybackSessionInterface
</ins><span class="cx">     WEBCORE_EXPORT void resetMediaState() final { }
</span><del>-    WEBCORE_EXPORT void setDuration(double) final;
-    WEBCORE_EXPORT void setCurrentTime(double /*currentTime*/, double /*anchorTime*/) final;
-    WEBCORE_EXPORT void setBufferedTime(double) final { }
-    WEBCORE_EXPORT void setRate(bool /*isPlaying*/, float /*playbackRate*/) final;
-    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&amp;) final;
-    WEBCORE_EXPORT void setCanPlayFastReverse(bool) final { }
-    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) final;
-    WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) final;
-    WEBCORE_EXPORT void setExternalPlayback(bool, ExternalPlaybackTargetType, String) final { }
-    WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) final { }
</del><ins>+
+    // WebPlaybackSessionModelClient
+    WEBCORE_EXPORT void durationChanged(double) final;
+    WEBCORE_EXPORT void currentTimeChanged(double /*currentTime*/, double /*anchorTime*/) final;
+    WEBCORE_EXPORT void rateChanged(bool /*isPlaying*/, float /*playbackRate*/) final;
+    WEBCORE_EXPORT void seekableRangesChanged(const TimeRanges&amp;) final;
+    WEBCORE_EXPORT void audioMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) final;
+    WEBCORE_EXPORT void legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) final;
</ins><span class="cx">     WEBCORE_EXPORT void invalidate();
</span><span class="cx">     WEBCORE_EXPORT void ensureControlsManager();
</span><span class="cx">     WEBCORE_EXPORT void setPlayBackControlsManager(WebPlaybackControlsManager *);
</span><span class="lines">@@ -78,9 +66,9 @@
</span><span class="cx">     WEBCORE_EXPORT WebPlaybackControlsManager *playBackControlsManager();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    WebPlaybackSessionInterfaceMac(WebPlaybackSessionModel&amp;);
</ins><span class="cx">     WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
</span><del>-    WebPlaybackControlsManager *m_playbackControlsManager;
-    WebPlaybackSessionInterfaceMacClient* m_client { nullptr };
</del><ins>+    WebPlaybackControlsManager *m_playbackControlsManager  { nullptr };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -45,24 +45,24 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac()
</del><ins>+Ref&lt;WebPlaybackSessionInterfaceMac&gt; WebPlaybackSessionInterfaceMac::create(WebPlaybackSessionModel&amp; model)
</ins><span class="cx"> {
</span><ins>+    auto interface = adoptRef(*new WebPlaybackSessionInterfaceMac(model));
+    model.addClient(interface);
+    return interface;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel(WebPlaybackSessionModel* model)
</del><ins>+WebPlaybackSessionInterfaceMac::WebPlaybackSessionInterfaceMac(WebPlaybackSessionModel&amp; model)
+    : m_playbackSessionModel(&amp;model)
</ins><span class="cx"> {
</span><del>-    m_playbackSessionModel = model;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceMac::setClient(WebPlaybackSessionInterfaceMacClient* client)
</del><ins>+WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac()
</ins><span class="cx"> {
</span><del>-    m_client = client;
-
-    if (m_client &amp;&amp; m_playbackSessionModel)
-        m_client-&gt;rateChanged(m_playbackSessionModel-&gt;isPlaying(), m_playbackSessionModel-&gt;playbackRate());
</del><ins>+    invalidate();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceMac::setDuration(double duration)
</del><ins>+void WebPlaybackSessionInterfaceMac::durationChanged(double duration)
</ins><span class="cx"> {
</span><span class="cx">     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
</span><span class="cx"> 
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     controlsManager.hasEnabledVideo = YES;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceMac::setCurrentTime(double currentTime, double anchorTime)
</del><ins>+void WebPlaybackSessionInterfaceMac::currentTimeChanged(double currentTime, double anchorTime)
</ins><span class="cx"> {
</span><span class="cx">     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
</span><span class="cx"> 
</span><span class="lines">@@ -84,14 +84,11 @@
</span><span class="cx">     [controlsManager setTiming:timing];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceMac::setRate(bool isPlaying, float playbackRate)
</del><ins>+void WebPlaybackSessionInterfaceMac::rateChanged(bool isPlaying, float playbackRate)
</ins><span class="cx"> {
</span><span class="cx">     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
</span><span class="cx">     [controlsManager setRate:isPlaying ? playbackRate : 0.];
</span><span class="cx">     [controlsManager setPlaying:isPlaying];
</span><del>-
-    if (m_client)
-        m_client-&gt;rateChanged(isPlaying, playbackRate);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static RetainPtr&lt;NSMutableArray&gt; timeRangesToArray(const TimeRanges&amp; timeRanges)
</span><span class="lines">@@ -107,26 +104,28 @@
</span><span class="cx">     return rangeArray;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceMac::setSeekableRanges(const TimeRanges&amp; timeRanges)
</del><ins>+void WebPlaybackSessionInterfaceMac::seekableRangesChanged(const TimeRanges&amp; timeRanges)
</ins><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
-    [controlsManager setSeekableTimeRanges:timeRangesToArray(timeRanges).get()];
</del><ins>+    [playBackControlsManager() setSeekableTimeRanges:timeRangesToArray(timeRanges).get()];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebPlaybackSessionInterfaceMac::audioMediaSelectionOptionsChanged(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
-    [controlsManager setAudioMediaSelectionOptions:options withSelectedIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)];
</del><ins>+    [playBackControlsManager() setAudioMediaSelectionOptions:options withSelectedIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebPlaybackSessionInterfaceMac::legibleMediaSelectionOptionsChanged(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
-    [controlsManager setLegibleMediaSelectionOptions:options withSelectedIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)];
</del><ins>+    [playBackControlsManager() setLegibleMediaSelectionOptions:options withSelectedIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionInterfaceMac::invalidate()
</span><span class="cx"> {
</span><ins>+    if (!m_playbackSessionModel)
+        return;
+
+    m_playbackSessionModel-&gt;removeClient(*this);
+    m_playbackSessionModel = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionInterfaceMac::ensureControlsManager()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -30,7 +30,9 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;HTMLMediaElementEnums.h&quot;
</span><span class="cx"> #include &quot;WebPlaybackSessionInterfaceMac.h&quot;
</span><ins>+#include &quot;WebPlaybackSessionModel.h&quot;
</ins><span class="cx"> #include &quot;WebVideoFullscreenInterface.h&quot;
</span><ins>+#include &quot;WebVideoFullscreenModel.h&quot;
</ins><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -40,13 +42,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class IntRect;
</span><ins>+class FloatSize;
</ins><span class="cx"> class WebPlaybackSessionInterfaceMac;
</span><span class="cx"> class WebVideoFullscreenChangeObserver;
</span><del>-class WebVideoFullscreenModel;
</del><span class="cx"> 
</span><span class="cx"> class WEBCORE_EXPORT WebVideoFullscreenInterfaceMac
</span><span class="cx">     : public WebVideoFullscreenInterface
</span><del>-    , private WebPlaybackSessionInterfaceMacClient
</del><ins>+    , public WebVideoFullscreenModelClient
+    , private WebPlaybackSessionModelClient
</ins><span class="cx">     , public RefCounted&lt;WebVideoFullscreenInterfaceMac&gt; {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><span class="lines">@@ -61,19 +64,14 @@
</span><span class="cx">     WebVideoFullscreenChangeObserver* webVideoFullscreenChangeObserver() const { return m_fullscreenChangeObserver; }
</span><span class="cx">     WEBCORE_EXPORT void setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver*);
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void resetMediaState() override { }
-    WEBCORE_EXPORT void setDuration(double) override;
-    WEBCORE_EXPORT void setCurrentTime(double /*currentTime*/, double /*anchorTime*/) override;
-    WEBCORE_EXPORT void setBufferedTime(double) override { }
-    WEBCORE_EXPORT void setRate(bool /*isPlaying*/, float /*playbackRate*/) override;
-    WEBCORE_EXPORT void setVideoDimensions(bool hasVideo, float width, float height) final;
-    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&amp;) override;
-    WEBCORE_EXPORT void setCanPlayFastReverse(bool) override { }
-    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) override;
-    WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) override;
-    WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String localizedDeviceName) override;
-    WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override { }
</del><ins>+    // WebPlaybackSessionModelClient
+    WEBCORE_EXPORT void rateChanged(bool isPlaying, float playbackRate) override;
+    WEBCORE_EXPORT void externalPlaybackChanged(bool  enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp; localizedDeviceName) override;
</ins><span class="cx"> 
</span><ins>+    // WebVideoFullscreenModelClient
+    WEBCORE_EXPORT void hasVideoChanged(bool) final;
+    WEBCORE_EXPORT void videoDimensionsChanged(const FloatSize&amp;) final;
+
</ins><span class="cx">     WEBCORE_EXPORT void setupFullscreen(NSView&amp; layerHostedView, const IntRect&amp; initialRect, NSWindow *parentWindow, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
</span><span class="cx">     WEBCORE_EXPORT void enterFullscreen();
</span><span class="cx">     WEBCORE_EXPORT void exitFullscreen(const IntRect&amp; finalRect, NSWindow *parentWindow);
</span><span class="lines">@@ -95,8 +93,6 @@
</span><span class="cx">     WEBCORE_EXPORT bool mayAutomaticallyShowVideoPictureInPicture() const { return false; }
</span><span class="cx">     void applicationDidBecomeActive() { }
</span><span class="cx"> 
</span><del>-    void rateChanged(bool isPlaying, float playbackRate) override;
-
</del><span class="cx">     WEBCORE_EXPORT WebVideoFullscreenInterfaceMacObjC *videoFullscreenInterfaceObjC();
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -351,18 +351,25 @@
</span><span class="cx"> WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac(WebPlaybackSessionInterfaceMac&amp; playbackSessionInterface)
</span><span class="cx">     : m_playbackSessionInterface(playbackSessionInterface)
</span><span class="cx"> {
</span><del>-    m_playbackSessionInterface-&gt;setClient(this);
</del><ins>+    ASSERT(m_playbackSessionInterface-&gt;webPlaybackSessionModel());
+    m_playbackSessionInterface-&gt;webPlaybackSessionModel()-&gt;addClient(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac()
</span><span class="cx"> {
</span><del>-    if (m_playbackSessionInterface-&gt;client() == this)
-        m_playbackSessionInterface-&gt;setClient(nullptr);
</del><ins>+    if (m_playbackSessionInterface-&gt;webPlaybackSessionModel())
+        m_playbackSessionInterface-&gt;webPlaybackSessionModel()-&gt;removeClient(*this);
+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel-&gt;removeClient(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
</span><span class="cx"> {
</span><ins>+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel-&gt;removeClient(*this);
</ins><span class="cx">     m_videoFullscreenModel = model;
</span><ins>+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel-&gt;addClient(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver* observer)
</span><span class="lines">@@ -392,41 +399,11 @@
</span><span class="cx">         m_videoFullscreenModel-&gt;fullscreenModeChanged(m_mode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceMac::setDuration(double duration)
-{
-    m_playbackSessionInterface-&gt;setDuration(duration);
-}
-
-void WebVideoFullscreenInterfaceMac::setCurrentTime(double currentTime, double anchorTime)
-{
-    m_playbackSessionInterface-&gt;setCurrentTime(currentTime, anchorTime);
-}
-
-void WebVideoFullscreenInterfaceMac::setRate(bool isPlaying, float playbackRate)
-{
-    m_playbackSessionInterface-&gt;setRate(isPlaying, playbackRate);
-}
-
</del><span class="cx"> void WebVideoFullscreenInterfaceMac::rateChanged(bool isPlaying, float playbackRate)
</span><span class="cx"> {
</span><span class="cx">     [videoFullscreenInterfaceObjC() updateIsPlaying:isPlaying newPlaybackRate:playbackRate];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceMac::setSeekableRanges(const TimeRanges&amp; timeRanges)
-{
-    m_playbackSessionInterface-&gt;setSeekableRanges(timeRanges);
-}
-
-void WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
-{
-    m_playbackSessionInterface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
-}
-
-void WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
-{
-    m_playbackSessionInterface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
-}
-
</del><span class="cx"> void WebVideoFullscreenInterfaceMac::ensureControlsManager()
</span><span class="cx"> {
</span><span class="cx">     m_playbackSessionInterface-&gt;ensureControlsManager();
</span><span class="lines">@@ -545,26 +522,29 @@
</span><span class="cx">     [m_webVideoFullscreenInterfaceObjC exitPIPAnimatingToRect:(NSRect)inlineRect inWindow:parentWindow];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceMac::setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String)
</del><ins>+void WebVideoFullscreenInterfaceMac::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp;)
</ins><span class="cx"> {
</span><del>-    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceMac::setExternalPlayback(%p), enabled:%s&quot;, this, boolString(enabled));
</del><ins>+    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceMac::externalPlaybackChanged(%p), enabled:%s&quot;, this, boolString(enabled));
</ins><span class="cx"> 
</span><span class="cx">     if (enabled &amp;&amp; m_mode == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture)
</span><span class="cx">         exitFullscreen(IntRect(), nil);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceMac::setVideoDimensions(bool hasVideo, float width, float height)
</del><ins>+void WebVideoFullscreenInterfaceMac::hasVideoChanged(bool hasVideo)
</ins><span class="cx"> {
</span><del>-    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceMac::setVideoDimensions(%p), hasVideo:%s, width:%.0f, height:%.0f&quot;, this, boolString(hasVideo), width, height);
</del><ins>+    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceMac::hasVideoChanged(%p):%s&quot;, this, boolString(hasVideo));
</ins><span class="cx"> 
</span><del>-    if (!hasVideo) {
</del><ins>+    if (!hasVideo)
</ins><span class="cx">         exitFullscreenWithoutAnimationToMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
</span><del>-        return;
-    }
</del><ins>+}
</ins><span class="cx"> 
</span><ins>+void WebVideoFullscreenInterfaceMac::videoDimensionsChanged(const FloatSize&amp; videoDimensions)
+{
+    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceMac::videoDimensionsChanged(%p), width:%.0f, height:%.0f&quot;, this, videoDimensions.width(), videoDimensions.height());
+
</ins><span class="cx">     // Width and height can be zero when we are transitioning from one video to another. Ignore zero values.
</span><del>-    if (width &amp;&amp; height)
-        [m_webVideoFullscreenInterfaceObjC setVideoDimensions:NSMakeSize(width, height)];
</del><ins>+    if (!videoDimensions.isZero())
+        [m_webVideoFullscreenInterfaceObjC setVideoDimensions:videoDimensions];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebVideoFullscreenInterfaceMac::isPlayingVideoInEnhancedFullscreen() const
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-07-08  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Refactor WebPlaybackSessionModelMediaElement to be client based.
+        https://bugs.webkit.org/show_bug.cgi?id=159580
+
+        Reviewed by Eric Carlson.
+
+        No longer necessary to tell the models and interfaces about each other.
+
+        * WebView/WebView.mm:
+        (-[WebView _setUpPlaybackControlsManagerForMediaElement:]):
+        (-[WebView _clearPlaybackControlsManager]):
+
</ins><span class="cx"> 2016-09-01  Dan Bernstein  &lt;mitz@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Build fix.
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -8636,10 +8636,8 @@
</span><span class="cx">     _private-&gt;playbackSessionModel-&gt;setMediaElement(&amp;mediaElement);
</span><span class="cx"> 
</span><span class="cx">     if (!_private-&gt;playbackSessionInterface)
</span><del>-        _private-&gt;playbackSessionInterface = WebPlaybackSessionInterfaceMac::create();
</del><ins>+        _private-&gt;playbackSessionInterface = WebPlaybackSessionInterfaceMac::create(*_private-&gt;playbackSessionModel);
</ins><span class="cx"> 
</span><del>-    _private-&gt;playbackSessionInterface-&gt;setWebPlaybackSessionModel(_private-&gt;playbackSessionModel.get());
-    _private-&gt;playbackSessionModel-&gt;setWebPlaybackSessionInterface(_private-&gt;playbackSessionInterface.get());
</del><span class="cx">     [self updateWebViewAdditions];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -8649,8 +8647,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     _private-&gt;playbackSessionModel-&gt;setMediaElement(nullptr);
</span><del>-    _private-&gt;playbackSessionModel-&gt;setWebPlaybackSessionInterface(nullptr);
-    _private-&gt;playbackSessionInterface-&gt;setWebPlaybackSessionModel(nullptr);
</del><ins>+    _private-&gt;playbackSessionInterface-&gt;invalidate();
</ins><span class="cx"> 
</span><span class="cx">     _private-&gt;playbackSessionModel = nullptr;
</span><span class="cx">     _private-&gt;playbackSessionInterface = nullptr;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/ChangeLog        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -1,3 +1,118 @@
</span><ins>+2016-07-08  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Refactor WebPlaybackSessionModelMediaElement to be client based.
+        https://bugs.webkit.org/show_bug.cgi?id=159580
+
+        Reviewed by Eric Carlson.
+
+        Adopt the changes made in the WebPlaybackSessionModel,Interface and WebVideoFullscreenModel,Interface
+        in the WebPlaybackSessionManager,Proxy classes.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]): Deleted.
+        * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h:
+        * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm:
+        (WebKit::WebPlaybackSessionModelContext::addClient):
+        (WebKit::WebPlaybackSessionModelContext::removeClient):
+        (WebKit::WebPlaybackSessionModelContext::setDuration):
+        (WebKit::WebPlaybackSessionModelContext::setCurrentTime):
+        (WebKit::WebPlaybackSessionModelContext::setBufferedTime):
+        (WebKit::WebPlaybackSessionModelContext::setRate):
+        (WebKit::WebPlaybackSessionModelContext::setSeekableRanges):
+        (WebKit::WebPlaybackSessionModelContext::setCanPlayFastReverse):
+        (WebKit::WebPlaybackSessionModelContext::setAudioMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionModelContext::setLegibleMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionModelContext::setExternalPlayback):
+        (WebKit::WebPlaybackSessionModelContext::setWirelessVideoPlaybackDisabled):
+        (WebKit::WebPlaybackSessionManagerProxy::createModelAndInterface):
+        (WebKit::WebPlaybackSessionManagerProxy::removeClientForContext):
+        (WebKit::WebPlaybackSessionManagerProxy::setCurrentTime):
+        (WebKit::WebPlaybackSessionManagerProxy::setBufferedTime):
+        (WebKit::WebPlaybackSessionManagerProxy::setSeekableRangesVector):
+        (WebKit::WebPlaybackSessionManagerProxy::setCanPlayFastReverse):
+        (WebKit::WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionManagerProxy::setExternalPlaybackProperties):
+        (WebKit::WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled):
+        (WebKit::WebPlaybackSessionManagerProxy::setDuration):
+        (WebKit::WebPlaybackSessionManagerProxy::setRate):
+        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
+        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in:
+        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
+        (WebKit::WebVideoFullscreenModelContext::addClient):
+        (WebKit::WebVideoFullscreenModelContext::removeClient):
+        (WebKit::WebVideoFullscreenManagerProxy::setHasVideo):
+        (WebKit::WebVideoFullscreenManagerProxy::setVideoDimensions):
+        * WebProcess/cocoa/WebPlaybackSessionManager.h:
+        * WebProcess/cocoa/WebPlaybackSessionManager.mm:
+        (WebKit::WebPlaybackSessionInterfaceContext::durationChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::currentTimeChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::bufferedTimeChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::rateChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::seekableRangesChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::canPlayFastReverseChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::audioMediaSelectionOptionsChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::legibleMediaSelectionOptionsChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::externalPlaybackChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::wirelessVideoPlaybackDisabledChanged):
+        (WebKit::WebPlaybackSessionManager::~WebPlaybackSessionManager):
+        (WebKit::WebPlaybackSessionManager::createModelAndInterface):
+        (WebKit::WebPlaybackSessionManager::removeContext):
+        (WebKit::WebPlaybackSessionManager::durationChanged):
+        (WebKit::WebPlaybackSessionManager::currentTimeChanged):
+        (WebKit::WebPlaybackSessionManager::bufferedTimeChanged):
+        (WebKit::WebPlaybackSessionManager::rateChanged):
+        (WebKit::WebPlaybackSessionManager::seekableRangesChanged):
+        (WebKit::WebPlaybackSessionManager::canPlayFastReverseChanged):
+        (WebKit::WebPlaybackSessionManager::audioMediaSelectionOptionsChanged):
+        (WebKit::WebPlaybackSessionManager::legibleMediaSelectionOptionsChanged):
+        (WebKit::WebPlaybackSessionManager::externalPlaybackChanged):
+        (WebKit::WebPlaybackSessionManager::wirelessVideoPlaybackDisabledChanged):
+        (WebKit::WebPlaybackSessionInterfaceContext::setDuration): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setCurrentTime): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setBufferedTime): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setRate): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setSeekableRanges): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setCanPlayFastReverse): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setAudioMediaSelectionOptions): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setLegibleMediaSelectionOptions): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setExternalPlayback): Deleted.
+        (WebKit::WebPlaybackSessionInterfaceContext::setWirelessVideoPlaybackDisabled): Deleted.
+        (WebKit::WebPlaybackSessionManager::setDuration): Deleted.
+        (WebKit::WebPlaybackSessionManager::setCurrentTime): Deleted.
+        (WebKit::WebPlaybackSessionManager::setBufferedTime): Deleted.
+        (WebKit::WebPlaybackSessionManager::setRate): Deleted.
+        (WebKit::WebPlaybackSessionManager::setSeekableRanges): Deleted.
+        (WebKit::WebPlaybackSessionManager::setCanPlayFastReverse): Deleted.
+        (WebKit::WebPlaybackSessionManager::setAudioMediaSelectionOptions): Deleted.
+        (WebKit::WebPlaybackSessionManager::setLegibleMediaSelectionOptions): Deleted.
+        (WebKit::WebPlaybackSessionManager::setExternalPlayback): Deleted.
+        (WebKit::WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled): Deleted.
+        * WebProcess/cocoa/WebVideoFullscreenManager.h:
+        (WebKit::WebVideoFullscreenInterfaceContext::create):
+        * WebProcess/cocoa/WebVideoFullscreenManager.mm:
+        (WebKit::WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext):
+        (WebKit::WebVideoFullscreenInterfaceContext::hasVideoChanged):
+        (WebKit::WebVideoFullscreenInterfaceContext::videoDimensionsChanged):
+        (WebKit::WebVideoFullscreenManager::~WebVideoFullscreenManager):
+        (WebKit::WebVideoFullscreenManager::createModelAndInterface):
+        (WebKit::WebVideoFullscreenManager::removeContext):
+        (WebKit::WebVideoFullscreenManager::hasVideoChanged):
+        (WebKit::WebVideoFullscreenManager::videoDimensionsChanged):
+        (WebKit::WebVideoFullscreenInterfaceContext::resetMediaState): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setDuration): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setCurrentTime): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setBufferedTime): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setRate): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setVideoDimensions): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setSeekableRanges): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setCanPlayFastReverse): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setExternalPlayback): Deleted.
+        (WebKit::WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled): Deleted.
+        (WebKit::WebVideoFullscreenManager::setVideoDimensions): Deleted.
+
</ins><span class="cx"> 2016-09-02  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix GObject bindings build breakage when compiling with ENABLE_USER_TIMING disabled.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -544,8 +544,6 @@
</span><span class="cx">         _page-&gt;setApplicationNameForUserAgent(applicationNameForUserAgent);
</span><span class="cx"> 
</span><span class="cx">     _navigationState = std::make_unique&lt;WebKit::NavigationState&gt;(self);
</span><del>-    _page-&gt;setNavigationClient(_navigationState-&gt;createNavigationClient());
-
</del><span class="cx">     _uiDelegate = std::make_unique&lt;WebKit::UIDelegate&gt;(self);
</span><span class="cx">     _page-&gt;setFindClient(std::make_unique&lt;WebKit::FindClient&gt;(self));
</span><span class="cx">     _page-&gt;setDiagnosticLoggingClient(std::make_unique&lt;WebKit::DiagnosticLoggingClient&gt;(self));
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &lt;WebCore/TimeRanges.h&gt;
</span><span class="cx"> #include &lt;WebCore/WebPlaybackSessionModel.h&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><ins>+#include &lt;wtf/HashSet.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -63,20 +64,21 @@
</span><span class="cx"> 
</span><span class="cx">     void invalidate() { m_manager = nullptr; }
</span><span class="cx"> 
</span><del>-    void setDuration(double duration) { m_duration = duration; }
-    void setCurrentTime(double currentTime) { m_currentTime = currentTime; }
-    void setBufferedTime(double bufferedTime) { m_bufferedTime = bufferedTime; }
-    void setIsPlaying(bool isPlaying) { m_isPlaying = isPlaying; }
-    void setPlaybackRate(float playbackRate) { m_playbackRate = playbackRate; }
-    void setSeekableRanges(WebCore::TimeRanges&amp; seekableRanges) { m_seekableRanges = seekableRanges; }
-    void setCanPlayFastReverse(bool canPlayFastReverse) { m_canPlayFastReverse = canPlayFastReverse; }
-    void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; audioMediaSelectionOptions) { m_audioMediaSelectionOptions = audioMediaSelectionOptions; }
-    void setAudioMediaSelectedIndex(uint64_t audioMediaSelectedIndex) { m_audioMediaSelectedIndex = audioMediaSelectedIndex; }
-    void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; legibleMediaSelectionOptions) { m_legibleMediaSelectionOptions = legibleMediaSelectionOptions; }
-    void setLegibleMediaSelectedIndex(uint64_t legibleMediaSelectedIndex) { m_legibleMediaSelectedIndex = legibleMediaSelectedIndex; }
-    void setExternalPlaybackEnabled(bool externalPlaybackEnabled) { m_externalPlaybackEnabled = externalPlaybackEnabled; }
-    void setWirelessVideoPlaybackDisabled(bool wirelessVideoPlaybackDisabled) { m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled; }
</del><ins>+    // WebPlaybackSessionModel
+    void addClient(WebCore::WebPlaybackSessionModelClient&amp;) final;
+    void removeClient(WebCore::WebPlaybackSessionModelClient&amp;)final;
</ins><span class="cx"> 
</span><ins>+    void setDuration(double);
+    void setCurrentTime(double);
+    void setBufferedTime(double);
+    void setRate(bool isPlaying, float playbackRate);
+    void setSeekableRanges(WebCore::TimeRanges&amp;);
+    void setCanPlayFastReverse(bool);
+    void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t index);
+    void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t index);
+    void setExternalPlayback(bool, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp;);
+    void setWirelessVideoPlaybackDisabled(bool);
+
</ins><span class="cx"> private:
</span><span class="cx">     friend class WebVideoFullscreenModelContext;
</span><span class="cx"> 
</span><span class="lines">@@ -112,10 +114,13 @@
</span><span class="cx">     Vector&lt;WTF::String&gt; legibleMediaSelectionOptions() const final { return m_legibleMediaSelectionOptions; }
</span><span class="cx">     uint64_t legibleMediaSelectedIndex() const final { return m_legibleMediaSelectedIndex; }
</span><span class="cx">     bool externalPlaybackEnabled() const final { return m_externalPlaybackEnabled; }
</span><ins>+    WebPlaybackSessionModel::ExternalPlaybackTargetType externalPlaybackTargetType() const final { return m_externalPlaybackTargetType; }
+    String externalPlaybackLocalizedDeviceName() const final { return m_externalPlaybackLocalizedDeviceName; }
</ins><span class="cx">     bool wirelessVideoPlaybackDisabled() const final { return m_wirelessVideoPlaybackDisabled; }
</span><span class="cx"> 
</span><span class="cx">     WebPlaybackSessionManagerProxy* m_manager;
</span><span class="cx">     uint64_t m_contextId;
</span><ins>+    HashSet&lt;WebCore::WebPlaybackSessionModelClient*&gt; m_clients;
</ins><span class="cx">     double m_duration { 0 };
</span><span class="cx">     double m_currentTime { 0 };
</span><span class="cx">     double m_bufferedTime { 0 };
</span><span class="lines">@@ -128,6 +133,8 @@
</span><span class="cx">     Vector&lt;WTF::String&gt; m_legibleMediaSelectionOptions;
</span><span class="cx">     uint64_t m_legibleMediaSelectedIndex { 0 };
</span><span class="cx">     bool m_externalPlaybackEnabled { false };
</span><ins>+    WebPlaybackSessionModel::ExternalPlaybackTargetType m_externalPlaybackTargetType { WebPlaybackSessionModel::TargetTypeNone };
+    String m_externalPlaybackLocalizedDeviceName;
</ins><span class="cx">     bool m_wirelessVideoPlaybackDisabled { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -40,6 +40,18 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - WebPlaybackSessionModelContext
</span><span class="cx"> 
</span><ins>+void WebPlaybackSessionModelContext::addClient(WebPlaybackSessionModelClient&amp; client)
+{
+    ASSERT(!m_clients.contains(&amp;client));
+    m_clients.add(&amp;client);
+}
+
+void WebPlaybackSessionModelContext::removeClient(WebPlaybackSessionModelClient&amp; client)
+{
+    ASSERT(m_clients.contains(&amp;client));
+    m_clients.remove(&amp;client);
+}
+
</ins><span class="cx"> void WebPlaybackSessionModelContext::play()
</span><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><span class="lines">@@ -112,6 +124,85 @@
</span><span class="cx">         m_manager-&gt;selectLegibleMediaOption(m_contextId, optionId);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPlaybackSessionModelContext::setDuration(double duration)
+{
+    m_duration = duration;
+    for (auto* client : m_clients)
+        client-&gt;durationChanged(duration);
+}
+
+void WebPlaybackSessionModelContext::setCurrentTime(double currentTime)
+{
+    m_currentTime = currentTime;
+    auto anchorTime = [[NSProcessInfo processInfo] systemUptime];
+
+    for (auto* client : m_clients)
+        client-&gt;currentTimeChanged(currentTime, anchorTime);
+}
+
+void WebPlaybackSessionModelContext::setBufferedTime(double bufferedTime)
+{
+    m_bufferedTime = bufferedTime;
+    for (auto* client : m_clients)
+        client-&gt;bufferedTimeChanged(bufferedTime);
+}
+
+void WebPlaybackSessionModelContext::setRate(bool isPlaying, float playbackRate)
+{
+    m_isPlaying = isPlaying;
+    m_playbackRate = playbackRate;
+    for (auto* client : m_clients)
+        client-&gt;rateChanged(isPlaying, playbackRate);
+}
+
+void WebPlaybackSessionModelContext::setSeekableRanges(WebCore::TimeRanges&amp; seekableRanges)
+{
+    m_seekableRanges = seekableRanges;
+    for (auto* client : m_clients)
+        client-&gt;seekableRangesChanged(seekableRanges);
+}
+
+void WebPlaybackSessionModelContext::setCanPlayFastReverse(bool canPlayFastReverse)
+{
+    m_canPlayFastReverse = canPlayFastReverse;
+    for (auto* client : m_clients)
+        client-&gt;canPlayFastReverseChanged(canPlayFastReverse);
+}
+
+void WebPlaybackSessionModelContext::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; audioMediaSelectionOptions, uint64_t audioMediaSelectedIndex)
+{
+    m_audioMediaSelectionOptions = audioMediaSelectionOptions;
+    m_audioMediaSelectedIndex = audioMediaSelectedIndex;
+    for (auto* client : m_clients)
+        client-&gt;audioMediaSelectionOptionsChanged(audioMediaSelectionOptions, audioMediaSelectedIndex);
+}
+
+void WebPlaybackSessionModelContext::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; legibleMediaSelectionOptions, uint64_t legibleMediaSelectedIndex)
+{
+    m_legibleMediaSelectionOptions = legibleMediaSelectionOptions;
+    m_legibleMediaSelectedIndex = legibleMediaSelectedIndex;
+
+    for (auto* client : m_clients)
+        client-&gt;legibleMediaSelectionOptionsChanged(legibleMediaSelectionOptions, legibleMediaSelectedIndex);
+}
+
+void WebPlaybackSessionModelContext::setExternalPlayback(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType type, const String&amp; localizedName)
+{
+    m_externalPlaybackEnabled = enabled;
+    m_externalPlaybackTargetType = type;
+    m_externalPlaybackLocalizedDeviceName = localizedName;
+
+    for (auto* client : m_clients)
+        client-&gt;externalPlaybackChanged(enabled, type, localizedName);
+}
+
+void WebPlaybackSessionModelContext::setWirelessVideoPlaybackDisabled(bool wirelessVideoPlaybackDisabled)
+{
+    m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled;
+    for (auto* client : m_clients)
+        client-&gt;wirelessVideoPlaybackDisabledChanged(wirelessVideoPlaybackDisabled);
+}
+
</ins><span class="cx"> #pragma mark - WebPlaybackSessionManagerProxy
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;WebPlaybackSessionManagerProxy&gt; WebPlaybackSessionManagerProxy::create(WebPageProxy&amp; page)
</span><span class="lines">@@ -152,10 +243,8 @@
</span><span class="cx"> WebPlaybackSessionManagerProxy::ModelInterfaceTuple WebPlaybackSessionManagerProxy::createModelAndInterface(uint64_t contextId)
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;WebPlaybackSessionModelContext&gt; model = WebPlaybackSessionModelContext::create(*this, contextId);
</span><del>-    Ref&lt;PlatformWebPlaybackSessionInterface&gt; interface = PlatformWebPlaybackSessionInterface::create();
</del><ins>+    Ref&lt;PlatformWebPlaybackSessionInterface&gt; interface = PlatformWebPlaybackSessionInterface::create(model);
</ins><span class="cx"> 
</span><del>-    interface-&gt;setWebPlaybackSessionModel(&amp;model.get());
-
</del><span class="cx">     return std::make_tuple(WTFMove(model), WTFMove(interface));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -194,6 +283,11 @@
</span><span class="cx"> 
</span><span class="cx">     if (clientCount &lt;= 0) {
</span><span class="cx">         m_clientCounts.remove(contextId);
</span><ins>+
+        RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
+        RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
+        std::tie(model, interface) = ensureModelAndInterface(contextId);
+        interface-&gt;invalidate();
</ins><span class="cx">         m_contextMap.remove(contextId);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -241,20 +335,12 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setCurrentTime(uint64_t contextId, double currentTime, double hostTime)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setCurrentTime(currentTime);
-    interface-&gt;setCurrentTime(currentTime, hostTime);
</del><ins>+    ensureModel(contextId).setCurrentTime(currentTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setBufferedTime(uint64_t contextId, double bufferedTime)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setBufferedTime(bufferedTime);
-    interface-&gt;setBufferedTime(bufferedTime);
</del><ins>+    ensureModel(contextId).setBufferedTime(bufferedTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setSeekableRangesVector(uint64_t contextId, Vector&lt;std::pair&lt;double, double&gt;&gt; ranges)
</span><span class="lines">@@ -267,80 +353,45 @@
</span><span class="cx">         timeRanges-&gt;add(range.first, range.second);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setSeekableRanges(timeRanges);
-    interface-&gt;setSeekableRanges(timeRanges);
</del><ins>+    ensureModel(contextId).setSeekableRanges(timeRanges);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setCanPlayFastReverse(uint64_t contextId, bool value)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setCanPlayFastReverse(value);
-    interface-&gt;setCanPlayFastReverse(value);
</del><ins>+    ensureModel(contextId).setCanPlayFastReverse(value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setAudioMediaSelectionOptions(options);
-    model-&gt;setAudioMediaSelectedIndex(selectedIndex);
-    interface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
</del><ins>+    ensureModel(contextId).setAudioMediaSelectionOptions(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setLegibleMediaSelectionOptions(options);
-    model-&gt;setLegibleMediaSelectedIndex(selectedIndex);
-    interface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
</del><ins>+    ensureModel(contextId).setLegibleMediaSelectionOptions(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
</span><span class="cx"> {
</span><del>-    WebPlaybackSessionInterface::ExternalPlaybackTargetType type = static_cast&lt;WebPlaybackSessionInterface::ExternalPlaybackTargetType&gt;(targetType);
-    ASSERT(type == WebPlaybackSessionInterface::TargetTypeAirPlay || type == WebPlaybackSessionInterface::TargetTypeTVOut || type == WebPlaybackSessionInterface::TargetTypeNone);
</del><ins>+    WebPlaybackSessionModel::ExternalPlaybackTargetType type = static_cast&lt;WebPlaybackSessionModel::ExternalPlaybackTargetType&gt;(targetType);
+    ASSERT(type == WebPlaybackSessionModel::TargetTypeAirPlay || type == WebPlaybackSessionModel::TargetTypeTVOut || type == WebPlaybackSessionModel::TargetTypeNone);
</ins><span class="cx"> 
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setExternalPlaybackEnabled(enabled);
-    interface-&gt;setExternalPlayback(enabled, type, localizedDeviceName);
</del><ins>+    ensureModel(contextId).setExternalPlayback(enabled, type, localizedDeviceName);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setWirelessVideoPlaybackDisabled(disabled);
-    interface-&gt;setWirelessVideoPlaybackDisabled(disabled);
</del><ins>+    ensureModel(contextId).setWirelessVideoPlaybackDisabled(disabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setDuration(uint64_t contextId, double duration)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setDuration(duration);
-    interface-&gt;setDuration(duration);
</del><ins>+    ensureModel(contextId).setDuration(duration);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionManagerProxy::setRate(uint64_t contextId, bool isPlaying, double rate)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
-    RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
-    model-&gt;setIsPlaying(isPlaying);
-    model-&gt;setPlaybackRate(rate);
-    interface-&gt;setRate(isPlaying, rate);
</del><ins>+    ensureModel(contextId).setRate(isPlaying, rate);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #pragma mark Messages to WebPlaybackSessionManager
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &lt;WebCore/WebVideoFullscreenChangeObserver.h&gt;
</span><span class="cx"> #include &lt;WebCore/WebVideoFullscreenModel.h&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><ins>+#include &lt;wtf/HashSet.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -56,7 +57,10 @@
</span><span class="cx"> class WebPlaybackSessionModelContext;
</span><span class="cx"> class WebVideoFullscreenManagerProxy;
</span><span class="cx"> 
</span><del>-class WebVideoFullscreenModelContext final: public RefCounted&lt;WebVideoFullscreenModelContext&gt;, public WebCore::WebVideoFullscreenModel, public WebCore::WebVideoFullscreenChangeObserver  {
</del><ins>+class WebVideoFullscreenModelContext final
+    : public RefCounted&lt;WebVideoFullscreenModelContext&gt;
+    , public WebCore::WebVideoFullscreenModel
+    , public WebCore::WebVideoFullscreenChangeObserver  {
</ins><span class="cx"> public:
</span><span class="cx">     static Ref&lt;WebVideoFullscreenModelContext&gt; create(WebVideoFullscreenManagerProxy&amp; manager, WebPlaybackSessionModelContext&amp; playbackSessionModel, uint64_t contextId)
</span><span class="cx">     {
</span><span class="lines">@@ -73,11 +77,15 @@
</span><span class="cx">     WebVideoFullscreenModelContext(WebVideoFullscreenManagerProxy&amp;, WebPlaybackSessionModelContext&amp;, uint64_t);
</span><span class="cx"> 
</span><span class="cx">     // WebVideoFullscreenModel
</span><ins>+    void addClient(WebCore::WebVideoFullscreenModelClient&amp;) override;
+    void removeClient(WebCore::WebVideoFullscreenModelClient&amp;) override;
</ins><span class="cx">     void requestFullscreenMode(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
</span><span class="cx">     void setVideoLayerFrame(WebCore::FloatRect) override;
</span><span class="cx">     void setVideoLayerGravity(VideoGravity) override;
</span><span class="cx">     void fullscreenModeChanged(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
</span><span class="cx">     bool isVisible() const override;
</span><ins>+    bool hasVideo() const override { return m_hasVideo; }
+    WebCore::FloatSize videoDimensions() const override { return m_videoDimensions; }
</ins><span class="cx"> 
</span><span class="cx">     // WebVideoFullscreenChangeObserver
</span><span class="cx">     void didSetupFullscreen() override;
</span><span class="lines">@@ -90,6 +98,9 @@
</span><span class="cx">     Ref&lt;WebPlaybackSessionModelContext&gt; m_playbackSessionModel;
</span><span class="cx">     uint64_t m_contextId;
</span><span class="cx">     RetainPtr&lt;PlatformView *&gt; m_layerHostView;
</span><ins>+    HashSet&lt;WebCore::WebVideoFullscreenModelClient*&gt; m_clients;
+    WebCore::FloatSize m_videoDimensions;
+    bool m_hasVideo { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenManagerProxy : public RefCounted&lt;WebVideoFullscreenManagerProxy&gt;, private IPC::MessageReceiver {
</span><span class="lines">@@ -125,7 +136,8 @@
</span><span class="cx"> 
</span><span class="cx">     // Messages from WebVideoFullscreenManager
</span><span class="cx">     void setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect&amp; initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture);
</span><del>-    void setVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height);
</del><ins>+    void setHasVideo(uint64_t contextId, bool);
+    void setVideoDimensions(uint64_t contextId, const WebCore::FloatSize&amp;);
</ins><span class="cx">     void enterFullscreen(uint64_t contextId);
</span><span class="cx">     void exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect);
</span><span class="cx">     void cleanupFullscreen(uint64_t contextId);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -22,7 +22,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if (PLATFORM(IOS) &amp;&amp; HAVE(AVKIT)) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx"> messages -&gt; WebVideoFullscreenManagerProxy {
</span><del>-    SetVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height)
</del><ins>+    SetHasVideo(uint64_t contextId, bool hasVideo)
+    SetVideoDimensions(uint64_t contextId, WebCore::FloatSize videoDimensions)
</ins><span class="cx">     SetupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture)
</span><span class="cx">     EnterFullscreen(uint64_t contextId)
</span><span class="cx">     ExitFullscreen(uint64_t contextId, WebCore::IntRect finalRect)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -124,6 +124,18 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenModelContext::addClient(WebVideoFullscreenModelClient&amp; client)
+{
+    ASSERT(!m_clients.contains(&amp;client));
+    m_clients.add(&amp;client);
+}
+
+void WebVideoFullscreenModelContext::removeClient(WebVideoFullscreenModelClient&amp; client)
+{
+    ASSERT(m_clients.contains(&amp;client));
+    m_clients.remove(&amp;client);
+}
+
</ins><span class="cx"> void WebVideoFullscreenModelContext::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><span class="lines">@@ -358,11 +370,16 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height)
</del><ins>+void WebVideoFullscreenManagerProxy::setHasVideo(uint64_t contextId, bool hasVideo)
</ins><span class="cx"> {
</span><del>-    ensureInterface(contextId).setVideoDimensions(hasVideo, width, height);
</del><ins>+    ensureInterface(contextId).hasVideoChanged(hasVideo);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, const FloatSize&amp; videoDimensions)
+{
+    ensureInterface(contextId).videoDimensionsChanged(videoDimensions);
+}
+
</ins><span class="cx"> void WebVideoFullscreenManagerProxy::enterFullscreen(uint64_t contextId)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; interface = ensureInterface(contextId);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -54,7 +54,10 @@
</span><span class="cx"> class WebPage;
</span><span class="cx"> class WebPlaybackSessionManager;
</span><span class="cx"> 
</span><del>-class WebPlaybackSessionInterfaceContext final : public RefCounted&lt;WebPlaybackSessionInterfaceContext&gt;, public WebCore::WebPlaybackSessionInterface {
</del><ins>+class WebPlaybackSessionInterfaceContext final
+    : public RefCounted&lt;WebPlaybackSessionInterfaceContext&gt;
+    , public WebCore::WebPlaybackSessionInterface
+    , public WebCore::WebPlaybackSessionModelClient {
</ins><span class="cx"> public:
</span><span class="cx">     static Ref&lt;WebPlaybackSessionInterfaceContext&gt; create(WebPlaybackSessionManager&amp; manager, uint64_t contextId)
</span><span class="cx">     {
</span><span class="lines">@@ -69,17 +72,19 @@
</span><span class="cx"> 
</span><span class="cx">     // WebPlaybackSessionInterface
</span><span class="cx">     void resetMediaState() final;
</span><del>-    void setDuration(double) final;
-    void setCurrentTime(double currentTime, double anchorTime) final;
-    void setBufferedTime(double) final;
-    void setRate(bool isPlaying, float playbackRate) final;
-    void setSeekableRanges(const WebCore::TimeRanges&amp;) final;
-    void setCanPlayFastReverse(bool value) final;
-    void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) final;
-    void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) final;
-    void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) final;
-    void setWirelessVideoPlaybackDisabled(bool) final;
</del><span class="cx"> 
</span><ins>+    // WebPlaybackModelClient
+    void durationChanged(double) final;
+    void currentTimeChanged(double currentTime, double anchorTime) final;
+    void bufferedTimeChanged(double) final;
+    void rateChanged(bool isPlaying, float playbackRate) final;
+    void seekableRangesChanged(const WebCore::TimeRanges&amp;) final;
+    void canPlayFastReverseChanged(bool value) final;
+    void audioMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) final;
+    void legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) final;
+    void externalPlaybackChanged(bool enabled, WebCore::WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&amp; localizedDeviceName) final;
+    void wirelessVideoPlaybackDisabledChanged(bool) final;
+
</ins><span class="cx">     WebPlaybackSessionInterfaceContext(WebPlaybackSessionManager&amp;, uint64_t contextId);
</span><span class="cx"> 
</span><span class="cx">     WebPlaybackSessionManager* m_manager;
</span><span class="lines">@@ -114,16 +119,16 @@
</span><span class="cx"> 
</span><span class="cx">     // Interface to WebPlaybackSessionInterfaceContext
</span><span class="cx">     void resetMediaState(uint64_t contextId);
</span><del>-    void setDuration(uint64_t contextId, double);
-    void setCurrentTime(uint64_t contextId, double currentTime, double anchorTime);
-    void setBufferedTime(uint64_t contextId, double bufferedTime);
-    void setRate(uint64_t contextId, bool isPlaying, float playbackRate);
-    void setSeekableRanges(uint64_t contextId, const WebCore::TimeRanges&amp;);
-    void setCanPlayFastReverse(uint64_t contextId, bool value);
-    void setAudioMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex);
-    void setLegibleMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex);
-    void setExternalPlayback(uint64_t contextId, bool enabled, WebCore::WebPlaybackSessionInterface::ExternalPlaybackTargetType, String localizedDeviceName);
-    void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);
</del><ins>+    void durationChanged(uint64_t contextId, double);
+    void currentTimeChanged(uint64_t contextId, double currentTime, double anchorTime);
+    void bufferedTimeChanged(uint64_t contextId, double bufferedTime);
+    void rateChanged(uint64_t contextId, bool isPlaying, float playbackRate);
+    void seekableRangesChanged(uint64_t contextId, const WebCore::TimeRanges&amp;);
+    void canPlayFastReverseChanged(uint64_t contextId, bool value);
+    void audioMediaSelectionOptionsChanged(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex);
+    void legibleMediaSelectionOptionsChanged(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex);
+    void externalPlaybackChanged(uint64_t contextId, bool enabled, WebCore::WebPlaybackSessionModel::ExternalPlaybackTargetType, String localizedDeviceName);
+    void wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool);
</ins><span class="cx"> 
</span><span class="cx">     // Messages from WebPlaybackSessionManagerProxy
</span><span class="cx">     void play(uint64_t contextId);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -72,64 +72,64 @@
</span><span class="cx">         m_manager-&gt;resetMediaState(m_contextId);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setDuration(double duration)
</del><ins>+void WebPlaybackSessionInterfaceContext::durationChanged(double duration)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setDuration(m_contextId, duration);
</del><ins>+        m_manager-&gt;durationChanged(m_contextId, duration);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setCurrentTime(double currentTime, double anchorTime)
</del><ins>+void WebPlaybackSessionInterfaceContext::currentTimeChanged(double currentTime, double anchorTime)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setCurrentTime(m_contextId, currentTime, anchorTime);
</del><ins>+        m_manager-&gt;currentTimeChanged(m_contextId, currentTime, anchorTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setBufferedTime(double bufferedTime)
</del><ins>+void WebPlaybackSessionInterfaceContext::bufferedTimeChanged(double bufferedTime)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setBufferedTime(m_contextId, bufferedTime);
</del><ins>+        m_manager-&gt;bufferedTimeChanged(m_contextId, bufferedTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setRate(bool isPlaying, float playbackRate)
</del><ins>+void WebPlaybackSessionInterfaceContext::rateChanged(bool isPlaying, float playbackRate)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setRate(m_contextId, isPlaying, playbackRate);
</del><ins>+        m_manager-&gt;rateChanged(m_contextId, isPlaying, playbackRate);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setSeekableRanges(const WebCore::TimeRanges&amp; ranges)
</del><ins>+void WebPlaybackSessionInterfaceContext::seekableRangesChanged(const WebCore::TimeRanges&amp; ranges)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setSeekableRanges(m_contextId, ranges);
</del><ins>+        m_manager-&gt;seekableRangesChanged(m_contextId, ranges);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setCanPlayFastReverse(bool value)
</del><ins>+void WebPlaybackSessionInterfaceContext::canPlayFastReverseChanged(bool value)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setCanPlayFastReverse(m_contextId, value);
</del><ins>+        m_manager-&gt;canPlayFastReverseChanged(m_contextId, value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebPlaybackSessionInterfaceContext::audioMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setAudioMediaSelectionOptions(m_contextId, options, selectedIndex);
</del><ins>+        m_manager-&gt;audioMediaSelectionOptionsChanged(m_contextId, options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebPlaybackSessionInterfaceContext::legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setLegibleMediaSelectionOptions(m_contextId, options, selectedIndex);
</del><ins>+        m_manager-&gt;legibleMediaSelectionOptionsChanged(m_contextId, options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, WTF::String localizedDeviceName)
</del><ins>+void WebPlaybackSessionInterfaceContext::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType type, const String&amp; localizedDeviceName)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setExternalPlayback(m_contextId, enabled, type, localizedDeviceName);
</del><ins>+        m_manager-&gt;externalPlaybackChanged(m_contextId, enabled, type, localizedDeviceName);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionInterfaceContext::setWirelessVideoPlaybackDisabled(bool disabled)
</del><ins>+void WebPlaybackSessionInterfaceContext::wirelessVideoPlaybackDisabledChanged(bool disabled)
</ins><span class="cx"> {
</span><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setWirelessVideoPlaybackDisabled(m_contextId, disabled);
</del><ins>+        m_manager-&gt;wirelessVideoPlaybackDisabledChanged(m_contextId, disabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - WebPlaybackSessionManager
</span><span class="lines">@@ -151,8 +151,7 @@
</span><span class="cx">         RefPtr&lt;WebPlaybackSessionModelMediaElement&gt; model;
</span><span class="cx">         RefPtr&lt;WebPlaybackSessionInterfaceContext&gt; interface;
</span><span class="cx">         std::tie(model, interface) = tuple;
</span><del>-
-        model-&gt;setWebPlaybackSessionInterface(nullptr);
</del><ins>+        model-&gt;removeClient(*interface);
</ins><span class="cx">         model-&gt;setMediaElement(nullptr);
</span><span class="cx"> 
</span><span class="cx">         interface-&gt;invalidate();
</span><span class="lines">@@ -169,9 +168,8 @@
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;WebPlaybackSessionModelMediaElement&gt; model = WebPlaybackSessionModelMediaElement::create();
</span><span class="cx">     RefPtr&lt;WebPlaybackSessionInterfaceContext&gt; interface = WebPlaybackSessionInterfaceContext::create(*this, contextId);
</span><ins>+    model-&gt;addClient(*interface);
</ins><span class="cx"> 
</span><del>-    model-&gt;setWebPlaybackSessionInterface(interface.get());
-
</del><span class="cx">     return std::make_tuple(WTFMove(model), WTFMove(interface));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -201,7 +199,7 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;HTMLMediaElement&gt; mediaElement = model-&gt;mediaElement();
</span><span class="cx">     model-&gt;setMediaElement(nullptr);
</span><del>-    model-&gt;setWebPlaybackSessionInterface(nullptr);
</del><ins>+    model-&gt;removeClient(*interface);
</ins><span class="cx">     interface-&gt;invalidate();
</span><span class="cx">     m_mediaElements.remove(mediaElement.get());
</span><span class="cx">     m_contextMap.remove(contextId);
</span><span class="lines">@@ -284,27 +282,27 @@
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::ResetMediaState(contextId), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setDuration(uint64_t contextId, double duration)
</del><ins>+void WebPlaybackSessionManager::durationChanged(uint64_t contextId, double duration)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetDuration(contextId, duration), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setCurrentTime(uint64_t contextId, double currentTime, double anchorTime)
</del><ins>+void WebPlaybackSessionManager::currentTimeChanged(uint64_t contextId, double currentTime, double anchorTime)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetCurrentTime(contextId, currentTime, anchorTime), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setBufferedTime(uint64_t contextId, double bufferedTime)
</del><ins>+void WebPlaybackSessionManager::bufferedTimeChanged(uint64_t contextId, double bufferedTime)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetBufferedTime(contextId, bufferedTime), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setRate(uint64_t contextId, bool isPlaying, float playbackRate)
</del><ins>+void WebPlaybackSessionManager::rateChanged(uint64_t contextId, bool isPlaying, float playbackRate)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetRate(contextId, isPlaying, playbackRate), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setSeekableRanges(uint64_t contextId, const WebCore::TimeRanges&amp; timeRanges)
</del><ins>+void WebPlaybackSessionManager::seekableRangesChanged(uint64_t contextId, const WebCore::TimeRanges&amp; timeRanges)
</ins><span class="cx"> {
</span><span class="cx">     Vector&lt;std::pair&lt;double, double&gt;&gt; rangesVector;
</span><span class="cx"> 
</span><span class="lines">@@ -318,27 +316,27 @@
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetSeekableRangesVector(contextId, WTFMove(rangesVector)), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setCanPlayFastReverse(uint64_t contextId, bool value)
</del><ins>+void WebPlaybackSessionManager::canPlayFastReverseChanged(uint64_t contextId, bool value)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetCanPlayFastReverse(contextId, value), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setAudioMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebPlaybackSessionManager::audioMediaSelectionOptionsChanged(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetAudioMediaSelectionOptions(contextId, options, selectedIndex), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setLegibleMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</del><ins>+void WebPlaybackSessionManager::legibleMediaSelectionOptionsChanged(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetLegibleMediaSelectionOptions(contextId, options, selectedIndex), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setExternalPlayback(uint64_t contextId, bool enabled, WebPlaybackSessionInterface::ExternalPlaybackTargetType targetType, String localizedDeviceName)
</del><ins>+void WebPlaybackSessionManager::externalPlaybackChanged(uint64_t contextId, bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType targetType, String localizedDeviceName)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetExternalPlaybackProperties(contextId, enabled, static_cast&lt;uint32_t&gt;(targetType), localizedDeviceName), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
</del><ins>+void WebPlaybackSessionManager::wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool disabled)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetWirelessVideoPlaybackDisabled(contextId, disabled));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+class FloatSize;
</ins><span class="cx"> class Node;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -56,11 +57,14 @@
</span><span class="cx"> class WebPlaybackSessionManager;
</span><span class="cx"> class WebVideoFullscreenManager;
</span><span class="cx"> 
</span><del>-class WebVideoFullscreenInterfaceContext : public RefCounted&lt;WebVideoFullscreenInterfaceContext&gt;, public WebCore::WebVideoFullscreenInterface {
</del><ins>+class WebVideoFullscreenInterfaceContext
+    : public RefCounted&lt;WebVideoFullscreenInterfaceContext&gt;
+    , public WebCore::WebVideoFullscreenInterface
+    , public WebCore::WebVideoFullscreenModelClient {
</ins><span class="cx"> public:
</span><del>-    static Ref&lt;WebVideoFullscreenInterfaceContext&gt; create(WebVideoFullscreenManager&amp; manager, WebPlaybackSessionInterfaceContext&amp; playbackSessionInterface, uint64_t contextId)
</del><ins>+    static Ref&lt;WebVideoFullscreenInterfaceContext&gt; create(WebVideoFullscreenManager&amp; manager, uint64_t contextId)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new WebVideoFullscreenInterfaceContext(manager, playbackSessionInterface, contextId));
</del><ins>+        return adoptRef(*new WebVideoFullscreenInterfaceContext(manager, contextId));
</ins><span class="cx">     }
</span><span class="cx">     virtual ~WebVideoFullscreenInterfaceContext();
</span><span class="cx"> 
</span><span class="lines">@@ -82,26 +86,13 @@
</span><span class="cx">     void setIsFullscreen(bool flag) { m_isFullscreen = flag; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    // WebPlaybackSessionInterface
-    void resetMediaState() override;
-    void setDuration(double) override;
-    void setCurrentTime(double currentTime, double anchorTime) override;
-    void setBufferedTime(double) override;
-    void setRate(bool isPlaying, float playbackRate) override;
-    void setSeekableRanges(const WebCore::TimeRanges&amp;) override;
-    void setCanPlayFastReverse(bool value) override;
-    void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
-    void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
-    void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
-    void setWirelessVideoPlaybackDisabled(bool) override;
</del><ins>+    // WebVideoFullscreenModelClient
+    void hasVideoChanged(bool) override;
+    void videoDimensionsChanged(const WebCore::FloatSize&amp;) override;
</ins><span class="cx"> 
</span><del>-    // WebVideoFullscreenInterface
-    void setVideoDimensions(bool hasVideo, float width, float height) override;
</del><ins>+    WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&amp;, uint64_t contextId);
</ins><span class="cx"> 
</span><del>-    WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&amp;, WebPlaybackSessionInterfaceContext&amp;, uint64_t contextId);
-
</del><span class="cx">     WebVideoFullscreenManager* m_manager;
</span><del>-    Ref&lt;WebPlaybackSessionInterfaceContext&gt; m_playbackSessionInterface;
</del><span class="cx">     uint64_t m_contextId;
</span><span class="cx">     std::unique_ptr&lt;LayerHostingContext&gt; m_layerHostingContext;
</span><span class="cx">     bool m_isAnimating { false };
</span><span class="lines">@@ -138,7 +129,8 @@
</span><span class="cx">     void removeClientForContext(uint64_t contextId);
</span><span class="cx"> 
</span><span class="cx">     // Interface to WebVideoFullscreenInterfaceContext
</span><del>-    void setVideoDimensions(uint64_t contextId, bool hasVideo, float width, float height);
</del><ins>+    void hasVideoChanged(uint64_t contextId, bool hasVideo);
+    void videoDimensionsChanged(uint64_t contextId, const WebCore::FloatSize&amp;);
</ins><span class="cx"> 
</span><span class="cx">     // Messages from WebVideoFullscreenManagerProxy
</span><span class="cx">     void requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm (205364 => 205365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm        2016-09-02 19:49:09 UTC (rev 205364)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm        2016-09-02 20:06:52 UTC (rev 205365)
</span><span class="lines">@@ -66,9 +66,8 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - WebVideoFullscreenInterfaceContext
</span><span class="cx"> 
</span><del>-WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&amp; manager, WebPlaybackSessionInterfaceContext&amp; playbackSessionInterface, uint64_t contextId)
</del><ins>+WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&amp; manager, uint64_t contextId)
</ins><span class="cx">     : m_manager(&amp;manager)
</span><del>-    , m_playbackSessionInterface(playbackSessionInterface)
</del><span class="cx">     , m_contextId(contextId)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -82,67 +81,18 @@
</span><span class="cx">     m_layerHostingContext = WTFMove(context);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceContext::resetMediaState()
</del><ins>+void WebVideoFullscreenInterfaceContext::hasVideoChanged(bool hasVideo)
</ins><span class="cx"> {
</span><del>-    m_playbackSessionInterface-&gt;resetMediaState();
</del><ins>+    if (m_manager)
+        m_manager-&gt;hasVideoChanged(m_contextId, hasVideo);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceContext::setDuration(double duration)
</del><ins>+void WebVideoFullscreenInterfaceContext::videoDimensionsChanged(const FloatSize&amp; videoDimensions)
</ins><span class="cx"> {
</span><del>-    m_playbackSessionInterface-&gt;setDuration(duration);
-}
-
-void WebVideoFullscreenInterfaceContext::setCurrentTime(double currentTime, double anchorTime)
-{
-    m_playbackSessionInterface-&gt;setCurrentTime(currentTime, anchorTime);
-}
-
-void WebVideoFullscreenInterfaceContext::setBufferedTime(double bufferedTime)
-{
-    m_playbackSessionInterface-&gt;setBufferedTime(bufferedTime);
-}
-
-void WebVideoFullscreenInterfaceContext::setRate(bool isPlaying, float playbackRate)
-{
-    m_playbackSessionInterface-&gt;setRate(isPlaying, playbackRate);
-}
-
-void WebVideoFullscreenInterfaceContext::setVideoDimensions(bool hasVideo, float width, float height)
-{
</del><span class="cx">     if (m_manager)
</span><del>-        m_manager-&gt;setVideoDimensions(m_contextId, hasVideo, width, height);
</del><ins>+        m_manager-&gt;videoDimensionsChanged(m_contextId, videoDimensions);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceContext::setSeekableRanges(const WebCore::TimeRanges&amp; ranges)
-{
-    m_playbackSessionInterface-&gt;setSeekableRanges(ranges);
-}
-
-void WebVideoFullscreenInterfaceContext::setCanPlayFastReverse(bool value)
-{
-    m_playbackSessionInterface-&gt;setCanPlayFastReverse(value);
-}
-
-void WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
-{
-    m_playbackSessionInterface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
-}
-
-void WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
-{
-    m_playbackSessionInterface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
-}
-
-void WebVideoFullscreenInterfaceContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, WTF::String localizedDeviceName)
-{
-    m_playbackSessionInterface-&gt;setExternalPlayback(enabled, type, localizedDeviceName);
-}
-
-void WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled(bool disabled)
-{
-    m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(disabled);
-}
-
</del><span class="cx"> #pragma mark - WebVideoFullscreenManager
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;WebVideoFullscreenManager&gt; WebVideoFullscreenManager::create(WebPage&amp; page, WebPlaybackSessionManager&amp; playbackSessionManager)
</span><span class="lines">@@ -164,8 +114,8 @@
</span><span class="cx">         RefPtr&lt;WebVideoFullscreenInterfaceContext&gt; interface;
</span><span class="cx">         std::tie(model, interface) = tuple;
</span><span class="cx"> 
</span><del>-        model-&gt;setWebVideoFullscreenInterface(nullptr);
</del><span class="cx">         model-&gt;setVideoElement(nullptr);
</span><ins>+        model-&gt;removeClient(*interface);
</ins><span class="cx"> 
</span><span class="cx">         interface-&gt;invalidate();
</span><span class="cx">     }
</span><span class="lines">@@ -179,14 +129,12 @@
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenManager::ModelInterfaceTuple WebVideoFullscreenManager::createModelAndInterface(uint64_t contextId)
</span><span class="cx"> {
</span><del>-    auto&amp; playbackSessionModel = m_playbackSessionManager-&gt;ensureModel(contextId);
-    RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; model = WebVideoFullscreenModelVideoElement::create(playbackSessionModel);
-    auto&amp; playbackSessionInterface = m_playbackSessionManager-&gt;ensureInterface(contextId);
-    RefPtr&lt;WebVideoFullscreenInterfaceContext&gt; interface = WebVideoFullscreenInterfaceContext::create(*this, playbackSessionInterface, contextId);
</del><ins>+    RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; model = WebVideoFullscreenModelVideoElement::create();
+    RefPtr&lt;WebVideoFullscreenInterfaceContext&gt; interface = WebVideoFullscreenInterfaceContext::create(*this, contextId);
</ins><span class="cx">     m_playbackSessionManager-&gt;addClientForContext(contextId);
</span><span class="cx"> 
</span><span class="cx">     interface-&gt;setLayerHostingContext(LayerHostingContext::createForExternalHostingProcess());
</span><del>-    model-&gt;setWebVideoFullscreenInterface(interface.get());
</del><ins>+    model-&gt;addClient(*interface);
</ins><span class="cx"> 
</span><span class="cx">     return std::make_tuple(WTFMove(model), WTFMove(interface));
</span><span class="cx"> }
</span><span class="lines">@@ -219,7 +167,7 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;HTMLVideoElement&gt; videoElement = model-&gt;videoElement();
</span><span class="cx">     model-&gt;setVideoElement(nullptr);
</span><del>-    model-&gt;setWebVideoFullscreenInterface(nullptr);
</del><ins>+    model-&gt;removeClient(*interface);
</ins><span class="cx">     interface-&gt;invalidate();
</span><span class="cx">     m_videoElements.remove(videoElement.get());
</span><span class="cx">     m_contextMap.remove(contextId);
</span><span class="lines">@@ -331,11 +279,16 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark Interface to WebVideoFullscreenInterfaceContext:
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManager::setVideoDimensions(uint64_t contextId, bool hasVideo, float width, float height)
</del><ins>+void WebVideoFullscreenManager::hasVideoChanged(uint64_t contextId, bool hasVideo)
</ins><span class="cx"> {
</span><del>-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(contextId, hasVideo, width, height), m_page-&gt;pageID());
</del><ins>+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetHasVideo(contextId, hasVideo), m_page-&gt;pageID());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenManager::videoDimensionsChanged(uint64_t contextId, const FloatSize&amp; videoDimensions)
+{
+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(contextId, videoDimensions), m_page-&gt;pageID());
+}
+
</ins><span class="cx"> #pragma mark Messages from WebVideoFullscreenManagerProxy:
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenManager::requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
</span></span></pre>
</div>
</div>

</body>
</html>