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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); |
327 for (var i = 0; i < this._treeOutlines.length; ++i) { | 327 for (var i = 0; i < this._treeOutlines.length; ++i) { |
328 if (!selectedNode || selectedNode.domModel() !== this._treeOutlines[
i].domModel()) | 328 if (!selectedNode || selectedNode.domModel() !== this._treeOutlines[
i].domModel()) |
329 this._treeOutlines[i].selectDOMNode(null); | 329 this._treeOutlines[i].selectDOMNode(null); |
330 } | 330 } |
331 | 331 |
| 332 if (!selectedNode && this._lastValidSelectedNode) |
| 333 this._selectedPathOnReset = this._lastValidSelectedNode.path(); |
| 334 |
332 this._breadcrumbs.setSelectedNode(selectedNode); | 335 this._breadcrumbs.setSelectedNode(selectedNode); |
333 | 336 |
334 WebInspector.context.setFlavor(WebInspector.DOMNode, selectedNode); | 337 WebInspector.context.setFlavor(WebInspector.DOMNode, selectedNode); |
335 | 338 |
336 if (!selectedNode) | 339 if (!selectedNode) |
337 return; | 340 return; |
338 selectedNode.setAsInspectedNode(); | 341 selectedNode.setAsInspectedNode(); |
339 if (!this._isSettingDefaultSelectedNode) { | 342 this._lastValidSelectedNode = selectedNode; |
340 this._selectedNodeOnReset = selectedNode; | |
341 this._hasNonDefaultSelectedNode = true; | |
342 } | |
343 | 343 |
344 var executionContexts = selectedNode.target().runtimeModel.executionCont
exts(); | 344 var executionContexts = selectedNode.target().runtimeModel.executionCont
exts(); |
345 var nodeFrameId = selectedNode.frameId(); | 345 var nodeFrameId = selectedNode.frameId(); |
346 for (var context of executionContexts) { | 346 for (var context of executionContexts) { |
347 if (context.frameId === nodeFrameId) { | 347 if (context.frameId === nodeFrameId) { |
348 WebInspector.context.setFlavor(WebInspector.ExecutionContext, co
ntext); | 348 WebInspector.context.setFlavor(WebInspector.ExecutionContext, co
ntext); |
349 break; | 349 break; |
350 } | 350 } |
351 } | 351 } |
352 }, | 352 }, |
(...skipping 22 matching lines...) Expand all Loading... |
375 | 375 |
376 var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(domModel)
; | 376 var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(domModel)
; |
377 treeOutline.rootDOMNode = inspectedRootDocument; | 377 treeOutline.rootDOMNode = inspectedRootDocument; |
378 | 378 |
379 if (!inspectedRootDocument) { | 379 if (!inspectedRootDocument) { |
380 if (this.isShowing()) | 380 if (this.isShowing()) |
381 domModel.requestDocument(); | 381 domModel.requestDocument(); |
382 return; | 382 return; |
383 } | 383 } |
384 | 384 |
385 this._hasNonDefaultSelectedNode = false; | |
386 WebInspector.domBreakpointsSidebarPane.restoreBreakpoints(inspectedRootD
ocument); | 385 WebInspector.domBreakpointsSidebarPane.restoreBreakpoints(inspectedRootD
ocument); |
387 | 386 |
| 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 |
388 if (this._omitDefaultSelection) | 421 if (this._omitDefaultSelection) |
389 return; | 422 return; |
390 | 423 |
391 var savedSelectedNodeOnReset = this._selectedNodeOnReset; | 424 if (this._selectedPathOnReset) |
392 restoreNode.call(this, domModel, this._selectedNodeOnReset); | 425 domModel.pushNodeByPathToFrontend(this._selectedPathOnReset, selectL
astSelectedNode.bind(this)); |
393 | 426 else |
394 /** | 427 selectNode.call(this, null); |
395 * @param {!WebInspector.DOMModel} domModel | 428 delete this._selectedPathOnReset; |
396 * @param {?WebInspector.DOMNode} staleNode | |
397 * @this {WebInspector.ElementsPanel} | |
398 */ | |
399 function restoreNode(domModel, staleNode) | |
400 { | |
401 var nodePath = staleNode ? staleNode.path() : null; | |
402 if (!nodePath) { | |
403 onNodeRestored.call(this, null); | |
404 return; | |
405 } | |
406 domModel.pushNodeByPathToFrontend(nodePath, onNodeRestored.bind(this
)); | |
407 } | |
408 | |
409 /** | |
410 * @param {?DOMAgent.NodeId} restoredNodeId | |
411 * @this {WebInspector.ElementsPanel} | |
412 */ | |
413 function onNodeRestored(restoredNodeId) | |
414 { | |
415 if (savedSelectedNodeOnReset !== this._selectedNodeOnReset) | |
416 return; | |
417 var node = restoredNodeId ? domModel.nodeForId(restoredNodeId) : nul
l; | |
418 if (!node) { | |
419 var inspectedDocument = domModel.existingDocument(); | |
420 node = inspectedDocument ? inspectedDocument.body || inspectedDo
cument.documentElement : null; | |
421 } | |
422 this._setDefaultSelectedNode(node); | |
423 this._lastSelectedNodeSelectedForTest(); | |
424 } | |
425 }, | 429 }, |
426 | 430 |
427 _lastSelectedNodeSelectedForTest: function() { }, | 431 _lastSelectedNodeSelectedForTest: function() { }, |
428 | 432 |
429 /** | 433 /** |
430 * @param {?WebInspector.DOMNode} node | |
431 */ | |
432 _setDefaultSelectedNode: function(node) | |
433 { | |
434 if (!node || this._hasNonDefaultSelectedNode || this._pendingNodeReveal) | |
435 return; | |
436 var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(node.domM
odel()); | |
437 if (!treeOutline) | |
438 return; | |
439 this._isSettingDefaultSelectedNode = true; | |
440 this.selectDOMNode(node); | |
441 this._isSettingDefaultSelectedNode = false; | |
442 if (treeOutline.selectedTreeElement) | |
443 treeOutline.selectedTreeElement.expand(); | |
444 }, | |
445 | |
446 /** | |
447 * @override | 434 * @override |
448 */ | 435 */ |
449 searchCanceled: function() | 436 searchCanceled: function() |
450 { | 437 { |
451 delete this._searchQuery; | 438 delete this._searchQuery; |
452 this._hideSearchHighlights(); | 439 this._hideSearchHighlights(); |
453 | 440 |
454 this._searchableView.updateSearchMatchesCount(0); | 441 this._searchableView.updateSearchMatchesCount(0); |
455 | 442 |
456 delete this._currentSearchResultIndex; | 443 delete this._currentSearchResultIndex; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 treeOutline.domModel().redo(); | 712 treeOutline.domModel().redo(); |
726 event.handled = true; | 713 event.handled = true; |
727 } | 714 } |
728 } | 715 } |
729 | 716 |
730 if (WebInspector.isEditing() && event.keyCode !== WebInspector.KeyboardS
hortcut.Keys.F2.code) | 717 if (WebInspector.isEditing() && event.keyCode !== WebInspector.KeyboardS
hortcut.Keys.F2.code) |
731 return; | 718 return; |
732 | 719 |
733 var treeOutline = null; | 720 var treeOutline = null; |
734 for (var i = 0; i < this._treeOutlines.length; ++i) { | 721 for (var i = 0; i < this._treeOutlines.length; ++i) { |
735 if (this._treeOutlines[i].selectedDOMNode()) | 722 if (this._treeOutlines[i].selectedDOMNode() === this._lastValidSelec
tedNode) |
736 treeOutline = this._treeOutlines[i]; | 723 treeOutline = this._treeOutlines[i]; |
737 } | 724 } |
738 if (!treeOutline) | 725 if (!treeOutline) |
739 return; | 726 return; |
740 | 727 |
741 if (!treeOutline.editing()) { | 728 if (!treeOutline.editing()) { |
742 handleUndoRedo.call(null, treeOutline); | 729 handleUndoRedo.call(null, treeOutline); |
743 if (event.handled) { | 730 if (event.handled) { |
744 this._stylesWidget.forceUpdate(); | 731 this._stylesWidget.forceUpdate(); |
745 return; | 732 return; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 /** | 1108 /** |
1122 * @override | 1109 * @override |
1123 * @param {!WebInspector.DOMNode} node | 1110 * @param {!WebInspector.DOMNode} node |
1124 * @return {?{title: string, color: string}} | 1111 * @return {?{title: string, color: string}} |
1125 */ | 1112 */ |
1126 decorate: function(node) | 1113 decorate: function(node) |
1127 { | 1114 { |
1128 return { color: "orange", title: WebInspector.UIString("Element state: %
s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) }; | 1115 return { color: "orange", title: WebInspector.UIString("Element state: %
s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) }; |
1129 } | 1116 } |
1130 } | 1117 } |
OLD | NEW |