Changeset 52556 in webkit
- Timestamp:
- Dec 25, 2009 6:24:07 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52555 r52556 1 2009-12-25 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: Implement Edit Inner HTML action. 6 7 https://bugs.webkit.org/show_bug.cgi?id=32924 8 9 * English.lproj/localizedStrings.js: 10 * bindings/js/JSInjectedScriptHostCustom.cpp: 11 (WebCore::JSInjectedScriptHost::pushNodePathToFrontend): 12 * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: 13 (WebCore::V8InjectedScriptHost::pushNodePathToFrontendCallback): 14 * inspector/InjectedScriptHost.cpp: 15 (WebCore::InjectedScriptHost::pushNodePathToFrontend): 16 * inspector/InjectedScriptHost.h: 17 * inspector/InjectedScriptHost.idl: 18 * inspector/InspectorDOMAgent.h: 19 * inspector/front-end/ElementsPanel.js: 20 (WebInspector.ElementsPanel.prototype.show): 21 (WebInspector.ElementsPanel.prototype._updateModifiedNodesSoon): 22 (WebInspector.ElementsPanel.prototype.updateModifiedNodes): 23 * inspector/front-end/ElementsTreeOutline.js: 24 (WebInspector.ElementsTreeElement.prototype._populateTagContextMenu): 25 (WebInspector.ElementsTreeElement.prototype._startEditingAsHTML.commit): 26 (WebInspector.ElementsTreeElement.prototype._startEditingAsHTML.dispose): 27 (WebInspector.ElementsTreeElement.prototype._startEditingAsHTML): 28 (): 29 * inspector/front-end/InjectedScript.js: 30 (InjectedScript.getNodePropertyValue): 31 (InjectedScript.setOuterHTML): 32 (InjectedScript.performSearch.addNodesToResults): 33 (InjectedScript._inspectObject): 34 (InjectedScript._copy): 35 (InjectedScript.pushNodeToFrontend): 36 * inspector/front-end/InjectedScriptAccess.js: 37 * inspector/front-end/InspectorFrontendHostStub.js: 38 (.WebInspector.InspectorFrontendHostStub.prototype.hiddenPanels): 39 (.WebInspector.InspectorFrontendHostStub.prototype.windowUnloading): 40 * inspector/front-end/inspector.css: 41 * inspector/front-end/inspector.js: 42 (WebInspector.startEditing.keyDownEventListener): 43 (WebInspector.startEditing): 44 1 45 2009-12-24 Dan Bernstein <mitz@apple.com> 2 46 -
trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
r51528 r52556 163 163 JSValue JSInjectedScriptHost::pushNodePathToFrontend(ExecState* exec, const ArgList& args) 164 164 { 165 if (args.size() < 2)165 if (args.size() < 3) 166 166 return jsUndefined(); 167 167 … … 174 174 return jsUndefined(); 175 175 176 bool selectInUI = args.at(1).toBoolean(exec); 177 return jsNumber(exec, impl()->pushNodePathToFrontend(node, selectInUI)); 176 bool withChildren = args.at(1).toBoolean(exec); 177 bool selectInUI = args.at(2).toBoolean(exec); 178 return jsNumber(exec, impl()->pushNodePathToFrontend(node, withChildren, selectInUI)); 178 179 } 179 180 -
trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
r52459 r52556 105 105 { 106 106 INC_STATS("InjectedScriptHost.pushNodePathToFrontend()"); 107 if (args.Length() < 2)107 if (args.Length() < 3) 108 108 return v8::Undefined(); 109 109 110 110 InjectedScriptHost* host = V8DOMWrapper::convertToNativeObject<InjectedScriptHost>(V8ClassIndex::INJECTEDSCRIPTHOST, args.Holder()); 111 111 Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); 112 bool selectInUI = args[1]->ToBoolean()->Value(); 112 bool withChildren = args[1]->ToBoolean()->Value(); 113 bool selectInUI = args[2]->ToBoolean()->Value(); 113 114 if (node) 114 return v8::Number::New(host->pushNodePathToFrontend(node, selectInUI));115 return v8::Number::New(host->pushNodePathToFrontend(node, withChildren, selectInUI)); 115 116 116 117 return v8::Undefined(); -
trunk/WebCore/inspector/InjectedScriptHost.cpp
r52545 r52556 112 112 } 113 113 114 long InjectedScriptHost::pushNodePathToFrontend(Node* node, bool selectInUI)114 long InjectedScriptHost::pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI) 115 115 { 116 116 InspectorFrontend* frontend = inspectorFrontend(); … … 119 119 return 0; 120 120 long id = domAgent->pushNodePathToFrontend(node); 121 if (withChildren) 122 domAgent->pushChildNodesToFrontend(id); 121 123 if (selectInUI) 122 124 frontend->updateFocusedNode(id); -
trunk/WebCore/inspector/InjectedScriptHost.h
r52545 r52556 65 65 ScriptValue wrapObject(const ScriptValue& object, const String& objectGroup); 66 66 ScriptValue unwrapObject(const String& objectId); 67 long pushNodePathToFrontend(Node* node, bool selectInUI);67 long pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI); 68 68 69 69 void addNodesToSearchResult(const String& nodeIds); -
trunk/WebCore/inspector/InjectedScriptHost.idl
r52545 r52556 41 41 [Custom] long wrapObject(in DOMObject object, in DOMString objectGroup); 42 42 [Custom] DOMObject unwrapObject(in long objectId); 43 [Custom] int pushNodePathToFrontend(in DOMObject node, in boolean selectInUI);43 [Custom] int pushNodePathToFrontend(in DOMObject node, in boolean withChildren, in boolean selectInUI); 44 44 45 45 void addNodesToSearchResult(in DOMString nodeIds); -
trunk/WebCore/inspector/InspectorDOMAgent.h
r51601 r52556 102 102 Node* nodeForPath(const String& path); 103 103 long pushNodePathToFrontend(Node* node); 104 void pushChildNodesToFrontend(long nodeId); 104 105 105 106 private: … … 114 115 115 116 bool pushDocumentToFrontend(); 116 void pushChildNodesToFrontend(long nodeId);117 117 118 118 ScriptObject buildObjectForNode(Node* node, int depth, NodeToIdMap* nodesMap); -
trunk/WebCore/inspector/front-end/ElementsPanel.js
r52203 r52556 147 147 this.treeOutline.updateSelection(); 148 148 if (this.recentlyModifiedNodes.length) 149 this. _updateModifiedNodes();149 this.updateModifiedNodes(); 150 150 }, 151 151 … … 492 492 if ("_updateModifiedNodesTimeout" in this) 493 493 return; 494 this._updateModifiedNodesTimeout = setTimeout(this. _updateModifiedNodes.bind(this), 0);495 }, 496 497 _updateModifiedNodes: function()494 this._updateModifiedNodesTimeout = setTimeout(this.updateModifiedNodes.bind(this), 0); 495 }, 496 497 updateModifiedNodes: function() 498 498 { 499 499 if ("_updateModifiedNodesTimeout" in this) { -
trunk/WebCore/inspector/front-end/ElementsTreeOutline.js
r52440 r52556 604 604 605 605 // Add node-related actions. 606 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), this._editAsHTML.bind(this)); 606 607 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copyHTML.bind(this)); 607 608 contextMenu.appendItem(WebInspector.UIString("Delete Node"), this.remove.bind(this)); … … 718 719 719 720 return true; 721 }, 722 723 _startEditingAsHTML: function(commitCallback, initialValue) 724 { 725 if (this._htmlEditElement && WebInspector.isBeingEdited(this._htmlEditElement)) 726 return true; 727 728 this._editing = true; 729 730 this._htmlEditElement = document.createElement("div"); 731 this._htmlEditElement.className = "source-code elements-tree-editor"; 732 this._htmlEditElement.textContent = initialValue; 733 734 // Hide header items. 735 var child = this.listItemElement.firstChild; 736 while (child) { 737 child.style.display = "none"; 738 child = child.nextSibling; 739 } 740 // Hide children item. 741 if (this._childrenListNode) 742 this._childrenListNode.style.display = "none"; 743 // Append editor. 744 this.listItemElement.appendChild(this._htmlEditElement); 745 746 this.updateSelection(); 747 748 function commit() 749 { 750 commitCallback(this._htmlEditElement.textContent); 751 dispose.call(this); 752 } 753 754 function dispose() 755 { 756 delete this._editing; 757 758 // Remove editor. 759 this.listItemElement.removeChild(this._htmlEditElement); 760 delete this._htmlEditElement; 761 // Unhide children item. 762 if (this._childrenListNode) 763 this._childrenListNode.style.removeProperty("display"); 764 // Unhide header items. 765 var child = this.listItemElement.firstChild; 766 while (child) { 767 child.style.removeProperty("display"); 768 child = child.nextSibling; 769 } 770 771 this.updateSelection(); 772 } 773 774 WebInspector.startEditing(this._htmlEditElement, commit.bind(this), dispose.bind(this), null, true); 720 775 }, 721 776 … … 963 1018 }, 964 1019 965 _copyHTML: function(node) 1020 _editAsHTML: function() 1021 { 1022 var treeOutline = this.treeOutline; 1023 var node = this.representedObject; 1024 var wasExpanded = this.expanded; 1025 1026 function selectNode(nodeId) 1027 { 1028 if (!nodeId) 1029 return; 1030 1031 // Select it and expand if necessary. We force tree update so that it processes dom events and is up to date. 1032 WebInspector.panels.elements.updateModifiedNodes(); 1033 1034 WebInspector.updateFocusedNode(nodeId); 1035 if (wasExpanded) { 1036 var newTreeItem = treeOutline.findTreeElement(WebInspector.domAgent.nodeForId(nodeId)); 1037 if (newTreeItem) 1038 newTreeItem.expand(); 1039 } 1040 } 1041 1042 function commitChange(value) 1043 { 1044 InjectedScriptAccess.setOuterHTML(node.id, value, wasExpanded, selectNode.bind(this)); 1045 } 1046 1047 InjectedScriptAccess.getNodePropertyValue(node.id, "outerHTML", this._startEditingAsHTML.bind(this, commitChange)); 1048 }, 1049 1050 _copyHTML: function() 966 1051 { 967 1052 InspectorBackend.copyNode(this.representedObject.id); -
trunk/WebCore/inspector/front-end/InjectedScript.js
r52545 r52556 511 511 } 512 512 513 InjectedScript.getNodePropertyValue = function(nodeId, propertyName) 514 { 515 var node = InjectedScript._nodeForId(nodeId); 516 if (!node) 517 return false; 518 var result = node[propertyName]; 519 return result !== undefined ? result : false; 520 } 521 522 InjectedScript.setOuterHTML = function(nodeId, value, expanded) 523 { 524 var node = InjectedScript._nodeForId(nodeId); 525 if (!node) 526 return false; 527 528 var parent = node.parentNode; 529 var prevSibling = node.previousSibling; 530 node.outerHTML = value; 531 var newNode = prevSibling ? prevSibling.nextSibling : parent.firstChild; 532 533 return InjectedScriptHost.pushNodePathToFrontend(newNode, expanded, false); 534 } 513 535 514 536 InjectedScript.getCompletions = function(expression, includeInspectorCommandLineAPI, callFrameId) … … 647 669 node[searchResultsProperty] = true; 648 670 InjectedScript._searchResults.push(node); 649 var nodeId = InjectedScriptHost.pushNodePathToFrontend(node, false );671 var nodeId = InjectedScriptHost.pushNodePathToFrontend(node, false, false); 650 672 nodeIds.push(nodeId); 651 673 } … … 892 914 inspectedWindow.console.log(o); 893 915 if (Object.type(o) === "node") { 894 InjectedScriptHost.pushNodePathToFrontend(o, true);916 InjectedScriptHost.pushNodePathToFrontend(o, false, true); 895 917 } else { 896 918 switch (Object.describe(o)) { … … 908 930 { 909 931 if (Object.type(o) === "node") { 910 var nodeId = InjectedScriptHost.pushNodePathToFrontend(o, false );932 var nodeId = InjectedScriptHost.pushNodePathToFrontend(o, false, false); 911 933 InjectedScriptHost.copyNode(nodeId); 912 934 } else { … … 1049 1071 if (!object || Object.type(object) !== "node") 1050 1072 return false; 1051 return InjectedScriptHost.pushNodePathToFrontend(object, false );1073 return InjectedScriptHost.pushNodePathToFrontend(object, false, false); 1052 1074 } 1053 1075 -
trunk/WebCore/inspector/front-end/InjectedScriptAccess.js
r52545 r52556 66 66 InjectedScriptAccess._installHandler("getComputedStyle"); 67 67 InjectedScriptAccess._installHandler("getInlineStyle"); 68 InjectedScriptAccess._installHandler("getNodePropertyValue"); 68 69 InjectedScriptAccess._installHandler("getProperties"); 69 70 InjectedScriptAccess._installHandler("getPrototypes"); … … 74 75 InjectedScriptAccess._installHandler("nodeByPath"); 75 76 InjectedScriptAccess._installHandler("searchCanceled"); 77 InjectedScriptAccess._installHandler("setOuterHTML"); 76 78 InjectedScriptAccess._installHandler("setPropertyValue"); 77 79 InjectedScriptAccess._installHandler("setStyleProperty"); -
trunk/WebCore/inspector/front-end/InspectorFrontendHostStub.js
r52547 r52556 93 93 { 94 94 return ""; 95 }, 96 97 windowUnloading: function() 98 { 95 99 } 96 100 } -
trunk/WebCore/inspector/front-end/inspector.css
r52555 r52556 1504 1504 } 1505 1505 1506 .elements-tree-editor { 1507 -webkit-user-select: text; 1508 -webkit-user-modify: read-write-plaintext-only; 1509 } 1510 1506 1511 .section .properties li.editing { 1507 1512 margin-left: 10px; -
trunk/WebCore/inspector/front-end/inspector.js
r52547 r52556 1624 1624 } 1625 1625 1626 WebInspector.startEditing = function(element, committedCallback, cancelledCallback, context )1626 WebInspector.startEditing = function(element, committedCallback, cancelledCallback, context, multiline) 1627 1627 { 1628 1628 if (element.__editing) … … 1685 1685 1686 1686 function keyDownEventListener(event) { 1687 if (isEnterKey(event)) { 1687 var isMetaOrCtrl = WebInspector.isMac() ? 1688 event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey : 1689 event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey; 1690 if (isEnterKey(event) && (!multiline || isMetaOrCtrl)) { 1688 1691 editingCommitted.call(element); 1689 1692 event.preventDefault();
Note: See TracChangeset
for help on using the changeset viewer.