OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2012 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/event.html"> | 8 <link rel="import" href="/tracing/base/event.html"> |
9 <link rel="import" href="/tracing/base/guid.html"> | 9 <link rel="import" href="/tracing/base/guid.html"> |
10 <link rel="import" href="/tracing/base/iteration_helpers.html"> | 10 <link rel="import" href="/tracing/base/iteration_helpers.html"> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 }, | 68 }, |
69 | 69 |
70 clear: function() { | 70 clear: function() { |
71 this.bounds_ = new tr.b.Range(); | 71 this.bounds_ = new tr.b.Range(); |
72 this.events_.clear(); | 72 this.events_.clear(); |
73 }, | 73 }, |
74 | 74 |
75 // push pushes only unique events. | 75 // push pushes only unique events. |
76 // If an event has been already pushed, do nothing. | 76 // If an event has been already pushed, do nothing. |
77 push: function(event) { | 77 push: function(event) { |
78 if (event.guid == undefined) | 78 if (event.guid === undefined) |
79 throw new Error('Event must have a GUID'); | 79 throw new Error('Event must have a GUID'); |
80 | 80 |
81 if (!this.events_.has(event)) { | 81 if (!this.events_.has(event)) { |
82 this.events_.add(event); | 82 this.events_.add(event); |
83 // Some uses of eventSet, particularly in tests, have Events as objects | 83 // Some uses of eventSet, particularly in tests, have Events as objects |
84 // that don't have addBoundsToRange as a function. Thus we need to | 84 // that don't have addBoundsToRange as a function. Thus we need to |
85 // handle this case. | 85 // handle this case. |
86 if (event.addBoundsToRange) | 86 if (event.addBoundsToRange) |
87 if (this.bounds_ !== undefined) | 87 if (this.bounds_ !== undefined) |
88 event.addBoundsToRange(this.bounds_); | 88 event.addBoundsToRange(this.bounds_); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 allTypeInfos.forEach(function(eventTypeInfo, eventIndex) { | 133 allTypeInfos.forEach(function(eventTypeInfo, eventIndex) { |
134 if (!(event instanceof eventTypeInfo.constructor)) | 134 if (!(event instanceof eventTypeInfo.constructor)) |
135 return; | 135 return; |
136 if (eventIndex > maxEventIndex) { | 136 if (eventIndex > maxEventIndex) { |
137 maxEventIndex = eventIndex; | 137 maxEventIndex = eventIndex; |
138 maxEventTypeInfo = eventTypeInfo; | 138 maxEventTypeInfo = eventTypeInfo; |
139 } | 139 } |
140 }); | 140 }); |
141 | 141 |
142 if (maxEventIndex == -1) { | 142 if (maxEventIndex === -1) { |
143 console.log(event); | 143 console.log(event); |
144 throw new Error('Unrecognized event type'); | 144 throw new Error('Unrecognized event type'); |
145 } | 145 } |
146 | 146 |
147 return maxEventTypeInfo.metadata.name; | 147 return maxEventTypeInfo.metadata.name; |
148 }); | 148 }); |
149 | 149 |
150 if (!opt_pruneEmpty) { | 150 if (!opt_pruneEmpty) { |
151 allTypeInfos.forEach(function(eventTypeInfo) { | 151 allTypeInfos.forEach(function(eventTypeInfo) { |
152 if (events[eventTypeInfo.metadata.name] === undefined) | 152 if (events[eventTypeInfo.metadata.name] === undefined) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 Object.freeze(s); | 268 Object.freeze(s); |
269 return s; | 269 return s; |
270 })(); | 270 })(); |
271 | 271 |
272 return { | 272 return { |
273 EventSet: EventSet, | 273 EventSet: EventSet, |
274 RequestSelectionChangeEvent: RequestSelectionChangeEvent | 274 RequestSelectionChangeEvent: RequestSelectionChangeEvent |
275 }; | 275 }; |
276 }); | 276 }); |
277 </script> | 277 </script> |
OLD | NEW |