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

Side by Side Diff: telemetry/telemetry/internal/actions/action_runner.py

Issue 3017493002: Fix coordinate calculations under pinch-zoom
Patch Set: 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import time 6 import time
7 import urlparse 7 import urlparse
8 8
9 from telemetry.core import exceptions 9 from telemetry.core import exceptions
10 from telemetry.internal.actions.drag import DragAction 10 from telemetry.internal.actions.drag import DragAction
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 of the final span and the initial span of the gesture. 355 of the final span and the initial span of the gesture.
356 356
357 Args: 357 Args:
358 left_anchor_ratio: The horizontal pinch anchor coordinate of the 358 left_anchor_ratio: The horizontal pinch anchor coordinate of the
359 gesture, as a ratio of the visible bounding rectangle for 359 gesture, as a ratio of the visible bounding rectangle for
360 document.body. 360 document.body.
361 top_anchor_ratio: The vertical pinch anchor coordinate of the 361 top_anchor_ratio: The vertical pinch anchor coordinate of the
362 gesture, as a ratio of the visible bounding rectangle for 362 gesture, as a ratio of the visible bounding rectangle for
363 document.body. 363 document.body.
364 scale_factor: The ratio of the final span to the initial span. 364 scale_factor: The ratio of the final span to the initial span.
365 The default scale factor is 365 The default scale factor is 3.0 / (current scale factor).
366 3.0 / (window.outerWidth/window.innerWidth).
367 speed_in_pixels_per_second: The speed of the gesture (in pixels/s). 366 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).
368 """ 367 """
369 self._RunAction(PinchAction( 368 self._RunAction(PinchAction(
370 left_anchor_ratio=left_anchor_ratio, top_anchor_ratio=top_anchor_ratio, 369 left_anchor_ratio=left_anchor_ratio, top_anchor_ratio=top_anchor_ratio,
371 scale_factor=scale_factor, 370 scale_factor=scale_factor,
372 speed_in_pixels_per_second=speed_in_pixels_per_second)) 371 speed_in_pixels_per_second=speed_in_pixels_per_second))
373 372
374 def PinchElement(self, selector=None, text=None, element_function=None,
ericrk 2017/09/15 16:41:04 Thanks for cleaning this up!
375 left_anchor_ratio=0.5, top_anchor_ratio=0.5,
376 scale_factor=None, speed_in_pixels_per_second=800):
377 """Perform the pinch gesture on an element.
378
379 It computes the pinch gesture automatically based on the anchor
380 coordinate and the scale factor. The scale factor is the ratio of
381 of the final span and the initial span of the gesture.
382
383 Args:
384 selector: A CSS selector describing the element.
385 text: The element must contains this exact text.
386 element_function: A JavaScript function (as string) that is used
387 to retrieve the element. For example:
388 'function() { return foo.element; }'.
389 left_anchor_ratio: The horizontal pinch anchor coordinate of the
390 gesture, as a ratio of the visible bounding rectangle for
391 the element.
392 top_anchor_ratio: The vertical pinch anchor coordinate of the
393 gesture, as a ratio of the visible bounding rectangle for
394 the element.
395 scale_factor: The ratio of the final span to the initial span.
396 The default scale factor is
397 3.0 / (window.outerWidth/window.innerWidth).
398 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).
399 """
400 self._RunAction(PinchAction(
401 selector=selector, text=text, element_function=element_function,
402 left_anchor_ratio=left_anchor_ratio, top_anchor_ratio=top_anchor_ratio,
403 scale_factor=scale_factor,
404 speed_in_pixels_per_second=speed_in_pixels_per_second))
405
406 def ScrollPage(self, left_start_ratio=0.5, top_start_ratio=0.5, 373 def ScrollPage(self, left_start_ratio=0.5, top_start_ratio=0.5,
407 direction='down', distance=None, distance_expr=None, 374 direction='down', distance=None, distance_expr=None,
408 speed_in_pixels_per_second=800, use_touch=False, 375 speed_in_pixels_per_second=800, use_touch=False,
409 synthetic_gesture_source=GESTURE_SOURCE_DEFAULT): 376 synthetic_gesture_source=GESTURE_SOURCE_DEFAULT):
410 """Perform scroll gesture on the page. 377 """Perform scroll gesture on the page.
411 378
412 You may specify distance or distance_expr, but not both. If 379 You may specify distance or distance_expr, but not both. If
413 neither is specified, the default scroll distance is variable 380 neither is specified, the default scroll distance is variable
414 depending on direction (see scroll.js for full implementation). 381 depending on direction (see scroll.js for full implementation).
415 382
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 marker=timeline_interaction_record.GetJavaScriptMarker( 833 marker=timeline_interaction_record.GetJavaScriptMarker(
867 self._label, self._flags)) 834 self._label, self._flags))
868 835
869 def End(self): 836 def End(self):
870 assert self._started 837 assert self._started
871 self._started = False 838 self._started = False
872 self._action_runner.ExecuteJavaScript( 839 self._action_runner.ExecuteJavaScript(
873 'console.timeEnd({{ marker }});', 840 'console.timeEnd({{ marker }});',
874 marker=timeline_interaction_record.GetJavaScriptMarker( 841 marker=timeline_interaction_record.GetJavaScriptMarker(
875 self._label, self._flags)) 842 self._label, self._flags))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698