Chromium Code Reviews| 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Class that represents a UI component. | 9 * Class that represents a UI component. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 this.removeChild(this.children_[0]); | 149 this.removeChild(this.children_[0]); |
| 150 } | 150 } |
| 151 }, | 151 }, |
| 152 | 152 |
| 153 /** | 153 /** |
| 154 * @param {string} query Selector query to select an element starting from | 154 * @param {string} query Selector query to select an element starting from |
| 155 * the component's root element using a depth first search for the first | 155 * the component's root element using a depth first search for the first |
| 156 * element that matches the query. | 156 * element that matches the query. |
| 157 * @return {!HTMLElement} Element selected by the given query. | 157 * @return {!HTMLElement} Element selected by the given query. |
| 158 * TODO(alekseys): Check all call sites and rename this function to | 158 * TODO(alekseys): Check all call sites and rename this function to |
| 159 * something like getRequiredChildElement. | 159 * something like getRequiredChildElement. |
|
Dan Beam
2014/09/29 18:42:00
either remove this ^ or figure out how to address
Vitaly Pavlenko
2014/10/01 00:33:37
Removed the assert for now.
| |
| 160 */ | 160 */ |
| 161 getChildElement: function(query) { | 161 getChildElement: function(query) { |
| 162 return assert(this.element_.querySelector(query)); | 162 return assertInstanceof(this.element_.querySelector(query), HTMLElement); |
| 163 }, | 163 }, |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * Sets the component's element. | 166 * Sets the component's element. |
| 167 * @param {Element} element HTML element to set as the component's element. | 167 * @param {Element} element HTML element to set as the component's element. |
| 168 * @protected | 168 * @protected |
| 169 */ | 169 */ |
| 170 setElementInternal: function(element) { | 170 setElementInternal: function(element) { |
| 171 this.element_ = element; | 171 this.element_ = element; |
| 172 }, | 172 }, |
| 173 | 173 |
| 174 /** | 174 /** |
| 175 * Decorates the given element for use as the element of the component. | 175 * Decorates the given element for use as the element of the component. |
| 176 * @protected | 176 * @protected |
| 177 */ | 177 */ |
| 178 decorateInternal: function() { /*abstract*/ }, | 178 decorateInternal: function() { /*abstract*/ }, |
| 179 | 179 |
| 180 /** | 180 /** |
| 181 * Clones a template HTML DOM tree. | 181 * Clones a template HTML DOM tree. |
| 182 * @param {string} templateId Template element ID. | 182 * @param {string} templateId Template element ID. |
| 183 * @param {boolean=} opt_keepHidden Whether to leave the cloned template | 183 * @param {boolean=} opt_keepHidden Whether to leave the cloned template |
| 184 * hidden after cloning. | 184 * hidden after cloning. |
| 185 * @return {Element} Cloned element with its 'id' attribute stripped. | 185 * @return {Element} Cloned element with its 'id' attribute stripped. |
| 186 * @protected | 186 * @protected |
| 187 */ | 187 */ |
| 188 cloneTemplateInternal: function(templateId, opt_keepHidden) { | 188 cloneTemplateInternal: function(templateId, opt_keepHidden) { |
| 189 var templateEl = $(templateId); | 189 var templateEl = $(templateId); |
| 190 assert(templateEl != null, | 190 assert(templateEl != null, |
| 191 'Could not find element with ID: ' + templateId); | 191 'Could not find element with ID: ' + templateId); |
| 192 var el = templateEl.cloneNode(true); | 192 var el = assertInstanceof(templateEl.cloneNode(true), HTMLElement); |
| 193 el.id = ''; | 193 el.id = ''; |
| 194 if (!opt_keepHidden) { | 194 if (!opt_keepHidden) { |
| 195 setIsVisible(el, true); | 195 setIsVisible(el, true); |
| 196 } | 196 } |
| 197 return el; | 197 return el; |
| 198 } | 198 } |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 return { | 201 return { |
| 202 Component: Component | 202 Component: Component |
| 203 }; | 203 }; |
| 204 }); | 204 }); |
| OLD | NEW |