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

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

Issue 2600683002: Run tools/clang-format-js on some of chrome/browser/resources/ (Closed)
Patch Set: event_handler.js Created 3 years, 12 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
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 27 matching lines...) Expand all
38 /** 38 /**
39 * Handles scroll events on the document. This adjusts the position of all 39 * Handles scroll events on the document. This adjusts the position of all
40 * headers and updates the parent frame when the page is scrolled. 40 * headers and updates the parent frame when the page is scrolled.
41 */ 41 */
42 function handleScroll() { 42 function handleScroll() {
43 var scrollLeft = scrollLeftForDocument(document); 43 var scrollLeft = scrollLeftForDocument(document);
44 var offset = scrollLeft * -1; 44 var offset = scrollLeft * -1;
45 for (var i = 0; i < headerElements.length; i++) { 45 for (var i = 0; i < headerElements.length; i++) {
46 // As a workaround for http://crbug.com/231830, set the transform to 46 // As a workaround for http://crbug.com/231830, set the transform to
47 // 'none' rather than 0px. 47 // 'none' rather than 0px.
48 headerElements[i].style.webkitTransform = offset ? 48 headerElements[i].style.webkitTransform =
49 'translateX(' + offset + 'px)' : 'none'; 49 offset ? 'translateX(' + offset + 'px)' : 'none';
50 } 50 }
51 51
52 invokeMethodOnParent('adjustToScroll', scrollLeft); 52 invokeMethodOnParent('adjustToScroll', scrollLeft);
53 } 53 }
54 54
55 /** 55 /**
56 * Tells the parent to focus the current frame if the mouse goes down in the 56 * Tells the parent to focus the current frame if the mouse goes down in the
57 * current frame (and it doesn't already have focus). 57 * current frame (and it doesn't already have focus).
58 * @param {Event} e A mousedown event. 58 * @param {Event} e A mousedown event.
59 */ 59 */
60 function handleMouseDownInFrame(e) { 60 function handleMouseDownInFrame(e) {
61 if (!e.isSynthetic && !document.hasFocus()) 61 if (!e.isSynthetic && !document.hasFocus())
62 window.focus(); 62 window.focus();
63 } 63 }
64 64
65 /** 65 /**
66 * Handles 'message' events on window. 66 * Handles 'message' events on window.
67 * @param {Event} e The message event. 67 * @param {Event} e The message event.
68 */ 68 */
69 function handleWindowMessage(e) { 69 function handleWindowMessage(e) {
70 e = /** @type {!MessageEvent<!{method: string, params: *}>} */(e); 70 e = /** @type {!MessageEvent<!{method: string, params: *}>} */ (e);
71 if (e.data.method === 'frameSelected') { 71 if (e.data.method === 'frameSelected') {
72 handleFrameSelected(); 72 handleFrameSelected();
73 } else if (e.data.method === 'mouseWheel') { 73 } else if (e.data.method === 'mouseWheel') {
74 handleMouseWheel( 74 handleMouseWheel(
75 /** @type {{deltaX: number, deltaY: number}} */(e.data.params)); 75 /** @type {{deltaX: number, deltaY: number}} */ (e.data.params));
76 } else if (e.data.method === 'mouseDown') { 76 } else if (e.data.method === 'mouseDown') {
77 handleMouseDown(); 77 handleMouseDown();
78 } else if (e.data.method === 'popState') { 78 } else if (e.data.method === 'popState') {
79 handlePopState(e.data.params.state, e.data.params.path); 79 handlePopState(e.data.params.state, e.data.params.path);
80 } 80 }
81 } 81 }
82 82
83 /** 83 /**
84 * This is called when a user selects this frame via the navigation bar 84 * This is called when a user selects this frame via the navigation bar
85 * frame (and is triggered via postMessage() from the uber page). 85 * frame (and is triggered via postMessage() from the uber page).
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 /** 162 /**
163 * Updates the page's history state. If the page is embedded in a child, 163 * Updates the page's history state. If the page is embedded in a child,
164 * forward the information to the parent for it to manage history for us. This 164 * forward the information to the parent for it to manage history for us. This
165 * is a replacement of history.replaceState and history.pushState. 165 * is a replacement of history.replaceState and history.pushState.
166 * @param {Object} state A state object for replaceState and pushState. 166 * @param {Object} state A state object for replaceState and pushState.
167 * @param {string} path The path the page navigated to. 167 * @param {string} path The path the page navigated to.
168 * @param {boolean} replace If true, navigate with replacement. 168 * @param {boolean} replace If true, navigate with replacement.
169 */ 169 */
170 function updateHistory(state, path, replace) { 170 function updateHistory(state, path, replace) {
171 var historyFunction = replace ? 171 var historyFunction =
172 window.history.replaceState : 172 replace ? window.history.replaceState : window.history.pushState;
173 window.history.pushState;
174 173
175 if (hasParent()) { 174 if (hasParent()) {
176 // If there's a parent, always replaceState. The parent will do the actual 175 // If there's a parent, always replaceState. The parent will do the actual
177 // pushState. 176 // pushState.
178 historyFunction = window.history.replaceState; 177 historyFunction = window.history.replaceState;
179 invokeMethodOnParent('updateHistory', { 178 invokeMethodOnParent(
180 state: state, path: path, replace: replace}); 179 'updateHistory', {state: state, path: path, replace: replace});
181 } 180 }
182 historyFunction.call(window.history, state, '', '/' + path); 181 historyFunction.call(window.history, state, '', '/' + path);
183 } 182 }
184 183
185 /** 184 /**
186 * Sets the current title for the page. If the page is embedded in a child, 185 * Sets the current title for the page. If the page is embedded in a child,
187 * forward the information to the parent. This is a replacement for setting 186 * forward the information to the parent. This is a replacement for setting
188 * document.title. 187 * document.title.
189 * @param {string} title The new title for the page. 188 * @param {string} title The new title for the page.
190 */ 189 */
(...skipping 26 matching lines...) Expand all
217 216
218 return { 217 return {
219 invokeMethodOnParent: invokeMethodOnParent, 218 invokeMethodOnParent: invokeMethodOnParent,
220 invokeMethodOnWindow: invokeMethodOnWindow, 219 invokeMethodOnWindow: invokeMethodOnWindow,
221 onContentFrameLoaded: onContentFrameLoaded, 220 onContentFrameLoaded: onContentFrameLoaded,
222 pushState: pushState, 221 pushState: pushState,
223 replaceState: replaceState, 222 replaceState: replaceState,
224 setTitle: setTitle, 223 setTitle: setTitle,
225 }; 224 };
226 }); 225 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698