Commit 1c714332 authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

[Media Controls] Keep events in node for panel in audio controls

This CL fixes an issue where we don't keep events in node for the
audio panel.

Bug: 884108
Change-Id: I039a606005b9be109c36f35a7bf33f4a77f951db
Reviewed-on: https://chromium-review.googlesource.com/1239006Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593407}
parent d69c35e9
<!DOCTYPE html>
<html>
<title>Test that clicks on audio elements are not propagated.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../media-controls.js"></script>
<div id="outer">
<audio controls></audio>
<!-- Also test for a video acting as an audio element. -->
<video controls src="../content/test.oga"></video>
</div>
<script>
async_test(t => {
const audio = document.querySelector('audio');
const video = document.querySelector('video');
const outerDiv = document.getElementById('outer');
const events = ['mousedown', 'click', 'mouseup'];
// The taps should not get propagated out to the outer div.
events.forEach(evtName => {
outerDiv.addEventListener(evtName, t.unreached_func(), { once: true });
});
window.addEventListener("load", t.step_func(() => {
singleTapOnControl(playButton(audio), t.step_func(() => {
singleTapOnControl(playButton(video), t.step_func(() => {
// Give the tap a chance to (hopefully not) propagate.
setTimeout(t.done.bind(t));
}));
}));
}));
});
</script>
</html>
...@@ -181,7 +181,8 @@ void MediaControlPanelElement::DefaultEventHandler(Event& event) { ...@@ -181,7 +181,8 @@ void MediaControlPanelElement::DefaultEventHandler(Event& event) {
} }
bool MediaControlPanelElement::KeepEventInNode(const Event& event) const { bool MediaControlPanelElement::KeepEventInNode(const Event& event) const {
return !MediaControlsImpl::IsModern() && return (!MediaControlsImpl::IsModern() ||
GetMediaControls().ShouldShowAudioControls()) &&
MediaControlElementsHelper::IsUserInteractionEvent(event); MediaControlElementsHelper::IsUserInteractionEvent(event);
} }
......
...@@ -192,6 +192,9 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement, ...@@ -192,6 +192,9 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement,
void OnAccessibleFocus(); void OnAccessibleFocus();
void OnAccessibleBlur(); void OnAccessibleBlur();
// Returns true/false based on which set of controls to display.
bool ShouldShowAudioControls() const;
private: private:
// MediaControlsMediaEventListener is a component that is listening to events // MediaControlsMediaEventListener is a component that is listening to events
// and calling the appropriate callback on MediaControlsImpl. The object is // and calling the appropriate callback on MediaControlsImpl. The object is
...@@ -290,7 +293,6 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement, ...@@ -290,7 +293,6 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement,
void UpdateActingAsAudioControls(); void UpdateActingAsAudioControls();
// Returns true/false based on which set of controls to display. // Returns true/false based on which set of controls to display.
bool ShouldShowAudioControls() const;
bool ShouldShowVideoControls() const; bool ShouldShowVideoControls() const;
// Node // Node
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment