Commit 933af274 authored by caseq@chromium.org's avatar caseq@chromium.org

DevTools: better visual feedback for hovered objects is Layers3DView

- rename WebInspector.Layers3DView.ActiveObject to ...Selection;
- introduce proper constructors and isEqual methods for Selection;
- generalize hover/selection handling logic for different objects;
- make hovered (but not selected) object bluish

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

git-svn-id: svn://svn.chromium.org/blink/trunk@185203 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 993247eb
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<script> <script>
function test() function test()
{ {
setTimeout(InspectorTest.completeTest.bind(InspectorTest), 4000);
var contentRoot; var contentRoot;
var layers; var layers;
var rootOffsetXInPixels, rootOffsetYInPixels, rootHeightInPixels, rootWidthInPixels; var rootOffsetXInPixels, rootOffsetYInPixels, rootHeightInPixels, rootWidthInPixels;
...@@ -53,7 +54,7 @@ function test() ...@@ -53,7 +54,7 @@ function test()
function checkLayer(layerInfo) function checkLayer(layerInfo)
{ {
var l3dview = WebInspector.panels.layers._layers3DView; var l3dview = WebInspector.panels.layers._layers3DView;
if (l3dview._lastActiveObject[type] && layerInfo.layer.id() === l3dview._lastActiveObject[type].layer.id()) if (l3dview._lastSelection[type] && layerInfo.layer.id() === l3dview._lastSelection[type].layer.id())
outlined = layerInfo.name; outlined = layerInfo.name;
} }
......
...@@ -163,8 +163,8 @@ WebInspector.LayersPanel.prototype = { ...@@ -163,8 +163,8 @@ WebInspector.LayersPanel.prototype = {
*/ */
_onObjectSelected: function(event) _onObjectSelected: function(event)
{ {
var activeObject = /** @type {!WebInspector.Layers3DView.ActiveObject} */ (event.data); var selection = /** @type {!WebInspector.Layers3DView.Selection} */ (event.data);
this._selectObject(activeObject); this._selectObject(selection);
}, },
/** /**
...@@ -172,8 +172,8 @@ WebInspector.LayersPanel.prototype = { ...@@ -172,8 +172,8 @@ WebInspector.LayersPanel.prototype = {
*/ */
_onObjectHovered: function(event) _onObjectHovered: function(event)
{ {
var activeObject = /** @type {!WebInspector.Layers3DView.ActiveObject} */ (event.data); var selection = /** @type {!WebInspector.Layers3DView.Selection} */ (event.data);
this._hoverObject(activeObject); this._hoverObject(selection);
}, },
/** /**
...@@ -187,40 +187,40 @@ WebInspector.LayersPanel.prototype = { ...@@ -187,40 +187,40 @@ WebInspector.LayersPanel.prototype = {
}, },
/** /**
* @param {?WebInspector.Layers3DView.ActiveObject} activeObject * @param {?WebInspector.Layers3DView.Selection} selection
*/ */
_selectObject: function(activeObject) _selectObject: function(selection)
{ {
var layer = activeObject && activeObject.layer; var layer = selection && selection.layer;
if (this._currentlySelectedLayer === activeObject) if (this._currentlySelectedLayer === selection)
return; return;
this._currentlySelectedLayer = activeObject; this._currentlySelectedLayer = selection;
var node = layer ? layer.nodeForSelfOrAncestor() : null; var node = layer ? layer.nodeForSelfOrAncestor() : null;
if (node) if (node)
node.highlightForTwoSeconds(); node.highlightForTwoSeconds();
else if (this._target) else if (this._target)
this._target.domModel.hideDOMNodeHighlight(); this._target.domModel.hideDOMNodeHighlight();
this._layerTreeOutline.selectLayer(layer); this._layerTreeOutline.selectLayer(layer);
this._layers3DView.selectObject(activeObject); this._layers3DView.selectObject(selection);
this._layerDetailsView.setObject(activeObject); this._layerDetailsView.setObject(selection);
}, },
/** /**
* @param {?WebInspector.Layers3DView.ActiveObject} activeObject * @param {?WebInspector.Layers3DView.Selection} selection
*/ */
_hoverObject: function(activeObject) _hoverObject: function(selection)
{ {
var layer = activeObject && activeObject.layer; var layer = selection && selection.layer;
if (this._currentlyHoveredLayer === activeObject) if (this._currentlyHoveredLayer === selection)
return; return;
this._currentlyHoveredLayer = activeObject; this._currentlyHoveredLayer = selection;
var node = layer ? layer.nodeForSelfOrAncestor() : null; var node = layer ? layer.nodeForSelfOrAncestor() : null;
if (node) if (node)
node.highlight(); node.highlight();
else if (this._target) else if (this._target)
this._target.domModel.hideDOMNodeHighlight(); this._target.domModel.hideDOMNodeHighlight();
this._layerTreeOutline.hoverLayer(layer); this._layerTreeOutline.hoverLayer(layer);
this._layers3DView.hoverObject(activeObject); this._layers3DView.hoverObject(selection);
}, },
__proto__: WebInspector.PanelWithSidebarTree.prototype __proto__: WebInspector.PanelWithSidebarTree.prototype
......
...@@ -88,12 +88,12 @@ WebInspector.LayerDetailsView.CompositingReasonDetail = { ...@@ -88,12 +88,12 @@ WebInspector.LayerDetailsView.CompositingReasonDetail = {
WebInspector.LayerDetailsView.prototype = { WebInspector.LayerDetailsView.prototype = {
/** /**
* @param {?WebInspector.Layers3DView.ActiveObject} activeObject * @param {?WebInspector.Layers3DView.Selection} selection
*/ */
setObject: function(activeObject) setObject: function(selection)
{ {
this._layer = activeObject ? activeObject.layer : null; this._layer = selection ? selection.layer : null;
this._scrollRectIndex = activeObject ? activeObject.scrollRectIndex : null; this._scrollRectIndex = selection ? selection.scrollRectIndex : null;
if (this.isShowing()) if (this.isShowing())
this.update(); this.update();
}, },
...@@ -112,7 +112,7 @@ WebInspector.LayerDetailsView.prototype = { ...@@ -112,7 +112,7 @@ WebInspector.LayerDetailsView.prototype = {
{ {
if (event.which !== 1) if (event.which !== 1)
return; return;
this.dispatchEventToListeners(WebInspector.LayerDetailsView.Events.ObjectSelected, {layer: this._layer, scrollRectIndex: index}); this.dispatchEventToListeners(WebInspector.LayerDetailsView.Events.ObjectSelected, new WebInspector.Layers3DView.ScrollRectSelection(this._layer, index));
}, },
/** /**
......
...@@ -140,7 +140,8 @@ WebInspector.LayerTreeOutline.prototype = { ...@@ -140,7 +140,8 @@ WebInspector.LayerTreeOutline.prototype = {
var node = this._treeOutline.treeElementFromEvent(event); var node = this._treeOutline.treeElementFromEvent(event);
if (node === this._lastHoveredNode) if (node === this._lastHoveredNode)
return; return;
this.dispatchEventToListeners(WebInspector.LayerTreeOutline.Events.LayerHovered, node && node.representedObject ? {layer: node.representedObject} : null); var selection = node && node.representedObject ? new WebInspector.Layers3DView.LayerSelection(node.representedObject) : null;
this.dispatchEventToListeners(WebInspector.LayerTreeOutline.Events.LayerHovered, selection);
}, },
/** /**
...@@ -149,7 +150,8 @@ WebInspector.LayerTreeOutline.prototype = { ...@@ -149,7 +150,8 @@ WebInspector.LayerTreeOutline.prototype = {
_selectedNodeChanged: function(node) _selectedNodeChanged: function(node)
{ {
var layer = /** @type {!WebInspector.Layer} */ (node.representedObject); var layer = /** @type {!WebInspector.Layer} */ (node.representedObject);
this.dispatchEventToListeners(WebInspector.LayerTreeOutline.Events.LayerSelected, {layer: layer}); var selection = node.representedObject ? new WebInspector.Layers3DView.LayerSelection(node.representedObject) : null;
this.dispatchEventToListeners(WebInspector.LayerTreeOutline.Events.LayerSelected, selection);
}, },
/** /**
......
...@@ -146,32 +146,32 @@ WebInspector.TimelineLayersView.prototype = { ...@@ -146,32 +146,32 @@ WebInspector.TimelineLayersView.prototype = {
}, },
/** /**
* @param {?WebInspector.Layers3DView.ActiveObject} activeObject * @param {?WebInspector.Layers3DView.Selection} selection
*/ */
_selectObject: function(activeObject) _selectObject: function(selection)
{ {
var layer = activeObject && activeObject.layer; var layer = selection && selection.layer;
if (this._currentlySelectedLayer === activeObject) if (this._currentlySelectedLayer === selection)
return; return;
this._currentlySelectedLayer = activeObject; this._currentlySelectedLayer = selection;
this._toggleNodeHighlight(layer ? layer.nodeForSelfOrAncestor() : null); this._toggleNodeHighlight(layer ? layer.nodeForSelfOrAncestor() : null);
this._layerTreeOutline.selectLayer(layer); this._layerTreeOutline.selectLayer(layer);
this._layers3DView.selectObject(activeObject); this._layers3DView.selectObject(selection);
this._layerDetailsView.setObject(activeObject); this._layerDetailsView.setObject(selection);
}, },
/** /**
* @param {?WebInspector.Layers3DView.ActiveObject} activeObject * @param {?WebInspector.Layers3DView.Selection} selection
*/ */
_hoverObject: function(activeObject) _hoverObject: function(selection)
{ {
var layer = activeObject && activeObject.layer; var layer = selection && selection.layer;
if (this._currentlyHoveredLayer === activeObject) if (this._currentlyHoveredLayer === selection)
return; return;
this._currentlyHoveredLayer = activeObject; this._currentlyHoveredLayer = selection;
this._toggleNodeHighlight(layer ? layer.nodeForSelfOrAncestor() : null); this._toggleNodeHighlight(layer ? layer.nodeForSelfOrAncestor() : null);
this._layerTreeOutline.hoverLayer(layer); this._layerTreeOutline.hoverLayer(layer);
this._layers3DView.hoverObject(activeObject); this._layers3DView.hoverObject(selection);
}, },
/** /**
...@@ -193,8 +193,8 @@ WebInspector.TimelineLayersView.prototype = { ...@@ -193,8 +193,8 @@ WebInspector.TimelineLayersView.prototype = {
*/ */
_onObjectSelected: function(event) _onObjectSelected: function(event)
{ {
var activeObject = /** @type {!WebInspector.Layers3DView.ActiveObject} */ (event.data); var selection = /** @type {!WebInspector.Layers3DView.Selection} */ (event.data);
this._selectObject(activeObject); this._selectObject(selection);
}, },
/** /**
...@@ -202,8 +202,8 @@ WebInspector.TimelineLayersView.prototype = { ...@@ -202,8 +202,8 @@ WebInspector.TimelineLayersView.prototype = {
*/ */
_onObjectHovered: function(event) _onObjectHovered: function(event)
{ {
var activeObject = /** @type {!WebInspector.Layers3DView.ActiveObject} */ (event.data); var selection = /** @type {!WebInspector.Layers3DView.Selection} */ (event.data);
this._hoverObject(activeObject); this._hoverObject(selection);
}, },
_disposeTiles: function() _disposeTiles: function()
......
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