Title: [197034] trunk/Source/WebInspectorUI
Revision
197034
Author
mattba...@apple.com
Date
2016-02-24 09:41:42 -0800 (Wed, 24 Feb 2016)

Log Message

Web Inspector: TimelineRuler should have a "select all" mode
https://bugs.webkit.org/show_bug.cgi?id=154561
<rdar://problem/24779872>

Reviewed by Timothy Hatcher.

TimelineRuler is initialized with a selected range of [0, Number.MAX_VALUE),
indicating the entire timeline is selected. This patch makes it possible to
return the ruler to this state, after being overwritten by a custom selection.
When no custom selection exists, the selection handles are hidden.

* UserInterface/Views/TimelineRuler.css:
(.timeline-ruler.selection-hidden > :matches(.selection-drag, .selection-handle, .shaded-area)):
Style for hiding selection controls as needed.

* UserInterface/Views/TimelineRuler.js:
(WebInspector.TimelineRuler):
Represent unbounded selection interval as [0, Number.MAX_VALUE).

(WebInspector.TimelineRuler.prototype.set allowsTimeRangeSelection):
Register double-click event listener.

(WebInspector.TimelineRuler.prototype.set zeroTime):
(WebInspector.TimelineRuler.prototype.get entireRangeSelected):
(WebInspector.TimelineRuler.prototype.selectEntireRange):
Let clients check and set the selection of the entire range without needing
to use the internal sentinel values 0 and Number.MAX_VALUE.

(WebInspector.TimelineRuler.prototype._updateSelection):
Update ruler styles and dispatch selection change event when entire
range is selected.

(WebInspector.TimelineRuler.prototype._handleDoubleClick):
If a user-defined selection exists, select the entire range.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (197033 => 197034)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-02-24 17:36:12 UTC (rev 197033)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-02-24 17:41:42 UTC (rev 197034)
@@ -1,3 +1,40 @@
+2016-02-24  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: TimelineRuler should have a "select all" mode
+        https://bugs.webkit.org/show_bug.cgi?id=154561
+        <rdar://problem/24779872>
+
+        Reviewed by Timothy Hatcher.
+
+        TimelineRuler is initialized with a selected range of [0, Number.MAX_VALUE),
+        indicating the entire timeline is selected. This patch makes it possible to
+        return the ruler to this state, after being overwritten by a custom selection.
+        When no custom selection exists, the selection handles are hidden.
+
+        * UserInterface/Views/TimelineRuler.css:
+        (.timeline-ruler.selection-hidden > :matches(.selection-drag, .selection-handle, .shaded-area)):
+        Style for hiding selection controls as needed.
+
+        * UserInterface/Views/TimelineRuler.js:
+        (WebInspector.TimelineRuler):
+        Represent unbounded selection interval as [0, Number.MAX_VALUE).
+
+        (WebInspector.TimelineRuler.prototype.set allowsTimeRangeSelection):
+        Register double-click event listener.
+
+        (WebInspector.TimelineRuler.prototype.set zeroTime):
+        (WebInspector.TimelineRuler.prototype.get entireRangeSelected):
+        (WebInspector.TimelineRuler.prototype.selectEntireRange):
+        Let clients check and set the selection of the entire range without needing
+        to use the internal sentinel values 0 and Number.MAX_VALUE.
+
+        (WebInspector.TimelineRuler.prototype._updateSelection):
+        Update ruler styles and dispatch selection change event when entire
+        range is selected.
+
+        (WebInspector.TimelineRuler.prototype._handleDoubleClick):
+        If a user-defined selection exists, select the entire range.
+
 2016-02-24  Nikita Vasilyev  <nvasil...@apple.com>
 
         Web Inspector: Dim selected items when docked Inspector window is inactive

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.css (197033 => 197034)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.css	2016-02-24 17:36:12 UTC (rev 197033)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.css	2016-02-24 17:41:42 UTC (rev 197034)
@@ -178,6 +178,10 @@
     z-index: 15;
 }
 
+.timeline-ruler.selection-hidden > :matches(.selection-drag, .selection-handle, .shaded-area) {
+    display: none;
+}
+
 .timeline-ruler > .selection-handle.clamped {
     border-color: hsl(0, 0%, 64%);
     background-color: white;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js (197033 => 197034)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js	2016-02-24 17:36:12 UTC (rev 197033)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js	2016-02-24 17:41:42 UTC (rev 197034)
@@ -45,7 +45,7 @@
         this._duration = NaN;
         this._secondsPerPixel = 0;
         this._selectionStartTime = 0;
-        this._selectionEndTime = Infinity;
+        this._selectionEndTime = Number.MAX_VALUE;
         this._endTimePinned = false;
         this._snapInterval = 0;
         this._allowsClippedLabels = false;
@@ -105,7 +105,9 @@
         this._allowsTimeRangeSelection = x;
 
         if (x) {
+            this._doubleClickEventListener = this._handleDoubleClick.bind(this);
             this._mouseDownEventListener = this._handleMouseDown.bind(this);
+            this.element.addEventListener("dblclick", this._doubleClickEventListener);
             this.element.addEventListener("mousedown", this._mouseDownEventListener);
 
             this._leftShadedAreaElement = document.createElement("div");
@@ -131,8 +133,10 @@
 
             this._needsSelectionLayout();
         } else {
+            this.element.removeEventListener("dblclick", this._doubleClickEventListener);
             this.element.removeEventListener("mousedown", this._mouseDownEventListener);
-            delete this._mouseDownEventListener;
+            this._doubleClickEventListener = null;
+            this._mouseDownEventListener = null;
 
             this._leftShadedAreaElement.remove();
             this._rightShadedAreaElement.remove();
@@ -171,6 +175,8 @@
             return;
 
         this._zeroTime = x;
+        if (this.entireRangeSelected)
+            this.selectionStartTime = this._zeroTime;
 
         this.needsLayout();
     }
@@ -292,6 +298,17 @@
         this._needsSelectionLayout();
     }
 
+    get entireRangeSelected()
+    {
+        return this._selectionStartTime === this._zeroTime && this._selectionEndTime === Number.MAX_VALUE;
+    }
+
+    selectEntireRange()
+    {
+        this.selectionStartTime = this._zeroTime;
+        this.selectionEndTime = Number.MAX_VALUE;
+    }
+
     addMarker(marker)
     {
         console.assert(marker instanceof WebInspector.TimelineMarker);
@@ -596,11 +613,18 @@
             this._scheduledSelectionLayoutUpdateIdentifier = undefined;
         }
 
-        this.element.classList.toggle(WebInspector.TimelineRuler.AllowsTimeRangeSelectionStyleClassName, this._allowsTimeRangeSelection);
+        this.element.classList.toggle("allows-time-range-selection", this._allowsTimeRangeSelection);
 
         if (!this._allowsTimeRangeSelection)
             return;
 
+        this.element.classList.toggle("selection-hidden", this.entireRangeSelected);
+
+        if (this.entireRangeSelected) {
+            this._dispatchTimeRangeSelectionChangedEvent();
+            return;
+        }
+
         let startTimeClamped = this._selectionStartTime < this._startTime || this._selectionStartTime > this._endTime;
         let endTimeClamped = this._selectionEndTime < this._startTime || this._selectionEndTime > this._endTime;
 
@@ -669,6 +693,14 @@
         this._needsMarkerLayout();
     }
 
+    _handleDoubleClick(event)
+    {
+        if (this.entireRangeSelected)
+            return;
+
+        this.selectEntireRange();
+    }
+
     _handleMouseDown(event)
     {
         // Only handle left mouse clicks.
@@ -857,7 +889,6 @@
 WebInspector.TimelineRuler.MinimumLeftDividerSpacing = 48;
 WebInspector.TimelineRuler.MinimumDividerSpacing = 64;
 
-WebInspector.TimelineRuler.AllowsTimeRangeSelectionStyleClassName = "allows-time-range-selection";
 WebInspector.TimelineRuler.ResizingSelectionStyleClassName = "resizing-selection";
 WebInspector.TimelineRuler.DividerElementStyleClassName = "divider";
 WebInspector.TimelineRuler.DividerLabelElementStyleClassName = "label";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to