Commit 6e77d802 authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

[Media Controls] Use zoom when calculating overlay play button hitbox

This CL modifies the overlay play button ShouldCausePlayPause function
to take CSS and Document zoom into account. This fixes a bug where a
zoomed video had an incorrect hitbox for the overlay play button.

Bug: 862063
Change-Id: I3f51454618e5c455bba62b4b019701d67fd8886c
Reviewed-on: https://chromium-review.googlesource.com/1135663Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575051}
parent 17b40315
......@@ -24,7 +24,7 @@ async_test(function(t) {
// Find the play button and click the middle of its bounding box.
var playCoords = mediaControlsButtonCoordinates(video, "overlay-play-button");
eventSender.mouseMoveTo(playCoords[0], playCoords[1]);
eventSender.mouseMoveTo(playCoords[0] * 1.5, playCoords[1] * 1.5);
eventSender.mouseDown();
eventSender.mouseUp();
}, 50);
......
......@@ -8,6 +8,7 @@
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
......@@ -15,6 +16,7 @@
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html/media/html_media_source.h"
#include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_elements_helper.h"
#include "third_party/blink/renderer/modules/media_controls/media_controls_impl.h"
#include "third_party/blink/renderer/modules/media_controls/media_controls_resource_loader.h"
......@@ -290,9 +292,15 @@ bool MediaControlOverlayPlayButtonElement::ShouldCausePlayPause(
// If the click happened on the internal button or a margin around it then
// we should play/pause.
return IsPointInRect(*internal_button_->getBoundingClientRect(),
kInnerButtonTouchPaddingSize, mouse_event->clientX(),
mouse_event->clientY());
DOMRect* box = internal_button_->getBoundingClientRect();
float zoom = ComputedStyleRef().EffectiveZoom() /
GetDocument().GetLayoutView()->ZoomFactor();
box->setX(box->x() * zoom);
box->setY(box->y() * zoom);
box->setWidth(box->width() * zoom);
box->setHeight(box->height() * zoom);
return IsPointInRect(*box, kInnerButtonTouchPaddingSize,
mouse_event->clientX(), mouse_event->clientY());
}
WebSize MediaControlOverlayPlayButtonElement::GetSizeOrDefault() const {
......
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