Title: [151592] trunk/Source/WebCore
- Revision
- 151592
- Author
- [email protected]
- Date
- 2013-06-14 07:43:01 -0700 (Fri, 14 Jun 2013)
Log Message
[Mac] clicking caption track glyph should dismiss menu
https://bugs.webkit.org/show_bug.cgi?id=117621
We now correctly capture all click events while the captions track menu
is showing, and ensure that no other control in the media player can be
activated as the track list gets dismissed by clicking anywhere but on
itself.
Reviewed by Eric Carlson.
* html/shadow/MediaControlsApple.cpp:
(WebCore::MediaControlsApple::showClosedCaptionTrackList):
Make the controls panel non-interactive and track click events in the
capture phase also on the controls container itself such that we can
identify correctly whether a click in the <video> shadow tree is on
the track list or another element (the target could only be resolved
to a shadow tree node if the event is handled within the shadow tree).
(WebCore::MediaControlsApple::hideClosedCaptionTrackList):
Make the controls panel interactive again and remove the new click
event handler on the controls container.
(WebCore::MediaControlsApple::handleClickEvent):
Capture any click event that targets a node anywhere outside of the track
list container and its subtree and hide the track list in this condition.
(WebCore::MediaControlsAppleEventListener::handleEvent):
Call handleClickEvent() on the media controls when a click event is handled.
* html/shadow/MediaControlsApple.h:
New public handleClickEvent() API such that it can be called from
MediaControlsAppleEventListener::handleEvent().
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (151591 => 151592)
--- trunk/Source/WebCore/ChangeLog 2013-06-14 14:04:20 UTC (rev 151591)
+++ trunk/Source/WebCore/ChangeLog 2013-06-14 14:43:01 UTC (rev 151592)
@@ -1,3 +1,38 @@
+2013-06-14 Antoine Quint <[email protected]>
+
+ [Mac] clicking caption track glyph should dismiss menu
+ https://bugs.webkit.org/show_bug.cgi?id=117621
+
+ We now correctly capture all click events while the captions track menu
+ is showing, and ensure that no other control in the media player can be
+ activated as the track list gets dismissed by clicking anywhere but on
+ itself.
+
+ Reviewed by Eric Carlson.
+
+ * html/shadow/MediaControlsApple.cpp:
+ (WebCore::MediaControlsApple::showClosedCaptionTrackList):
+ Make the controls panel non-interactive and track click events in the
+ capture phase also on the controls container itself such that we can
+ identify correctly whether a click in the <video> shadow tree is on
+ the track list or another element (the target could only be resolved
+ to a shadow tree node if the event is handled within the shadow tree).
+
+ (WebCore::MediaControlsApple::hideClosedCaptionTrackList):
+ Make the controls panel interactive again and remove the new click
+ event handler on the controls container.
+
+ (WebCore::MediaControlsApple::handleClickEvent):
+ Capture any click event that targets a node anywhere outside of the track
+ list container and its subtree and hide the track list in this condition.
+
+ (WebCore::MediaControlsAppleEventListener::handleEvent):
+ Call handleClickEvent() on the media controls when a click event is handled.
+
+ * html/shadow/MediaControlsApple.h:
+ New public handleClickEvent() API such that it can be called from
+ MediaControlsAppleEventListener::handleEvent().
+
2013-06-14 Arvid Nilsson <[email protected]>
[BlackBerry] Accelerated compositing layers that intersect the image plane are incorrectly transformed
Modified: trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp (151591 => 151592)
--- trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp 2013-06-14 14:04:20 UTC (rev 151591)
+++ trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp 2013-06-14 14:43:01 UTC (rev 151592)
@@ -29,6 +29,7 @@
#if ENABLE(VIDEO)
#include "MediaControlsApple.h"
+#include "CSSValueKeywords.h"
#include "Chrome.h"
#include "ExceptionCodePlaceholder.h"
#include "HTMLMediaElement.h"
@@ -515,9 +516,21 @@
m_closedCaptionsContainer->show();
+ // Ensure the controls panel does not receive any events while the captions
+ // track list is visible as all events now need to be captured by the
+ // track list.
+ m_panel->setInlineStyleProperty(CSSPropertyPointerEvents, CSSValueNone);
+
RefPtr<EventListener> listener = eventListener();
m_closedCaptionsContainer->addEventListener(eventNames().mousewheelEvent, listener, true);
+
+ // Track click events in the capture phase at two levels, first at the document level
+ // such that a click outside of the <video> may dismiss the track list, second at the
+ // media controls level such that a click anywhere outside of the track list hides the
+ // track list. These two levels are necessary since it would not be possible to get a
+ // reference to the track list when handling the event outside of the shadow tree.
document()->addEventListener(eventNames().clickEvent, listener, true);
+ addEventListener(eventNames().clickEvent, listener, true);
}
void MediaControlsApple::hideClosedCaptionTrackList()
@@ -527,9 +540,13 @@
m_closedCaptionsContainer->hide();
+ // Buttons in the controls panel may now be interactive.
+ m_panel->removeInlineStyleProperty(CSSPropertyPointerEvents);
+
EventListener* listener = eventListener().get();
m_closedCaptionsContainer->removeEventListener(eventNames().mousewheelEvent, listener, true);
document()->removeEventListener(eventNames().clickEvent, listener, true);
+ removeEventListener(eventNames().clickEvent, listener, true);
}
bool MediaControlsApple::shouldClosedCaptionsContainerPreventPageScrolling(int wheelDeltaY)
@@ -544,6 +561,18 @@
return false;
}
+void MediaControlsApple::handleClickEvent(Event* event)
+{
+ Node* currentTarget = event->currentTarget()->toNode();
+ Node* target = event->target()->toNode();
+
+ if ((currentTarget == document() && !shadowHost()->contains(target)) || (currentTarget == this && !m_closedCaptionsContainer->contains(target))) {
+ hideClosedCaptionTrackList();
+ event->stopImmediatePropagation();
+ event->setDefaultHandled();
+ }
+}
+
void MediaControlsApple::closedCaptionTracksChanged()
{
if (m_toggleClosedCaptionsButton) {
@@ -565,10 +594,10 @@
void MediaControlsAppleEventListener::handleEvent(ScriptExecutionContext*, Event* event)
{
- if (event->type() == eventNames().clickEvent && !m_mediaControls->contains(event->target()->toNode()))
- m_mediaControls->toggleClosedCaptionTrackList();
+ if (event->type() == eventNames().clickEvent)
+ m_mediaControls->handleClickEvent(event);
- if (event->type() == eventNames().mousewheelEvent && event->hasInterface(eventNames().interfaceForWheelEvent)) {
+ else if (event->type() == eventNames().mousewheelEvent && event->hasInterface(eventNames().interfaceForWheelEvent)) {
WheelEvent* wheelEvent = static_cast<WheelEvent*>(event);
if (m_mediaControls->shouldClosedCaptionsContainerPreventPageScrolling(wheelEvent->wheelDeltaY()))
event->preventDefault();
Modified: trunk/Source/WebCore/html/shadow/MediaControlsApple.h (151591 => 151592)
--- trunk/Source/WebCore/html/shadow/MediaControlsApple.h 2013-06-14 14:04:20 UTC (rev 151591)
+++ trunk/Source/WebCore/html/shadow/MediaControlsApple.h 2013-06-14 14:43:01 UTC (rev 151592)
@@ -89,6 +89,7 @@
virtual void closedCaptionTracksChanged() OVERRIDE;
bool shouldClosedCaptionsContainerPreventPageScrolling(int wheelDeltaY);
+ void handleClickEvent(Event*);
private:
MediaControlsApple(Document*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes