| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return new Constraints(this.minimum.addHeight(value), this.preferred.add
Height(value)); | 275 return new Constraints(this.minimum.addHeight(value), this.preferred.add
Height(value)); |
| 276 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred
.addHeight(value.preferred)); | 276 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred
.addHeight(value.preferred)); |
| 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 || this.ownerDocument.body; |
| 286 containerElement.appendChild(this); | 286 containerElement.appendChild(this); |
| 287 var fakingComponentRoot = false; | 287 var fakingComponentRoot = false; |
| 288 if (!this.classList.contains("component-root")) { | 288 if (!this.classList.contains("component-root")) { |
| 289 fakingComponentRoot = true; | 289 fakingComponentRoot = true; |
| 290 this.classList.add("component-root"); | 290 this.classList.add("component-root"); |
| 291 } | 291 } |
| 292 this.positionAt(0, 0); | 292 this.positionAt(0, 0); |
| 293 var result = new Size(this.offsetWidth, this.offsetHeight); | 293 var result = new Size(this.offsetWidth, this.offsetHeight); |
| 294 this.positionAt(undefined, undefined); | 294 this.positionAt(undefined, undefined); |
| 295 this.remove(); | 295 this.remove(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 var selection = window.getSelection(); | 393 var selection = window.getSelection(); |
| 394 if (!selection.rangeCount || !selection.isCollapsed) | 394 if (!selection.rangeCount || !selection.isCollapsed) |
| 395 return false; | 395 return false; |
| 396 var selectionRange = selection.getRangeAt(0); | 396 var selectionRange = selection.getRangeAt(0); |
| 397 return selectionRange.startContainer.isSelfOrDescendant(this); | 397 return selectionRange.startContainer.isSelfOrDescendant(this); |
| 398 } | 398 } |
| 399 | 399 |
| 400 /** | 400 /** |
| 401 * @param {string} tagName | 401 * @param {string} tagName |
| 402 * @return {!Element} | 402 * @return {!Element} |
| 403 * @suppressGlobalPropertiesCheck |
| 403 */ | 404 */ |
| 404 function createElement(tagName) | 405 function createElement(tagName) |
| 405 { | 406 { |
| 406 return document.createElement(tagName); | 407 return document.createElement(tagName); |
| 407 } | 408 } |
| 408 | 409 |
| 409 /** | 410 /** |
| 410 * @param {number|string} data | 411 * @param {number|string} data |
| 411 * @return {!Text} | 412 * @return {!Text} |
| 413 * @suppressGlobalPropertiesCheck |
| 412 */ | 414 */ |
| 413 function createTextNode(data) | 415 function createTextNode(data) |
| 414 { | 416 { |
| 415 return document.createTextNode(data); | 417 return document.createTextNode(data); |
| 416 } | 418 } |
| 417 | 419 |
| 418 /** | 420 /** |
| 419 * @param {string} elementName | 421 * @param {string} elementName |
| 420 * @param {string=} className | 422 * @param {string=} className |
| 421 * @return {!Element} | 423 * @return {!Element} |
| 422 */ | 424 */ |
| 423 Document.prototype.createElementWithClass = function(elementName, className) | 425 Document.prototype.createElementWithClass = function(elementName, className) |
| 424 { | 426 { |
| 425 var element = this.createElement(elementName); | 427 var element = this.createElement(elementName); |
| 426 if (className) | 428 if (className) |
| 427 element.className = className; | 429 element.className = className; |
| 428 return element; | 430 return element; |
| 429 } | 431 } |
| 430 | 432 |
| 431 /** | 433 /** |
| 432 * @param {string} elementName | 434 * @param {string} elementName |
| 433 * @param {string=} className | 435 * @param {string=} className |
| 434 * @return {!Element} | 436 * @return {!Element} |
| 437 * @suppressGlobalPropertiesCheck |
| 435 */ | 438 */ |
| 436 function createElementWithClass(elementName, className) | 439 function createElementWithClass(elementName, className) |
| 437 { | 440 { |
| 438 return document.createElementWithClass(elementName, className); | 441 return document.createElementWithClass(elementName, className); |
| 439 } | 442 } |
| 440 | 443 |
| 441 /** | 444 /** |
| 442 * @return {!DocumentFragment} | 445 * @return {!DocumentFragment} |
| 446 * @suppressGlobalPropertiesCheck |
| 443 */ | 447 */ |
| 444 function createDocumentFragment() | 448 function createDocumentFragment() |
| 445 { | 449 { |
| 446 return document.createDocumentFragment(); | 450 return document.createDocumentFragment(); |
| 447 } | 451 } |
| 448 | 452 |
| 449 /** | 453 /** |
| 450 * @param {string} elementName | 454 * @param {string} elementName |
| 451 * @param {string=} className | 455 * @param {string=} className |
| 452 * @return {!Element} | 456 * @return {!Element} |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 */ | 866 */ |
| 863 function isEnterKey(event) { | 867 function isEnterKey(event) { |
| 864 // Check if in IME. | 868 // Check if in IME. |
| 865 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; | 869 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; |
| 866 } | 870 } |
| 867 | 871 |
| 868 function consumeEvent(e) | 872 function consumeEvent(e) |
| 869 { | 873 { |
| 870 e.consume(); | 874 e.consume(); |
| 871 } | 875 } |
| OLD | NEW |