Web Inspector: Hide child rows for filtered tasks in the Rendering Frames data grid
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Models / RenderingFrameTimelineRecord.js
index 8738bab589d8ffbd3042847c9a131bd88c188787..5c9ec0c13bb507482ccd581af4f258af2793dde7 100644 (file)
@@ -54,6 +54,21 @@ WebInspector.RenderingFrameTimelineRecord = class RenderingFrameTimelineRecord e
         }
     }
 
+    static taskTypeForTimelineRecord(record)
+    {
+        switch(record.type) {
+        case WebInspector.TimelineRecord.Type.Script:
+            return WebInspector.RenderingFrameTimelineRecord.TaskType.Script;
+        case WebInspector.TimelineRecord.Type.Layout:
+            if (record.eventType  === WebInspector.LayoutTimelineRecord.EventType.Paint || record.eventType === WebInspector.LayoutTimelineRecord.EventType.Composite)
+                return WebInspector.RenderingFrameTimelineRecord.TaskType.Paint;
+            return WebInspector.RenderingFrameTimelineRecord.TaskType.Layout;
+        default:
+            console.error("Unsupported timeline record type: " + record.type);
+            return null;
+        }
+    }
+
     // Public
 
     get frameIndex()
@@ -71,27 +86,12 @@ WebInspector.RenderingFrameTimelineRecord = class RenderingFrameTimelineRecord e
         if (this._durationByTaskType.has(taskType))
             return this._durationByTaskType.get(taskType);
 
-        function validRecordForTaskType(record)
-        {
-            switch(taskType) {
-            case WebInspector.RenderingFrameTimelineRecord.TaskType.Script:
-                return record.type === WebInspector.TimelineRecord.Type.Script;
-            case WebInspector.RenderingFrameTimelineRecord.TaskType.Layout:
-                return record.type === WebInspector.TimelineRecord.Type.Layout && record.eventType !== WebInspector.LayoutTimelineRecord.EventType.Paint && record.eventType !== WebInspector.LayoutTimelineRecord.EventType.Composite;
-            case WebInspector.RenderingFrameTimelineRecord.TaskType.Paint:
-                return record.eventType === WebInspector.LayoutTimelineRecord.EventType.Paint || record.eventType === WebInspector.LayoutTimelineRecord.EventType.Composite;
-            default:
-                console.error("Unsupported task type: " + taskType);
-                return false;
-            }
-        }
-
         var duration;
         if (taskType === WebInspector.RenderingFrameTimelineRecord.TaskType.Other)
             duration = this._calculateDurationRemainder();
         else {
             duration = this.children.reduce(function(previousValue, currentValue) {
-                if (!validRecordForTaskType(currentValue))
+                if (taskType !== WebInspector.RenderingFrameTimelineRecord.taskTypeForTimelineRecord(currentValue))
                     return previousValue;
 
                 var currentDuration = currentValue.duration;