<!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>[203913] 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/203913">203913</a></dd>
<dt>Author</dt> <dd>n_wang@apple.com</dd>
<dt>Date</dt> <dd>2016-07-29 12:11:29 -0700 (Fri, 29 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>AX: Media controls accessibility improvement
https://bugs.webkit.org/show_bug.cgi?id=160223
&lt;rdar://problem/27558003&gt;

Reviewed by Eric Carlson.

Source/WebCore:

Changes in this patch:
1. Added a change observer for volume slider so that it will handle accessibility
   increment/decrement functions correctly.
2. Update the timer div's aria-label when time changes.
3. Added a keydown handler for left/right arrow adjusting the timeline, so that the
   value increment/decrement in a reasonable way.
4. Changed the mute button's role to checkbox since it only has on/off states.

Test: media/media-controls-accessibility.html

* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.createControls):
(Controller.prototype.updatePictureInPictureButton):
(Controller.prototype.timelineStepFromVideoDuration):
(Controller.prototype.incrementTimelineValue):
(Controller.prototype.decrementTimelineValue):
(Controller.prototype.showInlinePlaybackPlaceholderWhenSafe):
(Controller.prototype.handleTimelineMouseUp):
(Controller.prototype.handleTimelineKeyDown):
(Controller.prototype.handleMuteButtonClicked):
(Controller.prototype.handleMinButtonClicked):
(Controller.prototype.handleMaxButtonClicked):
(Controller.prototype.updateVideoVolume):
(Controller.prototype.handleVolumeSliderInput):
(Controller.prototype.handleVolumeSliderChange):
(Controller.prototype.handleVolumeSliderMouseDown):
(Controller.prototype.updateTime):
(Controller.prototype.updateControlsWhileScrubbing):
(Controller.prototype.updateVolume):

LayoutTests:

* accessibility/mac/video-volume-slider-accessibility-expected.txt:
* accessibility/mac/video-volume-slider-accessibility.html:
* accessibility/media-emits-object-replacement-expected.txt:
* media/media-controls-accessibility-expected.txt: Added.
* media/media-controls-accessibility.html: Added.
* platform/efl/accessibility/media-element-expected.txt:
* platform/efl/accessibility/media-emits-object-replacement-expected.txt:
* platform/gtk/accessibility/media-element-expected.txt:
* platform/gtk/accessibility/media-emits-object-replacement-expected.txt:
* platform/mac/accessibility/media-element-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsaccessibilitymacvideovolumeslideraccessibilityexpectedtxt">trunk/LayoutTests/accessibility/mac/video-volume-slider-accessibility-expected.txt</a></li>
<li><a href="#trunkLayoutTestsaccessibilitymacvideovolumeslideraccessibilityhtml">trunk/LayoutTests/accessibility/mac/video-volume-slider-accessibility.html</a></li>
<li><a href="#trunkLayoutTestsaccessibilitymediaemitsobjectreplacementexpectedtxt">trunk/LayoutTests/accessibility/media-emits-object-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformeflaccessibilitymediaelementexpectedtxt">trunk/LayoutTests/platform/efl/accessibility/media-element-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformeflaccessibilitymediaemitsobjectreplacementexpectedtxt">trunk/LayoutTests/platform/efl/accessibility/media-emits-object-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformgtkaccessibilitymediaelementexpectedtxt">trunk/LayoutTests/platform/gtk/accessibility/media-element-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformgtkaccessibilitymediaemitsobjectreplacementexpectedtxt">trunk/LayoutTests/platform/gtk/accessibility/media-emits-object-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacaccessibilitymediaelementexpectedtxt">trunk/LayoutTests/platform/mac/accessibility/media-element-expected.txt</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>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediamediacontrolsaccessibilityexpectedtxt">trunk/LayoutTests/media/media-controls-accessibility-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediamediacontrolsaccessibilityhtml">trunk/LayoutTests/media/media-controls-accessibility.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/ChangeLog        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-07-29  Nan Wang  &lt;n_wang@apple.com&gt;
+
+        AX: Media controls accessibility improvement
+        https://bugs.webkit.org/show_bug.cgi?id=160223
+        &lt;rdar://problem/27558003&gt;
+
+        Reviewed by Eric Carlson.
+
+        * accessibility/mac/video-volume-slider-accessibility-expected.txt:
+        * accessibility/mac/video-volume-slider-accessibility.html:
+        * accessibility/media-emits-object-replacement-expected.txt:
+        * media/media-controls-accessibility-expected.txt: Added.
+        * media/media-controls-accessibility.html: Added.
+        * platform/efl/accessibility/media-element-expected.txt:
+        * platform/efl/accessibility/media-emits-object-replacement-expected.txt:
+        * platform/gtk/accessibility/media-element-expected.txt:
+        * platform/gtk/accessibility/media-emits-object-replacement-expected.txt:
+        * platform/mac/accessibility/media-element-expected.txt:
+
</ins><span class="cx"> 2016-07-29  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unskip some media tests on iOS when run in WebKitTestRunner
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymacvideovolumeslideraccessibilityexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/accessibility/mac/video-volume-slider-accessibility-expected.txt (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/mac/video-volume-slider-accessibility-expected.txt        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/accessibility/mac/video-volume-slider-accessibility-expected.txt        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> PASS slider.valueDescription is 'AXValueDescription: 100%'
</span><del>-PASS slider.intValue.toFixed(2) is '0.95'
</del><ins>+PASS slider.valueDescription is 'AXValueDescription: 95%'
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymacvideovolumeslideraccessibilityhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/accessibility/mac/video-volume-slider-accessibility.html (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/mac/video-volume-slider-accessibility.html        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/accessibility/mac/video-volume-slider-accessibility.html        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx">           
</span><span class="cx">           // Then decrement the slider and check the step is 0.05.
</span><span class="cx">           slider.decrement();
</span><del>-          shouldBe(&quot;slider.intValue.toFixed(2)&quot;, &quot;'0.95'&quot;);
</del><ins>+          shouldBe(&quot;slider.valueDescription&quot;, &quot;'AXValueDescription: 95%'&quot;);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymediaemitsobjectreplacementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/accessibility/media-emits-object-replacement-expected.txt (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/media-emits-object-replacement-expected.txt        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/accessibility/media-emits-object-replacement-expected.txt        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx">                 AXRole: AXGroup AXValue: 
</span><span class="cx">                 AXRole: AXSlider AXValue: 1
</span><span class="cx">                     AXRole: AXValueIndicator AXValue: 1
</span><del>-                AXRole: AXButton AXValue: 
</del><ins>+                AXRole: AXCheckBox AXValue: 0
</ins><span class="cx">         AXRole: AXStaticText AXValue:  b
</span><span class="cx">     AXRole: AXGroup AXValue: 
</span><span class="cx">     AXRole: AXGroup AXValue: 
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx">                 AXRole: AXGroup AXValue: 
</span><span class="cx">                 AXRole: AXSlider AXValue: 1
</span><span class="cx">                     AXRole: AXValueIndicator AXValue: 1
</span><del>-                AXRole: AXButton AXValue: 
</del><ins>+                AXRole: AXCheckBox AXValue: 0
</ins><span class="cx">         AXRole: AXStaticText AXValue:  b
</span><span class="cx">     AXRole: AXGroup AXValue: 
</span><span class="cx"> This tests ensures that if video or audio tags are used, they will emit an object replacement character in a range for string operation.
</span></span></pre></div>
<a id="trunkLayoutTestsmediamediacontrolsaccessibilityexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/media-controls-accessibility-expected.txt (0 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/media-controls-accessibility-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/media-controls-accessibility-expected.txt        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+
+This tests that media controls have correct accessibility information.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+elapsedTimer.description: AXDescription: Elapsed 00:00
+remainingTimer.description: AXDescription: Remaining -00:06
+
+muteButton.description: AXDescription: Mute
+muteButton.role: AXRole: AXCheckBox
+muteButton.stringValue: AXValue: 0
+press muteButton
+muteButton.stringValue: AXValue: 1
+
+timeline.value: 0.5
+timeline.value: 0.0
+
+RUN(video.load())
+EVENT(canplaythrough)
+EVENT(seeked)
+EVENT(seeked)
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediamediacontrolsaccessibilityhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/media-controls-accessibility.html (0 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/media-controls-accessibility.html                                (rev 0)
+++ trunk/LayoutTests/media/media-controls-accessibility.html        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;video id=&quot;video&quot; controls&gt;&lt;/video&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;head&gt;
+&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;media-file.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;media-controls.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;video-test.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+
+&lt;script&gt;
+
+description(&quot;This tests that media controls have correct accessibility information.&quot;);
+
+if (window.accessibilityController) {
+    testRunner.overridePreference(&quot;WebKitTabToLinksPreferenceKey&quot;, 1); 
+    video.src = findMediaFile(&quot;video&quot;, &quot;content/test&quot;);
+    
+    var videoElement;
+    var elapsedTimer, remainingTimer, timeline, muteButton;
+    var rightArrow = true;
+    run(&quot;video.load()&quot;);
+    waitForEvent(&quot;canplaythrough&quot;, function () {
+        videoElement = accessibilityController.accessibleElementById(&quot;video&quot;);
+        // Elapsed and remaining timer have the right ax label.
+        elapsedTimer = videoElement.childAtIndex(0).childAtIndex(3);
+        remainingTimer = videoElement.childAtIndex(0).childAtIndex(5);
+        debug(&quot;elapsedTimer.description: &quot; + elapsedTimer.description);
+        debug(&quot;remainingTimer.description: &quot; + remainingTimer.description + &quot;\n&quot;);
+              
+        // Mute button should be a checkbox with on/off state.
+        muteButton = videoElement.childAtIndex(0).childAtIndex(9);
+        debug(&quot;muteButton.description: &quot; + muteButton.description);
+        debug(&quot;muteButton.role: &quot; + muteButton.role);
+        debug(&quot;muteButton.stringValue: &quot; + muteButton.stringValue);
+        debug(&quot;press muteButton&quot;);
+        muteButton.press();
+        debug(&quot;muteButton.stringValue: &quot; + muteButton.stringValue + &quot;\n&quot;);
+              
+        // Left/Right arrow key should have 0.5 second step on timeline. 
+        checkTimeLineValue(rightArrow);
+    }); 
+    
+    waitForEvent(&quot;seeked&quot;, function () {
+        var timeline = mediaControlsElement(internals.shadowRoot(video).firstChild.firstChild, '-webkit-media-controls-timeline');
+        if (!timeline)
+            throw &quot;Failed to find -webkit-media-controls-timeline&quot;;
+        debug(&quot;timeline.value: &quot; + parseFloat(timeline.value).toFixed(1));
+        if (rightArrow) {
+            rightArrow = false;
+            checkTimeLineValue(rightArrow);
+        } else {
+            debug(&quot;&quot;);
+            endTest();
+        }
+    });
+}
+     
+function checkTimeLineValue(isRightArrow)
+{
+    var timeline = mediaControlsElement(internals.shadowRoot(video).firstChild.firstChild, '-webkit-media-controls-timeline');
+    if (!timeline)
+        throw &quot;Failed to find -webkit-media-controls-timeline&quot;;
+        
+    timeline.focus();
+    if (isRightArrow) {
+        eventSender.keyDown(&quot;rightArrow&quot;);
+    } else {
+        eventSender.keyDown(&quot;leftArrow&quot;);
+    }
+}
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformeflaccessibilitymediaelementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/efl/accessibility/media-element-expected.txt (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/efl/accessibility/media-element-expected.txt        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/platform/efl/accessibility/media-element-expected.txt        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">             role: AXRole: AXButton
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-            title: AXTitle: Elapsed
</del><ins>+            title: AXTitle: Elapsed 00:00
</ins><span class="cx">             role: AXRole: AXTimer
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx">             role: AXRole: AXSlider
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-            title: AXTitle: Remaining
</del><ins>+            title: AXTitle: Remaining -00:06
</ins><span class="cx">             role: AXRole: AXTimer
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">             title: AXTitle: Mute
</span><del>-            role: AXRole: AXButton
</del><ins>+            role: AXRole: AXCheckbox
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">             title: AXTitle: Display Full Screen
</span></span></pre></div>
<a id="trunkLayoutTestsplatformeflaccessibilitymediaemitsobjectreplacementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/efl/accessibility/media-emits-object-replacement-expected.txt (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/efl/accessibility/media-emits-object-replacement-expected.txt        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/platform/efl/accessibility/media-emits-object-replacement-expected.txt        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -7,7 +7,7 @@
</span><span class="cx">         AXRole: AXVideo 
</span><span class="cx">             AXRole: AXToolbar 
</span><span class="cx">                 AXRole: AXToolbar 
</span><del>-                    AXRole: AXButton 
</del><ins>+                    AXRole: AXCheckBox 
</ins><span class="cx">                     AXRole: AXSlider 
</span><span class="cx">     AXRole: AXGroup AXValue: &lt;\n&gt;
</span><span class="cx">     AXRole: AXSection AXValue: a &lt;obj&gt; b
</span><span class="lines">@@ -14,7 +14,7 @@
</span><span class="cx">         AXRole: AXAudio 
</span><span class="cx">             AXRole: AXToolbar 
</span><span class="cx">                 AXRole: AXToolbar 
</span><del>-                    AXRole: AXButton 
</del><ins>+                    AXRole: AXCheckBox 
</ins><span class="cx">                     AXRole: AXSlider 
</span><span class="cx">     AXRole: AXSection AXValue: End of test
</span><span class="cx"> This tests ensures that if video or audio tags are used, they will emit an object replacement character in a range for string operation.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkaccessibilitymediaelementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/accessibility/media-element-expected.txt (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/accessibility/media-element-expected.txt        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/platform/gtk/accessibility/media-element-expected.txt        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">             role: AXRole: AXSlider
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-            title: AXTitle: Remaining
</del><ins>+            title: AXTitle: Remaining -00:06
</ins><span class="cx">             role: AXRole: AXTimer
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">             title: AXTitle: Mute
</span><del>-            role: AXRole: AXButton
</del><ins>+            role: AXRole: AXCheckbox
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">             title: AXTitle: Volume
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkaccessibilitymediaemitsobjectreplacementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/accessibility/media-emits-object-replacement-expected.txt (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/accessibility/media-emits-object-replacement-expected.txt        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/platform/gtk/accessibility/media-emits-object-replacement-expected.txt        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx">     AXRole: AXSection AXValue: a &lt;obj&gt; b
</span><span class="cx">         AXRole: AXVideo 
</span><span class="cx">             AXRole: AXToolbar 
</span><del>-                AXRole: AXButton 
</del><ins>+                AXRole: AXCheckBox 
</ins><span class="cx">                 AXRole: AXSlider 
</span><span class="cx">                 AXRole: AXTimer AXValue: 00:00
</span><span class="cx">     AXRole: AXSection AXValue: &lt;\n&gt;
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx">     AXRole: AXSection AXValue: a &lt;obj&gt; b
</span><span class="cx">         AXRole: AXAudio 
</span><span class="cx">             AXRole: AXToolbar 
</span><del>-                AXRole: AXButton 
</del><ins>+                AXRole: AXCheckBox 
</ins><span class="cx">                 AXRole: AXSlider 
</span><span class="cx">                 AXRole: AXTimer AXValue: 00:00
</span><span class="cx">     AXRole: AXSection AXValue: End of test
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacaccessibilitymediaelementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/accessibility/media-element-expected.txt (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/accessibility/media-element-expected.txt        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/LayoutTests/platform/mac/accessibility/media-element-expected.txt        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx">             role: AXRole: AXButton
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-            description: AXDescription: Elapsed
</del><ins>+            description: AXDescription: Elapsed 00:00
</ins><span class="cx">             role: AXRole: AXGroup
</span><span class="cx">             subrole: AXSubrole: AXApplicationTimer
</span><span class="cx"> 
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">                 role: AXRole: AXValueIndicator
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-            description: AXDescription: Remaining
</del><ins>+            description: AXDescription: Remaining -00:06
</ins><span class="cx">             role: AXRole: AXGroup
</span><span class="cx">             subrole: AXSubrole: AXApplicationTimer
</span><span class="cx"> 
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">             description: AXDescription: Mute
</span><del>-            role: AXRole: AXButton
</del><ins>+            role: AXRole: AXCheckBox
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">             description: AXDescription: Display Full Screen
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/Source/WebCore/ChangeLog        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2016-07-29  Nan Wang  &lt;n_wang@apple.com&gt;
+
+        AX: Media controls accessibility improvement
+        https://bugs.webkit.org/show_bug.cgi?id=160223
+        &lt;rdar://problem/27558003&gt;
+
+        Reviewed by Eric Carlson.
+
+        Changes in this patch:
+        1. Added a change observer for volume slider so that it will handle accessibility 
+           increment/decrement functions correctly.
+        2. Update the timer div's aria-label when time changes.
+        3. Added a keydown handler for left/right arrow adjusting the timeline, so that the
+           value increment/decrement in a reasonable way.
+        4. Changed the mute button's role to checkbox since it only has on/off states.
+
+        Test: media/media-controls-accessibility.html
+
+        * Modules/mediacontrols/mediaControlsApple.js:
+        (Controller.prototype.createControls):
+        (Controller.prototype.updatePictureInPictureButton):
+        (Controller.prototype.timelineStepFromVideoDuration):
+        (Controller.prototype.incrementTimelineValue):
+        (Controller.prototype.decrementTimelineValue):
+        (Controller.prototype.showInlinePlaybackPlaceholderWhenSafe):
+        (Controller.prototype.handleTimelineMouseUp):
+        (Controller.prototype.handleTimelineKeyDown):
+        (Controller.prototype.handleMuteButtonClicked):
+        (Controller.prototype.handleMinButtonClicked):
+        (Controller.prototype.handleMaxButtonClicked):
+        (Controller.prototype.updateVideoVolume):
+        (Controller.prototype.handleVolumeSliderInput):
+        (Controller.prototype.handleVolumeSliderChange):
+        (Controller.prototype.handleVolumeSliderMouseDown):
+        (Controller.prototype.updateTime):
+        (Controller.prototype.updateControlsWhileScrubbing):
+        (Controller.prototype.updateVolume):
+
</ins><span class="cx"> 2016-07-29  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove an unused line of code.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediacontrolsmediaControlsApplejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (203912 => 203913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js        2016-07-29 18:58:23 UTC (rev 203912)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js        2016-07-29 19:11:29 UTC (rev 203913)
</span><span class="lines">@@ -421,6 +421,7 @@
</span><span class="cx">         this.listenFor(timeline, 'mousemove', this.handleTimelineMouseMove);
</span><span class="cx">         this.listenFor(timeline, 'mousedown', this.handleTimelineMouseDown);
</span><span class="cx">         this.listenFor(timeline, 'mouseup', this.handleTimelineMouseUp);
</span><ins>+        this.listenFor(timeline, 'keydown', this.handleTimelineKeyDown);
</ins><span class="cx">         timeline.step = .01;
</span><span class="cx"> 
</span><span class="cx">         this.timelineContextName = &quot;_webkit-media-controls-timeline-&quot; + this.host.generateUUID();
</span><span class="lines">@@ -447,6 +448,8 @@
</span><span class="cx">         var muteButton = this.controls.muteButton = document.createElement('button');
</span><span class="cx">         muteButton.setAttribute('pseudo', '-webkit-media-controls-mute-button');
</span><span class="cx">         muteButton.setAttribute('aria-label', this.UIString('Mute'));
</span><ins>+        // Make the mute button a checkbox since it only has on/off states.
+        muteButton.setAttribute('role', 'checkbox');
</ins><span class="cx">         this.listenFor(muteButton, 'click', this.handleMuteButtonClicked);
</span><span class="cx"> 
</span><span class="cx">         var minButton = this.controls.minButton = document.createElement('button');
</span><span class="lines">@@ -477,6 +480,7 @@
</span><span class="cx">         volume.max = 1;
</span><span class="cx">         volume.step = .05;
</span><span class="cx">         this.listenFor(volume, 'input', this.handleVolumeSliderInput);
</span><ins>+        this.listenFor(volume, 'change', this.handleVolumeSliderChange);
</ins><span class="cx">         this.listenFor(volume, 'mousedown', this.handleVolumeSliderMouseDown);
</span><span class="cx">         this.listenFor(volume, 'mouseup', this.handleVolumeSliderMouseUp);
</span><span class="cx"> 
</span><span class="lines">@@ -863,7 +867,37 @@
</span><span class="cx">         } else
</span><span class="cx">             this.controls.pictureInPictureButton.classList.add(this.ClassNames.hidden);
</span><span class="cx">     },
</span><ins>+    
+    timelineStepFromVideoDuration: function()
+    {
+        var step;
+        var duration = this.video.duration;
+        if (duration &lt;= 10)
+            step = .5;
+        else if (duration &lt;= 60)
+            step = 1;
+        else if (duration &lt;= 600)
+            step = 10;
+        else if (duration &lt;= 3600)
+            step = 30;
+        else
+            step = 60;
+        
+        return step;
+    },
+    
+    incrementTimelineValue: function()
+    {
+        var value = this.video.currentTime + this.timelineStepFromVideoDuration();
+        return value &gt; this.video.duration ? this.video.duration : value;
+    },
</ins><span class="cx"> 
</span><ins>+    decrementTimelineValue: function()
+    {
+        var value = this.video.currentTime - this.timelineStepFromVideoDuration();
+        return value &lt; 0 ? 0 : value;
+    },
+
</ins><span class="cx">     showInlinePlaybackPlaceholderWhenSafe: function() {
</span><span class="cx">         if (this.presentationMode() != 'picture-in-picture')
</span><span class="cx">             return;
</span><span class="lines">@@ -1122,12 +1156,22 @@
</span><span class="cx">     {
</span><span class="cx">         this.scrubbing = false;
</span><span class="cx">     },
</span><ins>+    
+    handleTimelineKeyDown: function(event)
+    {
+        if (event.keyCode == this.KeyCodes.left)
+            this.controls.timeline.value = this.decrementTimelineValue();
+        else if (event.keyCode == this.KeyCodes.right)
+            this.controls.timeline.value = this.incrementTimelineValue();
+    },
</ins><span class="cx"> 
</span><span class="cx">     handleMuteButtonClicked: function(event)
</span><span class="cx">     {
</span><span class="cx">         this.video.muted = !this.video.muted;
</span><span class="cx">         if (this.video.muted)
</span><del>-            this.controls.muteButton.setAttribute('aria-label', this.UIString('Unmute'));
</del><ins>+            this.controls.muteButton.setAttribute('aria-checked', 'true');
+        else
+            this.controls.muteButton.setAttribute('aria-checked', 'false');
</ins><span class="cx">         this.drawVolumeBackground();
</span><span class="cx">         return true;
</span><span class="cx">     },
</span><span class="lines">@@ -1141,7 +1185,7 @@
</span><span class="cx">     {
</span><span class="cx">         if (this.video.muted) {
</span><span class="cx">             this.video.muted = false;
</span><del>-            this.controls.muteButton.setAttribute('aria-label', this.UIString('Mute'));
</del><ins>+            this.controls.muteButton.setAttribute('aria-checked', 'false');
</ins><span class="cx">         }
</span><span class="cx">         this.video.volume = 0;
</span><span class="cx">         return true;
</span><span class="lines">@@ -1151,21 +1195,31 @@
</span><span class="cx">     {
</span><span class="cx">         if (this.video.muted) {
</span><span class="cx">             this.video.muted = false;
</span><del>-            this.controls.muteButton.setAttribute('aria-label', this.UIString('Mute'));
</del><ins>+            this.controls.muteButton.setAttribute('aria-checked', 'false');
</ins><span class="cx">         }
</span><span class="cx">         this.video.volume = 1;
</span><span class="cx">     },
</span><span class="cx"> 
</span><del>-    handleVolumeSliderInput: function(event)
</del><ins>+    updateVideoVolume: function()
</ins><span class="cx">     {
</span><span class="cx">         if (this.video.muted) {
</span><span class="cx">             this.video.muted = false;
</span><del>-            this.controls.muteButton.setAttribute('aria-label', this.UIString('Mute'));
</del><ins>+            this.controls.muteButton.setAttribute('aria-checked', 'false');
</ins><span class="cx">         }
</span><span class="cx">         this.video.volume = this.controls.volume.value;
</span><del>-        this.controls.volume.setAttribute('aria-valuetext', this.controls.volume.value * 100 + '%');
</del><ins>+        this.controls.volume.setAttribute('aria-valuetext', `${parseInt(this.controls.volume.value * 100)}%`);
+    },
+
+    handleVolumeSliderInput: function(event)
+    {
+        this.updateVideoVolume();
</ins><span class="cx">         this.drawVolumeBackground();
</span><span class="cx">     },
</span><ins>+    
+    handleVolumeSliderChange: function(event)
+    {
+        this.updateVideoVolume();
+    },
</ins><span class="cx"> 
</span><span class="cx">     handleVolumeSliderMouseDown: function(event)
</span><span class="cx">     {
</span><span class="lines">@@ -1709,8 +1763,10 @@
</span><span class="cx">         var currentTime = this.video.currentTime;
</span><span class="cx">         var timeRemaining = currentTime - this.video.duration;
</span><span class="cx">         this.currentTimeClone.innerText = this.controls.currentTime.innerText = this.formatTime(currentTime);
</span><ins>+        this.controls.currentTime.setAttribute('aria-label', `${this.UIString('Elapsed')} ${this.formatTime(currentTime)}`);
</ins><span class="cx">         this.controls.timeline.value = this.video.currentTime;
</span><span class="cx">         this.remainingTimeClone.innerText = this.controls.remainingTime.innerText = this.formatTime(timeRemaining);
</span><ins>+        this.controls.remainingTime.setAttribute('aria-label', `${this.UIString('Remaining')} ${this.formatTime(timeRemaining)}`);
</ins><span class="cx">     },
</span><span class="cx">     
</span><span class="cx">     updateControlsWhileScrubbing: function()
</span><span class="lines">@@ -2084,7 +2140,7 @@
</span><span class="cx">             this.controls.muteButton.classList.remove(this.ClassNames.muted);
</span><span class="cx">             this.controls.volume.value = this.video.volume;
</span><span class="cx">         }
</span><del>-        this.controls.volume.setAttribute('aria-valuetext', this.controls.volume.value * 100 + '%');
</del><ins>+        this.controls.volume.setAttribute('aria-valuetext', `${parseInt(this.controls.volume.value * 100)}%`);
</ins><span class="cx">         this.drawVolumeBackground();
</span><span class="cx">     },
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>