Web Inspector: Hide child rows for filtered tasks in the Rendering Frames data grid
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Aug 2015 20:29:20 +0000 (20:29 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Aug 2015 20:29:20 +0000 (20:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147960

Reviewed by Timothy Hatcher.

* UserInterface/Models/RenderingFrameTimelineRecord.js:
(WebInspector.RenderingFrameTimelineRecord.taskTypeForTimelineRecord):
New static method for mapping TimelineRecords to rendering frame tasks.
(WebInspector.RenderingFrameTimelineRecord.prototype.durationForTask):
Refactored to use taskTypeForTimelineRecord.

* UserInterface/Views/TimelineSidebarPanel.js:
(WebInspector.TimelineSidebarPanel.prototype.matchTreeElementAgainstCustomFilters):
Task filtering is applied to children of the frame record only. Parent frame
record is hidden by default, and visible by virtue of having unfiltered children.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188398 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/RenderingFrameTimelineRecord.js
Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js

index 06494585070c431c4e35976d6dcbc6a07fbd41da..2efca65fd63649010a39488e234882ee884be1ce 100644 (file)
@@ -1,3 +1,21 @@
+2015-08-13  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: Hide child rows for filtered tasks in the Rendering Frames data grid
+        https://bugs.webkit.org/show_bug.cgi?id=147960
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/RenderingFrameTimelineRecord.js:
+        (WebInspector.RenderingFrameTimelineRecord.taskTypeForTimelineRecord):
+        New static method for mapping TimelineRecords to rendering frame tasks.
+        (WebInspector.RenderingFrameTimelineRecord.prototype.durationForTask):
+        Refactored to use taskTypeForTimelineRecord.
+
+        * UserInterface/Views/TimelineSidebarPanel.js:
+        (WebInspector.TimelineSidebarPanel.prototype.matchTreeElementAgainstCustomFilters):
+        Task filtering is applied to children of the frame record only. Parent frame
+        record is hidden by default, and visible by virtue of having unfiltered children.
+
 2015-08-13  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: Clearing frames timeline doesn't remove current time marker
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;
index ffa05e593ce7d48fe6416e0f52bedc288464f5f6..d5fbe2822f1ca8459b5b60234ada7a71cb108eb5 100644 (file)
@@ -395,23 +395,18 @@ WebInspector.TimelineSidebarPanel = class TimelineSidebarPanel extends WebInspec
             return true;
 
         if (this._viewMode === WebInspector.TimelineSidebarPanel.ViewMode.RenderingFrames && this._renderingFrameTaskFilter.size) {
-            while (treeElement && !(treeElement.record instanceof WebInspector.RenderingFrameTimelineRecord))
+            while (treeElement && !(treeElement.record instanceof WebInspector.TimelineRecord))
                 treeElement = treeElement.parent;
 
-            console.assert(treeElement, "Cannot apply task filter: no RenderingFrameTimelineRecord found.");
+            console.assert(treeElement, "Cannot apply task filter: no TimelineRecord found.");
             if (!treeElement)
                 return false;
 
             var visible = false;
-            for (var key in WebInspector.RenderingFrameTimelineRecord.TaskType) {
-                var taskType = WebInspector.RenderingFrameTimelineRecord.TaskType[key];
-                if (taskType === WebInspector.RenderingFrameTimelineRecord.TaskType.Other)
-                    continue;
-
-                if (!this._renderingFrameTaskFilter.has(taskType) && treeElement.record.durationForTask(taskType) > 0) {
+            if (!(treeElement.record instanceof WebInspector.RenderingFrameTimelineRecord)) {
+                var taskType = WebInspector.RenderingFrameTimelineRecord.taskTypeForTimelineRecord(treeElement.record);
+                if (!this._renderingFrameTaskFilter.has(taskType))
                     visible = true;
-                    break;
-                }
             }
 
             if (!visible)