OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This file provides common functionality for synthetic gesture actions. | 5 // This file provides common functionality for synthetic gesture actions. |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 (function() { | 8 (function() { |
9 | 9 |
10 // Returns the bounding rectangle wrt to the top-most document. | 10 // Returns the bounding rectangle wrt to the top-most document. |
(...skipping 21 matching lines...) Expand all Loading... |
32 var rect = getBoundingRect(el); | 32 var rect = getBoundingRect(el); |
33 if (rect.top < 0) { | 33 if (rect.top < 0) { |
34 rect.height += rect.top; | 34 rect.height += rect.top; |
35 rect.top = 0; | 35 rect.top = 0; |
36 } | 36 } |
37 if (rect.left < 0) { | 37 if (rect.left < 0) { |
38 rect.width += rect.left; | 38 rect.width += rect.left; |
39 rect.left = 0; | 39 rect.left = 0; |
40 } | 40 } |
41 | 41 |
42 var outsideHeight = (rect.top + rect.height) - window.innerHeight; | 42 // TODO(ymalik): Remove the fallback path once the visualViewportHeight and |
43 var outsideWidth = (rect.left + rect.width) - window.innerWidth; | 43 // visualViewportWidth properties roll into stable. |
| 44 var visualViewportHeight = window.innerHeight; |
| 45 var visualViewportWidth = window.innerWidth; |
| 46 if (chrome.gpuBenchmarking.visualViewportHeight) { |
| 47 visualViewportHeight = chrome.gpuBenchmarking.visualViewportHeight(); |
| 48 } |
| 49 if (chrome.gpuBenchmarking.visualViewportWidth) { |
| 50 visualViewportWidth = chrome.gpuBenchmarking.visualViewportWidth(); |
| 51 } |
| 52 var outsideHeight = (rect.top + rect.height) - visualViewportHeight; |
| 53 var outsideWidth = (rect.left + rect.width) - visualViewportWidth; |
44 | 54 |
45 if (outsideHeight > 0) { | 55 if (outsideHeight > 0) { |
46 rect.height -= outsideHeight; | 56 rect.height -= outsideHeight; |
47 } | 57 } |
48 if (outsideWidth > 0) { | 58 if (outsideWidth > 0) { |
49 rect.width -= outsideWidth; | 59 rect.width -= outsideWidth; |
50 } | 60 } |
51 return rect; | 61 return rect; |
52 }; | 62 }; |
53 | 63 |
54 window.__GestureCommon_GetBoundingVisibleRect = getBoundingVisibleRect; | 64 window.__GestureCommon_GetBoundingVisibleRect = getBoundingVisibleRect; |
55 })(); | 65 })(); |
OLD | NEW |