Changeset 49709 in webkit
- Timestamp:
- Oct 16, 2009 5:08:50 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r49706 r49709 1 2009-10-15 Joseph Pecoraro <joepeck@webkit.org> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: Handle the Enter Key in the Elements Tree Hierarchy 6 https://bugs.webkit.org/show_bug.cgi?id=30428 7 8 TextNode => Edit Text Node 9 Has Attributes => Edit First Attribute 10 No Attributes => Start Editing New Attribute 11 12 * inspector/front-end/ElementsTreeOutline.js: 13 (WebInspector.ElementsTreeOutline.prototype.handleKeyEvent): handle the "Enter" key 14 (WebInspector.ElementsTreeElement.prototype.set hovered): only add new attribute button on nodes with attributes 15 (WebInspector.ElementsTreeElement.prototype._addNewAttribute): prevent moving backwards where there are no attributes 16 (WebInspector.ElementsTreeElement.prototype._startEditingFromEvent): renamed to be clearer 17 (WebInspector.ElementsTreeElement.prototype._startEditing): transition to the appropriate edit state for a tree element 18 1 19 2009-10-16 Adam Barth <abarth@webkit.org> 2 20 -
trunk/WebCore/inspector/front-end/ElementsTreeOutline.js
r49506 r49709 189 189 { 190 190 var selectedElement = this.selectedTreeElement; 191 192 191 if (!selectedElement) 193 192 return; 194 195 if (event.keyCode == 8 || event.keyCode == 46) {196 // Delete or backspace pressed, delete the node.193 194 // Delete or backspace pressed, delete the node. 195 if (event.keyCode === 8 || event.keyCode === 46) { 197 196 selectedElement.remove(); 198 197 return; 199 198 } 200 199 200 // On Enter or Return start editing the first attribute 201 // or create a new attribute on the selected element. 202 if (event.keyIdentifier === "Enter") { 203 if (this._editing) 204 return; 205 206 selectedElement._startEditing(); 207 208 // prevent a newline from being immediately inserted 209 event.preventDefault(); 210 return; 211 } 212 201 213 TreeOutline.prototype.handleKeyEvent.call(this, event); 202 214 }, … … 296 308 this.updateSelection(); 297 309 this.listItemElement.addStyleClass("hovered"); 298 this._pendingToggleNewAttribute = setTimeout(this.toggleNewAttributeButton.bind(this, true), 500); 310 if (this._canAddAttributes) 311 this._pendingToggleNewAttribute = setTimeout(this.toggleNewAttributeButton.bind(this, true), 500); 299 312 } else { 300 313 this.listItemElement.removeStyleClass("hovered"); … … 507 520 return; 508 521 509 if (this._startEditing (event, treeElement))522 if (this._startEditingFromEvent(event, treeElement)) 510 523 return; 511 524 … … 532 545 }, 533 546 534 _startEditing : function(event, treeElement)547 _startEditingFromEvent: function(event, treeElement) 535 548 { 536 549 if (this.treeOutline.focusedDOMNode != this.representedObject) … … 553 566 554 567 return false; 568 }, 569 570 _startEditing: function() 571 { 572 if (this.treeOutline.focusedDOMNode !== this.representedObject) 573 return; 574 575 var listItem = this._listItemNode; 576 577 if (this._canAddAttributes) { 578 this.toggleNewAttributeButton(false); 579 var attribute = listItem.getElementsByClassName("webkit-html-attribute")[0]; 580 if (attribute) 581 return this._startEditingAttribute(attribute, attribute.getElementsByClassName("webkit-html-attribute-name")[0]); 582 583 return this._addNewAttribute(listItem); 584 } 585 586 if (this.representedObject.nodeType === Node.TEXT_NODE) { 587 var textNode = listItem.getElementsByClassName("webkit-html-text-node")[0]; 588 if (textNode) 589 return this._startEditingTextNode(textNode); 590 return; 591 } 555 592 }, 556 593 … … 662 699 } 663 700 664 if (!found && moveDirection === "backward" )701 if (!found && moveDirection === "backward" && attributes.length > 0) 665 702 moveToAttribute = attributes[attributes.length - 1].name; 666 703 else if (!found && moveDirection === "forward" && !/^\s*$/.test(newText))
Note: See TracChangeset
for help on using the changeset viewer.