Changeset 234021 in webkit


Ignore:
Timestamp:
Jul 19, 2018 9:29:21 PM (6 years ago)
Author:
Ross Kirsling
Message:

Web Inspector: Layers visualization shouldn't select on mousedown
https://bugs.webkit.org/show_bug.cgi?id=187488

Reviewed by Matt Baker.

  • UserInterface/Views/Layers3DContentView.js:

(WI.Layers3DContentView):
(WI.Layers3DContentView.prototype.initialLayout):
(WI.Layers3DContentView.prototype._canvasMouseDown):
(WI.Layers3DContentView.prototype._canvasMouseUp):
Don't update selection on mousedown, update on mouseup!
Specifically, only update when mousedown & mouseup targets are the same and mousemove hasn't been triggered.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r233989 r234021  
     12018-07-19  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        Web Inspector: Layers visualization shouldn't select on mousedown
     4        https://bugs.webkit.org/show_bug.cgi?id=187488
     5
     6        Reviewed by Matt Baker.
     7
     8        * UserInterface/Views/Layers3DContentView.js:
     9        (WI.Layers3DContentView):
     10        (WI.Layers3DContentView.prototype.initialLayout):
     11        (WI.Layers3DContentView.prototype._canvasMouseDown):
     12        (WI.Layers3DContentView.prototype._canvasMouseUp):
     13        Don't update selection on mousedown, update on mouseup!
     14        Specifically, only update when mousedown & mouseup targets are the same and mousemove hasn't been triggered.
     15
    1162018-07-19  Nikita Vasilyev  <nvasilyev@apple.com>
    217
  • trunk/Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js

    r233695 r234021  
    4646        this._layerGroupsById = new Map;
    4747        this._selectedLayerGroup = null;
     48        this._candidateSelection = null;
    4849        this._nodeToSelect = null;
    4950
     
    5455        this._boundingBox = null;
    5556        this._raycaster = null;
    56         this._mouse = null;
    5757        this._animationFrameRequestId = null;
    5858        this._documentNode = null;
     
    165165
    166166        this._raycaster = new THREE.Raycaster;
    167         this._mouse = new THREE.Vector2;
    168167        this._renderer.domElement.addEventListener("mousedown", this._canvasMouseDown.bind(this));
     168        this._renderer.domElement.addEventListener("mouseup", this._canvasMouseUp.bind(this));
    169169
    170170        this.element.appendChild(this._renderer.domElement);
     
    311311    _canvasMouseDown(event)
    312312    {
    313         this._mouse.x = (event.offsetX / event.target.width) * 2 - 1;
    314         this._mouse.y = -(event.offsetY / event.target.height) * 2 + 1;
    315         this._raycaster.setFromCamera(this._mouse, this._camera);
     313        let x = (event.offsetX / event.target.offsetWidth) * 2 - 1;
     314        let y = -(event.offsetY / event.target.offsetHeight) * 2 + 1;
     315        this._raycaster.setFromCamera(new THREE.Vector2(x, y), this._camera);
    316316
    317317        const recursive = true;
    318318        let intersects = this._raycaster.intersectObjects(this._scene.children, recursive);
    319         let selection = intersects.length ? intersects[0].object.parent : null;
     319        let layerGroup = intersects.length ? intersects[0].object.parent : null;
     320        this._candidateSelection = {layerGroup};
     321
     322        let canvasMouseMove = (event) => {
     323            this._candidateSelection = null;
     324            this._renderer.domElement.removeEventListener("mousemove", canvasMouseMove);
     325        };
     326
     327        this._renderer.domElement.addEventListener("mousemove", canvasMouseMove);
     328    }
     329
     330    _canvasMouseUp(event)
     331    {
     332        if (!this._candidateSelection)
     333            return;
     334
     335        let selection = this._candidateSelection.layerGroup;
    320336        if (selection && selection === this._selectedLayerGroup) {
    321337            if (!event.metaKey)
Note: See TracChangeset for help on using the changeset viewer.