Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: telemetry/telemetry/internal/actions/pinch.js

Issue 3017493002: Fix coordinate calculations under pinch-zoom
Patch Set: Add comments Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: telemetry/telemetry/internal/actions/pinch.js
diff --git a/telemetry/telemetry/internal/actions/pinch.js b/telemetry/telemetry/internal/actions/pinch.js
index 4abb66e6431620ec2f4db92cefed3eb091bc2dee..726cffde35e5922842a40cd1b59717e66face185 100644
--- a/telemetry/telemetry/internal/actions/pinch.js
+++ b/telemetry/telemetry/internal/actions/pinch.js
@@ -12,13 +12,11 @@
function PinchGestureOptions(opt_options) {
if (opt_options) {
- this.element_ = opt_options.element;
this.left_anchor_ratio_ = opt_options.left_anchor_ratio;
this.top_anchor_ratio_ = opt_options.top_anchor_ratio;
this.scale_factor_ = opt_options.scale_factor;
this.speed_ = opt_options.speed;
} else {
- this.element_ = document.body;
this.left_anchor_ratio_ = 0.5;
this.top_anchor_ratio_ = 0.5;
this.scale_factor_ = 2.0;
@@ -54,13 +52,25 @@
PinchAction.prototype.startPass_ = function() {
this.beginMeasuringHook();
- var rect = __GestureCommon_GetBoundingVisibleRect(this.options_.element_);
- var anchor_left =
- rect.left + rect.width * this.options_.left_anchor_ratio_;
- var anchor_top =
- rect.top + rect.height * this.options_.top_anchor_ratio_;
+ // TODO(bokan): Remove else-block once gpuBenchmarking is changed to take
+ // all coordinates in viewport space. crbug.com/610021.
+ let anchorLeft;
+ let anchorTop;
+ if ('gesturesExpectedInViewportCoordinates' in chrome.gpuBenchmarking) {
+ anchorLeft =
+ __GestureCommon_GetWindowWidth() *
+ this.options_.left_anchor_ratio_;
+ anchorTop =
+ __GestureCommon_GetWindowHeight() *
+ this.options_.top_anchor_ratio_;
+ } else {
+ var rect = __GestureCommon_GetBoundingVisibleRect(document.body);
+ anchorLeft = rect.left + rect.width * this.options_.left_anchor_ratio_;
+ anchorTop = rect.top + rect.height * this.options_.top_anchor_ratio_;
+ }
+
chrome.gpuBenchmarking.pinchBy(this.options_.scale_factor_,
- anchor_left, anchor_top,
+ anchorLeft, anchorTop,
this.onGestureComplete_.bind(this),
this.options_.speed_);
};
« no previous file with comments | « telemetry/telemetry/internal/actions/gesture_common.js ('k') | telemetry/telemetry/internal/actions/pinch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698