Commit 23fb6337 authored by malch@chromium.org's avatar malch@chromium.org

Fix bug with context menu in Layers3DView.

Review URL: https://codereview.chromium.org/312193002

Review URL: https://codereview.chromium.org/312193002

git-svn-id: svn://svn.chromium.org/blink/trunk@175543 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4510654b
...@@ -595,7 +595,7 @@ WebInspector.Layers3DView.prototype = { ...@@ -595,7 +595,7 @@ WebInspector.Layers3DView.prototype = {
* @param {?Event} event * @param {?Event} event
* @return {?WebInspector.Layers3DView.ActiveObject} * @return {?WebInspector.Layers3DView.ActiveObject}
*/ */
_layerFromEventPoint: function(event) _activeObjectFromEventPoint: function(event)
{ {
if (!this._layerTree) if (!this._layerTree)
return null; return null;
...@@ -638,8 +638,8 @@ WebInspector.Layers3DView.prototype = { ...@@ -638,8 +638,8 @@ WebInspector.Layers3DView.prototype = {
*/ */
_onContextMenu: function(event) _onContextMenu: function(event)
{ {
var layer = this._layerFromEventPoint(event).layer; var activeObject = this._activeObjectFromEventPoint(event);
var node = layer ? layer.nodeForSelfOrAncestor() : null; var node = activeObject && activeObject.layer && activeObject.layer.nodeForSelfOrAncestor();
var contextMenu = new WebInspector.ContextMenu(event); var contextMenu = new WebInspector.ContextMenu(event);
contextMenu.appendItem("Reset view", this._transformController._resetAndNotify.bind(this._transformController), false); contextMenu.appendItem("Reset view", this._transformController._resetAndNotify.bind(this._transformController), false);
if (node) if (node)
...@@ -654,7 +654,7 @@ WebInspector.Layers3DView.prototype = { ...@@ -654,7 +654,7 @@ WebInspector.Layers3DView.prototype = {
{ {
if (event.which) if (event.which)
return; return;
this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectHovered, this._layerFromEventPoint(event)); this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectHovered, this._activeObjectFromEventPoint(event));
}, },
/** /**
...@@ -673,7 +673,7 @@ WebInspector.Layers3DView.prototype = { ...@@ -673,7 +673,7 @@ WebInspector.Layers3DView.prototype = {
{ {
const maxDistanceInPixels = 6; const maxDistanceInPixels = 6;
if (this._mouseDownX && Math.abs(event.clientX - this._mouseDownX) < maxDistanceInPixels && Math.abs(event.clientY - this._mouseDownY) < maxDistanceInPixels) if (this._mouseDownX && Math.abs(event.clientX - this._mouseDownX) < maxDistanceInPixels && Math.abs(event.clientY - this._mouseDownY) < maxDistanceInPixels)
this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectSelected, this._layerFromEventPoint(event)); this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectSelected, this._activeObjectFromEventPoint(event));
delete this._mouseDownX; delete this._mouseDownX;
delete this._mouseDownY; delete this._mouseDownY;
}, },
...@@ -683,7 +683,7 @@ WebInspector.Layers3DView.prototype = { ...@@ -683,7 +683,7 @@ WebInspector.Layers3DView.prototype = {
*/ */
_onDoubleClick: function(event) _onDoubleClick: function(event)
{ {
var object = this._layerFromEventPoint(event); var object = this._activeObjectFromEventPoint(event);
if (object && object.layer) if (object && object.layer)
this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSnapshotRequested, object.layer); this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSnapshotRequested, object.layer);
event.stopPropagation(); event.stopPropagation();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment