OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 29 matching lines...) Expand all Loading... |
40 WebInspector.TimelineView = function(delegate, presentationModel, frameModel) | 40 WebInspector.TimelineView = function(delegate, presentationModel, frameModel) |
41 { | 41 { |
42 WebInspector.View.call(this); | 42 WebInspector.View.call(this); |
43 this.element.classList.add("timeline-view"); | 43 this.element.classList.add("timeline-view"); |
44 this.element.classList.add("hbox"); | 44 this.element.classList.add("hbox"); |
45 | 45 |
46 this._delegate = delegate; | 46 this._delegate = delegate; |
47 this._presentationModel = presentationModel; | 47 this._presentationModel = presentationModel; |
48 this._frameModel = frameModel; | 48 this._frameModel = frameModel; |
49 this._calculator = new WebInspector.TimelineCalculator(this._presentationMod
el); | 49 this._calculator = new WebInspector.TimelineCalculator(this._presentationMod
el); |
| 50 this._linkifier = new WebInspector.Linkifier(); |
50 | 51 |
51 this._boundariesAreValid = true; | 52 this._boundariesAreValid = true; |
52 this._scrollTop = 0; | 53 this._scrollTop = 0; |
53 | 54 |
54 this._recordsView = this._createRecordsView(); | 55 this._recordsView = this._createRecordsView(); |
55 this._recordsView.addEventListener(WebInspector.SplitView.Events.SidebarSize
Changed, this._sidebarResized, this); | 56 this._recordsView.addEventListener(WebInspector.SplitView.Events.SidebarSize
Changed, this._sidebarResized, this); |
56 this._recordsView.show(this.element); | 57 this._recordsView.show(this.element); |
57 this.element.appendChild(this._timelineGrid.gridHeaderElement); | 58 this.element.appendChild(this._timelineGrid.gridHeaderElement); |
58 | 59 |
59 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get
PopoverAnchor.bind(this), this._showPopover.bind(this)); | 60 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get
PopoverAnchor.bind(this), this._showPopover.bind(this)); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 this._timelineGrid.gridHeaderElement.style.width = this._itemsGraphsElem
ent.offsetWidth + "px"; | 261 this._timelineGrid.gridHeaderElement.style.width = this._itemsGraphsElem
ent.offsetWidth + "px"; |
261 this._scheduleRefresh(false, true); | 262 this._scheduleRefresh(false, true); |
262 }, | 263 }, |
263 | 264 |
264 _resetView: function() | 265 _resetView: function() |
265 { | 266 { |
266 this._windowStartTime = -1; | 267 this._windowStartTime = -1; |
267 this._windowEndTime = -1; | 268 this._windowEndTime = -1; |
268 this._boundariesAreValid = false; | 269 this._boundariesAreValid = false; |
269 this._adjustScrollPosition(0); | 270 this._adjustScrollPosition(0); |
| 271 this._linkifier.reset(); |
270 this._closeRecordDetails(); | 272 this._closeRecordDetails(); |
271 this._automaticallySizeWindow = true; | 273 this._automaticallySizeWindow = true; |
272 }, | 274 }, |
273 | 275 |
274 reset: function() | 276 reset: function() |
275 { | 277 { |
276 this._resetView(); | 278 this._resetView(); |
277 this._invalidateAndScheduleRefresh(true, true); | 279 this._invalidateAndScheduleRefresh(true, true); |
278 }, | 280 }, |
279 | 281 |
280 /** | 282 /** |
281 * @return {!Array.<!Element>} | 283 * @return {!Array.<!Element>} |
282 */ | 284 */ |
283 elementsToRestoreScrollPositionsFor: function() | 285 elementsToRestoreScrollPositionsFor: function() |
284 { | 286 { |
285 return [this._containerElement]; | 287 return [this._containerElement]; |
286 }, | 288 }, |
287 | 289 |
288 refreshRecords: function() | 290 refreshRecords: function() |
289 { | 291 { |
290 this._resetView(); | |
291 this._automaticallySizeWindow = false; | 292 this._automaticallySizeWindow = false; |
292 this._invalidateAndScheduleRefresh(false, true); | 293 this._invalidateAndScheduleRefresh(false, true); |
293 }, | 294 }, |
294 | 295 |
295 wasShown: function() | 296 wasShown: function() |
296 { | 297 { |
297 WebInspector.View.prototype.wasShown.call(this); | 298 WebInspector.View.prototype.wasShown.call(this); |
298 | 299 |
299 if (!WebInspector.TimelinePanel._categoryStylesInitialized) { | 300 if (!WebInspector.TimelinePanel._categoryStylesInitialized) { |
300 WebInspector.TimelinePanel._categoryStylesInitialized = true; | 301 WebInspector.TimelinePanel._categoryStylesInitialized = true; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 515 |
515 if (i < startIndex) { | 516 if (i < startIndex) { |
516 var lastChildIndex = i + record.visibleChildrenCount; | 517 var lastChildIndex = i + record.visibleChildrenCount; |
517 if (lastChildIndex >= startIndex && lastChildIndex < endIndex) { | 518 if (lastChildIndex >= startIndex && lastChildIndex < endIndex) { |
518 var expandElement = new WebInspector.TimelineExpandableEleme
nt(this._expandElements); | 519 var expandElement = new WebInspector.TimelineExpandableEleme
nt(this._expandElements); |
519 var positions = this._calculator.computeBarGraphWindowPositi
on(record); | 520 var positions = this._calculator.computeBarGraphWindowPositi
on(record); |
520 expandElement._update(record, i, positions.left - this._expa
ndOffset, positions.width); | 521 expandElement._update(record, i, positions.left - this._expa
ndOffset, positions.width); |
521 } | 522 } |
522 } else { | 523 } else { |
523 if (!listRowElement) { | 524 if (!listRowElement) { |
524 listRowElement = new WebInspector.TimelineRecordListRow(sele
ctRecordCallback, scheduleRefreshCallback).element; | 525 listRowElement = new WebInspector.TimelineRecordListRow(this
._linkifier, selectRecordCallback, scheduleRefreshCallback).element; |
525 this._sidebarListElement.appendChild(listRowElement); | 526 this._sidebarListElement.appendChild(listRowElement); |
526 } | 527 } |
527 if (!graphRowElement) { | 528 if (!graphRowElement) { |
528 graphRowElement = new WebInspector.TimelineRecordGraphRow(th
is._itemsGraphsElement, selectRecordCallback, scheduleRefreshCallback).element; | 529 graphRowElement = new WebInspector.TimelineRecordGraphRow(th
is._itemsGraphsElement, selectRecordCallback, scheduleRefreshCallback).element; |
529 this._graphRowsElement.appendChild(graphRowElement); | 530 this._graphRowsElement.appendChild(graphRowElement); |
530 } | 531 } |
531 | 532 |
532 listRowElement.row.update(record, visibleTop); | 533 listRowElement.row.update(record, visibleTop); |
533 graphRowElement.row.update(record, this._calculator, this._expan
dOffset, i); | 534 graphRowElement.row.update(record, this._calculator, this._expan
dOffset, i); |
534 if (this._lastSelectedRecord === record) { | 535 if (this._lastSelectedRecord === record) { |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 * @param {!Element} anchor | 794 * @param {!Element} anchor |
794 * @param {!WebInspector.Popover} popover | 795 * @param {!WebInspector.Popover} popover |
795 */ | 796 */ |
796 _showPopover: function(anchor, popover) | 797 _showPopover: function(anchor, popover) |
797 { | 798 { |
798 if (anchor.classList.contains("timeline-frame-strip")) { | 799 if (anchor.classList.contains("timeline-frame-strip")) { |
799 var frame = anchor._frame; | 800 var frame = anchor._frame; |
800 popover.show(WebInspector.TimelineUIUtils.generatePopupContentForFra
me(frame), anchor); | 801 popover.show(WebInspector.TimelineUIUtils.generatePopupContentForFra
me(frame), anchor); |
801 } else { | 802 } else { |
802 if (anchor.row && anchor.row._record) | 803 if (anchor.row && anchor.row._record) |
803 anchor.row._record.generatePopupContent(showCallback); | 804 anchor.row._record.generatePopupContent(this._linkifier, showCal
lback); |
804 else if (anchor._tasksInfo) | 805 else if (anchor._tasksInfo) |
805 popover.show(WebInspector.TimelineUIUtils.generateMainThreadBarP
opupContent(this._presentationModel, anchor._tasksInfo), anchor, null, null, Web
Inspector.Popover.Orientation.Bottom); | 806 popover.show(WebInspector.TimelineUIUtils.generateMainThreadBarP
opupContent(this._presentationModel, anchor._tasksInfo), anchor, null, null, Web
Inspector.Popover.Orientation.Bottom); |
806 } | 807 } |
807 | 808 |
808 function showCallback(popupContent) | 809 function showCallback(popupContent) |
809 { | 810 { |
810 popover.show(popupContent, anchor); | 811 popover.show(popupContent, anchor); |
811 } | 812 } |
812 }, | 813 }, |
813 | 814 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 * @return {number} | 971 * @return {number} |
971 */ | 972 */ |
972 boundarySpan: function() | 973 boundarySpan: function() |
973 { | 974 { |
974 return this._maximumBoundary - this._minimumBoundary; | 975 return this._maximumBoundary - this._minimumBoundary; |
975 } | 976 } |
976 } | 977 } |
977 | 978 |
978 /** | 979 /** |
979 * @constructor | 980 * @constructor |
| 981 * @param {!WebInspector.Linkifier} linkifier |
980 * @param {function(!WebInspector.TimelinePresentationModel.Record)} selectRecor
d | 982 * @param {function(!WebInspector.TimelinePresentationModel.Record)} selectRecor
d |
981 * @param {function()} scheduleRefresh | 983 * @param {function()} scheduleRefresh |
982 */ | 984 */ |
983 WebInspector.TimelineRecordListRow = function(selectRecord, scheduleRefresh) | 985 WebInspector.TimelineRecordListRow = function(linkifier, selectRecord, scheduleR
efresh) |
984 { | 986 { |
985 this.element = document.createElement("div"); | 987 this.element = document.createElement("div"); |
986 this.element.row = this; | 988 this.element.row = this; |
987 this.element.style.cursor = "pointer"; | 989 this.element.style.cursor = "pointer"; |
988 this.element.addEventListener("click", this._onClick.bind(this), false); | 990 this.element.addEventListener("click", this._onClick.bind(this), false); |
989 this.element.addEventListener("mouseover", this._onMouseOver.bind(this), fal
se); | 991 this.element.addEventListener("mouseover", this._onMouseOver.bind(this), fal
se); |
990 this.element.addEventListener("mouseout", this._onMouseOut.bind(this), false
); | 992 this.element.addEventListener("mouseout", this._onMouseOut.bind(this), false
); |
| 993 this._linkifier = linkifier; |
991 | 994 |
992 // Warning is float right block, it goes first. | 995 // Warning is float right block, it goes first. |
993 this._warningElement = this.element.createChild("div", "timeline-tree-item-w
arning hidden"); | 996 this._warningElement = this.element.createChild("div", "timeline-tree-item-w
arning hidden"); |
994 | 997 |
995 this._expandArrowElement = this.element.createChild("div", "timeline-tree-it
em-expand-arrow"); | 998 this._expandArrowElement = this.element.createChild("div", "timeline-tree-it
em-expand-arrow"); |
996 this._expandArrowElement.addEventListener("click", this._onExpandClick.bind(
this), false); | 999 this._expandArrowElement.addEventListener("click", this._onExpandClick.bind(
this), false); |
997 var iconElement = this.element.createChild("span", "timeline-tree-icon"); | 1000 var iconElement = this.element.createChild("span", "timeline-tree-icon"); |
998 this._typeElement = this.element.createChild("span", "type"); | 1001 this._typeElement = this.element.createChild("span", "type"); |
999 | 1002 |
1000 this._dataElement = this.element.createChild("span", "data dimmed"); | 1003 this._dataElement = this.element.createChild("span", "data dimmed"); |
1001 this._scheduleRefresh = scheduleRefresh; | 1004 this._scheduleRefresh = scheduleRefresh; |
1002 this._selectRecord = selectRecord; | 1005 this._selectRecord = selectRecord; |
1003 } | 1006 } |
1004 | 1007 |
1005 WebInspector.TimelineRecordListRow.prototype = { | 1008 WebInspector.TimelineRecordListRow.prototype = { |
1006 update: function(record, offset) | 1009 update: function(record, offset) |
1007 { | 1010 { |
1008 this._record = record; | 1011 this._record = record; |
1009 this._offset = offset; | 1012 this._offset = offset; |
1010 | 1013 |
1011 this.element.className = "timeline-tree-item timeline-category-" + recor
d.category.name; | 1014 this.element.className = "timeline-tree-item timeline-category-" + recor
d.category.name; |
1012 var paddingLeft = 5; | 1015 var paddingLeft = 5; |
1013 var step = -3; | 1016 var step = -3; |
1014 for (var currentRecord = record.parent ? record.parent.parent : null; cu
rrentRecord; currentRecord = currentRecord.parent) | 1017 for (var currentRecord = record.parent ? record.parent.parent : null; cu
rrentRecord; currentRecord = currentRecord.parent) |
1015 paddingLeft += 12 / (Math.max(1, step++)); | 1018 paddingLeft += 12 / (Math.max(1, step++)); |
1016 this.element.style.paddingLeft = paddingLeft + "px"; | 1019 this.element.style.paddingLeft = paddingLeft + "px"; |
1017 if (record.isBackground()) | 1020 if (record.isBackground()) |
1018 this.element.classList.add("background"); | 1021 this.element.classList.add("background"); |
1019 | 1022 |
1020 this._typeElement.textContent = record.title; | 1023 this._typeElement.textContent = record.title(); |
1021 | 1024 |
1022 if (this._dataElement.firstChild) | 1025 if (this._dataElement.firstChild) |
1023 this._dataElement.removeChildren(); | 1026 this._dataElement.removeChildren(); |
1024 | 1027 |
1025 this._warningElement.enableStyleClass("hidden", !record.hasWarnings() &&
!record.childHasWarnings()); | 1028 this._warningElement.enableStyleClass("hidden", !record.hasWarnings() &&
!record.childHasWarnings()); |
1026 this._warningElement.enableStyleClass("timeline-tree-item-child-warning"
, record.childHasWarnings() && !record.hasWarnings()); | 1029 this._warningElement.enableStyleClass("timeline-tree-item-child-warning"
, record.childHasWarnings() && !record.hasWarnings()); |
1027 | 1030 |
1028 if (record.detailsNode()) | 1031 var detailsNode = record.buildDetailsNode(this._linkifier); |
1029 this._dataElement.appendChild(record.detailsNode()); | 1032 if (detailsNode) { |
| 1033 this._dataElement.appendChild(document.createTextNode("(")); |
| 1034 this._dataElement.appendChild(detailsNode); |
| 1035 this._dataElement.appendChild(document.createTextNode(")")); |
| 1036 } |
1030 this._expandArrowElement.enableStyleClass("parent", record.children && r
ecord.children.length); | 1037 this._expandArrowElement.enableStyleClass("parent", record.children && r
ecord.children.length); |
1031 this._expandArrowElement.enableStyleClass("expanded", record.visibleChil
drenCount); | 1038 this._expandArrowElement.enableStyleClass("expanded", record.visibleChil
drenCount); |
1032 this._record.setUserObject("WebInspector.TimelineRecordListRow", this); | 1039 this._record.setUserObject("WebInspector.TimelineRecordListRow", this); |
1033 }, | 1040 }, |
1034 | 1041 |
1035 highlight: function(regExp, domChanges) | 1042 highlight: function(regExp, domChanges) |
1036 { | 1043 { |
1037 var matchInfo = this.element.textContent.match(regExp); | 1044 var matchInfo = this.element.textContent.match(regExp); |
1038 if (matchInfo) | 1045 if (matchInfo) |
1039 WebInspector.highlightSearchResult(this.element, matchInfo.index, ma
tchInfo[0].length, domChanges); | 1046 WebInspector.highlightSearchResult(this.element, matchInfo.index, ma
tchInfo[0].length, domChanges); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 this._element.classList.remove("hidden"); | 1240 this._element.classList.remove("hidden"); |
1234 } else | 1241 } else |
1235 this._element.classList.add("hidden"); | 1242 this._element.classList.add("hidden"); |
1236 }, | 1243 }, |
1237 | 1244 |
1238 _dispose: function() | 1245 _dispose: function() |
1239 { | 1246 { |
1240 this._element.remove(); | 1247 this._element.remove(); |
1241 } | 1248 } |
1242 } | 1249 } |
OLD | NEW |