Web Inspector: Make it possible to disable TimelineRuler UI
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Mar 2016 18:30:13 +0000 (18:30 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Mar 2016 18:30:13 +0000 (18:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155348
<rdar://problem/25103505>

Reviewed by Timothy Hatcher.

Adds an "enabled" property to TimelineRuler, allowing the selection UI
to be disabled without removing the current selection.

* UserInterface/Views/TimelineRuler.css:
(.timeline-ruler.allows-time-range-selection:not(.disabled)):
(.timeline-ruler > .selection-drag):
(.timeline-ruler:not(.disabled) > .selection-drag):
(.timeline-ruler:not(.disabled) > .selection-drag:active):
(.timeline-ruler.disabled > .selection-handle):
(.timeline-ruler.allows-time-range-selection): Deleted.
(.timeline-ruler > .selection-drag:active): Deleted.
Updated ruler styles for "disabled" state: pointer events are disabled,
selection handles hidden, and the default cursor is shown.

* UserInterface/Views/TimelineRuler.js:
(WebInspector.TimelineRuler):
(WebInspector.TimelineRuler.prototype.get enabled):
(WebInspector.TimelineRuler.prototype.set enabled):
New property.
(WebInspector.TimelineRuler.prototype._handleClick):
Corrected code which always reset the pointer events to "all", instead
of setting it back to the original value.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/TimelineRuler.css
Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js

index ac086f3..2d567f6 100644 (file)
@@ -1,3 +1,34 @@
+2016-03-11  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: Make it possible to disable TimelineRuler UI
+        https://bugs.webkit.org/show_bug.cgi?id=155348
+        <rdar://problem/25103505>
+
+        Reviewed by Timothy Hatcher.
+
+        Adds an "enabled" property to TimelineRuler, allowing the selection UI
+        to be disabled without removing the current selection.
+
+        * UserInterface/Views/TimelineRuler.css:
+        (.timeline-ruler.allows-time-range-selection:not(.disabled)):
+        (.timeline-ruler > .selection-drag):
+        (.timeline-ruler:not(.disabled) > .selection-drag):
+        (.timeline-ruler:not(.disabled) > .selection-drag:active):
+        (.timeline-ruler.disabled > .selection-handle):
+        (.timeline-ruler.allows-time-range-selection): Deleted.
+        (.timeline-ruler > .selection-drag:active): Deleted.
+        Updated ruler styles for "disabled" state: pointer events are disabled,
+        selection handles hidden, and the default cursor is shown.
+
+        * UserInterface/Views/TimelineRuler.js:
+        (WebInspector.TimelineRuler):
+        (WebInspector.TimelineRuler.prototype.get enabled):
+        (WebInspector.TimelineRuler.prototype.set enabled):
+        New property.
+        (WebInspector.TimelineRuler.prototype._handleClick):
+        Corrected code which always reset the pointer events to "all", instead
+        of setting it back to the original value.
+
 2016-03-10  Daniel Strokis  <dstrokis@icloud.com>
 
         Web Inspector: color swatch and border are misaligned in Visual Styles sidebar
index 1fef950..15c4f86 100644 (file)
@@ -29,7 +29,7 @@
     z-index: 1;
 }
 
-.timeline-ruler.allows-time-range-selection {
+.timeline-ruler.allows-time-range-selection:not(.disabled) {
     pointer-events: all;
 }
 
@@ -157,11 +157,14 @@ body.window-inactive .timeline-ruler > .header > .divider {
     position: absolute;
     top: 0;
     height: 23px;
+}
+
+.timeline-ruler:not(.disabled) > .selection-drag {
     cursor: -webkit-grab;
     pointer-events: all;
 }
 
-.timeline-ruler > .selection-drag:active {
+.timeline-ruler:not(.disabled) > .selection-drag:active {
     cursor: -webkit-grabbing;
 }
 
@@ -178,6 +181,10 @@ body.window-inactive .timeline-ruler > .header > .divider {
     z-index: 15;
 }
 
+.timeline-ruler.disabled > .selection-handle {
+    display: none;
+}
+
 .timeline-ruler.selection-hidden > :matches(.selection-drag, .selection-handle, .shaded-area) {
     display: none;
 }
index abe6055..f369d46 100644 (file)
@@ -53,12 +53,27 @@ WebInspector.TimelineRuler = class TimelineRuler extends WebInspector.View
         this._minimumSelectionDuration = 0.01;
         this._formatLabelCallback = null;
         this._timeRangeSelectionChanged = false;
+        this._enabled = true;
 
         this._markerElementMap = new Map;
     }
 
     // Public
 
+    get enabled()
+    {
+        return this._enabled;
+    }
+
+    set enabled(x)
+    {
+        if (this._enabled === x)
+            return;
+
+        this._enabled = x;
+        this.element.classList.toggle(WebInspector.TreeElementStatusButton.DisabledStyleClassName, !this._enabled);
+    }
+
     get allowsClippedLabels()
     {
         return this._allowsClippedLabels;
@@ -700,12 +715,15 @@ WebInspector.TimelineRuler = class TimelineRuler extends WebInspector.View
 
     _handleClick(event)
     {
-        if (this._mouseMoved)
+        if (!this._enabled)
+            return;
+
+        if (!this._mouseMoved)
             return;
 
         this.element.style.pointerEvents = "none";
         let newTarget = document.elementFromPoint(event.pageX, event.pageY);
-        this.element.style.pointerEvents = "all";
+        this.element.style.pointerEvents = null;
 
         if (newTarget && newTarget.click)
             newTarget.click();