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

Side by Side Diff: chrome/browser/resources/print_preview/print_preview_animations.js

Issue 595153003: Compile print_preview, part 5: reduce down to 104 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview_4
Patch Set: fix a comment Created 6 years, 3 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 // Counter used to give webkit animations unique names. 5 // Counter used to give webkit animations unique names.
6 var animationCounter = 0; 6 var animationCounter = 0;
7 7
8 var animationEventTracker_ = new EventTracker(); 8 var animationEventTracker_ = new EventTracker();
9 9
10 function addAnimation(code) { 10 function addAnimation(code) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 * appearing underneath the textfields. 66 * appearing underneath the textfields.
67 * @param {HTMLElement} el The element to be faded out. 67 * @param {HTMLElement} el The element to be faded out.
68 */ 68 */
69 function fadeOutElement(el) { 69 function fadeOutElement(el) {
70 if (!el.classList.contains('visible')) 70 if (!el.classList.contains('visible'))
71 return; 71 return;
72 fadeInAnimationCleanup(el); 72 fadeInAnimationCleanup(el);
73 el.style.height = 'auto'; 73 el.style.height = 'auto';
74 var height = el.offsetHeight; 74 var height = el.offsetHeight;
75 el.style.height = height + 'px'; 75 el.style.height = height + 'px';
76 el.offsetHeight; // Should force an update of the computed style. 76 /**
77 * Should force an update of the computed style.
78 * @suppress {uselessCode}
Dan Beam 2014/09/24 23:31:21 i think this is supposed to be suspicious code, no
Dan Beam 2014/09/24 23:31:21 nit: just add a /** @supress {suspiciousCode} *
Vitaly Pavlenko 2014/09/24 23:57:07 Either way works.
Vitaly Pavlenko 2014/09/24 23:57:07 Done.
79 */
80 el.offsetHeight;
77 animationEventTracker_.add( 81 animationEventTracker_.add(
78 el, 'webkitTransitionEnd', onFadeOutTransitionEnd.bind(el), false); 82 el, 'webkitTransitionEnd', onFadeOutTransitionEnd.bind(el), false);
79 el.classList.add('closing'); 83 el.classList.add('closing');
80 el.classList.remove('visible'); 84 el.classList.remove('visible');
81 el.setAttribute('aria-hidden', 'true'); 85 el.setAttribute('aria-hidden', 'true');
82 } 86 }
83 87
84 /** 88 /**
85 * Executes when a fade out animation ends. 89 * Executes when a fade out animation ends.
86 * @param {WebkitTransitionEvent} event The event that triggered this listener. 90 * @param {WebkitTransitionEvent} event The event that triggered this listener.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 * @param {HTMLElement} el The element to hide. 126 * @param {HTMLElement} el The element to hide.
123 * @param {boolean=} opt_justShow Whether {@code el} should be hidden with no 127 * @param {boolean=} opt_justShow Whether {@code el} should be hidden with no
124 * animation. 128 * animation.
125 */ 129 */
126 function fadeInOption(el, opt_justShow) { 130 function fadeInOption(el, opt_justShow) {
127 if (el.classList.contains('visible')) 131 if (el.classList.contains('visible'))
128 return; 132 return;
129 // To make the option visible during the first fade in. 133 // To make the option visible during the first fade in.
130 el.hidden = false; 134 el.hidden = false;
131 135
132 var leftColumn = el.querySelector('.left-column'); 136 var leftColumn = assertInstanceof(el.querySelector('.left-column'),
137 HTMLElement);
133 wrapContentsInDiv(leftColumn, ['invisible']); 138 wrapContentsInDiv(leftColumn, ['invisible']);
134 var rightColumn = el.querySelector('.right-column'); 139 var rightColumn = assertInstanceof(el.querySelector('.right-column'),
140 HTMLElement);
135 wrapContentsInDiv(rightColumn, ['invisible']); 141 wrapContentsInDiv(rightColumn, ['invisible']);
136 142
137 var toAnimate = el.querySelectorAll('.collapsible'); 143 var toAnimate = el.querySelectorAll('.collapsible');
138 for (var i = 0; i < toAnimate.length; i++) 144 for (var i = 0; i < toAnimate.length; i++)
139 fadeInElement(toAnimate[i], opt_justShow); 145 fadeInElement(toAnimate[i], opt_justShow);
140 el.classList.add('visible'); 146 el.classList.add('visible');
141 } 147 }
142 148
143 /** 149 /**
144 * Fades out a printing option existing under |el|. 150 * Fades out a printing option existing under |el|.
145 * @param {HTMLElement} el The element to hide. 151 * @param {HTMLElement} el The element to hide.
146 * @param {boolean=} opt_justHide Whether {@code el} should be hidden with no 152 * @param {boolean=} opt_justHide Whether {@code el} should be hidden with no
147 * animation. 153 * animation.
148 */ 154 */
149 function fadeOutOption(el, opt_justHide) { 155 function fadeOutOption(el, opt_justHide) {
150 if (!el.classList.contains('visible')) 156 if (!el.classList.contains('visible'))
151 return; 157 return;
152 158
153 var leftColumn = el.querySelector('.left-column'); 159 var leftColumn = assertInstanceof(el.querySelector('.left-column'),
160 HTMLElement);
154 wrapContentsInDiv(leftColumn, ['visible']); 161 wrapContentsInDiv(leftColumn, ['visible']);
155 var rightColumn = el.querySelector('.right-column'); 162 var rightColumn = assertInstanceof(el.querySelector('.right-column'),
163 HTMLElement);
156 wrapContentsInDiv(rightColumn, ['visible']); 164 wrapContentsInDiv(rightColumn, ['visible']);
157 165
158 var toAnimate = el.querySelectorAll('.collapsible'); 166 var toAnimate = el.querySelectorAll('.collapsible');
159 for (var i = 0; i < toAnimate.length; i++) { 167 for (var i = 0; i < toAnimate.length; i++) {
160 if (opt_justHide) { 168 if (opt_justHide) {
161 toAnimate[i].hidden = true; 169 toAnimate[i].hidden = true;
162 toAnimate[i].classList.add('closing'); 170 toAnimate[i].classList.add('closing');
163 toAnimate[i].classList.remove('visible'); 171 toAnimate[i].classList.remove('visible');
164 } else { 172 } else {
165 fadeOutElement(toAnimate[i]); 173 fadeOutElement(toAnimate[i]);
166 } 174 }
167 } 175 }
168 el.classList.remove('visible'); 176 el.classList.remove('visible');
169 } 177 }
170 178
171 /** 179 /**
172 * Wraps the contents of |el| in a div element and attaches css classes 180 * Wraps the contents of |el| in a div element and attaches css classes
173 * |classes| in the new div, only if has not been already done. It is necessary 181 * |classes| in the new div, only if has not been already done. It is necessary
174 * for animating the height of table cells. 182 * for animating the height of table cells.
175 * @param {HTMLElement} el The element to be processed. 183 * @param {HTMLElement} el The element to be processed.
176 * @param {array} classes The css classes to add. 184 * @param {Array} classes The css classes to add.
177 */ 185 */
178 function wrapContentsInDiv(el, classes) { 186 function wrapContentsInDiv(el, classes) {
179 var div = el.querySelector('div'); 187 var div = el.querySelector('div');
180 if (!div || !div.classList.contains('collapsible')) { 188 if (!div || !div.classList.contains('collapsible')) {
181 div = document.createElement('div'); 189 div = document.createElement('div');
182 while (el.childNodes.length > 0) 190 while (el.childNodes.length > 0)
183 div.appendChild(el.firstChild); 191 div.appendChild(el.firstChild);
184 el.appendChild(div); 192 el.appendChild(div);
185 } 193 }
186 194
187 div.className = ''; 195 div.className = '';
188 div.classList.add('collapsible'); 196 div.classList.add('collapsible');
189 for (var i = 0; i < classes.length; i++) 197 for (var i = 0; i < classes.length; i++)
190 div.classList.add(classes[i]); 198 div.classList.add(classes[i]);
191 } 199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698