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

Side by Side Diff: tracing/tracing/ui/tracks/slice_group_track.html

Issue 2776653002: [ESLint] Fix violations when enabling curly rule in eslint. (Closed)
Patch Set: Fix test Created 3 years, 9 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/sorted_array_utils.html"> 8 <link rel="import" href="/tracing/base/sorted_array_utils.html">
9 <link rel="import" href="/tracing/ui/base/ui.html"> 9 <link rel="import" href="/tracing/ui/base/ui.html">
10 <link rel="import" href="/tracing/ui/tracks/multi_row_track.html"> 10 <link rel="import" href="/tracing/ui/tracks/multi_row_track.html">
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // 2: [c][d] 90 // 2: [c][d]
91 // 91 //
92 // If we then get this slice: 92 // If we then get this slice:
93 // [f] 93 // [f]
94 // We do the same deepest-to-shallowest walk of the subrows trying to fit 94 // We do the same deepest-to-shallowest walk of the subrows trying to fit
95 // it. This time, it doesn't fit in any open slice. So, we simply append 95 // it. This time, it doesn't fit in any open slice. So, we simply append
96 // it to row 0: 96 // it to row 0:
97 // 0: [ a ] [f] 97 // 0: [ a ] [f]
98 // 1: [ b ][e] 98 // 1: [ b ][e]
99 // 2: [c][d] 99 // 2: [c][d]
100 if (!slices.length) 100 if (!slices.length) return [];
101 return [];
102 101
103 var ops = []; 102 var ops = [];
104 for (var i = 0; i < slices.length; i++) { 103 for (var i = 0; i < slices.length; i++) {
105 if (slices[i].subSlices) 104 if (slices[i].subSlices) {
106 slices[i].subSlices.splice(0, 105 slices[i].subSlices.splice(0,
107 slices[i].subSlices.length); 106 slices[i].subSlices.length);
107 }
108 ops.push(i); 108 ops.push(i);
109 } 109 }
110 110
111 ops.sort(function(ix, iy) { 111 ops.sort(function(ix, iy) {
112 var x = slices[ix]; 112 var x = slices[ix];
113 var y = slices[iy]; 113 var y = slices[iy];
114 if (x.start !== y.start) 114 if (x.start !== y.start) return x.start - y.start;
115 return x.start - y.start;
116 115
117 // Elements get inserted into the slices array in order of when the 116 // Elements get inserted into the slices array in order of when the
118 // slices start. Because slices must be properly nested, we break 117 // slices start. Because slices must be properly nested, we break
119 // start-time ties by assuming that the elements appearing earlier in 118 // start-time ties by assuming that the elements appearing earlier in
120 // the slices array (and thus ending earlier) start earlier. 119 // the slices array (and thus ending earlier) start earlier.
121 return ix - iy; 120 return ix - iy;
122 }); 121 });
123 122
124 var subRows = [[]]; 123 var subRows = [[]];
125 this.badSlices_ = []; // TODO(simonjam): Connect this again. 124 this.badSlices_ = []; // TODO(simonjam): Connect this again.
126 125
127 for (var i = 0; i < ops.length; i++) { 126 for (var i = 0; i < ops.length; i++) {
128 var op = ops[i]; 127 var op = ops[i];
129 var slice = slices[op]; 128 var slice = slices[op];
130 129
131 // Try to fit the slice into the existing subrows. 130 // Try to fit the slice into the existing subrows.
132 var inserted = false; 131 var inserted = false;
133 for (var j = subRows.length - 1; j >= 0; j--) { 132 for (var j = subRows.length - 1; j >= 0; j--) {
134 if (subRows[j].length === 0) 133 if (subRows[j].length === 0) continue;
135 continue;
136 134
137 var insertedSlice = subRows[j][subRows[j].length - 1]; 135 var insertedSlice = subRows[j][subRows[j].length - 1];
138 if (slice.start < insertedSlice.start) { 136 if (slice.start < insertedSlice.start) {
139 this.badSlices_.push(slice); 137 this.badSlices_.push(slice);
140 inserted = true; 138 inserted = true;
141 } 139 }
142 if (insertedSlice.bounds(slice, precisionUnit)) { 140 if (insertedSlice.bounds(slice, precisionUnit)) {
143 // Insert it into subRow j + 1. 141 // Insert it into subRow j + 1.
144 while (subRows.length <= j + 1) 142 while (subRows.length <= j + 1) {
145 subRows.push([]); 143 subRows.push([]);
144 }
146 subRows[j + 1].push(slice); 145 subRows[j + 1].push(slice);
147 if (insertedSlice.subSlices) 146 if (insertedSlice.subSlices) {
148 insertedSlice.subSlices.push(slice); 147 insertedSlice.subSlices.push(slice);
148 }
149 inserted = true; 149 inserted = true;
150 break; 150 break;
151 } 151 }
152 } 152 }
153 if (inserted) 153 if (inserted) continue;
154 continue;
155 154
156 // Append it to subRow[0] as a root. 155 // Append it to subRow[0] as a root.
157 subRows[0].push(slice); 156 subRows[0].push(slice);
158 } 157 }
159 158
160 return subRows; 159 return subRows;
161 } 160 }
162 }; 161 };
163 162
164 return { 163 return {
165 SliceGroupTrack, 164 SliceGroupTrack,
166 }; 165 };
167 }); 166 });
168 </script> 167 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698