Changeset 51946 in webkit
- Timestamp:
- Dec 10, 2009 4:53:42 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r51945 r51946 1 2009-12-10 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: Add context menu actions for DOM tree. 6 7 https://bugs.webkit.org/show_bug.cgi?id=32348 8 9 * English.lproj/localizedStrings.js: 10 * inspector/front-end/ContextMenu.js: 11 (WebInspector.ContextMenu): 12 (WebInspector.ContextMenu.prototype.show): 13 (WebInspector.ContextMenu.prototype.appendItem): 14 (WebInspector.ContextMenu.prototype.appendSeparator): 15 (WebInspector.ContextMenu.prototype._itemSelected): 16 (WebInspector.contextMenuItemSelected): 17 (WebInspector.contextMenuCleared): 18 * inspector/front-end/ElementsTreeOutline.js: 19 (WebInspector.ElementsTreeOutline.prototype._onmouseout): 20 (WebInspector.ElementsTreeOutline.prototype.populateContextMenu): 21 (WebInspector.ElementsTreeElement.prototype.ondblclick): 22 (WebInspector.ElementsTreeElement.prototype._startEditingFromEvent): 23 (WebInspector.ElementsTreeElement.prototype._populateTagContextMenu): 24 (WebInspector.ElementsTreeElement.prototype._populateTextContextMenu): 25 (WebInspector.ElementsTreeElement.prototype._startEditing): 26 (WebInspector.ElementsTreeElement.prototype._addNewAttribute): 27 * inspector/front-end/ObjectPropertiesSection.js: 28 (WebInspector.ObjectPropertyTreeElement.prototype.ondblclick): 29 * inspector/front-end/ResourceView.js: 30 (WebInspector.ResourceView.prototype._toggleURLdecoding): 31 * inspector/front-end/ResourcesPanel.js: 32 (WebInspector.ResourceSidebarTreeElement.prototype.ondblclick): 33 * inspector/front-end/StylesSidebarPane.js: 34 (WebInspector.StylePropertyTreeElement.prototype): 35 * inspector/front-end/inspector.js: 36 (WebInspector.contextMenuEventFired): 37 * inspector/front-end/treeoutline.js: 38 (TreeElement.treeElementDoubleClicked): 39 1 40 2009-12-09 Nikolas Zimmermann <nzimmermann@rim.com> 2 41 -
trunk/WebCore/inspector/front-end/ContextMenu.js
r51839 r51946 32 32 this._items = []; 33 33 this._handlers = {}; 34 this._appendItem(WebInspector.UIString("Edit as HTML"), this._noop.bind(this));35 this._appendItem(WebInspector.UIString("Add attribute"), this._noop.bind(this));36 this._appendSeparator();37 this._appendItem(WebInspector.UIString("Copy"), this._copy.bind(this));38 this._appendItem(WebInspector.UIString("Delete"), this._delete.bind(this));39 34 } 40 35 … … 42 37 show: function(event) 43 38 { 44 // FIXME: Uncomment when popup menu has meaningful items. 45 // InspectorFrontendHost.showContextMenu(event, this._items); 46 // event.preventDefault(); 39 // Remove trailing separator. 40 while (this._items.length > 0 && !("id" in this._items[this._items.length - 1])) 41 this._items.splice(this._items.length - 1, 1); 42 43 if (this._items.length) { 44 WebInspector._contextMenu = this; 45 InspectorFrontendHost.showContextMenu(event, this._items); 46 } 47 47 }, 48 48 49 _appendItem: function(label, handler)49 appendItem: function(label, handler) 50 50 { 51 51 var id = this._items.length; … … 54 54 }, 55 55 56 _appendSeparator: function()56 appendSeparator: function() 57 57 { 58 // No separator dupes allowed. 59 if (this._items.length === 0) 60 return; 61 if (!("id" in this._items[this._items.length - 1])) 62 return; 58 63 this._items.push({}); 59 64 }, 60 65 61 itemSelected: function(id)66 _itemSelected: function(id) 62 67 { 63 68 if (this._handlers[id]) 64 69 this._handlers[id].call(this); 65 },66 67 _copy: function()68 {69 console.log("context menu: copy");70 },71 72 _delete: function()73 {74 console.log("context menu: delete");75 },76 77 _noop: function()78 {79 console.log("context menu: noop");80 70 } 81 71 } 82 72 83 84 73 WebInspector.contextMenuItemSelected = function(id) 85 74 { 86 if (WebInspector. contextMenu)87 WebInspector. contextMenu.itemSelected(id);75 if (WebInspector._contextMenu) 76 WebInspector._contextMenu._itemSelected(id); 88 77 } 89 78 90 79 WebInspector.contextMenuCleared = function() 91 80 { 92 console.log("context menu: cleared"); 81 // FIXME: Unfortunately, contextMenuCleared is invoked between show and item selected 82 // so we can't delete last menu object from WebInspector. Fix the contract. 93 83 } -
trunk/WebCore/inspector/front-end/ElementsTreeOutline.js
r51559 r51946 42 42 this.rootDOMNode = null; 43 43 this.focusedDOMNode = null; 44 45 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true); 44 46 } 45 47 … … 260 262 261 263 WebInspector.hoveredDOMNode = null; 264 }, 265 266 _contextMenuEventFired: function(event) 267 { 268 var listItem = event.target.enclosingNodeOrSelfWithNodeName("LI"); 269 if (!listItem || !listItem.treeElement) 270 return; 271 272 var contextMenu = new WebInspector.ContextMenu(); 273 274 var tag = event.target.enclosingNodeOrSelfWithClass("webkit-html-tag"); 275 var textNode = event.target.enclosingNodeOrSelfWithClass("webkit-html-text-node"); 276 if (tag) 277 listItem.treeElement._populateTagContextMenu(contextMenu, event); 278 else if (textNode) 279 listItem.treeElement._populateTextContextMenu(contextMenu, textNode); 280 contextMenu.show(event); 262 281 } 263 282 } … … 550 569 }, 551 570 552 ondblclick: function( treeElement,event)571 ondblclick: function(event) 553 572 { 554 573 if (this._editing) 555 574 return; 556 575 557 if (this._startEditingFromEvent(event , treeElement))576 if (this._startEditingFromEvent(event)) 558 577 return; 559 578 … … 577 596 }, 578 597 579 _startEditingFromEvent: function(event , treeElement)598 _startEditingFromEvent: function(event) 580 599 { 581 600 if (this.treeOutline.focusedDOMNode != this.representedObject) … … 595 614 var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attribute"); 596 615 if (newAttribute) 597 return this._addNewAttribute( treeElement.listItemElement);616 return this._addNewAttribute(); 598 617 599 618 return false; 619 }, 620 621 _populateTagContextMenu: function(contextMenu, event) 622 { 623 var attribute = event.target.enclosingNodeOrSelfWithClass("webkit-html-attribute"); 624 var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attribute"); 625 626 // Add attribute-related actions. 627 contextMenu.appendItem(WebInspector.UIString("Add Attribute"), this._addNewAttribute.bind(this)); 628 if (attribute && !newAttribute) 629 contextMenu.appendItem(WebInspector.UIString("Edit Attribute"), this._startEditingAttribute.bind(this, attribute, event.target)); 630 contextMenu.appendSeparator(); 631 632 // Add node-related actions. 633 contextMenu.appendItem(WebInspector.UIString("Delete Node"), this.remove.bind(this)); 634 }, 635 636 _populateTextContextMenu: function(contextMenu, textNode) 637 { 638 contextMenu.appendItem(WebInspector.UIString("Edit Text"), this._startEditingTextNode.bind(this, textNode)); 600 639 }, 601 640 … … 613 652 return this._startEditingAttribute(attribute, attribute.getElementsByClassName("webkit-html-attribute-value")[0]); 614 653 615 return this._addNewAttribute( listItem);654 return this._addNewAttribute(); 616 655 } 617 656 … … 624 663 }, 625 664 626 _addNewAttribute: function( listItemElement)665 _addNewAttribute: function() 627 666 { 628 667 var attr = document.createElement("span"); … … 638 677 attr.appendChild(value); 639 678 640 var tag = listItemElement.getElementsByClassName("webkit-html-tag")[0];679 var tag = this.listItemElement.getElementsByClassName("webkit-html-tag")[0]; 641 680 this._insertInLastAttributePosition(tag, attr); 642 681 return this._startEditingAttribute(attr, attr); -
trunk/WebCore/inspector/front-end/ObjectPropertiesSection.js
r48431 r51946 151 151 }, 152 152 153 ondblclick: function(e lement, event)153 ondblclick: function(event) 154 154 { 155 155 this.startEditing(); -
trunk/WebCore/inspector/front-end/ResourceView.js
r49938 r51946 249 249 }, 250 250 251 _toggleURLdecoding: function( treeElement,event)251 _toggleURLdecoding: function(event) 252 252 { 253 253 this._decodeRequestParameters = !this._decodeRequestParameters; -
trunk/WebCore/inspector/front-end/ResourcesPanel.js
r51528 r51946 968 968 }, 969 969 970 ondblclick: function( treeElement,event)970 ondblclick: function(event) 971 971 { 972 972 InjectedScriptAccess.openInInspectedWindow(this.resource.url, function() {}); -
trunk/WebCore/inspector/front-end/StylesSidebarPane.js
r51528 r51946 1099 1099 }, 1100 1100 1101 ondblclick: function(e lement, event)1101 ondblclick: function(event) 1102 1102 { 1103 1103 this.startEditing(event.target); -
trunk/WebCore/inspector/front-end/inspector.js
r51846 r51946 761 761 if (event.handled || event.target.hasStyleClass("popup-glasspane")) 762 762 event.preventDefault(); 763 764 if (!this.contextMenu)765 this.contextMenu = new WebInspector.ContextMenu();766 this.contextMenu.show(event);767 763 } 768 764 -
trunk/WebCore/inspector/front-end/treeoutline.js
r47725 r51946 625 625 626 626 if (element.treeElement.ondblclick) 627 element.treeElement.ondblclick (element.treeElement, event);627 element.treeElement.ondblclick.call(element.treeElement, event); 628 628 else if (element.treeElement.hasChildren && !element.treeElement.expanded) 629 629 element.treeElement.expand();
Note: See TracChangeset
for help on using the changeset viewer.