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 | 207 WebInspector.context.setFlavor(WebInspector.ElementsPanel, this); |
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); | |
221 }, | 222 }, |
222 | 223 |
223 onResize: function() | 224 onResize: function() |
224 { | 225 { |
225 this._updateTreeOutlineVisibleWidth(); | 226 this._updateTreeOutlineVisibleWidth(); |
226 }, | 227 }, |
227 | 228 |
228 /** | 229 /** |
229 * @param {!WebInspector.DOMNode} node | 230 * @param {!WebInspector.DOMNode} node |
230 * @param {string} pseudoClass | 231 * @param {string} pseudoClass |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 { | 683 { |
683 var selectedDOMNode = this.selectedDOMNode(); | 684 var selectedDOMNode = this.selectedDOMNode(); |
684 if (!selectedDOMNode || !selectedDOMNode.target().cssModel.isEnabled()) | 685 if (!selectedDOMNode || !selectedDOMNode.target().cssModel.isEnabled()) |
685 return; | 686 return; |
686 | 687 |
687 this.sidebarPanes.styles.update(selectedDOMNode, true); | 688 this.sidebarPanes.styles.update(selectedDOMNode, true); |
688 this.sidebarPanes.metrics.setNode(selectedDOMNode); | 689 this.sidebarPanes.metrics.setNode(selectedDOMNode); |
689 this.sidebarPanes.platformFonts.setNode(selectedDOMNode); | 690 this.sidebarPanes.platformFonts.setNode(selectedDOMNode); |
690 }, | 691 }, |
691 | 692 |
693 _undo: function() | |
694 { | |
695 var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode); | |
696 if (!treeOutline) | |
697 return; | |
698 if (treeOutline.editing()) | |
apavlov
2014/11/07 17:24:49
You should also check that no sidebar is being edi
| |
699 return; | |
700 treeOutline.target().domModel.undo(this._updateSidebars.bind(this)); | |
701 }, | |
702 | |
703 _redo: function() | |
704 { | |
705 var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode); | |
706 if (!treeOutline) | |
707 return; | |
708 if (treeOutline.editing()) | |
apavlov
2014/11/07 17:24:49
ditto
| |
709 return; | |
710 treeOutline.target().domModel.redo(this._updateSidebars.bind(this)); | |
711 }, | |
712 | |
692 /** | 713 /** |
693 * @param {!KeyboardEvent} event | 714 * @param {!KeyboardEvent} event |
694 */ | 715 */ |
695 handleShortcut: function(event) | 716 handleShortcut: function(event) |
696 { | 717 { |
697 /** | 718 var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode); |
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 } | |
722 if (!treeOutline) | 719 if (!treeOutline) |
723 return; | 720 return; |
724 | 721 |
725 if (!treeOutline.editing()) { | |
726 handleUndoRedo.call(this, treeOutline); | |
727 if (event.handled) | |
728 return; | |
729 } | |
730 | |
731 treeOutline.handleShortcut(event); | 722 treeOutline.handleShortcut(event); |
732 if (event.handled) | 723 if (event.handled) |
733 return; | 724 return; |
734 | 725 |
735 WebInspector.Panel.prototype.handleShortcut.call(this, event); | 726 WebInspector.Panel.prototype.handleShortcut.call(this, event); |
736 }, | 727 }, |
737 | 728 |
738 /** | 729 /** |
739 * @param {?WebInspector.DOMNode} node | 730 * @param {?WebInspector.DOMNode} node |
740 * @return {?WebInspector.ElementsTreeOutline} | 731 * @return {?WebInspector.ElementsTreeOutline} |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1104 | 1095 |
1105 WebInspector.ElementsPanelFactory.prototype = { | 1096 WebInspector.ElementsPanelFactory.prototype = { |
1106 /** | 1097 /** |
1107 * @return {!WebInspector.Panel} | 1098 * @return {!WebInspector.Panel} |
1108 */ | 1099 */ |
1109 createPanel: function() | 1100 createPanel: function() |
1110 { | 1101 { |
1111 return WebInspector.ElementsPanel.instance(); | 1102 return WebInspector.ElementsPanel.instance(); |
1112 } | 1103 } |
1113 } | 1104 } |
1105 | |
1106 /** | |
1107 * @constructor | |
1108 * @implements {WebInspector.ActionDelegate} | |
1109 */ | |
1110 WebInspector.ElementsPanel.UndoActionDelegate = function() | |
1111 { | |
1112 } | |
1113 | |
1114 WebInspector.ElementsPanel.UndoActionDelegate.prototype = { | |
1115 /** | |
1116 * @return {boolean} | |
1117 */ | |
1118 handleAction: function() | |
1119 { | |
1120 var panel = WebInspector.ElementsPanel.instance(); | |
1121 panel._undo(); | |
1122 return true; | |
1123 } | |
1124 } | |
1125 | |
1126 /** | |
1127 * @constructor | |
1128 * @implements {WebInspector.ActionDelegate} | |
1129 */ | |
1130 WebInspector.ElementsPanel.RedoActionDelegate = function() | |
1131 { | |
1132 } | |
1133 | |
1134 WebInspector.ElementsPanel.RedoActionDelegate.prototype = { | |
1135 /** | |
1136 * @return {boolean} | |
1137 */ | |
1138 handleAction: function() | |
1139 { | |
1140 var panel = WebInspector.ElementsPanel.instance(); | |
1141 panel._redo(); | |
1142 return true; | |
1143 } | |
1144 } | |
1145 | |
OLD | NEW |