Changeset 53167 in webkit


Ignore:
Timestamp:
Jan 12, 2010 3:34:20 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-12 Alexander Pavlov <apavlov@chromium.org>

Reviewed by Timothy Hatcher.

Optimize WebInspector.TimelineGrid.prototype.updateDividers()

DOM element property access and modification are slow and should be done as lazily as possible.
https://bugs.webkit.org/show_bug.cgi?id=33536

  • inspector/front-end/TimelineGrid.js: (WebInspector.TimelineGrid.prototype.updateDividers): (WebInspector.TimelineGrid.prototype._setDividerAndBarLeft):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53166 r53167  
     12010-01-12  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Optimize WebInspector.TimelineGrid.prototype.updateDividers()
     6
     7        DOM element property access and modification are slow and should be done as lazily as possible.
     8        https://bugs.webkit.org/show_bug.cgi?id=33536
     9
     10        * inspector/front-end/TimelineGrid.js:
     11        (WebInspector.TimelineGrid.prototype.updateDividers):
     12        (WebInspector.TimelineGrid.prototype._setDividerAndBarLeft):
     13
    1142010-01-12  Beth Dakin  <bdakin@apple.com>
    215
  • trunk/WebCore/inspector/front-end/TimelineGrid.js

    r51339 r53167  
    6363            return false;
    6464
    65         if (!(typeof paddingLeft === "number"))
     65        if (typeof paddingLeft !== "number")
    6666            paddingLeft = 0;
    6767        this._currentDividerSlice = slice;
     
    7272        var dividerLabelBar = this._dividersLabelBarElement.firstChild;
    7373
    74         var clientWidth = this._dividersLabelBarElement.clientWidth - paddingLeft;
     74        var dividersLabelBarElementClientWidth = this._dividersLabelBarElement.clientWidth;
     75        var clientWidth = dividersLabelBarElementClientWidth - paddingLeft;
    7576        for (var i = paddingLeft ? 0 : 1; i <= dividerCount; ++i) {
    7677            if (!divider) {
     
    8687                dividerLabelBar.appendChild(label);
    8788                this._dividersLabelBarElement.appendChild(dividerLabelBar);
     89                dividersLabelBarElementClientWidth = this._dividersLabelBarElement.clientWidth;
    8890            }
    8991
     
    9496
    9597            var left = paddingLeft + clientWidth * (i / dividerCount);
    96             var percentLeft = 100 * left / this._dividersLabelBarElement.clientWidth + "%";
    97             divider.style.left = percentLeft;
    98             dividerLabelBar.style.left = percentLeft;
     98            var percentLeft = 100 * left / dividersLabelBarElementClientWidth;
     99            this._setDividerAndBarLeft(divider, dividerLabelBar, percentLeft);
    99100
    100101            if (!isNaN(slice))
     
    119120    },
    120121
     122    _setDividerAndBarLeft: function(divider, dividerLabelBar, percentLeft)
     123    {
     124        var percentStyleLeft = parseFloat(divider.style.left);
     125        if (!isNaN(percentStyleLeft) && Math.abs(percentStyleLeft - percentLeft) < 0.1)
     126            return;
     127        divider.style.left = percentLeft + "%";
     128        dividerLabelBar.style.left = percentLeft + "%";
     129    },
     130
    121131    addEventDivider: function(divider)
    122132    {
Note: See TracChangeset for help on using the changeset viewer.