| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 WebInspector.TimelinePanel = function() | |
| 32 { | |
| 33 WebInspector.Panel.call(this, true); | |
| 34 | |
| 35 this.element.addStyleClass("timeline"); | |
| 36 | |
| 37 this.timelineView = document.createElement("div"); | |
| 38 this.timelineView.id = "timeline-view"; | |
| 39 this.element.appendChild(this.timelineView); | |
| 40 | |
| 41 this.recordsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInsp
ector.UIString("RECORDS"), {}, true); | |
| 42 this.recordsTreeElement.expanded = true; | |
| 43 this.sidebarTree.appendChild(this.recordsTreeElement); | |
| 44 | |
| 45 this.toggleTimelineButton = new WebInspector.StatusBarButton("", "record-pro
file-status-bar-item"); | |
| 46 this.toggleTimelineButton.addEventListener("click", this._toggleTimelineButt
on.bind(this), false); | |
| 47 } | |
| 48 | |
| 49 WebInspector.TimelinePanel.prototype = { | |
| 50 toolbarItemClass: "timeline", | |
| 51 | |
| 52 get toolbarItemLabel() | |
| 53 { | |
| 54 return WebInspector.UIString("Timeline"); | |
| 55 }, | |
| 56 | |
| 57 get statusBarItems() | |
| 58 { | |
| 59 return [this.toggleTimelineButton.element]; | |
| 60 }, | |
| 61 | |
| 62 handleKeyEvent: function(event) | |
| 63 { | |
| 64 this.sidebarTree.handleKeyEvent(event); | |
| 65 }, | |
| 66 | |
| 67 timelineWasStarted: function() | |
| 68 { | |
| 69 this.toggleTimelineButton.toggled = true; | |
| 70 }, | |
| 71 | |
| 72 timelineWasStopped: function() | |
| 73 { | |
| 74 this.toggleTimelineButton.toggled = false; | |
| 75 }, | |
| 76 | |
| 77 addItemToTimeline: function(record) | |
| 78 { | |
| 79 this._innerAddItemToTimeline(this.recordsTreeElement, record); | |
| 80 }, | |
| 81 | |
| 82 _innerAddItemToTimeline: function(parentElement, record) | |
| 83 { | |
| 84 var treeItem = new WebInspector.TimelineRecordTreeElement(this, record); | |
| 85 parentElement.appendChild(treeItem); | |
| 86 if (record.children) | |
| 87 parentElement.expanded = true; | |
| 88 for (var i = 0; i < record.children.length; ++i) | |
| 89 this._innerAddItemToTimeline(treeItem, record.children[i]); | |
| 90 }, | |
| 91 | |
| 92 _toggleTimelineButton: function() | |
| 93 { | |
| 94 if (InspectorController.timelineProfilerEnabled()) | |
| 95 InspectorController.stopTimelineProfiler(); | |
| 96 else | |
| 97 InspectorController.startTimelineProfiler(); | |
| 98 }, | |
| 99 | |
| 100 setMainViewWidth: function(width) | |
| 101 { | |
| 102 this.timelineView.style.left = width + "px"; | |
| 103 }, | |
| 104 | |
| 105 getItemTypeName: function(record) | |
| 106 { | |
| 107 if (!this._itemTypeNames) { | |
| 108 this._itemTypeNames = {}; | |
| 109 var itemTypes = WebInspector.TimelineAgent.ItemType; | |
| 110 this._itemTypeNames[itemTypes.DOMDispatch] = WebInspector.UIString("
DOM Event"); | |
| 111 this._itemTypeNames[itemTypes.Layout] = WebInspector.UIString("Layou
t"); | |
| 112 this._itemTypeNames[itemTypes.RecalculateStyles] = WebInspector.UISt
ring("Recalculate Style"); | |
| 113 this._itemTypeNames[itemTypes.Paint] = WebInspector.UIString("Paint"
); | |
| 114 this._itemTypeNames[itemTypes.Layout] = WebInspector.UIString("Layou
t"); | |
| 115 this._itemTypeNames[itemTypes.ParseHTML] = WebInspector.UIString("Pa
rse"); | |
| 116 } | |
| 117 return this._itemTypeNames[record.type]; | |
| 118 } | |
| 119 } | |
| 120 | |
| 121 WebInspector.TimelinePanel.prototype.__proto__ = WebInspector.Panel.prototype; | |
| 122 | |
| 123 | |
| 124 WebInspector.TimelineRecordTreeElement = function(panel, record) | |
| 125 { | |
| 126 this._panel = panel; | |
| 127 this._record = record; | |
| 128 | |
| 129 // Pass an empty title, the title gets made later in onattach. | |
| 130 TreeElement.call(this, "", null, false); | |
| 131 } | |
| 132 | |
| 133 WebInspector.TimelineRecordTreeElement.prototype = { | |
| 134 onattach: function() | |
| 135 { | |
| 136 this.listItemElement.removeChildren(); | |
| 137 this.listItemElement.addStyleClass("timeline-tree-item"); | |
| 138 | |
| 139 var typeElement = document.createElement("span"); | |
| 140 typeElement.className = "type"; | |
| 141 typeElement.textContent = this._panel.getItemTypeName(this._record); | |
| 142 this.listItemElement.appendChild(typeElement); | |
| 143 | |
| 144 if (this._record.data) { | |
| 145 var separatorElement = document.createElement("span"); | |
| 146 separatorElement.className = "separator"; | |
| 147 separatorElement.textContent = " "; | |
| 148 | |
| 149 var dataElement = document.createElement("span"); | |
| 150 dataElement.className = "data"; | |
| 151 dataElement.textContent = "(" + this._record.data.type + ")"; | |
| 152 dataElement.addStyleClass("dimmed"); | |
| 153 this.listItemElement.appendChild(separatorElement); | |
| 154 this.listItemElement.appendChild(dataElement); | |
| 155 } | |
| 156 } | |
| 157 } | |
| 158 | |
| 159 WebInspector.TimelineRecordTreeElement.prototype.__proto__ = TreeElement.prototy
pe; | |
| OLD | NEW |