Commit 86cb9fc2 authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

[CCA] Fix tap to focus regression

Bug: 1012180
Test: On device with camera having tap-to-focus support, tap and see if
it focus as expected.

Change-Id: I0be548473af01b68427b3f782351da56a342552f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849550
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Shik Chen <shik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704140}
parent 330b4ec7
...@@ -425,16 +425,16 @@ cca.views.camera.Preview.prototype.onFocusClicked_ = function(event) { ...@@ -425,16 +425,16 @@ cca.views.camera.Preview.prototype.onFocusClicked_ = function(event) {
this.cancelFocus_(); this.cancelFocus_();
// Normalize to square space coordinates by W3C spec. // Normalize to square space coordinates by W3C spec.
var x = event.offsetX / this.video_.width; const x = event.offsetX / this.video_.offsetWidth;
var y = event.offsetY / this.video_.height; const y = event.offsetY / this.video_.offsetHeight;
var constraints = {advanced: [{pointsOfInterest: [{x, y}]}]}; const constraints = {advanced: [{pointsOfInterest: [{x, y}]}]};
var track = this.video_.srcObject.getVideoTracks()[0]; const track = this.video_.srcObject.getVideoTracks()[0];
var focus = track.applyConstraints(constraints).then(() => { const focus = track.applyConstraints(constraints).then(() => {
if (focus != this.focus_) { if (focus != this.focus_) {
return; // Focus was cancelled. return; // Focus was cancelled.
} }
var aim = document.querySelector('#preview-focus-aim'); const aim = document.querySelector('#preview-focus-aim');
var clone = aim.cloneNode(true); const clone = aim.cloneNode(true);
clone.style.left = `${event.offsetX + this.video_.offsetLeft}px`; clone.style.left = `${event.offsetX + this.video_.offsetLeft}px`;
clone.style.top = `${event.offsetY + this.video_.offsetTop}px`; clone.style.top = `${event.offsetY + this.video_.offsetTop}px`;
clone.hidden = false; clone.hidden = false;
......
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