⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185734 in webkit


Ignore:
Timestamp:
Jun 18, 2015, 9:45:34 PM (11 years ago)
Author:
Matt Baker
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.

Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r185723 r185734  
     12015-06-18  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: Rendering Frames timeline selection should snap to frame boundaries
     4        https://bugs.webkit.org/show_bug.cgi?id=146120
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Views/RenderingFrameTimelineOverview.js:
     9        Enable snapping to frame boundaries.
     10
     11        * UserInterface/Views/TimelineRecordingContentView.js:
     12        (WebInspector.TimelineRecordingContentView.prototype._updateFrameSelection):
     13        Updated filtering to account for ruler snapping.
     14
     15        * UserInterface/Views/TimelineRuler.js:
     16        (WebInspector.TimelineRuler.prototype.get snapInterval):
     17        (WebInspector.TimelineRuler.prototype.set snapInterval):
     18        (WebInspector.TimelineRuler.prototype.set selectionStartTime):
     19        (WebInspector.TimelineRuler.prototype.set selectionEndTime):
     20        (WebInspector.TimelineRuler.prototype._snapValue):
     21        (WebInspector.TimelineRuler.prototype._handleMouseMove):
     22        Added support for snapping to a specified interval.
     23
     24        * UserInterface/Views/TimelineSidebarPanel.js:
     25        Removed unnecessary code.
     26
    1272015-06-18  Devin Rousso  <drousso@apple.com>
    228
  • trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineOverview.js

    r183469 r185734  
    3838    WebInspector.TimelineOverview.call(this, "frames", timelineRecording, minimumDurationPerPixel, maximumDurationPerPixel, defaultSettingsValues);
    3939
     40    this.timelineRuler.snapInterval = 1;
    4041    this.timelineRuler.formatLabelCallback = function(value) {
    4142        return value.toFixed(0);
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js

    r185349 r185734  
    266266            if (this._renderingFrameTimeline && this._renderingFrameTimeline.records.length) {
    267267                var records = this._renderingFrameTimeline.records;
    268                 var startIndex = Math.floor(startTime);
     268                var startIndex = this._currentTimelineOverview.timelineRuler.snapInterval ? startTime : Math.floor(startTime);
    269269                if (startIndex >= records.length)
    270270                    return false;
    271271
    272                 var endIndex = Math.min(Math.floor(endTime), records.length - 1);
     272                var endIndex = this._currentTimelineOverview.timelineRuler.snapInterval ? endTime - 1: Math.floor(endTime);
     273                endIndex = Math.min(endIndex, records.length - 1);
    273274                console.assert(startIndex <= endIndex, startIndex);
    274275
     
    672673
    673674        var startIndex = this._renderingFrameTimelineOverview.selectionStartTime;
    674         var endIndex = startIndex + this._renderingFrameTimelineOverview.selectionDuration;
     675        var endIndex = startIndex + this._renderingFrameTimelineOverview.selectionDuration - 1;
    675676        this._timelineSidebarPanel.updateFrameSelection(startIndex, endIndex);
    676677    }
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js

    r184819 r185734  
    254254    },
    255255
     256    get snapInterval()
     257    {
     258        return this._snapInterval;
     259    },
     260
     261    set snapInterval(x)
     262    {
     263        if (this._snapInterval === x)
     264            return;
     265
     266        this._snapInterval = x;
     267    },
     268
    256269    get selectionStartTime()
    257270    {
     
    261274    set selectionStartTime(x)
    262275    {
     276        x = this._snapValue(x);
    263277        if (this._selectionStartTime === x)
    264278            return;
     
    277291    set selectionEndTime(x)
    278292    {
     293        x = this._snapValue(x);
    279294        if (this._selectionEndTime === x)
    280295            return;
     
    603618
    604619        return Number.secondsToString(value, true);
     620    },
     621
     622    _snapValue: function(value)
     623    {
     624        if (!value || !this.snapInterval)
     625            return value;
     626
     627        return Math.round(value / this.snapInterval) * this.snapInterval;
    605628    },
    606629
     
    658681            var offsetTime = (currentMousePosition - this._lastMousePosition) * this.secondsPerPixel;
    659682            var selectionDuration = this.selectionEndTime - this.selectionStartTime;
     683            var oldSelectionStartTime = this.selectionStartTime;
    660684
    661685            this.selectionStartTime = Math.max(this.startTime, Math.min(this.selectionStartTime + offsetTime, this.endTime - selectionDuration));
    662686            this.selectionEndTime = this.selectionStartTime + selectionDuration;
     687
     688            if (this.snapInterval) {
     689                // When snapping we need to check the mouse position delta relative to the last snap, rather than the
     690                // last mouse move. If a snap occurs we adjust for the amount the cursor drifted, so that the mouse
     691                // position relative to the selection remains constant.
     692                var snapOffset = this.selectionStartTime - oldSelectionStartTime;
     693                if (!snapOffset)
     694                    return;
     695
     696                var positionDrift = (offsetTime - snapOffset * this.snapInterval) / this.secondsPerPixel;
     697                currentMousePosition -= positionDrift;
     698            }
    663699
    664700            this._lastMousePosition = currentMousePosition;
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js

    r185455 r185734  
    318318        console.assert(startFrameIndex <= endFrameIndex);
    319319        console.assert(this.viewMode === WebInspector.TimelineSidebarPanel.ViewMode.RenderingFrames, this._viewMode);
    320 
    321         startFrameIndex = Math.floor(startFrameIndex);
    322         endFrameIndex = Math.floor(endFrameIndex);
    323320        if (this._startFrameIndex === startFrameIndex && this._endFrameIndex === endFrameIndex)
    324321            return;
Note: See TracChangeset for help on using the changeset viewer.