Changeset 35313 in webkit


Ignore:
Timestamp:
Jul 23, 2008 7:47:33 PM (16 years ago)
Author:
timothy@apple.com
Message:

Added TreeOutline.removeChildAtIndex and TreeElement.removeChildAtIndex
for efficiency of callers that know the index of the child. This
will be used in an upcoming change.

Reviewed by Adam Roben.

  • page/inspector/treeoutline.js: (TreeOutline._removeChildAtIndex): Renamed from _removeChild and modified to take an index. (TreeOutline._removeChild): Call _removeChildAtIndex with the child index found using indexOf. (TreeOutline.prototype.removeChildAtIndex): Added. Calls TreeOutline._removeChildAtIndex. (TreeElement.prototype.removeChildAtIndex): Ditto.
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r35312 r35313  
     12008-07-21  Timothy Hatcher  <timothy@apple.com>
     2
     3        Added TreeOutline.removeChildAtIndex and TreeElement.removeChildAtIndex
     4        for efficiency of callers that know the index of the child. This
     5        will be used in an upcoming change.
     6
     7        Reviewed by Adam Roben.
     8
     9        * page/inspector/treeoutline.js:
     10        (TreeOutline._removeChildAtIndex): Renamed from _removeChild
     11        and modified to take an index.
     12        (TreeOutline._removeChild): Call _removeChildAtIndex with the
     13        child index found using indexOf.
     14        (TreeOutline.prototype.removeChildAtIndex): Added. Calls
     15        TreeOutline._removeChildAtIndex.
     16        (TreeElement.prototype.removeChildAtIndex): Ditto.
     17
    1182008-07-21  Timothy Hatcher  <timothy@apple.com>
    219
  • trunk/WebCore/page/inspector/treeoutline.js

    r35312 r35313  
    134134}
    135135
    136 TreeOutline._removeChild = function(child)
    137 {
    138     if (!child)
    139         throw("child can't be undefined or null");
    140 
    141     for (var i = 0; i < this.children.length; ++i) {
    142         if (this.children[i] === child) {
    143             this.children.splice(i, 1);
    144             break;
    145         }
    146     }
     136TreeOutline._removeChildAtIndex = function(childIndex)
     137{
     138    if (childIndex < 0 || childIndex >= this.children.length)
     139        throw("childIndex out of range");
     140
     141    var child = this.children[childIndex];
     142    this.children.splice(childIndex, 1);
    147143
    148144    child.deselect();
     
    160156    child.nextSibling = null;
    161157    child.previousSibling = null;
     158}
     159
     160TreeOutline._removeChild = function(child)
     161{
     162    if (!child)
     163        throw("child can't be undefined or null");
     164
     165    var childIndex = this.children.indexOf(child);
     166    if (childIndex === -1)
     167        throw("child not found in this node's children");
     168
     169    TreeOutline._removeChildAtIndex.call(this, childIndex);
    162170}
    163171
     
    396404TreeOutline.prototype.insertChild = TreeOutline._insertChild;
    397405TreeOutline.prototype.removeChild = TreeOutline._removeChild;
     406TreeOutline.prototype.removeChildAtIndex = TreeOutline._removeChildAtIndex;
    398407TreeOutline.prototype.removeChildren = TreeOutline._removeChildren;
    399408TreeOutline.prototype.removeChildrenRecursive = TreeOutline._removeChildrenRecursive;
     
    492501TreeElement.prototype.insertChild = TreeOutline._insertChild;
    493502TreeElement.prototype.removeChild = TreeOutline._removeChild;
     503TreeElement.prototype.removeChildAtIndex = TreeOutline._removeChildAtIndex;
    494504TreeElement.prototype.removeChildren = TreeOutline._removeChildren;
    495505TreeElement.prototype.removeChildrenRecursive = TreeOutline._removeChildrenRecursive;
Note: See TracChangeset for help on using the changeset viewer.