Bug 147912

Summary: Web Inspector: Dragging a timeline ruler handle when both handles clamped is broken
Product: WebKit Reporter: Matt Baker <mattbaker>
Component: Web InspectorAssignee: Matt Baker <mattbaker>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, graouts, hi, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[Patch] Proposed Fix
none
[Patch] Proposed Fix
none
[Video] New behavior none

Description Matt Baker 2015-08-11 16:37:42 PDT
* SUMMARY
Dragging a timeline ruler handle when both handles clamped is broken. Overlapping handles are also styled incorrectly. When only one handle is clamped it should be styled white with a gray border (currently works), but when both are clamped the handle background color should match the ruler header.

* STEPS TO REPRODUCE
1. Record a timeline
2. Make a ruler selection near the beginning of the graph
3. Scroll graph until selection falls off the left edge and both handles are clamped
4. Click and drag the ruler handle to the right
  => The expected behavior is that the right handle was selected and that dragging will modify the selection end time. Instead the left handle is selected and selection behavior is erratic.
Comment 1 Matt Baker 2015-08-11 16:50:42 PDT
Created attachment 258781 [details]
[Patch] Proposed Fix
Comment 2 Devin Rousso 2015-08-11 17:18:25 PDT
Comment on attachment 258781 [details]
[Patch] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=258781&action=review

> Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js:591
> +        let endTimeClamped = this._selectionEndTime > this._endTime || this._selectionEndTime < this._startTime;

NIT: I would switch the order of these two expressions so that the "<" and ">" match on either side of the "||" compared to the line above.

> Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js:598
> +        let newLeftPosition = Math.max(0, Math.min(1, (this._selectionStartTime - this._startTime) / duration));

We actually have a function called "clamp" in Utilities for this exact purpose.

> Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js:607
> +        let newRightPosition = 1 - Math.max(0, Math.min(1, (this._selectionEndTime - this._startTime) / duration));

See line 598.
Comment 3 Matt Baker 2015-08-11 17:59:38 PDT
Created attachment 258788 [details]
[Patch] Proposed Fix
Comment 4 Matt Baker 2015-08-11 18:06:21 PDT
Created attachment 258790 [details]
[Video] New behavior
Comment 5 WebKit Commit Bot 2015-08-11 22:54:35 PDT
Comment on attachment 258788 [details]
[Patch] Proposed Fix

Clearing flags on attachment: 258788

Committed r188328: <http://trac.webkit.org/changeset/188328>
Comment 6 WebKit Commit Bot 2015-08-11 22:54:38 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 BJ Burg 2015-08-12 08:38:51 PDT
Comment on attachment 258781 [details]
[Patch] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=258781&action=review

>> Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js:598
>> +        let newLeftPosition = Math.max(0, Math.min(1, (this._selectionStartTime - this._startTime) / duration));
> 
> We actually have a function called "clamp" in Utilities for this exact purpose.

Number.constrain((this._selectionStartTime - this._startTime) / duration, 0, 1);
Comment 8 Timothy Hatcher 2015-08-12 10:09:15 PDT
(In reply to comment #7)
> Comment on attachment 258781 [details]
> [Patch] Proposed Fix
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=258781&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js:598
> >> +        let newLeftPosition = Math.max(0, Math.min(1, (this._selectionStartTime - this._startTime) / duration));
> > 
> > We actually have a function called "clamp" in Utilities for this exact purpose.
> 
> Number.constrain((this._selectionStartTime - this._startTime) / duration, 0,
> 1);

We should remove clamp and adopt Number.constrain.
Comment 9 Matt Baker 2015-08-12 13:47:45 PDT
> We should remove clamp and adopt Number.constrain.

https://bugs.webkit.org/show_bug.cgi?id=147952