Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: Source/devtools/front_end/timeline/TimelineView.js

Issue 367093003: DevTools: More code reduce via using document.createElementWithClass and document.createChild. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 this._timelineGrid.addEventDividers(dividers); 143 this._timelineGrid.addEventDividers(dividers);
144 }, 144 },
145 145
146 _updateFrameBars: function(frames) 146 _updateFrameBars: function(frames)
147 { 147 {
148 var clientWidth = this._graphRowsElementWidth; 148 var clientWidth = this._graphRowsElementWidth;
149 if (this._frameContainer) { 149 if (this._frameContainer) {
150 this._frameContainer.removeChildren(); 150 this._frameContainer.removeChildren();
151 } else { 151 } else {
152 const frameContainerBorderWidth = 1; 152 const frameContainerBorderWidth = 1;
153 this._frameContainer = document.createElement("div"); 153 this._frameContainer = document.createElementWithClass("div", "fill timeline-frame-container");
154 this._frameContainer.classList.add("fill");
155 this._frameContainer.classList.add("timeline-frame-container");
156 this._frameContainer.style.height = WebInspector.TimelinePanel.rowHe ight + frameContainerBorderWidth + "px"; 154 this._frameContainer.style.height = WebInspector.TimelinePanel.rowHe ight + frameContainerBorderWidth + "px";
157 this._frameContainer.addEventListener("dblclick", this._onFrameDoubl eClicked.bind(this), false); 155 this._frameContainer.addEventListener("dblclick", this._onFrameDoubl eClicked.bind(this), false);
158 this._frameContainer.addEventListener("click", this._onFrameClicked. bind(this), false); 156 this._frameContainer.addEventListener("click", this._onFrameClicked. bind(this), false);
159 } 157 }
160 this._frameStripByFrame.clear(); 158 this._frameStripByFrame.clear();
161 159
162 var dividers = []; 160 var dividers = [];
163 161
164 for (var i = 0; i < frames.length; ++i) { 162 for (var i = 0; i < frames.length; ++i) {
165 var frame = frames[i]; 163 var frame = frames[i];
166 var frameStart = this._calculator.computePosition(frame.startTime); 164 var frameStart = this._calculator.computePosition(frame.startTime);
167 var frameEnd = this._calculator.computePosition(frame.endTime); 165 var frameEnd = this._calculator.computePosition(frame.endTime);
168 166
169 var frameStrip = document.createElement("div"); 167 var frameStrip = document.createElementWithClass("div", "timeline-fr ame-strip");
170 frameStrip.className = "timeline-frame-strip";
171 var actualStart = Math.max(frameStart, 0); 168 var actualStart = Math.max(frameStart, 0);
172 var width = frameEnd - actualStart; 169 var width = frameEnd - actualStart;
173 frameStrip.style.left = actualStart + "px"; 170 frameStrip.style.left = actualStart + "px";
174 frameStrip.style.width = width + "px"; 171 frameStrip.style.width = width + "px";
175 frameStrip._frame = frame; 172 frameStrip._frame = frame;
176 this._frameStripByFrame.put(frame, frameStrip); 173 this._frameStripByFrame.put(frame, frameStrip);
177 174
178 const minWidthForFrameInfo = 60; 175 const minWidthForFrameInfo = 60;
179 if (width > minWidthForFrameInfo) 176 if (width > minWidthForFrameInfo)
180 frameStrip.textContent = Number.millisToString(frame.endTime - f rame.startTime, true); 177 frameStrip.textContent = Number.millisToString(frame.endTime - f rame.startTime, true);
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 this._dataElement.removeChildren(); 1070 this._dataElement.removeChildren();
1074 1071
1075 this._warningElement.classList.toggle("hidden", !presentationRecord.hasW arnings() && !presentationRecord.childHasWarnings()); 1072 this._warningElement.classList.toggle("hidden", !presentationRecord.hasW arnings() && !presentationRecord.childHasWarnings());
1076 this._warningElement.classList.toggle("timeline-tree-item-child-warning" , presentationRecord.childHasWarnings() && !presentationRecord.hasWarnings()); 1073 this._warningElement.classList.toggle("timeline-tree-item-child-warning" , presentationRecord.childHasWarnings() && !presentationRecord.hasWarnings());
1077 1074
1078 if (presentationRecord.coalesced()) { 1075 if (presentationRecord.coalesced()) {
1079 this._dataElement.createTextChild(WebInspector.UIString("× %d", pres entationRecord.presentationChildren().length)); 1076 this._dataElement.createTextChild(WebInspector.UIString("× %d", pres entationRecord.presentationChildren().length));
1080 } else { 1077 } else {
1081 var detailsNode = uiUtils.buildDetailsNode(record, this._linkifier, loadedFromFile); 1078 var detailsNode = uiUtils.buildDetailsNode(record, this._linkifier, loadedFromFile);
1082 if (detailsNode) { 1079 if (detailsNode) {
1083 this._dataElement.appendChild(document.createTextNode("(")); 1080 this._dataElement.createTextChild("(");
1084 this._dataElement.appendChild(detailsNode); 1081 this._dataElement.appendChild(detailsNode);
1085 this._dataElement.appendChild(document.createTextNode(")")); 1082 this._dataElement.createTextChild(")");
1086 } 1083 }
1087 } 1084 }
1088 1085
1089 this._expandArrowElement.classList.toggle("parent", presentationRecord.e xpandable()); 1086 this._expandArrowElement.classList.toggle("parent", presentationRecord.e xpandable());
1090 this._expandArrowElement.classList.toggle("expanded", !!presentationReco rd.visibleChildrenCount()); 1087 this._expandArrowElement.classList.toggle("expanded", !!presentationReco rd.visibleChildrenCount());
1091 this._record.setListRow(this); 1088 this._record.setListRow(this);
1092 }, 1089 },
1093 1090
1094 highlight: function(regExp, domChanges) 1091 highlight: function(regExp, domChanges)
1095 { 1092 {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 * @param {function()} scheduleRefresh 1154 * @param {function()} scheduleRefresh
1158 */ 1155 */
1159 WebInspector.TimelineRecordGraphRow = function(graphContainer, selectRecord, sch eduleRefresh) 1156 WebInspector.TimelineRecordGraphRow = function(graphContainer, selectRecord, sch eduleRefresh)
1160 { 1157 {
1161 this.element = document.createElement("div"); 1158 this.element = document.createElement("div");
1162 this.element.row = this; 1159 this.element.row = this;
1163 this.element.addEventListener("mouseover", this._onMouseOver.bind(this), fal se); 1160 this.element.addEventListener("mouseover", this._onMouseOver.bind(this), fal se);
1164 this.element.addEventListener("mouseout", this._onMouseOut.bind(this), false ); 1161 this.element.addEventListener("mouseout", this._onMouseOut.bind(this), false );
1165 this.element.addEventListener("click", this._onClick.bind(this), false); 1162 this.element.addEventListener("click", this._onClick.bind(this), false);
1166 1163
1167 this._barAreaElement = document.createElement("div"); 1164 this._barAreaElement = this.element.createChild("div", "timeline-graph-bar-a rea");
1168 this._barAreaElement.className = "timeline-graph-bar-area";
1169 this.element.appendChild(this._barAreaElement);
1170 1165
1171 this._barCpuElement = document.createElement("div"); 1166 this._barCpuElement = this._barAreaElement.createChild("div", "timeline-grap h-bar cpu");
1172 this._barCpuElement.className = "timeline-graph-bar cpu"
1173 this._barCpuElement.row = this; 1167 this._barCpuElement.row = this;
1174 this._barAreaElement.appendChild(this._barCpuElement);
1175 1168
1176 this._barElement = document.createElement("div"); 1169 this._barElement = this._barAreaElement.createChild("div", "timeline-graph-b ar");
1177 this._barElement.className = "timeline-graph-bar";
1178 this._barElement.row = this; 1170 this._barElement.row = this;
1179 this._barAreaElement.appendChild(this._barElement);
1180 1171
1181 this._expandElement = new WebInspector.TimelineExpandableElement(graphContai ner); 1172 this._expandElement = new WebInspector.TimelineExpandableElement(graphContai ner);
1182 1173
1183 this._selectRecord = selectRecord; 1174 this._selectRecord = selectRecord;
1184 this._scheduleRefresh = scheduleRefresh; 1175 this._scheduleRefresh = scheduleRefresh;
1185 } 1176 }
1186 1177
1187 WebInspector.TimelineRecordGraphRow.prototype = { 1178 WebInspector.TimelineRecordGraphRow.prototype = {
1188 /** 1179 /**
1189 * @param {!WebInspector.TimelinePresentationModel.Record} presentationRecor d 1180 * @param {!WebInspector.TimelinePresentationModel.Record} presentationRecor d
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 if (!record.collapsed()) { 1279 if (!record.collapsed()) {
1289 this._element.style.height = (record.visibleChildrenCount() + 1) * rowHeight + "px"; 1280 this._element.style.height = (record.visibleChildrenCount() + 1) * rowHeight + "px";
1290 this._element.classList.add("timeline-expandable-expanded"); 1281 this._element.classList.add("timeline-expandable-expanded");
1291 this._element.classList.remove("timeline-expandable-collapsed"); 1282 this._element.classList.remove("timeline-expandable-collapsed");
1292 } else { 1283 } else {
1293 this._element.style.height = rowHeight + "px"; 1284 this._element.style.height = rowHeight + "px";
1294 this._element.classList.add("timeline-expandable-collapsed"); 1285 this._element.classList.add("timeline-expandable-collapsed");
1295 this._element.classList.remove("timeline-expandable-expanded"); 1286 this._element.classList.remove("timeline-expandable-expanded");
1296 } 1287 }
1297 this._element.classList.remove("hidden"); 1288 this._element.classList.remove("hidden");
1298 } else 1289 } else {
1299 this._element.classList.add("hidden"); 1290 this._element.classList.add("hidden");
1291 }
1300 }, 1292 },
1301 1293
1302 _dispose: function() 1294 _dispose: function()
1303 { 1295 {
1304 this._element.remove(); 1296 this._element.remove();
1305 } 1297 }
1306 } 1298 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sources/TargetsToolbar.js ('k') | Source/devtools/front_end/ui/ProgressIndicator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698