Changeset 56684 in webkit
- Timestamp:
- Mar 28, 2010 1:49:52 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56683 r56684 1 2010-03-27 Joseph Pecoraro <joepeck@webkit.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Edit Tag Names 6 https://bugs.webkit.org/show_bug.cgi?id=36481 7 8 Allow tabbing back and forth between the tag name and element 9 attributes when editing. Also, fixed a number of minor issues with 10 editing attributes and tabbing. 11 12 * inspector/front-end/ElementsTreeOutline.js: 13 (WebInspector.ElementsTreeElement.prototype._startEditingTagName): find the tag name if it wasn't provided. 14 (WebInspector.ElementsTreeElement.prototype._attributeEditingCommitted): fix tabbing issues, enable tab to tag name. 15 (WebInspector.ElementsTreeElement.prototype._attributeEditingCommitted.regenerateStyledAttribute): cleanup styles when tabbing. 16 * inspector/front-end/inspector.css: do not display <br>s while editing 17 1 18 2010-03-27 Joseph Pecoraro <joepeck@webkit.org> 2 19 -
trunk/WebCore/inspector/front-end/ElementsTreeOutline.js
r56683 r56684 811 811 812 812 if (elem.hasStyleClass("webkit-html-attribute-value")) 813 return this._startEditingAttribute( attributeElements[i].parentNode, elem);813 return this._startEditingAttribute(elem.parentNode, elem); 814 814 } 815 815 } … … 868 868 _startEditingTagName: function(tagNameElement) 869 869 { 870 if (!tagNameElement) { 871 tagNameElement = this.listItemElement.getElementsByClassName("webkit-html-tag-name")[0]; 872 if (!tagNameElement) 873 return false; 874 } 875 870 876 if (WebInspector.isBeingEdited(tagNameElement)) 871 877 return true; … … 960 966 // Before we do anything, determine where we should move 961 967 // next based on the current element's settings 962 var moveToAttribute; 963 var newAttribute; 968 var moveToAttribute, moveToTagName, moveToNewAttribute; 964 969 if (moveDirection) { 965 970 var found = false; 971 972 // Search for the attribute's position, and then decide where to move to. 966 973 var attributes = this.representedObject.attributes; 967 for (var i = 0 , len = attributes.length; i < len; ++i) {974 for (var i = 0; i < attributes.length; ++i) { 968 975 if (attributes[i].name === attributeName) { 969 976 found = true; 970 if (moveDirection === "backward" && i > 0) 971 moveToAttribute = attributes[i - 1].name; 972 else if (moveDirection === "forward" && i < attributes.length - 1) 973 moveToAttribute = attributes[i + 1].name; 974 else if (moveDirection === "forward" && i === attributes.length - 1) 975 newAttribute = true; 977 if (moveDirection === "backward") { 978 if (i === 0) 979 moveToTagName = true; 980 else 981 moveToAttribute = attributes[i - 1].name; 982 } else if (moveDirection === "forward") { 983 if (i === attributes.length - 1) 984 moveToNewAttribute = true; 985 else 986 moveToAttribute = attributes[i + 1].name; 987 } 976 988 } 977 989 } 978 990 979 if (!found && moveDirection === "backward" && attributes.length > 0) 980 moveToAttribute = attributes[attributes.length - 1].name; 981 else if (!found && moveDirection === "forward" && !/^\s*$/.test(newText)) 982 newAttribute = true; 983 } 984 985 function moveToNextAttributeIfNeeded() { 991 // Moving From the "New Attribute" position. 992 if (!found) { 993 if (moveDirection === "backward" && attributes.length > 0) 994 moveToAttribute = attributes[attributes.length - 1].name; 995 else if (moveDirection === "forward" && !/^\s*$/.test(newText)) 996 moveToNewAttribute = true; 997 } 998 } 999 1000 function moveToNextAttributeIfNeeded() 1001 { 1002 // Cleanup empty new attribute sections. 1003 if (element.textContent.trim().length === 0) 1004 element.parentNode.removeChild(element); 1005 1006 // Make the move. 986 1007 if (moveToAttribute) 987 1008 this._triggerEditAttribute(moveToAttribute); 988 else if ( newAttribute)1009 else if (moveToNewAttribute) 989 1010 this._addNewAttribute(); 1011 else if (moveToTagName) 1012 this._startEditingTagName(); 1013 } 1014 1015 function regenerateStyledAttribute(name, value) 1016 { 1017 var previous = element.previousSibling; 1018 if (!previous || previous.nodeType !== Node.TEXT_NODE) 1019 element.parentNode.insertBefore(document.createTextNode(" "), element); 1020 element.outerHTML = "<span class=\"webkit-html-attribute\">" + 1021 "<span class=\"webkit-html-attribute-name\">" + attr.name.escapeHTML() + "</span>=​\"" + 1022 "<span class=\"webkit-html-attribute-value\">" + attr.value.escapeHTML() + "</span>​\"" + 1023 "</span>"; 990 1024 } 991 1025 … … 1012 1046 try { 1013 1047 this.representedObject.setAttribute(attr.name, attr.value); 1048 regenerateStyledAttribute(attr.name, attr.value); 1014 1049 } catch(e) {} // ignore invalid attribute (innerHTML doesn't throw errors, but this can) 1015 1050 } -
trunk/WebCore/inspector/front-end/inspector.css
r56664 r56684 1498 1498 } 1499 1499 1500 .editing br { 1501 display: none; 1502 } 1503 1500 1504 .elements-tree-editor { 1501 1505 -webkit-user-select: text;
Note: See TracChangeset
for help on using the changeset viewer.