Changeset 50909 in webkit


Ignore:
Timestamp:
Nov 12, 2009 3:07:25 PM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2009-11-12 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: profile timeline panel, fix obvious problems.

https://bugs.webkit.org/show_bug.cgi?id=31432

  • inspector/front-end/AbstractTimelinePanel.js: (WebInspector.AbstractTimelinePanel.prototype.updateGraphDividersIfNeeded):
  • inspector/front-end/TimelinePanel.js: (WebInspector.TimelinePanel.prototype._setWindowPosition): (WebInspector.TimelineCalculator): (WebInspector.TimelineCalculator.prototype.get minimumBoundary): (WebInspector.TimelineCalculator.prototype.get maximumBoundary): (WebInspector.TimelineCalculator.prototype.reset): (WebInspector.TimelineCalculator.prototype.updateBoundaries): (WebInspector.TimelineCalculator.prototype.formatValue): (WebInspector.TimelineGraph): (WebInspector.TimelineGraph.prototype.refresh):
  • inspector/front-end/utilities.js: (Element.prototype.hasStyleClass):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r50908 r50909  
     12009-11-12  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: profile timeline panel, fix obvious problems.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=31432
     8
     9        * inspector/front-end/AbstractTimelinePanel.js:
     10        (WebInspector.AbstractTimelinePanel.prototype.updateGraphDividersIfNeeded):
     11        * inspector/front-end/TimelinePanel.js:
     12        (WebInspector.TimelinePanel.prototype._setWindowPosition):
     13        (WebInspector.TimelineCalculator):
     14        (WebInspector.TimelineCalculator.prototype.get minimumBoundary):
     15        (WebInspector.TimelineCalculator.prototype.get maximumBoundary):
     16        (WebInspector.TimelineCalculator.prototype.reset):
     17        (WebInspector.TimelineCalculator.prototype.updateBoundaries):
     18        (WebInspector.TimelineCalculator.prototype.formatValue):
     19        (WebInspector.TimelineGraph):
     20        (WebInspector.TimelineGraph.prototype.refresh):
     21        * inspector/front-end/utilities.js:
     22        (Element.prototype.hasStyleClass):
     23
    1242009-11-12  Pavel Feldman  <pfeldman@chromium.org>
    225
  • trunk/WebCore/inspector/front-end/AbstractTimelinePanel.js

    r50875 r50909  
    210210            return false;
    211211        }
    212 
    213         if (document.body.offsetWidth <= 0) {
    214             // The stylesheet hasn't loaded yet or the window is closed,
    215             // so we can't calculate what is need. Return early.
    216             return false;
    217         }
    218 
    219212        return this._timelineGrid.updateDividers(force, this.calculator);
    220213    },
  • trunk/WebCore/inspector/front-end/TimelinePanel.js

    r50885 r50909  
    418418        this.invalidateAllItems();
    419419        if (typeof start === "number") {
    420           if (start > this._rightResizeElement.offsetLeft - 25)
    421               start = this._rightResizeElement.offsetLeft - 25;
    422 
    423           this.calculator.windowLeft = start / this._overviewGridElement.clientWidth;
    424           this._leftResizeElement.style.left = this.calculator.windowLeft*100 + "%";
    425           this._overviewWindowElement.style.left = this.calculator.windowLeft*100 + "%";
     420            if (start > this._rightResizeElement.offsetLeft - 25)
     421                start = this._rightResizeElement.offsetLeft - 25;
     422
     423            var windowLeft = start / this._overviewGridElement.clientWidth;
     424            this.calculator.windowLeft = windowLeft;
     425            this._leftResizeElement.style.left = windowLeft * 100 + "%";
     426            this._overviewWindowElement.style.left = windowLeft * 100 + "%";
    426427        }
    427428        if (typeof end === "number") {
     
    429430                end = this._leftResizeElement.offsetLeft + 30;
    430431
    431             this.calculator.windowRight = end / this._overviewGridElement.clientWidth;
    432             this._rightResizeElement.style.left = this.calculator.windowRight*100 + "%";
    433         }
    434         this._overviewWindowElement.style.width = (this.calculator.windowRight - this.calculator.windowLeft)*100 + "%";
     432            var windowRight = end / this._overviewGridElement.clientWidth;
     433            this.calculator.windowRight = windowRight;
     434            this._rightResizeElement.style.left = windowRight * 100 + "%";
     435        }
     436        this._overviewWindowElement.style.width = (this.calculator.windowRight - this.calculator.windowLeft) * 100 + "%";
    435437        this.needsRefresh = true;
    436438    },
     
    541543    },
    542544
    543     _updateDetails: function() {
     545    _updateDetails: function()
     546    {
    544547        if (this.dataElement && this._record.details !== this._details) {
    545548            this._details = this._record.details;
     
    574577    this.windowLeft = 0.0;
    575578    this.windowRight = 1.0;
     579    this._uiString = WebInspector.UIString.bind(WebInspector);
    576580}
    577581
     
    596600    get minimumBoundary()
    597601    {
     602        if (typeof this._minimumBoundary === "number")
     603            return this._minimumBoundary;
     604
    598605        if (typeof this.windowLeft === "number")
    599             return this._absoluteMinimumBoundary + this.windowLeft * (this._absoluteMaximumBoundary - this._absoluteMinimumBoundary);
    600         return this._absoluteMinimumBoundary;
     606            this._minimumBoundary = this._absoluteMinimumBoundary + this.windowLeft * (this._absoluteMaximumBoundary - this._absoluteMinimumBoundary);
     607        else
     608            this._minimumBoundary = this._absoluteMinimumBoundary;
     609        return this._minimumBoundary;
    601610    },
    602611
    603612    get maximumBoundary()
    604613    {
     614        if (typeof this._maximumBoundary === "number")
     615            return this._maximumBoundary;
     616
    605617        if (typeof this.windowLeft === "number")
    606             return this._absoluteMinimumBoundary + this.windowRight * (this._absoluteMaximumBoundary - this._absoluteMinimumBoundary);
    607         return this._absoluteMaximumBoundary;
     618            this._maximumBoundary = this._absoluteMinimumBoundary + this.windowRight * (this._absoluteMaximumBoundary - this._absoluteMinimumBoundary);
     619        else
     620            this._maximumBoundary = this._absoluteMaximumBoundary;
     621        return this._maximumBoundary;
    608622    },
    609623
     
    612626        delete this._absoluteMinimumBoundary;
    613627        delete this._absoluteMaximumBoundary;
     628        delete this._minimumBoundary;
     629        delete this._maximumBoundary;
    614630    },
    615631
     
    622638        if (typeof this._absoluteMinimumBoundary === "undefined" || lowerBound < this._absoluteMinimumBoundary) {
    623639            this._absoluteMinimumBoundary = lowerBound;
     640            delete this._minimumBoundary;
    624641            didChange = true;
    625642        }
     
    628645        if (typeof this._absoluteMaximumBoundary === "undefined" || upperBound > this._absoluteMaximumBoundary) {
    629646            this._absoluteMaximumBoundary = upperBound;
     647            delete this._maximumBoundary;
    630648            didChange = true;
    631649        }
     
    636654    formatValue: function(value)
    637655    {
    638         return Number.secondsToString(value + this.minimumBoundary - this._absoluteMinimumBoundary, WebInspector.UIString.bind(WebInspector));
     656        return Number.secondsToString(value + this.minimumBoundary - this._absoluteMinimumBoundary, this._uiString);
    639657    }
    640658}
     
    701719
    702720    this._graphElement.addStyleClass("timeline-category-" + record.category.name);
     721    this._hidden = false;
    703722}
    704723
     
    721740
    722741        if (percentages.start > 100 || percentages.end < 0) {
    723             this._graphElement.addStyleClass("hidden");
    724             this.record._itemsTreeElement.listItemElement.addStyleClass("hidden");
     742            if (!this._hidden) {
     743                this._graphElement.addStyleClass("hidden");
     744                this.record._itemsTreeElement.listItemElement.addStyleClass("hidden");
     745                this._hidden = true;
     746            }
    725747        } else {
    726748            this._barElement.style.setProperty("left", percentages.start + "%");
    727749            this._barElement.style.setProperty("right", (100 - percentages.end) + "%");
    728             this._graphElement.removeStyleClass("hidden");
    729             this.record._itemsTreeElement.listItemElement.removeStyleClass("hidden");
     750            if (this._hidden) {
     751                this._graphElement.removeStyleClass("hidden");
     752                this.record._itemsTreeElement.listItemElement.removeStyleClass("hidden");
     753                this._hidden = false;
     754            }
    730755        }
    731756        var tooltip = (labels.tooltip || "");
  • trunk/WebCore/inspector/front-end/utilities.js

    r50663 r50909  
    148148Element.prototype.removeStyleClass = function(className)
    149149{
    150     // Test for the simple case before using a RegExp.
     150    // Test for the simple case first.
    151151    if (this.className === className) {
    152152        this.className = "";
     
    154154    }
    155155
    156     this.removeMatchingStyleClasses(className.escapeForRegExp());
     156    var index = this.className.indexOf(className);
     157    if (index === -1)
     158        return;
     159
     160    var newClassName = " " + this.className + " ";
     161    this.className = newClassName.replace(" " + className + " ", " ");
    157162}
    158163
     
    177182    if (this.className === className)
    178183        return true;
    179     var regex = new RegExp("(^|\\s)" + className.escapeForRegExp() + "($|\\s)");
    180     return regex.test(this.className);
     184
     185    var index = this.className.indexOf(className);
     186    if (index === -1)
     187        return false;
     188    var toTest = " " + this.className + " ";
     189    return toTest.indexOf(" " + className + " ", index) !== -1;
    181190}
    182191
Note: See TracChangeset for help on using the changeset viewer.