OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 277 } |
278 | 278 |
279 /** | 279 /** |
280 * @param {?Element=} containerElement | 280 * @param {?Element=} containerElement |
281 * @return {!Size} | 281 * @return {!Size} |
282 */ | 282 */ |
283 Element.prototype.measurePreferredSize = function(containerElement) | 283 Element.prototype.measurePreferredSize = function(containerElement) |
284 { | 284 { |
285 containerElement = containerElement || document.body; | 285 containerElement = containerElement || document.body; |
286 containerElement.appendChild(this); | 286 containerElement.appendChild(this); |
| 287 var fakingComponentRoot = false; |
| 288 if (!this.classList.contains("component-root")) { |
| 289 fakingComponentRoot = true; |
| 290 this.classList.add("component-root"); |
| 291 } |
287 this.positionAt(0, 0); | 292 this.positionAt(0, 0); |
288 var result = new Size(this.offsetWidth, this.offsetHeight); | 293 var result = new Size(this.offsetWidth, this.offsetHeight); |
289 this.positionAt(undefined, undefined); | 294 this.positionAt(undefined, undefined); |
290 this.remove(); | 295 this.remove(); |
| 296 if (fakingComponentRoot) |
| 297 this.classList.remove("component-root"); |
291 return result; | 298 return result; |
292 } | 299 } |
293 | 300 |
294 /** | 301 /** |
295 * @param {!Event} event | 302 * @param {!Event} event |
296 * @return {boolean} | 303 * @return {boolean} |
297 */ | 304 */ |
298 Element.prototype.containsEventPoint = function(event) | 305 Element.prototype.containsEventPoint = function(event) |
299 { | 306 { |
300 var box = this.getBoundingClientRect(); | 307 var box = this.getBoundingClientRect(); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 */ | 817 */ |
811 function isEnterKey(event) { | 818 function isEnterKey(event) { |
812 // Check if in IME. | 819 // Check if in IME. |
813 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; | 820 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; |
814 } | 821 } |
815 | 822 |
816 function consumeEvent(e) | 823 function consumeEvent(e) |
817 { | 824 { |
818 e.consume(); | 825 e.consume(); |
819 } | 826 } |
OLD | NEW |