[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
pfeldman at chromium.org
pfeldman at chromium.org
Wed Jan 6 00:00:26 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 5ea2c1c58bdac3f3ad836b3d5831787a98d50738
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 25 14:24:07 2009 +0000
2009-12-25 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: Implement Edit Inner HTML action.
https://bugs.webkit.org/show_bug.cgi?id=32924
* English.lproj/localizedStrings.js:
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::JSInjectedScriptHost::pushNodePathToFrontend):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::V8InjectedScriptHost::pushNodePathToFrontendCallback):
* inspector/InjectedScriptHost.cpp:
(WebCore::InjectedScriptHost::pushNodePathToFrontend):
* inspector/InjectedScriptHost.h:
* inspector/InjectedScriptHost.idl:
* inspector/InspectorDOMAgent.h:
* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel.prototype.show):
(WebInspector.ElementsPanel.prototype._updateModifiedNodesSoon):
(WebInspector.ElementsPanel.prototype.updateModifiedNodes):
* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeElement.prototype._populateTagContextMenu):
(WebInspector.ElementsTreeElement.prototype._startEditingAsHTML.commit):
(WebInspector.ElementsTreeElement.prototype._startEditingAsHTML.dispose):
(WebInspector.ElementsTreeElement.prototype._startEditingAsHTML):
():
* inspector/front-end/InjectedScript.js:
(InjectedScript.getNodePropertyValue):
(InjectedScript.setOuterHTML):
(InjectedScript.performSearch.addNodesToResults):
(InjectedScript._inspectObject):
(InjectedScript._copy):
(InjectedScript.pushNodeToFrontend):
* inspector/front-end/InjectedScriptAccess.js:
* inspector/front-end/InspectorFrontendHostStub.js:
(.WebInspector.InspectorFrontendHostStub.prototype.hiddenPanels):
(.WebInspector.InspectorFrontendHostStub.prototype.windowUnloading):
* inspector/front-end/inspector.css:
* inspector/front-end/inspector.js:
(WebInspector.startEditing.keyDownEventListener):
(WebInspector.startEditing):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52556 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9e8fea6..a326677 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2009-12-25 Pavel Feldman <pfeldman at chromium.org>
+
+ Reviewed by Timothy Hatcher.
+
+ Web Inspector: Implement Edit Inner HTML action.
+
+ https://bugs.webkit.org/show_bug.cgi?id=32924
+
+ * English.lproj/localizedStrings.js:
+ * bindings/js/JSInjectedScriptHostCustom.cpp:
+ (WebCore::JSInjectedScriptHost::pushNodePathToFrontend):
+ * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+ (WebCore::V8InjectedScriptHost::pushNodePathToFrontendCallback):
+ * inspector/InjectedScriptHost.cpp:
+ (WebCore::InjectedScriptHost::pushNodePathToFrontend):
+ * inspector/InjectedScriptHost.h:
+ * inspector/InjectedScriptHost.idl:
+ * inspector/InspectorDOMAgent.h:
+ * inspector/front-end/ElementsPanel.js:
+ (WebInspector.ElementsPanel.prototype.show):
+ (WebInspector.ElementsPanel.prototype._updateModifiedNodesSoon):
+ (WebInspector.ElementsPanel.prototype.updateModifiedNodes):
+ * inspector/front-end/ElementsTreeOutline.js:
+ (WebInspector.ElementsTreeElement.prototype._populateTagContextMenu):
+ (WebInspector.ElementsTreeElement.prototype._startEditingAsHTML.commit):
+ (WebInspector.ElementsTreeElement.prototype._startEditingAsHTML.dispose):
+ (WebInspector.ElementsTreeElement.prototype._startEditingAsHTML):
+ ():
+ * inspector/front-end/InjectedScript.js:
+ (InjectedScript.getNodePropertyValue):
+ (InjectedScript.setOuterHTML):
+ (InjectedScript.performSearch.addNodesToResults):
+ (InjectedScript._inspectObject):
+ (InjectedScript._copy):
+ (InjectedScript.pushNodeToFrontend):
+ * inspector/front-end/InjectedScriptAccess.js:
+ * inspector/front-end/InspectorFrontendHostStub.js:
+ (.WebInspector.InspectorFrontendHostStub.prototype.hiddenPanels):
+ (.WebInspector.InspectorFrontendHostStub.prototype.windowUnloading):
+ * inspector/front-end/inspector.css:
+ * inspector/front-end/inspector.js:
+ (WebInspector.startEditing.keyDownEventListener):
+ (WebInspector.startEditing):
+
2009-12-24 Dan Bernstein <mitz at apple.com>
Reviewed by Timothy Hatcher.
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 5eba2ea..6b84021 100644
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
index fcc9e5e..8dfc5e4 100644
--- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
@@ -162,7 +162,7 @@ JSValue JSInjectedScriptHost::unwrapObject(ExecState* exec, const ArgList& args)
JSValue JSInjectedScriptHost::pushNodePathToFrontend(ExecState* exec, const ArgList& args)
{
- if (args.size() < 2)
+ if (args.size() < 3)
return jsUndefined();
JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0));
@@ -173,8 +173,9 @@ JSValue JSInjectedScriptHost::pushNodePathToFrontend(ExecState* exec, const ArgL
if (!node)
return jsUndefined();
- bool selectInUI = args.at(1).toBoolean(exec);
- return jsNumber(exec, impl()->pushNodePathToFrontend(node, selectInUI));
+ bool withChildren = args.at(1).toBoolean(exec);
+ bool selectInUI = args.at(2).toBoolean(exec);
+ return jsNumber(exec, impl()->pushNodePathToFrontend(node, withChildren, selectInUI));
}
#if ENABLE(DATABASE)
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index 415f89d..36c32c8 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -104,14 +104,15 @@ v8::Handle<v8::Value> V8InjectedScriptHost::unwrapObjectCallback(const v8::Argum
v8::Handle<v8::Value> V8InjectedScriptHost::pushNodePathToFrontendCallback(const v8::Arguments& args)
{
INC_STATS("InjectedScriptHost.pushNodePathToFrontend()");
- if (args.Length() < 2)
+ if (args.Length() < 3)
return v8::Undefined();
InjectedScriptHost* host = V8DOMWrapper::convertToNativeObject<InjectedScriptHost>(V8ClassIndex::INJECTEDSCRIPTHOST, args.Holder());
Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0]));
- bool selectInUI = args[1]->ToBoolean()->Value();
+ bool withChildren = args[1]->ToBoolean()->Value();
+ bool selectInUI = args[2]->ToBoolean()->Value();
if (node)
- return v8::Number::New(host->pushNodePathToFrontend(node, selectInUI));
+ return v8::Number::New(host->pushNodePathToFrontend(node, withChildren, selectInUI));
return v8::Undefined();
}
diff --git a/WebCore/inspector/InjectedScriptHost.cpp b/WebCore/inspector/InjectedScriptHost.cpp
index a33a1aa..47b2916 100644
--- a/WebCore/inspector/InjectedScriptHost.cpp
+++ b/WebCore/inspector/InjectedScriptHost.cpp
@@ -111,13 +111,15 @@ ScriptValue InjectedScriptHost::unwrapObject(const String& objectId)
return ScriptValue();
}
-long InjectedScriptHost::pushNodePathToFrontend(Node* node, bool selectInUI)
+long InjectedScriptHost::pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI)
{
InspectorFrontend* frontend = inspectorFrontend();
InspectorDOMAgent* domAgent = inspectorDOMAgent();
if (!domAgent || !frontend)
return 0;
long id = domAgent->pushNodePathToFrontend(node);
+ if (withChildren)
+ domAgent->pushChildNodesToFrontend(id);
if (selectInUI)
frontend->updateFocusedNode(id);
return id;
diff --git a/WebCore/inspector/InjectedScriptHost.h b/WebCore/inspector/InjectedScriptHost.h
index 49b5d20..e90217f 100644
--- a/WebCore/inspector/InjectedScriptHost.h
+++ b/WebCore/inspector/InjectedScriptHost.h
@@ -64,7 +64,7 @@ public:
Node* nodeForId(long nodeId);
ScriptValue wrapObject(const ScriptValue& object, const String& objectGroup);
ScriptValue unwrapObject(const String& objectId);
- long pushNodePathToFrontend(Node* node, bool selectInUI);
+ long pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI);
void addNodesToSearchResult(const String& nodeIds);
long pushNodeByPathToFrontend(const String& path);
diff --git a/WebCore/inspector/InjectedScriptHost.idl b/WebCore/inspector/InjectedScriptHost.idl
index a7e111c..7d15895 100644
--- a/WebCore/inspector/InjectedScriptHost.idl
+++ b/WebCore/inspector/InjectedScriptHost.idl
@@ -40,7 +40,7 @@ module core {
[Custom] DOMObject nodeForId(in long nodeId);
[Custom] long wrapObject(in DOMObject object, in DOMString objectGroup);
[Custom] DOMObject unwrapObject(in long objectId);
- [Custom] int pushNodePathToFrontend(in DOMObject node, in boolean selectInUI);
+ [Custom] int pushNodePathToFrontend(in DOMObject node, in boolean withChildren, in boolean selectInUI);
void addNodesToSearchResult(in DOMString nodeIds);
long pushNodeByPathToFrontend(in DOMString path);
diff --git a/WebCore/inspector/InspectorDOMAgent.h b/WebCore/inspector/InspectorDOMAgent.h
index 4579548..26df5aa 100644
--- a/WebCore/inspector/InspectorDOMAgent.h
+++ b/WebCore/inspector/InspectorDOMAgent.h
@@ -101,6 +101,7 @@ namespace WebCore {
Node* nodeForId(long nodeId);
Node* nodeForPath(const String& path);
long pushNodePathToFrontend(Node* node);
+ void pushChildNodesToFrontend(long nodeId);
private:
void startListening(Document* document);
@@ -113,7 +114,6 @@ namespace WebCore {
void unbind(Node* node, NodeToIdMap* nodesMap);
bool pushDocumentToFrontend();
- void pushChildNodesToFrontend(long nodeId);
ScriptObject buildObjectForNode(Node* node, int depth, NodeToIdMap* nodesMap);
ScriptArray buildArrayForElementAttributes(Element* element);
diff --git a/WebCore/inspector/front-end/ElementsPanel.js b/WebCore/inspector/front-end/ElementsPanel.js
index 03d024c..90639fe 100644
--- a/WebCore/inspector/front-end/ElementsPanel.js
+++ b/WebCore/inspector/front-end/ElementsPanel.js
@@ -146,7 +146,7 @@ WebInspector.ElementsPanel.prototype = {
this.updateBreadcrumb();
this.treeOutline.updateSelection();
if (this.recentlyModifiedNodes.length)
- this._updateModifiedNodes();
+ this.updateModifiedNodes();
},
hide: function()
@@ -491,10 +491,10 @@ WebInspector.ElementsPanel.prototype = {
{
if ("_updateModifiedNodesTimeout" in this)
return;
- this._updateModifiedNodesTimeout = setTimeout(this._updateModifiedNodes.bind(this), 0);
+ this._updateModifiedNodesTimeout = setTimeout(this.updateModifiedNodes.bind(this), 0);
},
- _updateModifiedNodes: function()
+ updateModifiedNodes: function()
{
if ("_updateModifiedNodesTimeout" in this) {
clearTimeout(this._updateModifiedNodesTimeout);
diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js
index b865316..74a422f 100644
--- a/WebCore/inspector/front-end/ElementsTreeOutline.js
+++ b/WebCore/inspector/front-end/ElementsTreeOutline.js
@@ -603,6 +603,7 @@ WebInspector.ElementsTreeElement.prototype = {
contextMenu.appendSeparator();
// Add node-related actions.
+ contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), this._editAsHTML.bind(this));
contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copyHTML.bind(this));
contextMenu.appendItem(WebInspector.UIString("Delete Node"), this.remove.bind(this));
},
@@ -719,6 +720,60 @@ WebInspector.ElementsTreeElement.prototype = {
return true;
},
+ _startEditingAsHTML: function(commitCallback, initialValue)
+ {
+ if (this._htmlEditElement && WebInspector.isBeingEdited(this._htmlEditElement))
+ return true;
+
+ this._editing = true;
+
+ this._htmlEditElement = document.createElement("div");
+ this._htmlEditElement.className = "source-code elements-tree-editor";
+ this._htmlEditElement.textContent = initialValue;
+
+ // Hide header items.
+ var child = this.listItemElement.firstChild;
+ while (child) {
+ child.style.display = "none";
+ child = child.nextSibling;
+ }
+ // Hide children item.
+ if (this._childrenListNode)
+ this._childrenListNode.style.display = "none";
+ // Append editor.
+ this.listItemElement.appendChild(this._htmlEditElement);
+
+ this.updateSelection();
+
+ function commit()
+ {
+ commitCallback(this._htmlEditElement.textContent);
+ dispose.call(this);
+ }
+
+ function dispose()
+ {
+ delete this._editing;
+
+ // Remove editor.
+ this.listItemElement.removeChild(this._htmlEditElement);
+ delete this._htmlEditElement;
+ // Unhide children item.
+ if (this._childrenListNode)
+ this._childrenListNode.style.removeProperty("display");
+ // Unhide header items.
+ var child = this.listItemElement.firstChild;
+ while (child) {
+ child.style.removeProperty("display");
+ child = child.nextSibling;
+ }
+
+ this.updateSelection();
+ }
+
+ WebInspector.startEditing(this._htmlEditElement, commit.bind(this), dispose.bind(this), null, true);
+ },
+
_attributeEditingCommitted: function(element, newText, oldText, attributeName, moveDirection)
{
delete this._editing;
@@ -962,7 +1017,37 @@ WebInspector.ElementsTreeElement.prototype = {
InspectorBackend.removeNode(callId, this.representedObject.id);
},
- _copyHTML: function(node)
+ _editAsHTML: function()
+ {
+ var treeOutline = this.treeOutline;
+ var node = this.representedObject;
+ var wasExpanded = this.expanded;
+
+ function selectNode(nodeId)
+ {
+ if (!nodeId)
+ return;
+
+ // Select it and expand if necessary. We force tree update so that it processes dom events and is up to date.
+ WebInspector.panels.elements.updateModifiedNodes();
+
+ WebInspector.updateFocusedNode(nodeId);
+ if (wasExpanded) {
+ var newTreeItem = treeOutline.findTreeElement(WebInspector.domAgent.nodeForId(nodeId));
+ if (newTreeItem)
+ newTreeItem.expand();
+ }
+ }
+
+ function commitChange(value)
+ {
+ InjectedScriptAccess.setOuterHTML(node.id, value, wasExpanded, selectNode.bind(this));
+ }
+
+ InjectedScriptAccess.getNodePropertyValue(node.id, "outerHTML", this._startEditingAsHTML.bind(this, commitChange));
+ },
+
+ _copyHTML: function()
{
InspectorBackend.copyNode(this.representedObject.id);
}
diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js
index 330af9d..e47522c 100644
--- a/WebCore/inspector/front-end/InjectedScript.js
+++ b/WebCore/inspector/front-end/InjectedScript.js
@@ -510,6 +510,28 @@ InjectedScript.setPropertyValue = function(objectProxy, propertyName, expression
}
}
+InjectedScript.getNodePropertyValue = function(nodeId, propertyName)
+{
+ var node = InjectedScript._nodeForId(nodeId);
+ if (!node)
+ return false;
+ var result = node[propertyName];
+ return result !== undefined ? result : false;
+}
+
+InjectedScript.setOuterHTML = function(nodeId, value, expanded)
+{
+ var node = InjectedScript._nodeForId(nodeId);
+ if (!node)
+ return false;
+
+ var parent = node.parentNode;
+ var prevSibling = node.previousSibling;
+ node.outerHTML = value;
+ var newNode = prevSibling ? prevSibling.nextSibling : parent.firstChild;
+
+ return InjectedScriptHost.pushNodePathToFrontend(newNode, expanded, false);
+}
InjectedScript.getCompletions = function(expression, includeInspectorCommandLineAPI, callFrameId)
{
@@ -646,7 +668,7 @@ InjectedScript.performSearch = function(whitespaceTrimmedQuery)
node[searchResultsProperty] = true;
InjectedScript._searchResults.push(node);
- var nodeId = InjectedScriptHost.pushNodePathToFrontend(node, false);
+ var nodeId = InjectedScriptHost.pushNodePathToFrontend(node, false, false);
nodeIds.push(nodeId);
}
InjectedScriptHost.addNodesToSearchResult(nodeIds.join(","));
@@ -891,7 +913,7 @@ InjectedScript._inspectObject = function(o)
var inspectedWindow = InjectedScript._window();
inspectedWindow.console.log(o);
if (Object.type(o) === "node") {
- InjectedScriptHost.pushNodePathToFrontend(o, true);
+ InjectedScriptHost.pushNodePathToFrontend(o, false, true);
} else {
switch (Object.describe(o)) {
case "Database":
@@ -907,7 +929,7 @@ InjectedScript._inspectObject = function(o)
InjectedScript._copy = function(o)
{
if (Object.type(o) === "node") {
- var nodeId = InjectedScriptHost.pushNodePathToFrontend(o, false);
+ var nodeId = InjectedScriptHost.pushNodePathToFrontend(o, false, false);
InjectedScriptHost.copyNode(nodeId);
} else {
InjectedScriptHost.copyText(o);
@@ -1048,7 +1070,7 @@ InjectedScript.pushNodeToFrontend = function(objectProxy)
var object = InjectedScript._resolveObject(objectProxy);
if (!object || Object.type(object) !== "node")
return false;
- return InjectedScriptHost.pushNodePathToFrontend(object, false);
+ return InjectedScriptHost.pushNodePathToFrontend(object, false, false);
}
InjectedScript.nodeByPath = function(path)
diff --git a/WebCore/inspector/front-end/InjectedScriptAccess.js b/WebCore/inspector/front-end/InjectedScriptAccess.js
index 4c04fb9..c07cd4d 100644
--- a/WebCore/inspector/front-end/InjectedScriptAccess.js
+++ b/WebCore/inspector/front-end/InjectedScriptAccess.js
@@ -65,6 +65,7 @@ InjectedScriptAccess._installHandler("evaluateInCallFrame");
InjectedScriptAccess._installHandler("getCompletions");
InjectedScriptAccess._installHandler("getComputedStyle");
InjectedScriptAccess._installHandler("getInlineStyle");
+InjectedScriptAccess._installHandler("getNodePropertyValue");
InjectedScriptAccess._installHandler("getProperties");
InjectedScriptAccess._installHandler("getPrototypes");
InjectedScriptAccess._installHandler("getStyles");
@@ -73,6 +74,7 @@ InjectedScriptAccess._installHandler("performSearch");
InjectedScriptAccess._installHandler("pushNodeToFrontend");
InjectedScriptAccess._installHandler("nodeByPath");
InjectedScriptAccess._installHandler("searchCanceled");
+InjectedScriptAccess._installHandler("setOuterHTML");
InjectedScriptAccess._installHandler("setPropertyValue");
InjectedScriptAccess._installHandler("setStyleProperty");
InjectedScriptAccess._installHandler("setStyleText");
diff --git a/WebCore/inspector/front-end/InspectorFrontendHostStub.js b/WebCore/inspector/front-end/InspectorFrontendHostStub.js
index fb91794..9141c0f 100644
--- a/WebCore/inspector/front-end/InspectorFrontendHostStub.js
+++ b/WebCore/inspector/front-end/InspectorFrontendHostStub.js
@@ -92,6 +92,10 @@ WebInspector.InspectorFrontendHostStub.prototype = {
hiddenPanels: function()
{
return "";
+ },
+
+ windowUnloading: function()
+ {
}
}
diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css
index 9c2cef1..b676175 100644
--- a/WebCore/inspector/front-end/inspector.css
+++ b/WebCore/inspector/front-end/inspector.css
@@ -1503,6 +1503,11 @@ body.inactive .placard.selected {
text-decoration: none !important;
}
+.elements-tree-editor {
+ -webkit-user-select: text;
+ -webkit-user-modify: read-write-plaintext-only;
+}
+
.section .properties li.editing {
margin-left: 10px;
text-overflow: clip;
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index 7237ba9..7deb1e2 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -1623,7 +1623,7 @@ WebInspector.isBeingEdited = function(element)
return element.__editing;
}
-WebInspector.startEditing = function(element, committedCallback, cancelledCallback, context)
+WebInspector.startEditing = function(element, committedCallback, cancelledCallback, context, multiline)
{
if (element.__editing)
return;
@@ -1684,7 +1684,10 @@ WebInspector.startEditing = function(element, committedCallback, cancelledCallba
}
function keyDownEventListener(event) {
- if (isEnterKey(event)) {
+ var isMetaOrCtrl = WebInspector.isMac() ?
+ event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey :
+ event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey;
+ if (isEnterKey(event) && (!multiline || isMetaOrCtrl)) {
editingCommitted.call(element);
event.preventDefault();
event.stopPropagation();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list