0

DoubleTapToJump: Depend on touch events instead of RuntimeEnabledFeature

This CL removes the DoubleTapToJump RuntimeEnabledFeature that was used
to determine whether to jump a video 10 seconds or go into fullscreen
on a double-tap. Instead, the video will jump 10 seconds if both taps
are from touch events.

Bug: 821834
Change-Id: Ie0fa6a56c3775a74b575ae2ac7343afcf47a8d47
Reviewed-on: https://chromium-review.googlesource.com/981417
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Becca Hughes <beccahughes@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546831}
This commit is contained in:
Tommy Steimel
2018-03-29 14:52:31 +00:00
committed by Commit Bot
parent 0601da40e5
commit 46546d34e5
15 changed files with 40 additions and 59 deletions

@ -81,10 +81,6 @@ static void SetRuntimeFeatureDefaultsForPlatform() {
#if !defined(OS_MACOSX)
WebRuntimeFeatures::EnableNotificationContentImage(true);
#endif
#if defined(OS_ANDROID)
WebRuntimeFeatures::EnableDoubleTapToJumpOnVideo(true);
#endif
}
void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(

@ -7,8 +7,6 @@
<video controls width=400 src="../../content/60_sec_video.webm"></video>
<script>
async_test(t => {
enableDoubleTapToJumpForTest(t);
const video = document.querySelector('video');
let count = 0;
@ -16,7 +14,7 @@ async_test(t => {
// Double tap in the top left hand corner
const coordinates =
coordinatesOutsideElement(mediaControlsOverlayPlayButton(video));
doubleTapAtCoordinates(coordinates[0] + 1, coordinates[1] + 1);
doubleTouchAtCoordinates(coordinates[0] + 1, coordinates[1] + 1);
}), { once: true });
video.ontimeupdate = t.step_func(() => {

@ -7,8 +7,6 @@
<video controls width=400 src="../../content/60_sec_video.webm"></video>
<script>
async_test(t => {
enableDoubleTapToJumpForTest(t);
const video = document.querySelector('video');
let time = 0;
@ -30,7 +28,7 @@ async_test(t => {
time = currentTime;
const coordinates =
coordinatesOutsideElement(mediaControlsOverlayPlayButton(video));
doubleTapAtCoordinates(coordinates[0] + 1, coordinates[1] + 1);
doubleTouchAtCoordinates(coordinates[0] + 1, coordinates[1] + 1);
} else if (time > 0) {
// Check the video went back 10 seconds
assert_greater_than(time, 0);

@ -7,8 +7,6 @@
<video controls width=400 src="../../content/60_sec_video.webm"></video>
<script>
async_test(t => {
enableDoubleTapToJumpForTest(t);
const video = document.querySelector('video');
video.addEventListener('playing', () => {
@ -19,7 +17,7 @@ async_test(t => {
// Double tap in the top right hand corner
const coordinates =
coordinatesOutsideElement(mediaControlsOverlayPlayButton(video));
doubleTapAtCoordinates(coordinates[0] + video.width, coordinates[1] + 1);
doubleTouchAtCoordinates(coordinates[0] + video.width, coordinates[1] + 1);
}
}, { once: true });

@ -7,8 +7,6 @@
<video controls width=400 src="../../content/60_sec_video.webm"></video>
<script>
async_test(t => {
enableDoubleTapToJumpForTest(t);
const video = document.querySelector('video');
let time = 0;
@ -17,7 +15,7 @@ async_test(t => {
time = Math.round(video.currentTime);
const coordinates =
coordinatesOutsideElement(mediaControlsOverlayPlayButton(video));
doubleTapAtCoordinates(coordinates[0] + video.width, coordinates[1] + 1);
doubleTouchAtCoordinates(coordinates[0] + video.width, coordinates[1] + 1);
}), { once: true });
video.ontimeupdate = t.step_func(() => {

@ -10,6 +10,7 @@ async_test(t => {
const video = document.querySelector('video');
const timeline = timelineElement(video);
const thumb = timelineThumb(video);
const scrubbingMessage = scrubbingMessageElement(video);
video.addEventListener('playing', t.step_func(() => {
// Get the coordinates of the thumb and the timeline.
@ -30,12 +31,18 @@ async_test(t => {
// Check the scrubbing UI is shown with the correct time.
checkControlsClassName(video, 'phase-ready state-scrubbing');
// Check the scrubbing message is shown.
assert_true(isControlVisible(scrubbingMessage));
// Ensure that the timeline now has a value in the middle.
assert_equals(30, Math.round(timeline.value));
// Add an event listener for when we start playing again after seeking.
video.addEventListener('playing', t.step_func_done(() => {
checkControlsClassName(video, 'phase-ready state-playing');
// Check the scrubbing message is no longer shown.
assert_false(isControlVisible(scrubbingMessage));
}), { once: true });
// Release the touch.

@ -4,20 +4,10 @@
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../media-controls.js"></script>
<body></body>
<video controls width=400 src="../../content/60_sec_video.webm"></video>
<script>
async_test(t => {
// Need to enable double-tap to check the scrubbing message.
enableDoubleTapToJumpForTest(t);
// We create the video on the fly, since we need double-tap to jump enabled
// before the video is created.
let video = document.createElement('video');
video.controls = true;
video.width = 400;
video.src = "../../content/60_sec_video.webm";
document.body.appendChild(video);
const video = document.querySelector('video');
const timeline = timelineElement(video);
const thumb = timelineThumb(video);
const scrubbingMessage = scrubbingMessageElement(video);
@ -34,7 +24,7 @@ async_test(t => {
assert_true(seeked);
checkControlsClassName(video, 'phase-ready state-playing');
// Check the scrubbing message is no longer shown.
// Check the scrubbing message not shown.
assert_false(isControlVisible(scrubbingMessage));
}), { once: true });
@ -56,8 +46,8 @@ async_test(t => {
video.addEventListener('seeking', t.step_func(() => {
checkControlsClassName(video, 'phase-ready state-scrubbing');
// Check the scrubbing message is shown.
assert_true(isControlVisible(scrubbingMessage));
// Check the scrubbing message is not shown since we're scrubbing with the mouse.
assert_false(isControlVisible(scrubbingMessage));
}), { once: true });
video.addEventListener('seeked', t.step_func(() => {

@ -371,8 +371,7 @@ function checkPictureInPictureInterstitialDoesNotExist(videoElement) {
}
function doubleTapAtCoordinates(x, y, timeout, callback) {
if (timeout == undefined)
timeout = 100;
timeout = timeout == undefined ? 100 : timeout;
chrome.gpuBenchmarking.pointerActionSequence([
{
@ -417,15 +416,21 @@ function singleTouchAtCoordinates(xPos, yPos, callback) {
], callback);
}
function enableDoubleTapToJumpForTest(t) {
var doubleTapToJumpOnVideoEnabledValue =
internals.runtimeFlags.doubleTapToJumpOnVideoEnabled;
internals.runtimeFlags.doubleTapToJumpOnVideoEnabled = true;
function doubleTouchAtCoordinates(x, y, timeout, callback) {
timeout = timeout == undefined ? 100 : timeout;
t.add_cleanup(() => {
internals.runtimeFlags.doubleTapToJumpOnVideoEnabled =
doubleTapToJumpOnVideoEnabledValue;
});
chrome.gpuBenchmarking.pointerActionSequence([
{
source: 'touch',
actions: [
{ name: 'pointerDown', x: x, y: y },
{ name: 'pointerUp' },
{ name: 'pause', duration: timeout / 1000 },
{ name: 'pointerDown', x: x, y: y },
{ name: 'pointerUp' }
]
}
], callback);
}
function enablePictureInPictureForTest(t) {

@ -499,9 +499,7 @@ void MediaControlsImpl::InitializeControls() {
// seperate button panel. This is because they are displayed in two lines.
if (IsModern() && MediaElement().IsHTMLVideoElement()) {
media_button_panel_ = new MediaControlButtonPanelElement(*this);
if (RuntimeEnabledFeatures::DoubleTapToJumpOnVideoEnabled()) {
scrubbing_message_ = new MediaControlScrubbingMessageElement(*this);
}
scrubbing_message_ = new MediaControlScrubbingMessageElement(*this);
}
play_button_ = new MediaControlPlayButtonElement(*this);
@ -916,13 +914,13 @@ HTMLDivElement* MediaControlsImpl::PanelElement() {
return panel_;
}
void MediaControlsImpl::BeginScrubbing() {
void MediaControlsImpl::BeginScrubbing(bool is_touch_event) {
if (!MediaElement().paused()) {
is_paused_for_scrubbing_ = true;
MediaElement().pause();
}
if (scrubbing_message_) {
if (scrubbing_message_ && is_touch_event) {
scrubbing_message_->SetIsWanted(true);
if (scrubbing_message_->DoesFit())
panel_->setAttribute("class", kScrubbingMessageCSSClass);

@ -134,7 +134,7 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement,
void ShowOverlayCastButtonIfNeeded();
// Methods call by the scrubber.
void BeginScrubbing();
void BeginScrubbing(bool);
void EndScrubbing();
void UpdateCurrentTimeDisplay();

@ -218,9 +218,10 @@ void MediaControlOverlayPlayButtonElement::DefaultEventHandler(Event* event) {
} else {
// Cancel the play pause event.
tap_timer_.Stop();
tap_was_touch_event_.reset();
if (RuntimeEnabledFeatures::DoubleTapToJumpOnVideoEnabled()) {
// If both taps were touch events, then jump.
if (tap_was_touch_event_.value() &&
MediaControlsImpl::IsTouchEvent(event)) {
// Jump forwards or backwards based on the position of the tap.
WebSize element_size =
MediaControlElementsHelper::GetSizeOrDefault(*this, WebSize(0, 0));
@ -240,6 +241,7 @@ void MediaControlOverlayPlayButtonElement::DefaultEventHandler(Event* event) {
}
}
tap_was_touch_event_.reset();
event->SetDefaultHandled();
}
}

@ -118,7 +118,7 @@ void MediaControlTimelineElement::DefaultEventHandler(Event* event) {
if (BeginScrubbingEvent(*event)) {
Platform::Current()->RecordAction(
UserMetricsAction("Media.Controls.ScrubbingBegin"));
GetMediaControls().BeginScrubbing();
GetMediaControls().BeginScrubbing(MediaControlsImpl::IsTouchEvent(event));
Element* thumb = UserAgentShadowRoot()->getElementById(
ShadowElementNames::SliderThumb());
bool started_from_thumb = thumb && thumb == event->target()->ToNode();

@ -490,10 +490,6 @@ void WebRuntimeFeatures::EnablePWAFullCodeCache(bool enable) {
RuntimeEnabledFeatures::SetPWAFullCodeCacheEnabled(enable);
}
void WebRuntimeFeatures::EnableDoubleTapToJumpOnVideo(bool enable) {
RuntimeEnabledFeatures::SetDoubleTapToJumpOnVideoEnabled(enable);
}
void WebRuntimeFeatures::EnableCodeCacheAfterExecute(bool enable) {
RuntimeEnabledFeatures::SetCodeCacheAfterExecuteEnabled(enable);
}

@ -394,10 +394,6 @@
{
name: "DocumentWrite",
},
{
name: "DoubleTapToJumpOnVideo",
settable_from_internals: true
},
{
name: "EmbedderCSPEnforcement",
status: "stable",

@ -183,7 +183,6 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableStopLoadingInBackground(bool);
BLINK_PLATFORM_EXPORT static void EnableStopNonTimersInBackground(bool);
BLINK_PLATFORM_EXPORT static void EnablePWAFullCodeCache(bool);
BLINK_PLATFORM_EXPORT static void EnableDoubleTapToJumpOnVideo(bool);
BLINK_PLATFORM_EXPORT static void EnableCodeCacheAfterExecute(bool);
BLINK_PLATFORM_EXPORT static void EnableUnifiedTouchAdjustment(bool);
BLINK_PLATFORM_EXPORT static void EnableMojoBlobURLs(bool);