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

Side by Side Diff: chrome/browser/resources/uber/uber_utils.js

Issue 26719003: Fix cross-frame horizontal scrolling on the uber page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 32
33 window.addEventListener('message', handleWindowMessage); 33 window.addEventListener('message', handleWindowMessage);
34 } 34 }
35 35
36 /** 36 /**
37 * Handles scroll events on the document. This adjusts the position of all 37 * Handles scroll events on the document. This adjusts the position of all
38 * headers and updates the parent frame when the page is scrolled. 38 * headers and updates the parent frame when the page is scrolled.
39 * @private 39 * @private
40 */ 40 */
41 function handleScroll() { 41 function handleScroll() {
42 var offset = document.body.scrollLeft * -1; 42 var offset = document.documentElement.scrollLeft * -1;
43 for (var i = 0; i < headerElements.length; i++) { 43 for (var i = 0; i < headerElements.length; i++) {
44 // As a workaround for http://crbug.com/231830, set the transform to 44 // As a workaround for http://crbug.com/231830, set the transform to
45 // 'none' rather than 0px. 45 // 'none' rather than 0px.
46 headerElements[i].style.webkitTransform = offset ? 46 headerElements[i].style.webkitTransform = offset ?
47 'translateX(' + offset + 'px)' : 'none'; 47 'translateX(' + offset + 'px)' : 'none';
48 } 48 }
49 49
50 invokeMethodOnParent('adjustToScroll', document.body.scrollLeft); 50 invokeMethodOnParent('adjustToScroll', document.documentElement.scrollLeft);
51 }; 51 };
52 52
53 /** 53 /**
54 * Handles 'message' events on window. 54 * Handles 'message' events on window.
55 * @param {Event} e The message event. 55 * @param {Event} e The message event.
56 */ 56 */
57 function handleWindowMessage(e) { 57 function handleWindowMessage(e) {
58 if (e.data.method === 'frameSelected') 58 if (e.data.method === 'frameSelected')
59 handleFrameSelected(); 59 handleFrameSelected();
60 else if (e.data.method === 'mouseWheel') 60 else if (e.data.method === 'mouseWheel')
61 handleMouseWheel(e.data.params); 61 handleMouseWheel(e.data.params);
62 } 62 }
63 63
64 /** 64 /**
65 * This is called when a user selects this frame via the navigation bar 65 * This is called when a user selects this frame via the navigation bar
66 * frame (and is triggered via postMessage() from the uber page). 66 * frame (and is triggered via postMessage() from the uber page).
67 * @private 67 * @private
68 */ 68 */
69 function handleFrameSelected() { 69 function handleFrameSelected() {
70 document.body.scrollLeft = 0; 70 document.documentElement.scrollLeft = 0;
71 } 71 }
72 72
73 /** 73 /**
74 * Called when a user mouse wheels (or trackpad scrolls) over the nav frame. 74 * Called when a user mouse wheels (or trackpad scrolls) over the nav frame.
75 * The wheel event is forwarded here and we scroll the body. 75 * The wheel event is forwarded here and we scroll the body.
76 * There's no way to figure out the actual scroll amount for a given delta. 76 * There's no way to figure out the actual scroll amount for a given delta.
77 * It differs for every platform and even initWebKitWheelEvent takes a 77 * It differs for every platform and even initWebKitWheelEvent takes a
78 * pixel amount instead of a wheel delta. So we just choose something 78 * pixel amount instead of a wheel delta. So we just choose something
79 * reasonable and hope no one notices the difference. 79 * reasonable and hope no one notices the difference.
80 * @param {Object} params A structure that holds wheel deltas in X and Y. 80 * @param {Object} params A structure that holds wheel deltas in X and Y.
(...skipping 30 matching lines...) Expand all
111 var data = {method: method, params: opt_params}; 111 var data = {method: method, params: opt_params};
112 targetWindow.postMessage(data, opt_url ? opt_url : '*'); 112 targetWindow.postMessage(data, opt_url ? opt_url : '*');
113 } 113 }
114 114
115 return { 115 return {
116 invokeMethodOnParent: invokeMethodOnParent, 116 invokeMethodOnParent: invokeMethodOnParent,
117 invokeMethodOnWindow: invokeMethodOnWindow, 117 invokeMethodOnWindow: invokeMethodOnWindow,
118 onContentFrameLoaded: onContentFrameLoaded, 118 onContentFrameLoaded: onContentFrameLoaded,
119 }; 119 };
120 }); 120 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698