| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 Element.prototype.isInsertionCaretInside = function() | 391 Element.prototype.isInsertionCaretInside = function() |
| 392 { | 392 { |
| 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 |
| 402 * @return {!Element} |
| 403 */ |
| 404 function createElement(tagName) |
| 405 { |
| 406 return document.createElement(tagName); |
| 407 } |
| 408 |
| 409 /** |
| 410 * @param {number|string} data |
| 411 * @return {!Text} |
| 412 */ |
| 413 function createTextNode(data) |
| 414 { |
| 415 return document.createTextNode(data); |
| 416 } |
| 417 |
| 418 /** |
| 401 * @param {string} elementName | 419 * @param {string} elementName |
| 402 * @param {string=} className | 420 * @param {string=} className |
| 403 * @return {!Element} | 421 * @return {!Element} |
| 404 */ | 422 */ |
| 405 Document.prototype.createElementWithClass = function(elementName, className) | 423 Document.prototype.createElementWithClass = function(elementName, className) |
| 406 { | 424 { |
| 407 var element = this.createElement(elementName); | 425 var element = this.createElement(elementName); |
| 408 if (className) | 426 if (className) |
| 409 element.className = className; | 427 element.className = className; |
| 410 return element; | 428 return element; |
| 411 } | 429 } |
| 412 | 430 |
| 413 /** | 431 /** |
| 414 * @param {string} elementName | 432 * @param {string} elementName |
| 415 * @param {string=} className | 433 * @param {string=} className |
| 416 * @return {!Element} | 434 * @return {!Element} |
| 417 */ | 435 */ |
| 436 function createElementWithClass(elementName, className) |
| 437 { |
| 438 return document.createElementWithClass(elementName, className); |
| 439 } |
| 440 |
| 441 /** |
| 442 * @return {!DocumentFragment} |
| 443 */ |
| 444 function createDocumentFragment() |
| 445 { |
| 446 return document.createDocumentFragment(); |
| 447 } |
| 448 |
| 449 /** |
| 450 * @param {string} elementName |
| 451 * @param {string=} className |
| 452 * @return {!Element} |
| 453 */ |
| 418 Element.prototype.createChild = function(elementName, className) | 454 Element.prototype.createChild = function(elementName, className) |
| 419 { | 455 { |
| 420 var element = this.ownerDocument.createElementWithClass(elementName, classNa
me); | 456 var element = this.ownerDocument.createElementWithClass(elementName, classNa
me); |
| 421 this.appendChild(element); | 457 this.appendChild(element); |
| 422 return element; | 458 return element; |
| 423 } | 459 } |
| 424 | 460 |
| 425 DocumentFragment.prototype.createChild = Element.prototype.createChild; | 461 DocumentFragment.prototype.createChild = Element.prototype.createChild; |
| 426 | 462 |
| 427 /** | 463 /** |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 */ | 853 */ |
| 818 function isEnterKey(event) { | 854 function isEnterKey(event) { |
| 819 // Check if in IME. | 855 // Check if in IME. |
| 820 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; | 856 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; |
| 821 } | 857 } |
| 822 | 858 |
| 823 function consumeEvent(e) | 859 function consumeEvent(e) |
| 824 { | 860 { |
| 825 e.consume(); | 861 e.consume(); |
| 826 } | 862 } |
| OLD | NEW |