Title: [241226] trunk/Source/WebInspectorUI
Revision
241226
Author
[email protected]
Date
2019-02-08 17:47:08 -0800 (Fri, 08 Feb 2019)

Log Message

Web Inspector: Styles: easier way to select a single line
https://bugs.webkit.org/show_bug.cgi?id=193305

Reviewed by Devin Rousso.

Start property selection after mousedown when mouse cursor moves 8px,
which is ~1.5 times the width of a text character in the style editor.

* UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
(WI.SpreadsheetCSSStyleDeclarationSection):
(WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleMouseDown):
(WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleWindowMouseMove): Added.
(WI.SpreadsheetCSSStyleDeclarationSection.prototype._stopSelection):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (241225 => 241226)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-02-09 01:30:16 UTC (rev 241225)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-02-09 01:47:08 UTC (rev 241226)
@@ -1,3 +1,19 @@
+2019-02-08  Nikita Vasilyev  <[email protected]>
+
+        Web Inspector: Styles: easier way to select a single line
+        https://bugs.webkit.org/show_bug.cgi?id=193305
+
+        Reviewed by Devin Rousso.
+
+        Start property selection after mousedown when mouse cursor moves 8px,
+        which is ~1.5 times the width of a text character in the style editor.
+
+        * UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
+        (WI.SpreadsheetCSSStyleDeclarationSection):
+        (WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleMouseDown):
+        (WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleWindowMouseMove): Added.
+        (WI.SpreadsheetCSSStyleDeclarationSection.prototype._stopSelection):
+
 2019-02-08  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Debugger Popover should work with value in template string `${identifier}`

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js (241225 => 241226)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js	2019-02-09 01:30:16 UTC (rev 241225)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js	2019-02-09 01:47:08 UTC (rev 241226)
@@ -45,6 +45,8 @@
 
         this._isMousePressed = false;
         this._mouseDownIndex = NaN;
+        this._mouseDownPoint = null;
+        this._boundHandleWindowMouseMove = null;
     }
 
     // Public
@@ -404,8 +406,13 @@
         let propertyIndex = parseInt(propertyElement.dataset.propertyIndex);
         if (event.shiftKey && this._propertiesEditor.hasSelectedProperties())
             this._propertiesEditor.extendSelectedProperties(propertyIndex);
-        else
+        else {
             this._propertiesEditor.deselectProperties();
+            this._mouseDownPoint = WI.Point.fromEvent(event);
+            if (!this._boundHandleWindowMouseMove)
+                this._boundHandleWindowMouseMove = this._handleWindowMouseMove.bind(this);
+            window.addEventListener("mousemove", this._boundHandleWindowMouseMove);
+        }
 
         if (propertyElement.parentNode) {
             this._mouseDownIndex = propertyIndex;
@@ -423,6 +430,22 @@
         this._stopSelection();
     }
 
+    _handleWindowMouseMove(event)
+    {
+        console.assert(this._mouseDownPoint);
+
+        if (this._mouseDownPoint.distance(WI.Point.fromEvent(event)) < 8)
+            return;
+
+        if (!this._propertiesEditor.hasSelectedProperties()) {
+            console.assert(!isNaN(this._mouseDownIndex));
+            this._propertiesEditor.selectProperties(this._mouseDownIndex, this._mouseDownIndex);
+        }
+
+        window.removeEventListener("mousemove", this._boundHandleWindowMouseMove);
+        this._mouseDownPoint = null;
+    }
+
     _handleClick(event)
     {
         this._stopSelection();
@@ -457,6 +480,9 @@
         this._isMousePressed = false;
         this._mouseDownIndex = NaN;
         this._element.classList.remove("selecting");
+
+        window.removeEventListener("mousemove", this._boundHandleWindowMouseMove);
+        this._mouseDownPoint = null;
     }
 
     _highlightNodesWithSelector()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to