<!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>[150371] 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/150371">150371</a></dd>
<dt>Author</dt> <dd>graouts@apple.com</dd>
<dt>Date</dt> <dd>2013-05-20 09:47:07 -0700 (Mon, 20 May 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Mac] captions menu should behave more like a menu
https://bugs.webkit.org/show_bug.cgi?id=116436

Reviewed by Eric Carlson.

Let the captions menu behave more like a native Mac menu by hiding it when
clicking anywhere on the page and preventing the page from scrolling when
attempting to scroll the captions menu when it cannot scroll in the requested
direction.

Test: media/video-controls-captions-trackmenu-hide-on-click-outside.html

* dom/EventListener.h:
Add the new MediaControlsAppleEventListenerType.

* html/shadow/MediaControlsApple.cpp:
(WebCore::MediaControlsApple::defaultEventHandler):
(WebCore::MediaControlsApple::hide):
(WebCore::MediaControlsApple::makeTransparent):
(WebCore::MediaControlsApple::changedClosedCaptionsVisibility):
(WebCore::MediaControlsApple::reportedError):
(WebCore::MediaControlsApple::toggleClosedCaptionTrackList):
Use the hideClosedCaptionTrackList() and showClosedCaptionTrackList()
methods to hide and show the captions menu instead of calling hide()
and show() directly on m_closedCaptionsContainer.

(WebCore::MediaControlsApple::showClosedCaptionTrackList):
Show the m_closedCaptionsContainer and register a &quot;mousewheel&quot; event
listener on it as well as a &quot;click&quot; event listener on the entire document.

(WebCore::MediaControlsApple::hideClosedCaptionTrackList):
Hide the m_closedCaptionsContainer and remove the &quot;mousewheel&quot; event
listener on it as well as the &quot;click&quot; event listener on the entire document.

(WebCore::MediaControlsApple::shouldClosedCaptionsContainerPreventPageScrolling):
New private utility to determine whether the m_closedCaptionsContainer can scroll
in the provided scroll direction.

(WebCore::MediaControlsApple::eventListener):
Obtain the event listener used for &quot;mousewheel&quot; and &quot;click&quot; event handlers.

(WebCore::MediaControlsAppleEventListener::handleEvent):
Event handler for the &quot;mousewheel&quot; and &quot;click&quot; events. If we get a &quot;click&quot; event, we
toggle the captions menu visibility and if we get a &quot;mousewheel&quot; event, we call into
shouldClosedCaptionsContainerPreventPageScrolling() to see if we can scroll in the
current scroll direction, and if not prevent the event from resulting in a scroll by
calling preventDefault().

(WebCore::MediaControlsAppleEventListener::operator==):
Required for the successful subclassing of EventListener.

* html/shadow/MediaControlsApple.h:
(MediaControlsAppleEventListener):
(WebCore::MediaControlsAppleEventListener::create):
(WebCore::MediaControlsAppleEventListener::cast):
(WebCore::MediaControlsAppleEventListener::MediaControlsAppleEventListener):
New subclass of EventListener required to provide a custom event listener for the
&quot;mousewheel&quot; and &quot;click&quot; events registered in showClosedCaptionTrackList() and
hideClosedCaptionTrackList().</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformeflTestExpectations">trunk/LayoutTests/platform/efl/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformgtkTestExpectations">trunk/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformqtTestExpectations">trunk/LayoutTests/platform/qt/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwinTestExpectations">trunk/LayoutTests/platform/win/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomEventListenerh">trunk/Source/WebCore/dom/EventListener.h</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowMediaControlsApplecpp">trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowMediaControlsAppleh">trunk/Source/WebCore/html/shadow/MediaControlsApple.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediavideocontrolscaptionstrackmenuhideonclickoutsideexpectedtxt">trunk/LayoutTests/media/video-controls-captions-trackmenu-hide-on-click-outside-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediavideocontrolscaptionstrackmenuhideonclickoutsidehtml">trunk/LayoutTests/media/video-controls-captions-trackmenu-hide-on-click-outside.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/LayoutTests/ChangeLog        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2013-05-20  Antoine Quint  &lt;graouts@apple.com&gt;
+
+        [Mac] captions menu should behave more like a menu
+        https://bugs.webkit.org/show_bug.cgi?id=116436
+
+        Reviewed by Eric Carlson.
+
+        New test that checks that the caption menu hides when clicking outside
+        of the bounds of the media element.
+
+        * media/video-controls-captions-trackmenu-hide-on-click-outside-expected.txt: Added.
+        * media/video-controls-captions-trackmenu-hide-on-click-outside.html: Added.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/qt/TestExpectations:
+        * platform/win/TestExpectations:
+
</ins><span class="cx"> 2013-05-18  Rashmi Shyamasundar  &lt;rashmi.s2@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Cairo] Canvas-shadow behavior is not being as expected
</span></span></pre></div>
<a id="trunkLayoutTestsmediavideocontrolscaptionstrackmenuhideonclickoutsideexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-controls-captions-trackmenu-hide-on-click-outside-expected.txt (0 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-controls-captions-trackmenu-hide-on-click-outside-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/video-controls-captions-trackmenu-hide-on-click-outside-expected.txt        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test that we are able to trigger the list of captions, and then click elsewhere to hide it.
+
+EVENT(canplaythrough)
+
+*** Set the user language preference.
+RUN(internals.setUserPreferredLanguages(['en']))
+*** Track menu should be visible block
+EXPECTED (displayStyle == 'block') OK
+*** Track menu should be invisible none
+EXPECTED (displayStyle == 'none') OK
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediavideocontrolscaptionstrackmenuhideonclickoutsidehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-controls-captions-trackmenu-hide-on-click-outside.html (0 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-controls-captions-trackmenu-hide-on-click-outside.html                                (rev 0)
+++ trunk/LayoutTests/media/video-controls-captions-trackmenu-hide-on-click-outside.html        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;Test dismissal of track menu when clicking anywhere in the page&lt;/title&gt;
+        &lt;script src=&quot;media-controls.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;media-file.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;video-test.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;trackmenu-test.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            var displayStyle;
+
+            if (window.testRunner)
+                testRunner.dumpAsText();
+
+            function startTest()
+            {
+                testMenuIsVisible();
+            }
+
+            function testMenuIsVisible()
+            {
+                var trackListElement = getTrackListElement();
+                displayStyle = window.getComputedStyle(trackListElement.parentNode).display;
+                consoleWrite(&quot;*** Track menu should be visible &quot; + displayStyle);
+                testExpected(&quot;displayStyle&quot;, &quot;block&quot;);
+                // Now, click outside of the video to test that the track menu hides when clicking anywhere else.
+                eventSender.mouseMoveTo(1, 1);
+                eventSender.mouseDown();
+                eventSender.mouseUp();
+                testMenuIsInvisible();
+            }
+
+            function testMenuIsInvisible()
+            {
+                var trackListElement = getTrackListElement();
+                displayStyle = window.getComputedStyle(trackListElement.parentNode).display;
+                consoleWrite(&quot;*** Track menu should be invisible &quot; + displayStyle);
+                testExpected(&quot;displayStyle&quot;, &quot;none&quot;);
+                endTest();
+            }
+
+            function start()
+            {
+                findMediaElement();
+                video.src = findMediaFile('video', 'content/test');
+                waitForEvent('canplaythrough', function () { startTrackMenuTest(startTest); });
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+
+    &lt;body onload=&quot;start()&quot;&gt;
+        &lt;p&gt;Test that we are able to trigger the list of captions, and then click elsewhere to hide it.&lt;/p&gt;
+        &lt;video width=&quot;500&quot; height=&quot;300&quot; controls&gt;
+            &lt;track kind=&quot;captions&quot; src=&quot;track/captions-webvtt/captions-fast.vtt&quot; srclang=&quot;en&quot;&gt;
+        &lt;/video&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformeflTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/efl/TestExpectations (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/efl/TestExpectations        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/LayoutTests/platform/efl/TestExpectations        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -1618,6 +1618,7 @@
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ]
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click.html [ Skip ]
</span><ins>+webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click-outside.html [ Skip ]
</ins><span class="cx"> webkit.org/b/101670 media/track/track-user-preferences.html [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> # Fails until we enable the Resource Timing API.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/TestExpectations (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/TestExpectations        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/LayoutTests/platform/gtk/TestExpectations        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -744,6 +744,7 @@
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ]
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click.html [ Skip ]
</span><ins>+webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click-outside.html [ Skip ]
</ins><span class="cx"> webkit.org/b/101670 media/track/track-user-preferences.html [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/107194 storage/indexeddb/database-quota.html [ Timeout ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformqtTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/qt/TestExpectations (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/qt/TestExpectations        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/LayoutTests/platform/qt/TestExpectations        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -2597,6 +2597,7 @@
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ]
</span><span class="cx"> webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click.html [ Skip ]
</span><ins>+webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click-outside.html [ Skip ]
</ins><span class="cx"> webkit.org/b/101670 media/track/track-user-preferences.html [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> # New, but failing test
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwinTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/win/TestExpectations (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/win/TestExpectations        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/LayoutTests/platform/win/TestExpectations        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -2559,6 +2559,7 @@
</span><span class="cx"> media/video-controls-captions-trackmenu-sorted.html
</span><span class="cx"> media/video-controls-captions-trackmenu.html
</span><span class="cx"> media/video-controls-captions-trackmenu-hide-on-click.html
</span><ins>+media/video-controls-captions-trackmenu-hide-on-click-outside.html
</ins><span class="cx"> media/video-controls-visible-exiting-fullscreen.html
</span><span class="cx"> 
</span><span class="cx"> # Fails on JSC platforms due to gc timing issues
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/Source/WebCore/ChangeLog        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2013-05-20  Antoine Quint  &lt;graouts@apple.com&gt;
+
+        [Mac] captions menu should behave more like a menu
+        https://bugs.webkit.org/show_bug.cgi?id=116436
+
+        Reviewed by Eric Carlson.
+
+        Let the captions menu behave more like a native Mac menu by hiding it when
+        clicking anywhere on the page and preventing the page from scrolling when
+        attempting to scroll the captions menu when it cannot scroll in the requested
+        direction.
+
+        Test: media/video-controls-captions-trackmenu-hide-on-click-outside.html
+
+        * dom/EventListener.h:
+        Add the new MediaControlsAppleEventListenerType.
+
+        * html/shadow/MediaControlsApple.cpp:
+        (WebCore::MediaControlsApple::defaultEventHandler):
+        (WebCore::MediaControlsApple::hide):
+        (WebCore::MediaControlsApple::makeTransparent):
+        (WebCore::MediaControlsApple::changedClosedCaptionsVisibility):
+        (WebCore::MediaControlsApple::reportedError):
+        (WebCore::MediaControlsApple::toggleClosedCaptionTrackList):
+        Use the hideClosedCaptionTrackList() and showClosedCaptionTrackList()
+        methods to hide and show the captions menu instead of calling hide()
+        and show() directly on m_closedCaptionsContainer.
+
+        (WebCore::MediaControlsApple::showClosedCaptionTrackList):
+        Show the m_closedCaptionsContainer and register a &quot;mousewheel&quot; event
+        listener on it as well as a &quot;click&quot; event listener on the entire document.
+
+        (WebCore::MediaControlsApple::hideClosedCaptionTrackList):
+        Hide the m_closedCaptionsContainer and remove the &quot;mousewheel&quot; event
+        listener on it as well as the &quot;click&quot; event listener on the entire document.
+
+        (WebCore::MediaControlsApple::shouldClosedCaptionsContainerPreventPageScrolling):
+        New private utility to determine whether the m_closedCaptionsContainer can scroll
+        in the provided scroll direction.
+
+        (WebCore::MediaControlsApple::eventListener):
+        Obtain the event listener used for &quot;mousewheel&quot; and &quot;click&quot; event handlers.
+
+        (WebCore::MediaControlsAppleEventListener::handleEvent):
+        Event handler for the &quot;mousewheel&quot; and &quot;click&quot; events. If we get a &quot;click&quot; event, we
+        toggle the captions menu visibility and if we get a &quot;mousewheel&quot; event, we call into
+        shouldClosedCaptionsContainerPreventPageScrolling() to see if we can scroll in the
+        current scroll direction, and if not prevent the event from resulting in a scroll by
+        calling preventDefault().
+
+        (WebCore::MediaControlsAppleEventListener::operator==):
+        Required for the successful subclassing of EventListener.
+
+        * html/shadow/MediaControlsApple.h:
+        (MediaControlsAppleEventListener):
+        (WebCore::MediaControlsAppleEventListener::create):
+        (WebCore::MediaControlsAppleEventListener::cast):
+        (WebCore::MediaControlsAppleEventListener::MediaControlsAppleEventListener):
+        New subclass of EventListener required to provide a custom event listener for the
+        &quot;mousewheel&quot; and &quot;click&quot; events registered in showClosedCaptionTrackList() and
+        hideClosedCaptionTrackList().
+
</ins><span class="cx"> 2013-05-18  Rashmi Shyamasundar  &lt;rashmi.s2@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Cairo] Canvas-shadow behavior is not being as expected
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventListenerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/EventListener.h (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/EventListener.h        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/Source/WebCore/dom/EventListener.h        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -43,7 +43,8 @@
</span><span class="cx">             ConditionEventListenerType,
</span><span class="cx">             GObjectEventListenerType,
</span><span class="cx">             NativeEventListenerType,
</span><del>-            SVGTRefTargetEventListenerType
</del><ins>+            SVGTRefTargetEventListenerType,
+            MediaControlsAppleEventListenerType 
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         virtual ~EventListener() { }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowMediaControlsApplecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;RenderTheme.h&quot;
</span><span class="cx"> #include &quot;Text.h&quot;
</span><ins>+#include &quot;WheelEvent.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx"> #include &quot;TextTrackCue.h&quot;
</span><span class="lines">@@ -278,7 +279,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (event-&gt;type() == eventNames().clickEvent) {
</span><span class="cx">         if (m_closedCaptionsContainer &amp;&amp; m_closedCaptionsContainer-&gt;isShowing()) {
</span><del>-            m_closedCaptionsContainer-&gt;hide();
</del><ins>+            hideClosedCaptionTrackList();
</ins><span class="cx">             event-&gt;setDefaultHandled();
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -291,7 +292,7 @@
</span><span class="cx">     MediaControls::hide();
</span><span class="cx">     m_volumeSliderContainer-&gt;hide();
</span><span class="cx">     if (m_closedCaptionsContainer)
</span><del>-        m_closedCaptionsContainer-&gt;hide();
</del><ins>+        hideClosedCaptionTrackList();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaControlsApple::makeTransparent()
</span><span class="lines">@@ -299,14 +300,14 @@
</span><span class="cx">     MediaControls::makeTransparent();
</span><span class="cx">     m_volumeSliderContainer-&gt;hide();
</span><span class="cx">     if (m_closedCaptionsContainer)
</span><del>-        m_closedCaptionsContainer-&gt;hide();
</del><ins>+        hideClosedCaptionTrackList();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaControlsApple::changedClosedCaptionsVisibility()
</span><span class="cx"> {
</span><span class="cx">     MediaControls::changedClosedCaptionsVisibility();
</span><span class="cx">     if (m_closedCaptionsContainer &amp;&amp; m_closedCaptionsContainer-&gt;isShowing())
</span><del>-        m_closedCaptionsContainer-&gt;hide();
</del><ins>+        hideClosedCaptionTrackList();
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -414,7 +415,7 @@
</span><span class="cx">     if (m_toggleClosedCaptionsButton &amp;&amp; !page-&gt;theme()-&gt;hasOwnDisabledStateHandlingFor(MediaToggleClosedCaptionsButtonPart))
</span><span class="cx">         m_toggleClosedCaptionsButton-&gt;hide();
</span><span class="cx">     if (m_closedCaptionsContainer)
</span><del>-        m_closedCaptionsContainer-&gt;hide();
</del><ins>+        hideClosedCaptionTrackList();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaControlsApple::updateStatusDisplay()
</span><span class="lines">@@ -498,15 +499,51 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_closedCaptionsContainer) {
</span><span class="cx">         if (m_closedCaptionsContainer-&gt;isShowing())
</span><del>-            m_closedCaptionsContainer-&gt;hide();
</del><ins>+            hideClosedCaptionTrackList();
</ins><span class="cx">         else {
</span><span class="cx">             if (m_closedCaptionsTrackList)
</span><span class="cx">                 m_closedCaptionsTrackList-&gt;updateDisplay();
</span><del>-            m_closedCaptionsContainer-&gt;show();
</del><ins>+            showClosedCaptionTrackList();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaControlsApple::showClosedCaptionTrackList()
+{
+    if (!m_closedCaptionsContainer || m_closedCaptionsContainer-&gt;isShowing())
+        return;
+
+    m_closedCaptionsContainer-&gt;show();
+
+    RefPtr&lt;EventListener&gt; listener = eventListener();
+    m_closedCaptionsContainer-&gt;addEventListener(eventNames().mousewheelEvent, listener, true);
+    document()-&gt;addEventListener(eventNames().clickEvent, listener, true);
+}
+
+void MediaControlsApple::hideClosedCaptionTrackList()
+{
+    if (!m_closedCaptionsContainer || !m_closedCaptionsContainer-&gt;isShowing())
+        return;
+
+    m_closedCaptionsContainer-&gt;hide();
+
+    EventListener* listener = eventListener().get();
+    m_closedCaptionsContainer-&gt;removeEventListener(eventNames().mousewheelEvent, listener, true);
+    document()-&gt;removeEventListener(eventNames().clickEvent, listener, true);
+}
+
+bool MediaControlsApple::shouldClosedCaptionsContainerPreventPageScrolling(int wheelDeltaY)
+{
+    int scrollTop = m_closedCaptionsContainer-&gt;scrollTop();
+    // Scrolling down.
+    if (wheelDeltaY &lt; 0 &amp;&amp; (scrollTop + m_closedCaptionsContainer-&gt;offsetHeight()) &gt;= m_closedCaptionsContainer-&gt;scrollHeight())
+        return true;
+    // Scrolling up.
+    if (wheelDeltaY &gt; 0 &amp;&amp; scrollTop &lt;= 0)
+        return true;
+    return false;
+}
+
</ins><span class="cx"> void MediaControlsApple::closedCaptionTracksChanged()
</span><span class="cx"> {
</span><span class="cx">     if (m_toggleClosedCaptionsButton) {
</span><span class="lines">@@ -517,6 +554,34 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;MediaControlsAppleEventListener&gt; MediaControlsApple::eventListener()
+{
+    if (!m_eventListener)
+        m_eventListener = MediaControlsAppleEventListener::create(this);
+    return m_eventListener;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// --------
+
+void MediaControlsAppleEventListener::handleEvent(ScriptExecutionContext*, Event* event)
+{
+    if (event-&gt;type() == eventNames().clickEvent &amp;&amp; !m_mediaControls-&gt;contains(event-&gt;target()-&gt;toNode()))
+        m_mediaControls-&gt;toggleClosedCaptionTrackList();
+
+    if (event-&gt;type() == eventNames().mousewheelEvent &amp;&amp; event-&gt;hasInterface(eventNames().interfaceForWheelEvent)) {
+        WheelEvent* wheelEvent = static_cast&lt;WheelEvent*&gt;(event);
+        if (m_mediaControls-&gt;shouldClosedCaptionsContainerPreventPageScrolling(wheelEvent-&gt;wheelDeltaY()))
+            event-&gt;preventDefault();
+    }
+}
+
+bool MediaControlsAppleEventListener::operator==(const EventListener&amp; listener)
+{
+    if (const MediaControlsAppleEventListener* mediaControlsAppleEventListener = MediaControlsAppleEventListener::cast(&amp;listener))
+        return m_mediaControls == mediaControlsAppleEventListener-&gt;m_mediaControls;
+    return false;
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowMediaControlsAppleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/MediaControlsApple.h (150370 => 150371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/MediaControlsApple.h        2013-05-20 16:39:30 UTC (rev 150370)
+++ trunk/Source/WebCore/html/shadow/MediaControlsApple.h        2013-05-20 16:47:07 UTC (rev 150371)
</span><span class="lines">@@ -33,6 +33,32 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class MediaControlsApple;
+
+class MediaControlsAppleEventListener : public EventListener {
+public:
+    static PassRefPtr&lt;MediaControlsAppleEventListener&gt; create(MediaControlsApple* mediaControls) { return adoptRef(new MediaControlsAppleEventListener(mediaControls)); }
+    static const MediaControlsAppleEventListener* cast(const EventListener* listener)
+    {
+        return listener-&gt;type() == MediaControlsAppleEventListenerType
+            ? static_cast&lt;const MediaControlsAppleEventListener*&gt;(listener)
+            : 0;
+    }
+
+    virtual bool operator==(const EventListener&amp; other);
+
+private:
+    MediaControlsAppleEventListener(MediaControlsApple* mediaControls)
+        : EventListener(MediaControlsAppleEventListenerType)
+        , m_mediaControls(mediaControls)
+    {
+    }
+
+    virtual void handleEvent(ScriptExecutionContext*, Event*);
+
+    MediaControlsApple* m_mediaControls;
+};
+
</ins><span class="cx"> class MediaControlsApple : public MediaControls {
</span><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;MediaControlsApple&gt; createControls(Document*);
</span><span class="lines">@@ -62,11 +88,17 @@
</span><span class="cx">     virtual void toggleClosedCaptionTrackList() OVERRIDE;
</span><span class="cx">     virtual void closedCaptionTracksChanged() OVERRIDE;
</span><span class="cx"> 
</span><ins>+    bool shouldClosedCaptionsContainerPreventPageScrolling(int wheelDeltaY);
+
</ins><span class="cx"> private:
</span><span class="cx">     MediaControlsApple(Document*);
</span><span class="cx"> 
</span><span class="cx">     virtual void defaultEventHandler(Event*) OVERRIDE;
</span><ins>+    PassRefPtr&lt;MediaControlsAppleEventListener&gt; eventListener();
</ins><span class="cx"> 
</span><ins>+    void showClosedCaptionTrackList();
+    void hideClosedCaptionTrackList();
+
</ins><span class="cx">     MediaControlRewindButtonElement* m_rewindButton;
</span><span class="cx">     MediaControlReturnToRealtimeButtonElement* m_returnToRealTimeButton;
</span><span class="cx">     MediaControlStatusDisplayElement* m_statusDisplay;
</span><span class="lines">@@ -81,6 +113,7 @@
</span><span class="cx">     MediaControlFullscreenVolumeMinButtonElement* m_fullScreenMinVolumeButton;
</span><span class="cx">     MediaControlFullscreenVolumeSliderElement* m_fullScreenVolumeSlider;
</span><span class="cx">     MediaControlFullscreenVolumeMaxButtonElement* m_fullScreenMaxVolumeButton;
</span><ins>+    RefPtr&lt;MediaControlsAppleEventListener&gt; m_eventListener;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>