[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
pfeldman at chromium.org
pfeldman at chromium.org
Tue Jan 5 23:46:38 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 69ec5c6c67667d788b6dddafd3dfc6fc6421d721
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Dec 10 12:53:42 2009 +0000
2009-12-10 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: Add context menu actions for DOM tree.
https://bugs.webkit.org/show_bug.cgi?id=32348
* English.lproj/localizedStrings.js:
* inspector/front-end/ContextMenu.js:
(WebInspector.ContextMenu):
(WebInspector.ContextMenu.prototype.show):
(WebInspector.ContextMenu.prototype.appendItem):
(WebInspector.ContextMenu.prototype.appendSeparator):
(WebInspector.ContextMenu.prototype._itemSelected):
(WebInspector.contextMenuItemSelected):
(WebInspector.contextMenuCleared):
* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeOutline.prototype._onmouseout):
(WebInspector.ElementsTreeOutline.prototype.populateContextMenu):
(WebInspector.ElementsTreeElement.prototype.ondblclick):
(WebInspector.ElementsTreeElement.prototype._startEditingFromEvent):
(WebInspector.ElementsTreeElement.prototype._populateTagContextMenu):
(WebInspector.ElementsTreeElement.prototype._populateTextContextMenu):
(WebInspector.ElementsTreeElement.prototype._startEditing):
(WebInspector.ElementsTreeElement.prototype._addNewAttribute):
* inspector/front-end/ObjectPropertiesSection.js:
(WebInspector.ObjectPropertyTreeElement.prototype.ondblclick):
* inspector/front-end/ResourceView.js:
(WebInspector.ResourceView.prototype._toggleURLdecoding):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourceSidebarTreeElement.prototype.ondblclick):
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylePropertyTreeElement.prototype):
* inspector/front-end/inspector.js:
(WebInspector.contextMenuEventFired):
* inspector/front-end/treeoutline.js:
(TreeElement.treeElementDoubleClicked):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51946 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3bd01c9..28b1551 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,42 @@
+2009-12-10 Pavel Feldman <pfeldman at chromium.org>
+
+ Reviewed by Timothy Hatcher.
+
+ Web Inspector: Add context menu actions for DOM tree.
+
+ https://bugs.webkit.org/show_bug.cgi?id=32348
+
+ * English.lproj/localizedStrings.js:
+ * inspector/front-end/ContextMenu.js:
+ (WebInspector.ContextMenu):
+ (WebInspector.ContextMenu.prototype.show):
+ (WebInspector.ContextMenu.prototype.appendItem):
+ (WebInspector.ContextMenu.prototype.appendSeparator):
+ (WebInspector.ContextMenu.prototype._itemSelected):
+ (WebInspector.contextMenuItemSelected):
+ (WebInspector.contextMenuCleared):
+ * inspector/front-end/ElementsTreeOutline.js:
+ (WebInspector.ElementsTreeOutline.prototype._onmouseout):
+ (WebInspector.ElementsTreeOutline.prototype.populateContextMenu):
+ (WebInspector.ElementsTreeElement.prototype.ondblclick):
+ (WebInspector.ElementsTreeElement.prototype._startEditingFromEvent):
+ (WebInspector.ElementsTreeElement.prototype._populateTagContextMenu):
+ (WebInspector.ElementsTreeElement.prototype._populateTextContextMenu):
+ (WebInspector.ElementsTreeElement.prototype._startEditing):
+ (WebInspector.ElementsTreeElement.prototype._addNewAttribute):
+ * inspector/front-end/ObjectPropertiesSection.js:
+ (WebInspector.ObjectPropertyTreeElement.prototype.ondblclick):
+ * inspector/front-end/ResourceView.js:
+ (WebInspector.ResourceView.prototype._toggleURLdecoding):
+ * inspector/front-end/ResourcesPanel.js:
+ (WebInspector.ResourceSidebarTreeElement.prototype.ondblclick):
+ * inspector/front-end/StylesSidebarPane.js:
+ (WebInspector.StylePropertyTreeElement.prototype):
+ * inspector/front-end/inspector.js:
+ (WebInspector.contextMenuEventFired):
+ * inspector/front-end/treeoutline.js:
+ (TreeElement.treeElementDoubleClicked):
+
2009-12-09 Nikolas Zimmermann <nzimmermann at rim.com>
Reviewed by Oliver Hunt.
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 63039ec..e18a163 100644
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
diff --git a/WebCore/inspector/front-end/ContextMenu.js b/WebCore/inspector/front-end/ContextMenu.js
index 0d89493..3cdb152 100644
--- a/WebCore/inspector/front-end/ContextMenu.js
+++ b/WebCore/inspector/front-end/ContextMenu.js
@@ -31,63 +31,53 @@
WebInspector.ContextMenu = function() {
this._items = [];
this._handlers = {};
- this._appendItem(WebInspector.UIString("Edit as HTML"), this._noop.bind(this));
- this._appendItem(WebInspector.UIString("Add attribute"), this._noop.bind(this));
- this._appendSeparator();
- this._appendItem(WebInspector.UIString("Copy"), this._copy.bind(this));
- this._appendItem(WebInspector.UIString("Delete"), this._delete.bind(this));
}
WebInspector.ContextMenu.prototype = {
show: function(event)
{
- // FIXME: Uncomment when popup menu has meaningful items.
- // InspectorFrontendHost.showContextMenu(event, this._items);
- // event.preventDefault();
+ // Remove trailing separator.
+ while (this._items.length > 0 && !("id" in this._items[this._items.length - 1]))
+ this._items.splice(this._items.length - 1, 1);
+
+ if (this._items.length) {
+ WebInspector._contextMenu = this;
+ InspectorFrontendHost.showContextMenu(event, this._items);
+ }
},
- _appendItem: function(label, handler)
+ appendItem: function(label, handler)
{
var id = this._items.length;
this._items.push({id: id, label: label});
this._handlers[id] = handler;
},
- _appendSeparator: function()
+ appendSeparator: function()
{
+ // No separator dupes allowed.
+ if (this._items.length === 0)
+ return;
+ if (!("id" in this._items[this._items.length - 1]))
+ return;
this._items.push({});
},
- itemSelected: function(id)
+ _itemSelected: function(id)
{
if (this._handlers[id])
this._handlers[id].call(this);
- },
-
- _copy: function()
- {
- console.log("context menu: copy");
- },
-
- _delete: function()
- {
- console.log("context menu: delete");
- },
-
- _noop: function()
- {
- console.log("context menu: noop");
}
}
-
WebInspector.contextMenuItemSelected = function(id)
{
- if (WebInspector.contextMenu)
- WebInspector.contextMenu.itemSelected(id);
+ if (WebInspector._contextMenu)
+ WebInspector._contextMenu._itemSelected(id);
}
WebInspector.contextMenuCleared = function()
{
- console.log("context menu: cleared");
+ // FIXME: Unfortunately, contextMenuCleared is invoked between show and item selected
+ // so we can't delete last menu object from WebInspector. Fix the contract.
}
diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js
index d6326f0..68a516f 100644
--- a/WebCore/inspector/front-end/ElementsTreeOutline.js
+++ b/WebCore/inspector/front-end/ElementsTreeOutline.js
@@ -41,6 +41,8 @@ WebInspector.ElementsTreeOutline = function() {
this.showInElementsPanelEnabled = false;
this.rootDOMNode = null;
this.focusedDOMNode = null;
+
+ this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true);
}
WebInspector.ElementsTreeOutline.prototype = {
@@ -259,6 +261,23 @@ WebInspector.ElementsTreeOutline.prototype = {
}
WebInspector.hoveredDOMNode = null;
+ },
+
+ _contextMenuEventFired: function(event)
+ {
+ var listItem = event.target.enclosingNodeOrSelfWithNodeName("LI");
+ if (!listItem || !listItem.treeElement)
+ return;
+
+ var contextMenu = new WebInspector.ContextMenu();
+
+ var tag = event.target.enclosingNodeOrSelfWithClass("webkit-html-tag");
+ var textNode = event.target.enclosingNodeOrSelfWithClass("webkit-html-text-node");
+ if (tag)
+ listItem.treeElement._populateTagContextMenu(contextMenu, event);
+ else if (textNode)
+ listItem.treeElement._populateTextContextMenu(contextMenu, textNode);
+ contextMenu.show(event);
}
}
@@ -549,12 +568,12 @@ WebInspector.ElementsTreeElement.prototype = {
event.preventDefault();
},
- ondblclick: function(treeElement, event)
+ ondblclick: function(event)
{
if (this._editing)
return;
- if (this._startEditingFromEvent(event, treeElement))
+ if (this._startEditingFromEvent(event))
return;
if (this.hasChildren && !this.expanded)
@@ -576,7 +595,7 @@ WebInspector.ElementsTreeElement.prototype = {
this.updateSelection();
},
- _startEditingFromEvent: function(event, treeElement)
+ _startEditingFromEvent: function(event)
{
if (this.treeOutline.focusedDOMNode != this.representedObject)
return;
@@ -594,11 +613,31 @@ WebInspector.ElementsTreeElement.prototype = {
var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attribute");
if (newAttribute)
- return this._addNewAttribute(treeElement.listItemElement);
+ return this._addNewAttribute();
return false;
},
+ _populateTagContextMenu: function(contextMenu, event)
+ {
+ var attribute = event.target.enclosingNodeOrSelfWithClass("webkit-html-attribute");
+ var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attribute");
+
+ // Add attribute-related actions.
+ contextMenu.appendItem(WebInspector.UIString("Add Attribute"), this._addNewAttribute.bind(this));
+ if (attribute && !newAttribute)
+ contextMenu.appendItem(WebInspector.UIString("Edit Attribute"), this._startEditingAttribute.bind(this, attribute, event.target));
+ contextMenu.appendSeparator();
+
+ // Add node-related actions.
+ contextMenu.appendItem(WebInspector.UIString("Delete Node"), this.remove.bind(this));
+ },
+
+ _populateTextContextMenu: function(contextMenu, textNode)
+ {
+ contextMenu.appendItem(WebInspector.UIString("Edit Text"), this._startEditingTextNode.bind(this, textNode));
+ },
+
_startEditing: function()
{
if (this.treeOutline.focusedDOMNode !== this.representedObject)
@@ -612,7 +651,7 @@ WebInspector.ElementsTreeElement.prototype = {
if (attribute)
return this._startEditingAttribute(attribute, attribute.getElementsByClassName("webkit-html-attribute-value")[0]);
- return this._addNewAttribute(listItem);
+ return this._addNewAttribute();
}
if (this.representedObject.nodeType === Node.TEXT_NODE) {
@@ -623,7 +662,7 @@ WebInspector.ElementsTreeElement.prototype = {
}
},
- _addNewAttribute: function(listItemElement)
+ _addNewAttribute: function()
{
var attr = document.createElement("span");
attr.className = "webkit-html-attribute";
@@ -637,7 +676,7 @@ WebInspector.ElementsTreeElement.prototype = {
attr.appendChild(name);
attr.appendChild(value);
- var tag = listItemElement.getElementsByClassName("webkit-html-tag")[0];
+ var tag = this.listItemElement.getElementsByClassName("webkit-html-tag")[0];
this._insertInLastAttributePosition(tag, attr);
return this._startEditingAttribute(attr, attr);
},
diff --git a/WebCore/inspector/front-end/ObjectPropertiesSection.js b/WebCore/inspector/front-end/ObjectPropertiesSection.js
index 8bb4e35..7bdf17f 100644
--- a/WebCore/inspector/front-end/ObjectPropertiesSection.js
+++ b/WebCore/inspector/front-end/ObjectPropertiesSection.js
@@ -150,7 +150,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
InjectedScriptAccess.getProperties(this.property.value, false, callback.bind(this));
},
- ondblclick: function(element, event)
+ ondblclick: function(event)
{
this.startEditing();
},
diff --git a/WebCore/inspector/front-end/ResourceView.js b/WebCore/inspector/front-end/ResourceView.js
index 2ea7fdb..8175c2f 100644
--- a/WebCore/inspector/front-end/ResourceView.js
+++ b/WebCore/inspector/front-end/ResourceView.js
@@ -248,7 +248,7 @@ WebInspector.ResourceView.prototype = {
}
},
- _toggleURLdecoding: function(treeElement, event)
+ _toggleURLdecoding: function(event)
{
this._decodeRequestParameters = !this._decodeRequestParameters;
this._refreshQueryString();
diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js
index 121eba5..60c1895 100644
--- a/WebCore/inspector/front-end/ResourcesPanel.js
+++ b/WebCore/inspector/front-end/ResourcesPanel.js
@@ -967,7 +967,7 @@ WebInspector.ResourceSidebarTreeElement.prototype = {
WebInspector.panels.resources.showResource(this.resource);
},
- ondblclick: function(treeElement, event)
+ ondblclick: function(event)
{
InjectedScriptAccess.openInInspectedWindow(this.resource.url, function() {});
},
diff --git a/WebCore/inspector/front-end/StylesSidebarPane.js b/WebCore/inspector/front-end/StylesSidebarPane.js
index 699e3ce..5178a98 100644
--- a/WebCore/inspector/front-end/StylesSidebarPane.js
+++ b/WebCore/inspector/front-end/StylesSidebarPane.js
@@ -1098,7 +1098,7 @@ WebInspector.StylePropertyTreeElement.prototype = {
}
},
- ondblclick: function(element, event)
+ ondblclick: function(event)
{
this.startEditing(event.target);
event.stopPropagation();
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index 9fcc657..73dc74c 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -760,10 +760,6 @@ WebInspector.contextMenuEventFired = function(event)
{
if (event.handled || event.target.hasStyleClass("popup-glasspane"))
event.preventDefault();
-
- if (!this.contextMenu)
- this.contextMenu = new WebInspector.ContextMenu();
- this.contextMenu.show(event);
}
WebInspector.mainKeyDown = function(event)
diff --git a/WebCore/inspector/front-end/treeoutline.js b/WebCore/inspector/front-end/treeoutline.js
index ecc322b..2cde151 100644
--- a/WebCore/inspector/front-end/treeoutline.js
+++ b/WebCore/inspector/front-end/treeoutline.js
@@ -624,7 +624,7 @@ TreeElement.treeElementDoubleClicked = function(event)
return;
if (element.treeElement.ondblclick)
- element.treeElement.ondblclick(element.treeElement, event);
+ element.treeElement.ondblclick.call(element.treeElement, event);
else if (element.treeElement.hasChildren && !element.treeElement.expanded)
element.treeElement.expand();
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list