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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 { | 206 { |
207 WebInspector.View.__assert(parentElement, "Attempt to attach view with n
o parent element"); | 207 WebInspector.View.__assert(parentElement, "Attempt to attach view with n
o parent element"); |
208 | 208 |
209 // Update view hierarchy | 209 // Update view hierarchy |
210 if (this.element.parentElement !== parentElement) { | 210 if (this.element.parentElement !== parentElement) { |
211 if (this.element.parentElement) | 211 if (this.element.parentElement) |
212 this.detach(); | 212 this.detach(); |
213 | 213 |
214 var currentParent = parentElement; | 214 var currentParent = parentElement; |
215 while (currentParent && !currentParent.__view) | 215 while (currentParent && !currentParent.__view) |
216 currentParent = currentParent.parentElement; | 216 currentParent = currentParent.parentElementOrShadowHost(); |
217 | 217 |
218 if (currentParent) { | 218 if (currentParent) { |
219 this._parentView = currentParent.__view; | 219 this._parentView = currentParent.__view; |
220 this._parentView._children.push(this); | 220 this._parentView._children.push(this); |
221 this._isRoot = false; | 221 this._isRoot = false; |
222 } else | 222 } else |
223 WebInspector.View.__assert(this._isRoot, "Attempt to attach view
to orphan node"); | 223 WebInspector.View.__assert(this._isRoot, "Attempt to attach view
to orphan node"); |
224 } else if (this._visible) { | 224 } else if (this._visible) { |
225 return; | 225 return; |
226 } | 226 } |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 WebInspector.View._originalRemoveChildren = Element.prototype.removeChildren; | 488 WebInspector.View._originalRemoveChildren = Element.prototype.removeChildren; |
489 | 489 |
490 WebInspector.View._incrementViewCounter = function(parentElement, childElement) | 490 WebInspector.View._incrementViewCounter = function(parentElement, childElement) |
491 { | 491 { |
492 var count = (childElement.__viewCounter || 0) + (childElement.__view ? 1 : 0
); | 492 var count = (childElement.__viewCounter || 0) + (childElement.__view ? 1 : 0
); |
493 if (!count) | 493 if (!count) |
494 return; | 494 return; |
495 | 495 |
496 while (parentElement) { | 496 while (parentElement) { |
497 parentElement.__viewCounter = (parentElement.__viewCounter || 0) + count
; | 497 parentElement.__viewCounter = (parentElement.__viewCounter || 0) + count
; |
498 parentElement = parentElement.parentElement; | 498 parentElement = parentElement.parentElementOrShadowHost(); |
499 } | 499 } |
500 } | 500 } |
501 | 501 |
502 WebInspector.View._decrementViewCounter = function(parentElement, childElement) | 502 WebInspector.View._decrementViewCounter = function(parentElement, childElement) |
503 { | 503 { |
504 var count = (childElement.__viewCounter || 0) + (childElement.__view ? 1 : 0
); | 504 var count = (childElement.__viewCounter || 0) + (childElement.__view ? 1 : 0
); |
505 if (!count) | 505 if (!count) |
506 return; | 506 return; |
507 | 507 |
508 while (parentElement) { | 508 while (parentElement) { |
509 parentElement.__viewCounter -= count; | 509 parentElement.__viewCounter -= count; |
510 parentElement = parentElement.parentElement; | 510 parentElement = parentElement.parentElementOrShadowHost(); |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 WebInspector.View.__assert = function(condition, message) | 514 WebInspector.View.__assert = function(condition, message) |
515 { | 515 { |
516 if (!condition) { | 516 if (!condition) { |
517 console.trace(); | 517 console.trace(); |
518 throw new Error(message); | 518 throw new Error(message); |
519 } | 519 } |
520 } | 520 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 { | 643 { |
644 WebInspector.View.__assert(!child.__viewCounter && !child.__view, "Attempt t
o remove element containing view via regular DOM operation"); | 644 WebInspector.View.__assert(!child.__viewCounter && !child.__view, "Attempt t
o remove element containing view via regular DOM operation"); |
645 return WebInspector.View._originalRemoveChild.call(this, child); | 645 return WebInspector.View._originalRemoveChild.call(this, child); |
646 } | 646 } |
647 | 647 |
648 Element.prototype.removeChildren = function() | 648 Element.prototype.removeChildren = function() |
649 { | 649 { |
650 WebInspector.View.__assert(!this.__viewCounter, "Attempt to remove element c
ontaining view via regular DOM operation"); | 650 WebInspector.View.__assert(!this.__viewCounter, "Attempt to remove element c
ontaining view via regular DOM operation"); |
651 WebInspector.View._originalRemoveChildren.call(this); | 651 WebInspector.View._originalRemoveChildren.call(this); |
652 } | 652 } |
OLD | NEW |