Web Inspector: Bezier editor popover should be strictly LTR
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Feb 2020 22:45:08 +0000 (22:45 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Feb 2020 22:45:08 +0000 (22:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=206968
<rdar://problem/59007065>

Reviewed by Timothy Hatcher.

webkitConvertPointFromPageToNode does not work correctly with the zoom level other than 1.
Replace all uses of webkitConvertPointFromPageToNode with getBoundingClientRect.

* UserInterface/Models/Geometry.js:
(WI.Point.fromEventInElement):
* UserInterface/Views/ColorSquare.js:
(WI.ColorSquare.prototype._updateColorForMouseEvent):
* UserInterface/Views/GradientSlider.js:
(WI.GradientSlider.prototype._updateShadowKnob):
* UserInterface/Views/Slider.js:
(WI.Slider.prototype._localPointForEvent):
(WI.Slider):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/Geometry.js
Source/WebInspectorUI/UserInterface/Views/ColorSquare.js
Source/WebInspectorUI/UserInterface/Views/GradientSlider.js
Source/WebInspectorUI/UserInterface/Views/Slider.js

index 654e01a..4d376d7 100644 (file)
@@ -1,3 +1,24 @@
+2020-02-14  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Web Inspector: Bezier editor popover should be strictly LTR
+        https://bugs.webkit.org/show_bug.cgi?id=206968
+        <rdar://problem/59007065>
+
+        Reviewed by Timothy Hatcher.
+
+        webkitConvertPointFromPageToNode does not work correctly with the zoom level other than 1.
+        Replace all uses of webkitConvertPointFromPageToNode with getBoundingClientRect.
+
+        * UserInterface/Models/Geometry.js:
+        (WI.Point.fromEventInElement):
+        * UserInterface/Views/ColorSquare.js:
+        (WI.ColorSquare.prototype._updateColorForMouseEvent):
+        * UserInterface/Views/GradientSlider.js:
+        (WI.GradientSlider.prototype._updateShadowKnob):
+        * UserInterface/Views/Slider.js:
+        (WI.Slider.prototype._localPointForEvent):
+        (WI.Slider):
+
 2020-02-12  Pavel Feldman  <pavel.feldman@gmail.com>
 
         Web Inspector: encode binary web socket frames using base64
index 9f798b3..8b2c6f9 100644 (file)
@@ -40,8 +40,8 @@ WI.Point = class Point
 
     static fromEventInElement(event, element)
     {
-        var wkPoint = window.webkitConvertPointFromPageToNode(element, new WebKitPoint(event.pageX, event.pageY));
-        return new WI.Point(wkPoint.x, wkPoint.y);
+        let rect = element.getBoundingClientRect();
+        return new WI.Point(event.pageX - rect.x, event.pageY - rect.y);
     }
 
     // Public
index c500f3f..cda8ae6 100644 (file)
@@ -205,8 +205,11 @@ WI.ColorSquare = class ColorSquare
 
     _updateColorForMouseEvent(event)
     {
-        let point = window.webkitConvertPointFromPageToNode(this._element, new WebKitPoint(event.pageX, event.pageY));
-        this._setCrosshairPosition(point);
+        let rect = this._element.getBoundingClientRect();
+        this._setCrosshairPosition({
+            x: event.pageX - rect.x,
+            y: event.pageY - rect.y,
+        });
 
         if (this._delegate && this._delegate.colorSquareColorDidChange)
             this._delegate.colorSquareColorDidChange(this);
index 32aefb7..8d3c545 100644 (file)
@@ -195,7 +195,7 @@ WI.GradientSlider = class GradientSlider extends WI.Object
             this.element.appendChild(this._shadowKnob.element);
         }
 
-        this._shadowKnob.x = window.webkitConvertPointFromPageToNode(this.element, new WebKitPoint(event.pageX, event.pageY)).x;
+        this._shadowKnob.x = event.pageX - this.element.getBoundingClientRect().x;
 
         var colorData = this._canvas.getContext("2d").getImageData(this._shadowKnob.x - 1, 0, 1, 1).data;
         this._shadowKnob.wellColor = new WI.Color(WI.Color.Format.RGB, [colorData[0], colorData[1], colorData[2], colorData[3] / 255]);
index 62b87c4..f3ead4f 100644 (file)
@@ -167,7 +167,11 @@ WI.Slider = class Slider extends WI.Object
     {
         // We convert all event coordinates from page coordinates to local coordinates such that the slider
         // may be transformed using CSS Transforms and interaction works as expected.
-        return window.webkitConvertPointFromPageToNode(this._element, new WebKitPoint(event.pageX, event.pageY));
+        let rect = this._element.getBoundingClientRect();
+        return {
+            x: event.pageX - rect.x,
+            y: event.pageY - rect.y,
+        };
     }
 };