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 3// found in the LICENSE file. 4 5// This file provides common functionality for synthetic gesture actions. 6'use strict'; 7 8(function() { 9 10 function getBoundingVisibleRect(el) { 11 var bound = el.getBoundingClientRect(); 12 var rect = { top: bound.top, 13 left: bound.left, 14 width: bound.width, 15 height: bound.height }; 16 var outsideHeight = (rect.top + rect.height) - window.innerHeight; 17 var outsideWidth = (rect.left + rect.width) - window.innerWidth; 18 19 if (outsideHeight > 0) { 20 rect.height -= outsideHeight; 21 } 22 if (outsideWidth > 0) { 23 rect.width -= outsideWidth; 24 } 25 return rect; 26 }; 27 28 window.__GestureCommon_GetBoundingVisibleRect = getBoundingVisibleRect; 29})(); 30