1d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// found in the LICENSE file. 4d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// This file provides common functionality for synthetic gesture actions. 6d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)'use strict'; 7d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)(function() { 9d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) function getBoundingVisibleRect(el) { 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) var bound = el.getBoundingClientRect(); 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) var rect = { top: bound.top, 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) left: bound.left, 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) width: bound.width, 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) height: bound.height }; 16010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) if (rect.top < 0) { 17010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) rect.height += rect.top; 18010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) rect.top = 0; 19010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) } 20010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) if (rect.left < 0) { 21010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) rect.width += rect.left; 22010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) rect.left = 0; 23010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) } 24010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) var outsideHeight = (rect.top + rect.height) - window.innerHeight; 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) var outsideWidth = (rect.left + rect.width) - window.innerWidth; 27d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (outsideHeight > 0) { 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) rect.height -= outsideHeight; 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (outsideWidth > 0) { 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) rect.width -= outsideWidth; 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return rect; 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) }; 36d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window.__GestureCommon_GetBoundingVisibleRect = getBoundingVisibleRect; 38d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)})(); 39