Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / timeline / TimelineOverviewPane.js
index d98dd8e..933bb7b 100644 (file)
  * @constructor
  * @extends {WebInspector.VBox}
  * @param {!WebInspector.TimelineModel} model
+ * @param {!WebInspector.TimelineUIUtils} uiUtils
  */
-WebInspector.TimelineOverviewPane = function(model)
+WebInspector.TimelineOverviewPane = function(model, uiUtils)
 {
     WebInspector.VBox.call(this);
+    this._uiUtils = uiUtils;
     this.element.id = "timeline-overview-pane";
 
-    this._eventDividers = [];
-
     this._model = model;
+    this._overviewCalculator = new WebInspector.TimelineOverviewCalculator();
 
     this._overviewGrid = new WebInspector.OverviewGrid("timeline");
     this.element.appendChild(this._overviewGrid.element);
 
-    this._overviewCalculator = new WebInspector.TimelineOverviewCalculator();
-
     model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleared, this._reset, this);
     this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged, this._onWindowChanged, this);
     this._overviewControls = [];
@@ -88,9 +87,11 @@ WebInspector.TimelineOverviewPane.prototype = {
 
     update: function()
     {
-        delete this._refreshTimeout;
+        if (this._model.isEmpty())
+            this._overviewCalculator._setWindow(0, 1000);
+        else
+            this._overviewCalculator._setWindow(this._model.minimumRecordTime(), this._model.maximumRecordTime());
 
-        this._overviewCalculator._setWindow(this._model.minimumRecordTime(), this._model.maximumRecordTime());
         this._overviewCalculator._setDisplayWindow(0, this._overviewGrid.clientWidth());
         for (var i = 0; i < this._overviewControls.length; ++i)
             this._overviewControls[i].update();
@@ -101,7 +102,7 @@ WebInspector.TimelineOverviewPane.prototype = {
 
     _updateEventDividers: function()
     {
-        var records = this._eventDividers;
+        var records = this._model.eventDividerRecords();
         this._overviewGrid.removeEventDividers();
         var dividers = [];
         for (var i = 0; i < records.length; ++i) {
@@ -110,34 +111,19 @@ WebInspector.TimelineOverviewPane.prototype = {
             var dividerPosition = Math.round(positions.start * 10);
             if (dividers[dividerPosition])
                 continue;
-            var divider = WebInspector.TimelineUIUtils.createEventDivider(record.type());
+            var title = this._uiUtils.titleForRecord(record);
+            var divider = this._uiUtils.createEventDivider(record.type(), title);
             divider.style.left = positions.start + "%";
             dividers[dividerPosition] = divider;
         }
         this._overviewGrid.addEventDividers(dividers);
     },
 
-    /**
-     * @param {!WebInspector.TimelineModel.Record} record
-     */
-    addRecord: function(record)
-    {
-        var eventDividers = this._eventDividers;
-        function addEventDividers(record)
-        {
-            if (WebInspector.TimelineUIUtils.isEventDivider(record))
-                eventDividers.push(record);
-        }
-        WebInspector.TimelineModel.forAllRecords([record], addEventDividers);
-        this._scheduleRefresh();
-    },
-
     _reset: function()
     {
         this._overviewCalculator.reset();
         this._overviewGrid.reset();
         this._overviewGrid.setResizeEnabled(false);
-        this._eventDividers = [];
         this._overviewGrid.updateDividers(this._overviewCalculator);
         for (var i = 0; i < this._overviewControls.length; ++i)
             this._overviewControls[i].reset();
@@ -185,15 +171,6 @@ WebInspector.TimelineOverviewPane.prototype = {
         this._muteOnWindowChanged = false;
     },
 
-    _scheduleRefresh: function()
-    {
-        if (this._refreshTimeout)
-            return;
-        if (!this.isShowing())
-            return;
-        this._refreshTimeout = setTimeout(this.update.bind(this), 300);
-    },
-
     __proto__: WebInspector.VBox.prototype
 }
 
@@ -409,7 +386,7 @@ WebInspector.TimelineOverviewBase.prototype = {
     {
         var absoluteMin = this._model.minimumRecordTime();
         var timeSpan = this._model.maximumRecordTime() - absoluteMin;
-        var haveRecords = absoluteMin >= 0;
+        var haveRecords = absoluteMin > 0;
         return {
             left: haveRecords && startTime ? Math.min((startTime - absoluteMin) / timeSpan, 1) : 0,
             right: haveRecords && endTime < Infinity ? (endTime - absoluteMin) / timeSpan : 1