<!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>[203151] trunk</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/203151">203151</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2016-07-12 21:50:14 -0700 (Tue, 12 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/202509">r202509</a>): media controls controls enabled AirPlay placeholder is shown
https://bugs.webkit.org/show_bug.cgi?id=159685
&lt;rdar://problem/27198899&gt;

Reviewed by Dean Jackson.

Source/WebCore:

Test: media/controls/airplay-controls.html

* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.shouldShowControls): Split some of the logic out of shouldHaveControls.
(Controller.prototype.shouldHaveControls): Having controls != showing controls.
(Controller.prototype.updateControls): Call shouldShowControls, not shouldHaveControls.
(Controller.prototype.updateWirelessPlaybackStatus): Add 'appletv' to the class when active.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::getCurrentMediaControlsStatus): Call ensureMediaControlsShadowRoot
in case the controls haven't been created yet.

LayoutTests:

* media/controls/airplay-controls-expected.txt: Added.
* media/controls/airplay-controls.html: Added.

* media/controls/controls-test-helpers.js:
(ControlsTest.prototype.get currentState): Put a try block around the call to get the current
status in case it fails.

* platform/mac/TestExpectations: Skip the new test on Yosemite where AirPlay doesn't work.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsmediacontrolscontrolstesthelpersjs">trunk/LayoutTests/media/controls/controls-test-helpers.js</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediacontrolsmediaControlsApplejs">trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediacontrolsairplaycontrolsexpectedtxt">trunk/LayoutTests/media/controls/airplay-controls-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsairplaycontrolshtml">trunk/LayoutTests/media/controls/airplay-controls.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (203150 => 203151)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-13 04:47:00 UTC (rev 203150)
+++ trunk/LayoutTests/ChangeLog        2016-07-13 04:50:14 UTC (rev 203151)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-07-12  Eric Carlson  &lt;eric.carlson@apple.com&gt;
+
+        REGRESSION (r202509): media controls controls enabled AirPlay placeholder is shown
+        https://bugs.webkit.org/show_bug.cgi?id=159685
+        &lt;rdar://problem/27198899&gt;
+
+        Reviewed by Dean Jackson.
+
+        * media/controls/airplay-controls-expected.txt: Added.
+        * media/controls/airplay-controls.html: Added.
+
+        * media/controls/controls-test-helpers.js:
+        (ControlsTest.prototype.get currentState): Put a try block around the call to get the current
+        status in case it fails.
+
+        * platform/mac/TestExpectations: Skip the new test on Yosemite where AirPlay doesn't work.
+
</ins><span class="cx"> 2016-07-12  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] Array.prototype.join() fails some conformance tests
</span></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsairplaycontrolsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/controls/airplay-controls-expected.txt (0 => 203151)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/airplay-controls-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/controls/airplay-controls-expected.txt        2016-07-13 04:50:14 UTC (rev 203151)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+This tests that showing the wireless device placeholder does not show controls.
+
+This test only runs in DRT!
+
+
+EVENT: canplaythrough
+
+Test initial state
+
+PASS: We are using the apple idiom
+PASS: video.controls should be false
+PASS: Controls should not be visible
+
+Select an AppleTV device
+
+PASS: Placeholder is visible
+PASS: Placeholder has classname 'appletv'
+PASS: Controls should not be visible
+
+Testing finished.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsairplaycontrolshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/controls/airplay-controls.html (0 => 203151)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/airplay-controls.html                                (rev 0)
+++ trunk/LayoutTests/media/controls/airplay-controls.html        2016-07-13 04:50:14 UTC (rev 203151)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=&quot;../media-file.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;controls-test-helpers.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            internals.setMockMediaPlaybackTargetPickerEnabled(true);
+            internals.settings.setAllowsAirPlayForMediaPlayback(true);
+
+            let eventCounter = 0;
+
+            function isVisible(state)
+            {
+                if (state === null || typeof state.className !== &quot;string&quot;)
+                    return true;
+
+                const classes = state.className.split();
+                return !classes.includes(&quot;dropped&quot;) &amp;&amp; !classes.includes(&quot;hidden&quot;);
+            }
+
+            function start() 
+            {
+                tester.startNewSection(&quot;Test initial state&quot;);
+
+                tester.test(&quot;We are using the apple idiom&quot;)
+                    .value(tester.currentState.idiom)
+                    .isEqualTo(&quot;apple&quot;);
+
+                tester.test(&quot;video.controls should be false&quot;)
+                    .value(tester.media.controls)
+                    .isFalse();
+
+                const controlPanel = tester.stateForControlsElement(&quot;Media Controls Panel&quot;);
+                tester.test(&quot;Controls should not be visible&quot;)
+                    .value(isVisible(controlPanel))
+                    .isFalse();
+
+                tester.startNewSection(&quot;Select an AppleTV device&quot;);
+                internals.setMediaElementRestrictions(tester.media, &quot;norestrictions&quot;);
+                tester.media.addEventListener('webkitplaybacktargetavailabilitychanged', () =&gt; { }, false);
+                tester.media.addEventListener('webkitcurrentplaybacktargetiswirelesschanged', targetChanged, false);
+                internals.setMockMediaPlaybackTargetPickerState(&quot;Sleepy TV&quot;, &quot;DeviceAvailable&quot;);
+            }
+
+            function targetChanged()
+            {
+                if (!tester.media.webkitCurrentPlaybackTargetIsWireless)
+                    return;
+
+                // Because this script is triggered by the same event the default controls use to
+                // show the placeholder, this may run before the controls have been reconfigured.
+                const placeholder = tester.stateForControlsElement(&quot;Inline playback placeholder&quot;, true);
+                if (!isVisible(placeholder) &amp;&amp; ++eventCounter &lt; 5) {
+                    setTimeout(targetChanged, 100);
+                    return;
+                }
+
+                tester.test(&quot;Placeholder is visible&quot;)
+                    .value(isVisible(placeholder))
+                    .isTrue();
+                tester.test(&quot;Placeholder has classname 'appletv'&quot;)
+                    .value(placeholder.className)
+                    .contains(&quot;appletv&quot;);
+
+                const controlPanel = tester.stateForControlsElement(&quot;Media Controls Panel&quot;);
+                tester.test(&quot;Controls should not be visible&quot;)
+                    .value(isVisible(controlPanel))
+                    .isFalse();
+
+                tester.end();
+            }
+
+            const tester = new ControlsTest()
+                .whenReady(start)
+                .start();
+
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;p&gt;This tests that showing the wireless device placeholder does not show controls.&lt;/p&gt;
+        &lt;p&gt;This test only runs in DRT!&lt;/p&gt;
+        &lt;video &gt;&lt;/video&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsmediacontrolscontrolstesthelpersjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/controls-test-helpers.js (203150 => 203151)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/controls-test-helpers.js        2016-07-13 04:47:00 UTC (rev 203150)
+++ trunk/LayoutTests/media/controls/controls-test-helpers.js        2016-07-13 04:50:14 UTC (rev 203151)
</span><span class="lines">@@ -40,7 +40,11 @@
</span><span class="cx">             return null;
</span><span class="cx"> 
</span><span class="cx">         if (window.internals) {
</span><del>-            this.cachedCurrentState = JSON.parse(internals.getCurrentMediaControlsStatusForElement(this.media));
</del><ins>+            let state = { idiom: &quot;apple&quot;, status: &quot;fail&quot; };
+            try {
+                state = JSON.parse(internals.getCurrentMediaControlsStatusForElement(this.media));
+            } catch(e) { }
+            this.cachedCurrentState = state;
</ins><span class="cx">             return this.cachedCurrentState;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (203150 => 203151)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2016-07-13 04:47:00 UTC (rev 203150)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2016-07-13 04:50:14 UTC (rev 203151)
</span><span class="lines">@@ -1288,6 +1288,7 @@
</span><span class="cx"> [ Yosemite ] media/airplay-target-availability.html
</span><span class="cx"> [ Yosemite ] media/controls/airplay-picker.html
</span><span class="cx"> [ Yosemite ] media/airplay-autoplay.html
</span><ins>+[ Yosemite ] media/controls/airplay-controls.html
</ins><span class="cx"> 
</span><span class="cx"> webkit.org/b/153086 sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/15.1.3/15.1.3.3_encodeURI/S15.1.3.3_A2.4_T2.html [ Pass Crash ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203150 => 203151)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-13 04:47:00 UTC (rev 203150)
+++ trunk/Source/WebCore/ChangeLog        2016-07-13 04:50:14 UTC (rev 203151)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-07-12  Eric Carlson  &lt;eric.carlson@apple.com&gt;
+
+        REGRESSION (r202509): media controls controls enabled AirPlay placeholder is shown
+        https://bugs.webkit.org/show_bug.cgi?id=159685
+        &lt;rdar://problem/27198899&gt;
+
+        Reviewed by Dean Jackson.
+
+        Test: media/controls/airplay-controls.html
+
+        * Modules/mediacontrols/mediaControlsApple.js:
+        (Controller.prototype.shouldShowControls): Split some of the logic out of shouldHaveControls.
+        (Controller.prototype.shouldHaveControls): Having controls != showing controls.
+        (Controller.prototype.updateControls): Call shouldShowControls, not shouldHaveControls.
+        (Controller.prototype.updateWirelessPlaybackStatus): Add 'appletv' to the class when active.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::getCurrentMediaControlsStatus): Call ensureMediaControlsShadowRoot
+        in case the controls haven't been created yet.
+
</ins><span class="cx"> 2016-07-12  Frederic Wang  &lt;fwang@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move parsing of mpadded attributes to a MathMLPaddedElement class
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediacontrolsmediaControlsApplejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (203150 => 203151)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js        2016-07-13 04:47:00 UTC (rev 203150)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js        2016-07-13 04:50:14 UTC (rev 203151)
</span><span class="lines">@@ -118,7 +118,8 @@
</span><span class="cx">         out: 'out',
</span><span class="cx">         pictureInPictureButton: 'picture-in-picture-button',
</span><span class="cx">         placeholderShowing: 'placeholder-showing',
</span><del>-        usesLTRUserInterfaceLayoutDirection: 'uses-ltr-user-interface-layout-direction'
</del><ins>+        usesLTRUserInterfaceLayoutDirection: 'uses-ltr-user-interface-layout-direction',
+        appleTV: 'appletv',
</ins><span class="cx">     },
</span><span class="cx">     KeyCodes: {
</span><span class="cx">         enter: 13,
</span><span class="lines">@@ -301,16 +302,19 @@
</span><span class="cx">         return this.shouldHaveControls() || (this.video.textTracks &amp;&amp; this.video.textTracks.length) || this.currentPlaybackTargetIsWireless();
</span><span class="cx">     },
</span><span class="cx"> 
</span><del>-    shouldHaveControls: function()
</del><ins>+    shouldShowControls: function()
</ins><span class="cx">     {
</span><span class="cx">         if (!this.isAudio() &amp;&amp; !this.host.allowsInlineMediaPlayback)
</span><span class="cx">             return true;
</span><span class="cx"> 
</span><del>-        if (this.isFullScreen() || this.presentationMode() === 'picture-in-picture' || this.currentPlaybackTargetIsWireless())
-            return true;
</del><ins>+        return this.video.controls || this.isFullScreen();
+    },
</ins><span class="cx"> 
</span><del>-        return this.video.controls;
</del><ins>+    shouldHaveControls: function()
+    {
+        return this.shouldShowControls() || this.isFullScreen() || this.presentationMode() === 'picture-in-picture' || this.currentPlaybackTargetIsWireless();
</ins><span class="cx">     },
</span><ins>+    
</ins><span class="cx"> 
</span><span class="cx">     setNeedsTimelineMetricsUpdate: function()
</span><span class="cx">     {
</span><span class="lines">@@ -670,7 +674,7 @@
</span><span class="cx">         this.updateLayoutForDisplayedWidth();
</span><span class="cx">         this.setNeedsTimelineMetricsUpdate();
</span><span class="cx"> 
</span><del>-        if (this.shouldHaveControls()) {
</del><ins>+        if (this.shouldShowControls()) {
</ins><span class="cx">             this.controls.panel.classList.add(this.ClassNames.show);
</span><span class="cx">             this.controls.panel.classList.remove(this.ClassNames.hidden);
</span><span class="cx">             this.resetHideControlsTimer();
</span><span class="lines">@@ -2153,6 +2157,7 @@
</span><span class="cx">             this.controls.inlinePlaybackPlaceholderTextTop.innerText = deviceType;
</span><span class="cx">             this.controls.inlinePlaybackPlaceholderTextBottom.innerText = deviceName;
</span><span class="cx">             this.controls.inlinePlaybackPlaceholder.setAttribute('aria-label', deviceType + &quot;, &quot; + deviceName);
</span><ins>+            this.controls.inlinePlaybackPlaceholder.classList.add(this.ClassNames.appleTV);
</ins><span class="cx">             this.controls.inlinePlaybackPlaceholder.classList.remove(this.ClassNames.hidden);
</span><span class="cx">             this.controls.wirelessTargetPicker.classList.add(this.ClassNames.playing);
</span><span class="cx">             if (!this.isFullScreen() &amp;&amp; (this.video.offsetWidth &lt;= 250 || this.video.offsetHeight &lt;= 200)) {
</span><span class="lines">@@ -2170,6 +2175,7 @@
</span><span class="cx">             this.showControls();
</span><span class="cx">         } else {
</span><span class="cx">             this.controls.inlinePlaybackPlaceholder.classList.add(this.ClassNames.hidden);
</span><ins>+            this.controls.inlinePlaybackPlaceholder.classList.remove(this.ClassNames.appleTV);
</ins><span class="cx">             this.controls.wirelessTargetPicker.classList.remove(this.ClassNames.playing);
</span><span class="cx">             this.controls.volumeBox.classList.remove(this.ClassNames.hidden);
</span><span class="cx">             this.controls.muteBox.classList.remove(this.ClassNames.hidden);
</span><span class="lines">@@ -2364,6 +2370,15 @@
</span><span class="cx">                 name: &quot;Inline playback placeholder&quot;,
</span><span class="cx">                 object: this.controls.inlinePlaybackPlaceholder,
</span><span class="cx">             },
</span><ins>+            {
+                name: &quot;Media Controls Panel&quot;,
+                object: this.controls.panel,
+                extraProperties: [&quot;hidden&quot;],
+            },
+            {
+                name: &quot;Control Base Element&quot;,
+                object: this.base || null,
+            },
</ins><span class="cx">         ];
</span><span class="cx"> 
</span><span class="cx">         elements.forEach(function (element) {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (203150 => 203151)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-07-13 04:47:00 UTC (rev 203150)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-07-13 04:50:14 UTC (rev 203151)
</span><span class="lines">@@ -6704,6 +6704,8 @@
</span><span class="cx"> String HTMLMediaElement::getCurrentMediaControlsStatus()
</span><span class="cx"> {
</span><span class="cx">     DOMWrapperWorld&amp; world = ensureIsolatedWorld();
</span><ins>+    ensureMediaControlsShadowRoot();
+
</ins><span class="cx">     ScriptController&amp; scriptController = document().frame()-&gt;script();
</span><span class="cx">     JSDOMGlobalObject* globalObject = JSC::jsCast&lt;JSDOMGlobalObject*&gt;(scriptController.globalObject(world));
</span><span class="cx">     JSC::ExecState* exec = globalObject-&gt;globalExec();
</span></span></pre>
</div>
</div>

</body>
</html>