⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 101315 in webkit


Ignore:
Timestamp:
Nov 28, 2011, 6:34:38 PM (15 years ago)
Author:
timothy@apple.com
Message:

Add support for knowing when a TreeElement is added or changed anywhere in a TreeOutline.

Reviewed by Brian Weinstein.

  • inspector/front-end/treeoutline.js:

(TreeOutline.prototype.appendChild): Call onadd if it exists.
(TreeOutline.prototype.insertChild): Ditto.
(TreeOutline.prototype._treeElementDidChange): Added. Call onchange if it exists.
(TreeElement.prototype.set title): Call didChange.
(TreeElement.prototype.set titleHTML): Ditto.
(TreeElement.prototype.set tooltip): Ditto.
(TreeElement.prototype.set hasChildren): Ditto.
(TreeElement.prototype._fireDidChange): Added. Call TreeOutline._treeElementDidChange.
(TreeElement.prototype.didChange): Added. Schedule a timeout for _fireDidChange.
(TreeElement.prototype.expand): Move the code that sets the expanded flag to the beginning
which is before onpopulate. Since onpopulate can add elements and call onadd, this makes
sure the expanded flag is true before calling those functions.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r101314 r101315  
     12011-11-28  Timothy Hatcher  <timothy@apple.com>
     2
     3        Add support for knowing when a TreeElement is added or changed anywhere in a TreeOutline.
     4
     5        Reviewed by Brian Weinstein.
     6
     7        * inspector/front-end/treeoutline.js:
     8        (TreeOutline.prototype.appendChild): Call onadd if it exists.
     9        (TreeOutline.prototype.insertChild): Ditto.
     10        (TreeOutline.prototype._treeElementDidChange): Added. Call onchange if it exists.
     11        (TreeElement.prototype.set title): Call didChange.
     12        (TreeElement.prototype.set titleHTML): Ditto.
     13        (TreeElement.prototype.set tooltip): Ditto.
     14        (TreeElement.prototype.set hasChildren): Ditto.
     15        (TreeElement.prototype._fireDidChange): Added. Call TreeOutline._treeElementDidChange.
     16        (TreeElement.prototype.didChange): Added. Schedule a timeout for _fireDidChange.
     17        (TreeElement.prototype.expand): Move the code that sets the expanded flag to the beginning
     18        which is before onpopulate. Since onpopulate can add elements and call onadd, this makes
     19        sure the expanded flag is true before calling those functions.
     20
    1212011-11-28  Timothy Hatcher  <timothy@apple.com>
    222
  • trunk/Source/WebCore/inspector/front-end/treeoutline.js

    r101314 r101315  
    9393
    9494    child._attach();
     95
     96    if (this.treeOutline.onadd)
     97        this.treeOutline.onadd(child);
    9598}
    9699
     
    141144
    142145    child._attach();
     146
     147    if (this.treeOutline.onadd)
     148        this.treeOutline.onadd(child);
    143149}
    144150
     
    334340
    335341    return this.getCachedTreeElement(representedObject);
     342}
     343
     344TreeOutline.prototype._treeElementDidChange = function(treeElement)
     345{
     346    if (treeElement.treeOutline !== this)
     347        return;
     348
     349    if (this.onchange)
     350        this.onchange(treeElement);
    336351}
    337352
     
    513528        this._title = x;
    514529        this._setListItemNodeContent();
     530        this.didChange();
    515531    },
    516532
     
    522538        this._titleHTML = x;
    523539        this._setListItemNodeContent();
     540        this.didChange();
    524541    },
    525542
     
    532549        if (this._listItemNode)
    533550            this._listItemNode.title = x ? x : "";
     551        this.didChange();
    534552    },
    535553
     
    553571            this.collapse();
    554572        }
     573
     574        this.didChange();
    555575    },
    556576
     
    586606        if (x && this.expanded)
    587607            this.expand();
     608    },
     609
     610    _fireDidChange: function()
     611    {
     612        delete this._didChangeTimeoutIdentifier;
     613
     614        if (this.treeOutline)
     615            this.treeOutline._treeElementDidChange(this);
     616    },
     617
     618    didChange: function()
     619    {
     620        if (!this.treeOutline)
     621            return;
     622
     623        // Prevent telling the TreeOutline multiple times in a row by delaying it with a timeout.
     624        if (!this._didChangeTimeoutIdentifier)
     625            this._didChangeTimeoutIdentifier = setTimeout(this._fireDidChange.bind(this), 0);
    588626    },
    589627
     
    742780        return;
    743781
     782    // Set this before onpopulate. Since onpopulate can add elements and call onadd, this makes
     783    // sure the expanded flag is true before calling those functions. This prevents the possibility
     784    // of an infinite loop if onpopulate or onadd were to call expand.
     785
     786    this.expanded = true;
     787    if (this.treeOutline)
     788        this.treeOutline._treeElementsExpandedState[this.identifier] = true;
     789
    744790    if (this.treeOutline && (!this._childrenListNode || this._shouldRefreshChildren)) {
    745791        if (this._childrenListNode && this._childrenListNode.parentNode)
     
    769815    if (this._childrenListNode)
    770816        this._childrenListNode.classList.add("expanded");
    771 
    772     this.expanded = true;
    773     if (this.treeOutline)
    774         this.treeOutline._treeElementsExpandedState[this.identifier] = true;
    775817
    776818    if (this.onexpand)
Note: See TracChangeset for help on using the changeset viewer.