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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 var treeOutline = this._treeOutlines[i]; | 197 var treeOutline = this._treeOutlines[i]; |
198 treeOutline.updateSelection(); | 198 treeOutline.updateSelection(); |
199 treeOutline.setVisible(true); | 199 treeOutline.setVisible(true); |
200 | 200 |
201 if (!treeOutline.rootDOMNode) | 201 if (!treeOutline.rootDOMNode) |
202 if (treeOutline.domModel().existingDocument()) | 202 if (treeOutline.domModel().existingDocument()) |
203 this._documentUpdated(treeOutline.domModel(), treeOutline.do
mModel().existingDocument()); | 203 this._documentUpdated(treeOutline.domModel(), treeOutline.do
mModel().existingDocument()); |
204 else | 204 else |
205 treeOutline.domModel().requestDocument(); | 205 treeOutline.domModel().requestDocument(); |
206 } | 206 } |
207 WebInspector.context.setFlavor(WebInspector.ElementsPanel, this); | 207 |
208 }, | 208 }, |
209 | 209 |
210 willHide: function() | 210 willHide: function() |
211 { | 211 { |
212 for (var i = 0; i < this._treeOutlines.length; ++i) { | 212 for (var i = 0; i < this._treeOutlines.length; ++i) { |
213 var treeOutline = this._treeOutlines[i]; | 213 var treeOutline = this._treeOutlines[i]; |
214 treeOutline.domModel().hideDOMNodeHighlight(); | 214 treeOutline.domModel().hideDOMNodeHighlight(); |
215 treeOutline.setVisible(false); | 215 treeOutline.setVisible(false); |
216 // Detach heavy component on hide | 216 // Detach heavy component on hide |
217 this._contentElement.removeChild(treeOutline.element); | 217 this._contentElement.removeChild(treeOutline.element); |
218 } | 218 } |
219 this._popoverHelper.hidePopover(); | 219 this._popoverHelper.hidePopover(); |
220 WebInspector.Panel.prototype.willHide.call(this); | 220 WebInspector.Panel.prototype.willHide.call(this); |
221 WebInspector.context.setFlavor(WebInspector.ElementsPanel, null); | |
222 }, | 221 }, |
223 | 222 |
224 onResize: function() | 223 onResize: function() |
225 { | 224 { |
226 this._updateTreeOutlineVisibleWidth(); | 225 this._updateTreeOutlineVisibleWidth(); |
227 }, | 226 }, |
228 | 227 |
229 /** | 228 /** |
230 * @param {!WebInspector.DOMNode} node | 229 * @param {!WebInspector.DOMNode} node |
231 * @param {string} pseudoClass | 230 * @param {string} pseudoClass |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 { | 682 { |
684 var selectedDOMNode = this.selectedDOMNode(); | 683 var selectedDOMNode = this.selectedDOMNode(); |
685 if (!selectedDOMNode || !selectedDOMNode.target().cssModel.isEnabled()) | 684 if (!selectedDOMNode || !selectedDOMNode.target().cssModel.isEnabled()) |
686 return; | 685 return; |
687 | 686 |
688 this.sidebarPanes.styles.update(selectedDOMNode, true); | 687 this.sidebarPanes.styles.update(selectedDOMNode, true); |
689 this.sidebarPanes.metrics.setNode(selectedDOMNode); | 688 this.sidebarPanes.metrics.setNode(selectedDOMNode); |
690 this.sidebarPanes.platformFonts.setNode(selectedDOMNode); | 689 this.sidebarPanes.platformFonts.setNode(selectedDOMNode); |
691 }, | 690 }, |
692 | 691 |
693 _undo: function() | |
694 { | |
695 var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode); | |
696 if (!treeOutline || WebInspector.isEditing()) | |
697 return; | |
698 treeOutline.target().domModel.undo(this._updateSidebars.bind(this)); | |
699 }, | |
700 | |
701 _redo: function() | |
702 { | |
703 var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode); | |
704 if (!treeOutline || WebInspector.isEditing()) | |
705 return; | |
706 treeOutline.target().domModel.redo(this._updateSidebars.bind(this)); | |
707 }, | |
708 | |
709 /** | 692 /** |
710 * @param {!KeyboardEvent} event | 693 * @param {!KeyboardEvent} event |
711 */ | 694 */ |
712 handleShortcut: function(event) | 695 handleShortcut: function(event) |
713 { | 696 { |
714 var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode); | 697 /** |
| 698 * @param {!WebInspector.ElementsTreeOutline} treeOutline |
| 699 * @this {WebInspector.ElementsPanel} |
| 700 */ |
| 701 function handleUndoRedo(treeOutline) |
| 702 { |
| 703 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !even
t.shiftKey && event.keyIdentifier === "U+005A") { // Z key |
| 704 treeOutline.target().domModel.undo(this._updateSidebars.bind(thi
s)); |
| 705 event.handled = true; |
| 706 return; |
| 707 } |
| 708 |
| 709 var isRedoKey = WebInspector.isMac() ? event.metaKey && event.shiftK
ey && event.keyIdentifier === "U+005A" : // Z key |
| 710 event.ctrlKey && event.keyIde
ntifier === "U+0059"; // Y key |
| 711 if (isRedoKey) { |
| 712 treeOutline.target().domModel.redo(this._updateSidebars.bind(thi
s)); |
| 713 event.handled = true; |
| 714 } |
| 715 } |
| 716 |
| 717 var treeOutline = null; |
| 718 for (var i = 0; i < this._treeOutlines.length; ++i) { |
| 719 if (this._treeOutlines[i].selectedDOMNode() === this._lastValidSelec
tedNode) |
| 720 treeOutline = this._treeOutlines[i]; |
| 721 } |
715 if (!treeOutline) | 722 if (!treeOutline) |
716 return; | 723 return; |
717 | 724 |
| 725 if (!treeOutline.editing()) { |
| 726 handleUndoRedo.call(this, treeOutline); |
| 727 if (event.handled) |
| 728 return; |
| 729 } |
| 730 |
718 treeOutline.handleShortcut(event); | 731 treeOutline.handleShortcut(event); |
719 if (event.handled) | 732 if (event.handled) |
720 return; | 733 return; |
721 | 734 |
722 WebInspector.Panel.prototype.handleShortcut.call(this, event); | 735 WebInspector.Panel.prototype.handleShortcut.call(this, event); |
723 }, | 736 }, |
724 | 737 |
725 /** | 738 /** |
726 * @param {?WebInspector.DOMNode} node | 739 * @param {?WebInspector.DOMNode} node |
727 * @return {?WebInspector.ElementsTreeOutline} | 740 * @return {?WebInspector.ElementsTreeOutline} |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 | 1104 |
1092 WebInspector.ElementsPanelFactory.prototype = { | 1105 WebInspector.ElementsPanelFactory.prototype = { |
1093 /** | 1106 /** |
1094 * @return {!WebInspector.Panel} | 1107 * @return {!WebInspector.Panel} |
1095 */ | 1108 */ |
1096 createPanel: function() | 1109 createPanel: function() |
1097 { | 1110 { |
1098 return WebInspector.ElementsPanel.instance(); | 1111 return WebInspector.ElementsPanel.instance(); |
1099 } | 1112 } |
1100 } | 1113 } |
1101 | |
1102 /** | |
1103 * @constructor | |
1104 * @implements {WebInspector.ActionDelegate} | |
1105 */ | |
1106 WebInspector.ElementsPanel.UndoActionDelegate = function() | |
1107 { | |
1108 } | |
1109 | |
1110 WebInspector.ElementsPanel.UndoActionDelegate.prototype = { | |
1111 /** | |
1112 * @return {boolean} | |
1113 */ | |
1114 handleAction: function() | |
1115 { | |
1116 var panel = WebInspector.ElementsPanel.instance(); | |
1117 panel._undo(); | |
1118 return true; | |
1119 } | |
1120 } | |
1121 | |
1122 /** | |
1123 * @constructor | |
1124 * @implements {WebInspector.ActionDelegate} | |
1125 */ | |
1126 WebInspector.ElementsPanel.RedoActionDelegate = function() | |
1127 { | |
1128 } | |
1129 | |
1130 WebInspector.ElementsPanel.RedoActionDelegate.prototype = { | |
1131 /** | |
1132 * @return {boolean} | |
1133 */ | |
1134 handleAction: function() | |
1135 { | |
1136 var panel = WebInspector.ElementsPanel.instance(); | |
1137 panel._redo(); | |
1138 return true; | |
1139 } | |
1140 } | |
1141 | |
OLD | NEW |