| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
| 6 * @fileoverview A collection of utility methods for UberPage and its contained | 6 * @fileoverview A collection of utility methods for UberPage and its contained |
| 7 * pages. | 7 * pages. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('uber', function() { | 10 cr.define('uber', function() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 window.addEventListener('message', handleWindowMessage); | 29 window.addEventListener('message', handleWindowMessage); |
| 30 } | 30 } |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Handles scroll events on the document. This adjusts the position of all | 33 * Handles scroll events on the document. This adjusts the position of all |
| 34 * headers and updates the parent frame when the page is scrolled. | 34 * headers and updates the parent frame when the page is scrolled. |
| 35 * @private | 35 * @private |
| 36 */ | 36 */ |
| 37 function handleScroll() { | 37 function handleScroll() { |
| 38 var offset = document.body.scrollLeft * -1; | 38 var offset = document.body.scrollLeft * -1; |
| 39 for (var i = 0; i < headerElements.length; i++) | 39 for (var i = 0; i < headerElements.length; i++) { |
| 40 headerElements[i].style.webkitTransform = 'translateX(' + offset + 'px)'; | 40 // As a workaround for http://crbug.com/231830, set the transform to |
| 41 // 'none' rather than 0px. |
| 42 headerElements[i].style.webkitTransform = offset ? |
| 43 'translateX(' + offset + 'px)' : 'none'; |
| 44 } |
| 41 | 45 |
| 42 invokeMethodOnParent('adjustToScroll', document.body.scrollLeft); | 46 invokeMethodOnParent('adjustToScroll', document.body.scrollLeft); |
| 43 }; | 47 }; |
| 44 | 48 |
| 45 /** | 49 /** |
| 46 * Handles 'message' events on window. | 50 * Handles 'message' events on window. |
| 47 * @param {Event} e The message event. | 51 * @param {Event} e The message event. |
| 48 */ | 52 */ |
| 49 function handleWindowMessage(e) { | 53 function handleWindowMessage(e) { |
| 50 if (e.data.method === 'frameSelected') | 54 if (e.data.method === 'frameSelected') |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 var data = {method: method, params: opt_params}; | 107 var data = {method: method, params: opt_params}; |
| 104 targetWindow.postMessage(data, opt_url ? opt_url : '*'); | 108 targetWindow.postMessage(data, opt_url ? opt_url : '*'); |
| 105 } | 109 } |
| 106 | 110 |
| 107 return { | 111 return { |
| 108 invokeMethodOnParent: invokeMethodOnParent, | 112 invokeMethodOnParent: invokeMethodOnParent, |
| 109 invokeMethodOnWindow: invokeMethodOnWindow, | 113 invokeMethodOnWindow: invokeMethodOnWindow, |
| 110 onContentFrameLoaded: onContentFrameLoaded, | 114 onContentFrameLoaded: onContentFrameLoaded, |
| 111 }; | 115 }; |
| 112 }); | 116 }); |
| OLD | NEW |