Title: [185734] trunk/Source/WebInspectorUI
Revision
185734
Author
[email protected]
Date
2015-06-18 21:45:34 -0700 (Thu, 18 Jun 2015)

Log Message

Web Inspector: Rendering Frames timeline selection should snap to frame boundaries
https://bugs.webkit.org/show_bug.cgi?id=146120

Reviewed by Timothy Hatcher.

* UserInterface/Views/RenderingFrameTimelineOverview.js:
Enable snapping to frame boundaries.

* UserInterface/Views/TimelineRecordingContentView.js:
(WebInspector.TimelineRecordingContentView.prototype._updateFrameSelection):
Updated filtering to account for ruler snapping.

* UserInterface/Views/TimelineRuler.js:
(WebInspector.TimelineRuler.prototype.get snapInterval):
(WebInspector.TimelineRuler.prototype.set snapInterval):
(WebInspector.TimelineRuler.prototype.set selectionStartTime):
(WebInspector.TimelineRuler.prototype.set selectionEndTime):
(WebInspector.TimelineRuler.prototype._snapValue):
(WebInspector.TimelineRuler.prototype._handleMouseMove):
Added support for snapping to a specified interval.

* UserInterface/Views/TimelineSidebarPanel.js:
Removed unnecessary code.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (185733 => 185734)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-06-19 03:46:06 UTC (rev 185733)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-06-19 04:45:34 UTC (rev 185734)
@@ -1,3 +1,29 @@
+2015-06-18  Matt Baker  <[email protected]>
+
+        Web Inspector: Rendering Frames timeline selection should snap to frame boundaries
+        https://bugs.webkit.org/show_bug.cgi?id=146120
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/RenderingFrameTimelineOverview.js:
+        Enable snapping to frame boundaries.
+
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WebInspector.TimelineRecordingContentView.prototype._updateFrameSelection):
+        Updated filtering to account for ruler snapping.
+
+        * UserInterface/Views/TimelineRuler.js:
+        (WebInspector.TimelineRuler.prototype.get snapInterval):
+        (WebInspector.TimelineRuler.prototype.set snapInterval):
+        (WebInspector.TimelineRuler.prototype.set selectionStartTime):
+        (WebInspector.TimelineRuler.prototype.set selectionEndTime):
+        (WebInspector.TimelineRuler.prototype._snapValue):
+        (WebInspector.TimelineRuler.prototype._handleMouseMove):
+        Added support for snapping to a specified interval.
+
+        * UserInterface/Views/TimelineSidebarPanel.js:
+        Removed unnecessary code.
+
 2015-06-18  Devin Rousso  <[email protected]>
 
         Web Inspector: Add a filter for CSS properties in the Styles sidebar

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineOverview.js (185733 => 185734)


--- trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineOverview.js	2015-06-19 03:46:06 UTC (rev 185733)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineOverview.js	2015-06-19 04:45:34 UTC (rev 185734)
@@ -37,6 +37,7 @@
 
     WebInspector.TimelineOverview.call(this, "frames", timelineRecording, minimumDurationPerPixel, maximumDurationPerPixel, defaultSettingsValues);
 
+    this.timelineRuler.snapInterval = 1;
     this.timelineRuler.formatLabelCallback = function(value) {
         return value.toFixed(0);
     };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js (185733 => 185734)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2015-06-19 03:46:06 UTC (rev 185733)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2015-06-19 04:45:34 UTC (rev 185734)
@@ -265,11 +265,12 @@
 
             if (this._renderingFrameTimeline && this._renderingFrameTimeline.records.length) {
                 var records = this._renderingFrameTimeline.records;
-                var startIndex = Math.floor(startTime);
+                var startIndex = this._currentTimelineOverview.timelineRuler.snapInterval ? startTime : Math.floor(startTime);
                 if (startIndex >= records.length)
                     return false;
 
-                var endIndex = Math.min(Math.floor(endTime), records.length - 1);
+                var endIndex = this._currentTimelineOverview.timelineRuler.snapInterval ? endTime - 1: Math.floor(endTime);
+                endIndex = Math.min(endIndex, records.length - 1);
                 console.assert(startIndex <= endIndex, startIndex);
 
                 startTime = records[startIndex].startTime;
@@ -671,7 +672,7 @@
             return;
 
         var startIndex = this._renderingFrameTimelineOverview.selectionStartTime;
-        var endIndex = startIndex + this._renderingFrameTimelineOverview.selectionDuration;
+        var endIndex = startIndex + this._renderingFrameTimelineOverview.selectionDuration - 1;
         this._timelineSidebarPanel.updateFrameSelection(startIndex, endIndex);
     }
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js (185733 => 185734)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js	2015-06-19 03:46:06 UTC (rev 185733)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js	2015-06-19 04:45:34 UTC (rev 185734)
@@ -253,6 +253,19 @@
         this._needsLayout();
     },
 
+    get snapInterval()
+    {
+        return this._snapInterval;
+    },
+
+    set snapInterval(x)
+    {
+        if (this._snapInterval === x)
+            return;
+
+        this._snapInterval = x;
+    },
+
     get selectionStartTime()
     {
         return this._selectionStartTime;
@@ -260,6 +273,7 @@
 
     set selectionStartTime(x)
     {
+        x = this._snapValue(x);
         if (this._selectionStartTime === x)
             return;
 
@@ -276,6 +290,7 @@
 
     set selectionEndTime(x)
     {
+        x = this._snapValue(x);
         if (this._selectionEndTime === x)
             return;
 
@@ -604,6 +619,14 @@
         return Number.secondsToString(value, true);
     },
 
+    _snapValue: function(value)
+    {
+        if (!value || !this.snapInterval)
+            return value;
+
+        return Math.round(value / this.snapInterval) * this.snapInterval;
+    },
+
     _dispatchTimeRangeSelectionChangedEvent: function()
     {
         delete this._timeRangeSelectionChanged;
@@ -657,10 +680,23 @@
 
             var offsetTime = (currentMousePosition - this._lastMousePosition) * this.secondsPerPixel;
             var selectionDuration = this.selectionEndTime - this.selectionStartTime;
+            var oldSelectionStartTime = this.selectionStartTime;
 
             this.selectionStartTime = Math.max(this.startTime, Math.min(this.selectionStartTime + offsetTime, this.endTime - selectionDuration));
             this.selectionEndTime = this.selectionStartTime + selectionDuration;
 
+            if (this.snapInterval) {
+                // When snapping we need to check the mouse position delta relative to the last snap, rather than the
+                // last mouse move. If a snap occurs we adjust for the amount the cursor drifted, so that the mouse
+                // position relative to the selection remains constant.
+                var snapOffset = this.selectionStartTime - oldSelectionStartTime;
+                if (!snapOffset)
+                    return;
+
+                var positionDrift = (offsetTime - snapOffset * this.snapInterval) / this.secondsPerPixel;
+                currentMousePosition -= positionDrift;
+            }
+
             this._lastMousePosition = currentMousePosition;
         } else {
             var currentMousePosition = event.pageX - this._rulerBoundingClientRect.left;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js (185733 => 185734)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js	2015-06-19 03:46:06 UTC (rev 185733)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js	2015-06-19 04:45:34 UTC (rev 185734)
@@ -317,9 +317,6 @@
     {
         console.assert(startFrameIndex <= endFrameIndex);
         console.assert(this.viewMode === WebInspector.TimelineSidebarPanel.ViewMode.RenderingFrames, this._viewMode);
-
-        startFrameIndex = Math.floor(startFrameIndex);
-        endFrameIndex = Math.floor(endFrameIndex);
         if (this._startFrameIndex === startFrameIndex && this._endFrameIndex === endFrameIndex)
             return;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to