| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2011 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 if (!count) | 69 if (!count) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 while (parentElement) { | 72 while (parentElement) { |
| 73 parentElement.__widgetCounter -= count; | 73 parentElement.__widgetCounter -= count; |
| 74 parentElement = parentElement.parentElementOrShadowHost(); | 74 parentElement = parentElement.parentElementOrShadowHost(); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 static __assert(condition, message) { | 78 static __assert(condition, message) { |
| 79 if (!condition) { | 79 if (!condition) |
| 80 console.trace(); | |
| 81 throw new Error(message); | 80 throw new Error(message); |
| 82 } | |
| 83 } | 81 } |
| 84 | 82 |
| 85 /** | 83 /** |
| 86 * @param {?Node} node | 84 * @param {?Node} node |
| 87 */ | 85 */ |
| 88 static focusWidgetForNode(node) { | 86 static focusWidgetForNode(node) { |
| 89 while (node) { | 87 while (node) { |
| 90 if (node.__widget) | 88 if (node.__widget) |
| 91 break; | 89 break; |
| 92 node = node.parentNodeOrShadowHost(); | 90 node = node.parentNodeOrShadowHost(); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 /** | 429 /** |
| 432 * @param {string} cssFile | 430 * @param {string} cssFile |
| 433 */ | 431 */ |
| 434 registerRequiredCSS(cssFile) { | 432 registerRequiredCSS(cssFile) { |
| 435 UI.appendStyle(this._isWebComponent ? this._shadowRoot : this.element, cssFi
le); | 433 UI.appendStyle(this._isWebComponent ? this._shadowRoot : this.element, cssFi
le); |
| 436 } | 434 } |
| 437 | 435 |
| 438 printWidgetHierarchy() { | 436 printWidgetHierarchy() { |
| 439 var lines = []; | 437 var lines = []; |
| 440 this._collectWidgetHierarchy('', lines); | 438 this._collectWidgetHierarchy('', lines); |
| 441 console.log(lines.join('\n')); | 439 console.log(lines.join('\n')); // eslint-disable-line no-console |
| 442 } | 440 } |
| 443 | 441 |
| 444 _collectWidgetHierarchy(prefix, lines) { | 442 _collectWidgetHierarchy(prefix, lines) { |
| 445 lines.push(prefix + '[' + this.element.className + ']' + (this._children.len
gth ? ' {' : '')); | 443 lines.push(prefix + '[' + this.element.className + ']' + (this._children.len
gth ? ' {' : '')); |
| 446 | 444 |
| 447 for (var i = 0; i < this._children.length; ++i) | 445 for (var i = 0; i < this._children.length; ++i) |
| 448 this._children[i]._collectWidgetHierarchy(prefix + ' ', lines); | 446 this._children[i]._collectWidgetHierarchy(prefix + ' ', lines); |
| 449 | 447 |
| 450 if (this._children.length) | 448 if (this._children.length) |
| 451 lines.push(prefix + '}'); | 449 lines.push(prefix + '}'); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 UI.Widget.__assert( | 745 UI.Widget.__assert( |
| 748 !child.__widgetCounter && !child.__widget, | 746 !child.__widgetCounter && !child.__widget, |
| 749 'Attempt to remove element containing widget via regular DOM operation'); | 747 'Attempt to remove element containing widget via regular DOM operation'); |
| 750 return UI.Widget._originalRemoveChild.call(this, child); | 748 return UI.Widget._originalRemoveChild.call(this, child); |
| 751 }; | 749 }; |
| 752 | 750 |
| 753 Element.prototype.removeChildren = function() { | 751 Element.prototype.removeChildren = function() { |
| 754 UI.Widget.__assert(!this.__widgetCounter, 'Attempt to remove element containin
g widget via regular DOM operation'); | 752 UI.Widget.__assert(!this.__widgetCounter, 'Attempt to remove element containin
g widget via regular DOM operation'); |
| 755 UI.Widget._originalRemoveChildren.call(this); | 753 UI.Widget._originalRemoveChildren.call(this); |
| 756 }; | 754 }; |
| OLD | NEW |