OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 if (WebInspector.moduleSetting("sidebarPosition").get() === "auto") | 316 if (WebInspector.moduleSetting("sidebarPosition").get() === "auto") |
317 this.element.window().requestAnimationFrame(this._updateSidebarPosit
ion.bind(this)); // Do not force layout. | 317 this.element.window().requestAnimationFrame(this._updateSidebarPosit
ion.bind(this)); // Do not force layout. |
318 this._updateTreeOutlineVisibleWidth(); | 318 this._updateTreeOutlineVisibleWidth(); |
319 }, | 319 }, |
320 | 320 |
321 /** | 321 /** |
322 * @param {!WebInspector.Event} event | 322 * @param {!WebInspector.Event} event |
323 */ | 323 */ |
324 _selectedNodeChanged: function(event) | 324 _selectedNodeChanged: function(event) |
325 { | 325 { |
326 var selectedNode = /** @type {?WebInspector.DOMNode} */ (event.data); | 326 var selectedNode = /** @type {?WebInspector.DOMNode} */ (event.data.node
); |
| 327 var focus = /** @type {boolean} */ (event.data.focus); |
327 for (var i = 0; i < this._treeOutlines.length; ++i) { | 328 for (var i = 0; i < this._treeOutlines.length; ++i) { |
328 if (!selectedNode || selectedNode.domModel() !== this._treeOutlines[
i].domModel()) | 329 if (!selectedNode || selectedNode.domModel() !== this._treeOutlines[
i].domModel()) |
329 this._treeOutlines[i].selectDOMNode(null); | 330 this._treeOutlines[i].selectDOMNode(null); |
330 } | 331 } |
331 | 332 |
332 if (!selectedNode && this._lastValidSelectedNode) | |
333 this._selectedPathOnReset = this._lastValidSelectedNode.path(); | |
334 | |
335 this._breadcrumbs.setSelectedNode(selectedNode); | 333 this._breadcrumbs.setSelectedNode(selectedNode); |
336 | 334 |
337 WebInspector.context.setFlavor(WebInspector.DOMNode, selectedNode); | 335 WebInspector.context.setFlavor(WebInspector.DOMNode, selectedNode); |
338 | 336 |
339 if (!selectedNode) | 337 if (!selectedNode) |
340 return; | 338 return; |
341 selectedNode.setAsInspectedNode(); | 339 selectedNode.setAsInspectedNode(); |
342 this._lastValidSelectedNode = selectedNode; | 340 if (focus) { |
| 341 this._selectedNodeOnReset = selectedNode; |
| 342 this._hasNonDefaultSelectedNode = true; |
| 343 } |
343 | 344 |
344 var executionContexts = selectedNode.target().runtimeModel.executionCont
exts(); | 345 var executionContexts = selectedNode.target().runtimeModel.executionCont
exts(); |
345 var nodeFrameId = selectedNode.frameId(); | 346 var nodeFrameId = selectedNode.frameId(); |
346 for (var context of executionContexts) { | 347 for (var context of executionContexts) { |
347 if (context.frameId === nodeFrameId) { | 348 if (context.frameId === nodeFrameId) { |
348 WebInspector.context.setFlavor(WebInspector.ExecutionContext, co
ntext); | 349 WebInspector.context.setFlavor(WebInspector.ExecutionContext, co
ntext); |
349 break; | 350 break; |
350 } | 351 } |
351 } | 352 } |
352 }, | 353 }, |
(...skipping 22 matching lines...) Expand all Loading... |
375 | 376 |
376 var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(domModel)
; | 377 var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(domModel)
; |
377 treeOutline.rootDOMNode = inspectedRootDocument; | 378 treeOutline.rootDOMNode = inspectedRootDocument; |
378 | 379 |
379 if (!inspectedRootDocument) { | 380 if (!inspectedRootDocument) { |
380 if (this.isShowing()) | 381 if (this.isShowing()) |
381 domModel.requestDocument(); | 382 domModel.requestDocument(); |
382 return; | 383 return; |
383 } | 384 } |
384 | 385 |
| 386 this._hasNonDefaultSelectedNode = false; |
385 WebInspector.domBreakpointsSidebarPane.restoreBreakpoints(inspectedRootD
ocument); | 387 WebInspector.domBreakpointsSidebarPane.restoreBreakpoints(inspectedRootD
ocument); |
386 | 388 |
387 /** | |
388 * @this {WebInspector.ElementsPanel} | |
389 * @param {?WebInspector.DOMNode} candidateFocusNode | |
390 */ | |
391 function selectNode(candidateFocusNode) | |
392 { | |
393 if (!candidateFocusNode) | |
394 candidateFocusNode = inspectedRootDocument.body || inspectedRoot
Document.documentElement; | |
395 | |
396 if (!candidateFocusNode) | |
397 return; | |
398 | |
399 if (!this._pendingNodeReveal) { | |
400 this.selectDOMNode(candidateFocusNode); | |
401 if (treeOutline.selectedTreeElement) | |
402 treeOutline.selectedTreeElement.expand(); | |
403 } | |
404 } | |
405 | |
406 /** | |
407 * @param {?DOMAgent.NodeId} nodeId | |
408 * @this {WebInspector.ElementsPanel} | |
409 */ | |
410 function selectLastSelectedNode(nodeId) | |
411 { | |
412 if (this.selectedDOMNode()) { | |
413 // Focused node has been explicitly set while reaching out for t
he last selected node. | |
414 return; | |
415 } | |
416 var node = nodeId ? domModel.nodeForId(nodeId) : null; | |
417 selectNode.call(this, node); | |
418 this._lastSelectedNodeSelectedForTest(); | |
419 } | |
420 | |
421 if (this._omitDefaultSelection) | 389 if (this._omitDefaultSelection) |
422 return; | 390 return; |
423 | 391 |
424 if (this._selectedPathOnReset) | 392 var savedSelectedNodeOnReset = this._selectedNodeOnReset; |
425 domModel.pushNodeByPathToFrontend(this._selectedPathOnReset, selectL
astSelectedNode.bind(this)); | 393 restoreNode.call(this, domModel, this._selectedNodeOnReset); |
426 else | 394 |
427 selectNode.call(this, null); | 395 /** |
428 delete this._selectedPathOnReset; | 396 * @param {!WebInspector.DOMModel} domModel |
| 397 * @param {?WebInspector.DOMNode} staleNode |
| 398 * @this {WebInspector.ElementsPanel} |
| 399 */ |
| 400 function restoreNode(domModel, staleNode) |
| 401 { |
| 402 var nodePath = staleNode ? staleNode.path() : null; |
| 403 if (!nodePath) { |
| 404 onNodeRestored.call(this, null); |
| 405 return; |
| 406 } |
| 407 domModel.pushNodeByPathToFrontend(nodePath, onNodeRestored.bind(this
)); |
| 408 } |
| 409 |
| 410 /** |
| 411 * @param {?DOMAgent.NodeId} restoredNodeId |
| 412 * @this {WebInspector.ElementsPanel} |
| 413 */ |
| 414 function onNodeRestored(restoredNodeId) |
| 415 { |
| 416 if (savedSelectedNodeOnReset !== this._selectedNodeOnReset) |
| 417 return; |
| 418 var node = restoredNodeId ? domModel.nodeForId(restoredNodeId) : nul
l; |
| 419 if (!node) { |
| 420 var inspectedDocument = domModel.existingDocument(); |
| 421 node = inspectedDocument ? inspectedDocument.body || inspectedDo
cument.documentElement : null; |
| 422 } |
| 423 this._setDefaultSelectedNode(node); |
| 424 this._lastSelectedNodeSelectedForTest(); |
| 425 } |
429 }, | 426 }, |
430 | 427 |
431 _lastSelectedNodeSelectedForTest: function() { }, | 428 _lastSelectedNodeSelectedForTest: function() { }, |
432 | 429 |
433 /** | 430 /** |
| 431 * @param {?WebInspector.DOMNode} node |
| 432 */ |
| 433 _setDefaultSelectedNode: function(node) |
| 434 { |
| 435 if (!node || this._hasNonDefaultSelectedNode || this._pendingNodeReveal) |
| 436 return; |
| 437 var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(node.domM
odel()); |
| 438 if (!treeOutline) |
| 439 return; |
| 440 this.selectDOMNode(node); |
| 441 if (treeOutline.selectedTreeElement) |
| 442 treeOutline.selectedTreeElement.expand(); |
| 443 }, |
| 444 |
| 445 /** |
434 * @override | 446 * @override |
435 */ | 447 */ |
436 searchCanceled: function() | 448 searchCanceled: function() |
437 { | 449 { |
438 delete this._searchQuery; | 450 delete this._searchQuery; |
439 this._hideSearchHighlights(); | 451 this._hideSearchHighlights(); |
440 | 452 |
441 this._searchableView.updateSearchMatchesCount(0); | 453 this._searchableView.updateSearchMatchesCount(0); |
442 | 454 |
443 delete this._currentSearchResultIndex; | 455 delete this._currentSearchResultIndex; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 treeOutline.domModel().redo(); | 724 treeOutline.domModel().redo(); |
713 event.handled = true; | 725 event.handled = true; |
714 } | 726 } |
715 } | 727 } |
716 | 728 |
717 if (WebInspector.isEditing() && event.keyCode !== WebInspector.KeyboardS
hortcut.Keys.F2.code) | 729 if (WebInspector.isEditing() && event.keyCode !== WebInspector.KeyboardS
hortcut.Keys.F2.code) |
718 return; | 730 return; |
719 | 731 |
720 var treeOutline = null; | 732 var treeOutline = null; |
721 for (var i = 0; i < this._treeOutlines.length; ++i) { | 733 for (var i = 0; i < this._treeOutlines.length; ++i) { |
722 if (this._treeOutlines[i].selectedDOMNode() === this._lastValidSelec
tedNode) | 734 if (this._treeOutlines[i].selectedDOMNode()) |
723 treeOutline = this._treeOutlines[i]; | 735 treeOutline = this._treeOutlines[i]; |
724 } | 736 } |
725 if (!treeOutline) | 737 if (!treeOutline) |
726 return; | 738 return; |
727 | 739 |
728 if (!treeOutline.editing()) { | 740 if (!treeOutline.editing()) { |
729 handleUndoRedo.call(null, treeOutline); | 741 handleUndoRedo.call(null, treeOutline); |
730 if (event.handled) { | 742 if (event.handled) { |
731 this._stylesWidget.forceUpdate(); | 743 this._stylesWidget.forceUpdate(); |
732 return; | 744 return; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 /** | 1120 /** |
1109 * @override | 1121 * @override |
1110 * @param {!WebInspector.DOMNode} node | 1122 * @param {!WebInspector.DOMNode} node |
1111 * @return {?{title: string, color: string}} | 1123 * @return {?{title: string, color: string}} |
1112 */ | 1124 */ |
1113 decorate: function(node) | 1125 decorate: function(node) |
1114 { | 1126 { |
1115 return { color: "orange", title: WebInspector.UIString("Element state: %
s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) }; | 1127 return { color: "orange", title: WebInspector.UIString("Element state: %
s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) }; |
1116 } | 1128 } |
1117 }; | 1129 }; |
OLD | NEW |