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 | |
335 this._breadcrumbs.setSelectedNode(selectedNode); | 332 this._breadcrumbs.setSelectedNode(selectedNode); |
336 | 333 |
337 WebInspector.context.setFlavor(WebInspector.DOMNode, selectedNode); | 334 WebInspector.context.setFlavor(WebInspector.DOMNode, selectedNode); |
338 | 335 |
339 if (!selectedNode) | 336 if (!selectedNode) |
340 return; | 337 return; |
341 selectedNode.setAsInspectedNode(); | 338 selectedNode.setAsInspectedNode(); |
342 this._lastValidSelectedNode = selectedNode; | 339 if (!this._isSettingDefaultSelectedNode) { |
| 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; |
385 WebInspector.domBreakpointsSidebarPane.restoreBreakpoints(inspectedRootD
ocument); | 386 WebInspector.domBreakpointsSidebarPane.restoreBreakpoints(inspectedRootD
ocument); |
386 | 387 |
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) | 388 if (this._omitDefaultSelection) |
422 return; | 389 return; |
423 | 390 |
424 if (this._selectedPathOnReset) | 391 var savedSelectedNodeOnReset = this._selectedNodeOnReset; |
425 domModel.pushNodeByPathToFrontend(this._selectedPathOnReset, selectL
astSelectedNode.bind(this)); | 392 restoreNode.call(this, domModel, this._selectedNodeOnReset); |
426 else | 393 |
427 selectNode.call(this, null); | 394 /** |
428 delete this._selectedPathOnReset; | 395 * @param {!WebInspector.DOMModel} domModel |
| 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 } |
429 }, | 425 }, |
430 | 426 |
431 _lastSelectedNodeSelectedForTest: function() { }, | 427 _lastSelectedNodeSelectedForTest: function() { }, |
432 | 428 |
433 /** | 429 /** |
| 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 /** |
434 * @override | 447 * @override |
435 */ | 448 */ |
436 searchCanceled: function() | 449 searchCanceled: function() |
437 { | 450 { |
438 delete this._searchQuery; | 451 delete this._searchQuery; |
439 this._hideSearchHighlights(); | 452 this._hideSearchHighlights(); |
440 | 453 |
441 this._searchableView.updateSearchMatchesCount(0); | 454 this._searchableView.updateSearchMatchesCount(0); |
442 | 455 |
443 delete this._currentSearchResultIndex; | 456 delete this._currentSearchResultIndex; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 treeOutline.domModel().redo(); | 725 treeOutline.domModel().redo(); |
713 event.handled = true; | 726 event.handled = true; |
714 } | 727 } |
715 } | 728 } |
716 | 729 |
717 if (WebInspector.isEditing() && event.keyCode !== WebInspector.KeyboardS
hortcut.Keys.F2.code) | 730 if (WebInspector.isEditing() && event.keyCode !== WebInspector.KeyboardS
hortcut.Keys.F2.code) |
718 return; | 731 return; |
719 | 732 |
720 var treeOutline = null; | 733 var treeOutline = null; |
721 for (var i = 0; i < this._treeOutlines.length; ++i) { | 734 for (var i = 0; i < this._treeOutlines.length; ++i) { |
722 if (this._treeOutlines[i].selectedDOMNode() === this._lastValidSelec
tedNode) | 735 if (this._treeOutlines[i].selectedDOMNode()) |
723 treeOutline = this._treeOutlines[i]; | 736 treeOutline = this._treeOutlines[i]; |
724 } | 737 } |
725 if (!treeOutline) | 738 if (!treeOutline) |
726 return; | 739 return; |
727 | 740 |
728 if (!treeOutline.editing()) { | 741 if (!treeOutline.editing()) { |
729 handleUndoRedo.call(null, treeOutline); | 742 handleUndoRedo.call(null, treeOutline); |
730 if (event.handled) { | 743 if (event.handled) { |
731 this._stylesWidget.forceUpdate(); | 744 this._stylesWidget.forceUpdate(); |
732 return; | 745 return; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 /** | 1121 /** |
1109 * @override | 1122 * @override |
1110 * @param {!WebInspector.DOMNode} node | 1123 * @param {!WebInspector.DOMNode} node |
1111 * @return {?{title: string, color: string}} | 1124 * @return {?{title: string, color: string}} |
1112 */ | 1125 */ |
1113 decorate: function(node) | 1126 decorate: function(node) |
1114 { | 1127 { |
1115 return { color: "orange", title: WebInspector.UIString("Element state: %
s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) }; | 1128 return { color: "orange", title: WebInspector.UIString("Element state: %
s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) }; |
1116 } | 1129 } |
1117 } | 1130 } |
OLD | NEW |