OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @param {!WebInspector.TracingManager} tracingManager | 7 * @param {!WebInspector.TracingManager} tracingManager |
8 * @param {!WebInspector.TracingModel} tracingModel | 8 * @param {!WebInspector.TracingModel} tracingModel |
9 * @param {!WebInspector.TimelineModel.Filter} recordFilter | 9 * @param {!WebInspector.TimelineModel.Filter} recordFilter |
10 * @extends {WebInspector.TimelineModel} | 10 * @extends {WebInspector.TimelineModel} |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 588 |
589 case recordTypes.FireAnimationFrame: | 589 case recordTypes.FireAnimationFrame: |
590 event.initiator = this._requestAnimationFrameEvents[event.args["data
"]["id"]]; | 590 event.initiator = this._requestAnimationFrameEvents[event.args["data
"]["id"]]; |
591 break; | 591 break; |
592 | 592 |
593 case recordTypes.ScheduleStyleRecalculation: | 593 case recordTypes.ScheduleStyleRecalculation: |
594 this._lastScheduleStyleRecalculation[event.args["frame"]] = event; | 594 this._lastScheduleStyleRecalculation[event.args["frame"]] = event; |
595 break; | 595 break; |
596 | 596 |
597 case recordTypes.RecalculateStyles: | 597 case recordTypes.RecalculateStyles: |
| 598 this._invalidationTracker.didRecalcStyle(event); |
598 event.initiator = this._lastScheduleStyleRecalculation[event.args["f
rame"]]; | 599 event.initiator = this._lastScheduleStyleRecalculation[event.args["f
rame"]]; |
599 this._lastRecalculateStylesEvent = event; | 600 this._lastRecalculateStylesEvent = event; |
600 break; | 601 break; |
601 | 602 |
602 case recordTypes.StyleRecalcInvalidationTracking: | 603 case recordTypes.StyleRecalcInvalidationTracking: |
603 case recordTypes.LayoutInvalidationTracking: | 604 case recordTypes.LayoutInvalidationTracking: |
604 case recordTypes.LayerInvalidationTracking: | 605 case recordTypes.LayerInvalidationTracking: |
605 case recordTypes.PaintInvalidationTracking: | 606 case recordTypes.PaintInvalidationTracking: |
606 this._invalidationTracker.addInvalidation(event); | 607 this._invalidationTracker.addInvalidation(event); |
607 break; | 608 break; |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 if (invalidationToUpdate.nodeId !== invalidation.nodeId) | 1171 if (invalidationToUpdate.nodeId !== invalidation.nodeId) |
1171 return; | 1172 return; |
1172 if (invalidationToUpdate.type === recordTypes.StyleRecalcInvalidatio
nTracking | 1173 if (invalidationToUpdate.type === recordTypes.StyleRecalcInvalidatio
nTracking |
1173 || invalidationToUpdate.type === recordTypes.LayoutInvalidat
ionTracking) { | 1174 || invalidationToUpdate.type === recordTypes.LayoutInvalidat
ionTracking) { |
1174 invalidationToUpdate.paintId = invalidation.paintId; | 1175 invalidationToUpdate.paintId = invalidation.paintId; |
1175 } | 1176 } |
1176 } | 1177 } |
1177 }, | 1178 }, |
1178 | 1179 |
1179 /** | 1180 /** |
| 1181 * @param {!WebInspector.TracingModel.Event} styleRecalcEvent |
| 1182 */ |
| 1183 didRecalcStyle: function(styleRecalcEvent) |
| 1184 { |
| 1185 var recalcFrameId = styleRecalcEvent.args["frame"]; |
| 1186 var index = this._lastStyleRecalcEventIndex; |
| 1187 var invalidationCount = this._invalidationEvents.length; |
| 1188 for (; index < invalidationCount; index++) { |
| 1189 var invalidation = this._invalidationEvents[index]; |
| 1190 if (invalidation.type !== WebInspector.TracingTimelineModel.RecordTy
pe.StyleRecalcInvalidationTracking) |
| 1191 continue; |
| 1192 if (invalidation.frameId === recalcFrameId) |
| 1193 this._addInvalidationTrackingEvent(styleRecalcEvent, invalidatio
n); |
| 1194 } |
| 1195 |
| 1196 this._lastStyleRecalcEventIndex = invalidationCount; |
| 1197 }, |
| 1198 |
| 1199 /** |
1180 * @param {!WebInspector.TracingModel.Event} paintEvent | 1200 * @param {!WebInspector.TracingModel.Event} paintEvent |
1181 */ | 1201 */ |
1182 didPaint: function(paintEvent) | 1202 didPaint: function(paintEvent) |
1183 { | 1203 { |
1184 this._didPaint = true; | 1204 this._didPaint = true; |
1185 | 1205 |
1186 // If a paint doesn't have a corresponding graphics layer id, it paints | 1206 // If a paint doesn't have a corresponding graphics layer id, it paints |
1187 // into its parent so add an effectivePaintId to these events. | 1207 // into its parent so add an effectivePaintId to these events. |
1188 var layerId = paintEvent.args["data"]["layerId"]; | 1208 var layerId = paintEvent.args["data"]["layerId"]; |
1189 if (layerId) | 1209 if (layerId) |
1190 this._lastPaintWithLayer = paintEvent; | 1210 this._lastPaintWithLayer = paintEvent; |
1191 if (!this._lastPaintWithLayer) { | 1211 if (!this._lastPaintWithLayer) { |
1192 console.error("Failed to find the paint container for a paint event.
"); | 1212 console.error("Failed to find the paint container for a paint event.
"); |
1193 return; | 1213 return; |
1194 } | 1214 } |
1195 | 1215 |
1196 var effectivePaintId = this._lastPaintWithLayer.args["data"]["nodeId"]; | 1216 var effectivePaintId = this._lastPaintWithLayer.args["data"]["nodeId"]; |
1197 var frameId = paintEvent.args["data"]["frame"]; | 1217 var frameId = paintEvent.args["data"]["frame"]; |
1198 this._invalidationEvents.forEach(recordInvalidationForPaint); | 1218 this._invalidationEvents.forEach(recordInvalidationForPaint.bind(this)); |
1199 | 1219 |
1200 function recordInvalidationForPaint(invalidation) | 1220 function recordInvalidationForPaint(invalidation) |
1201 { | 1221 { |
1202 if (invalidation.paintId === effectivePaintId && invalidation.frameI
d === frameId) { | 1222 if (invalidation.paintId === effectivePaintId && invalidation.frameI
d === frameId) |
1203 if (!paintEvent.invalidationTrackingEvents) | 1223 this._addInvalidationTrackingEvent(paintEvent, invalidation); |
1204 paintEvent.invalidationTrackingEvents = []; | |
1205 paintEvent.invalidationTrackingEvents.push(invalidation); | |
1206 } | |
1207 } | 1224 } |
1208 }, | 1225 }, |
1209 | 1226 |
| 1227 /** |
| 1228 * @param {!WebInspector.TracingModel.Event} event |
| 1229 * @param {!WebInspector.InvalidationTrackingEvent} invalidation |
| 1230 */ |
| 1231 _addInvalidationTrackingEvent: function(event, invalidation) |
| 1232 { |
| 1233 if (!event.invalidationTrackingEvents) |
| 1234 event.invalidationTrackingEvents = [ invalidation ]; |
| 1235 else |
| 1236 event.invalidationTrackingEvents.push(invalidation); |
| 1237 }, |
| 1238 |
1210 _startNewFrameIfNeeded: function() | 1239 _startNewFrameIfNeeded: function() |
1211 { | 1240 { |
1212 if (!this._didPaint) | 1241 if (!this._didPaint) |
1213 return; | 1242 return; |
1214 | 1243 |
1215 this._initializePerFrameState(); | 1244 this._initializePerFrameState(); |
1216 }, | 1245 }, |
1217 | 1246 |
1218 _initializePerFrameState: function() | 1247 _initializePerFrameState: function() |
1219 { | 1248 { |
1220 this._invalidationEvents = []; | 1249 this._invalidationEvents = []; |
| 1250 this._lastStyleRecalcEventIndex = 0; |
1221 this._lastPaintWithLayer = undefined; | 1251 this._lastPaintWithLayer = undefined; |
1222 this._didPaint = false; | 1252 this._didPaint = false; |
1223 } | 1253 } |
1224 } | 1254 } |
OLD | NEW |