Commit 7fc15755 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

Web Inspector: convert DOM breakpoint types to strings.

https://bugs.webkit.org/show_bug.cgi?id=66304

Reviewed by Yury Semikhatsky.

* inspector/Inspector.json:
* inspector/InspectorDOMDebuggerAgent.cpp:
(WebCore::domTypeForName):
(WebCore::InspectorDOMDebuggerAgent::setDOMBreakpoint):
(WebCore::InspectorDOMDebuggerAgent::removeDOMBreakpoint):
* inspector/InspectorDOMDebuggerAgent.h:
* inspector/front-end/DOMBreakpointsSidebarPane.js:
(WebInspector.DOMBreakpointsSidebarPane):

git-svn-id: svn://svn.chromium.org/blink/trunk@93125 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 07ae87e9
2011-08-16 Pavel Feldman <pfeldman@google.com>
Web Inspector: convert DOM breakpoint types to strings.
https://bugs.webkit.org/show_bug.cgi?id=66304
Reviewed by Yury Semikhatsky.
* inspector/Inspector.json:
* inspector/InspectorDOMDebuggerAgent.cpp:
(WebCore::domTypeForName):
(WebCore::InspectorDOMDebuggerAgent::setDOMBreakpoint):
(WebCore::InspectorDOMDebuggerAgent::removeDOMBreakpoint):
* inspector/InspectorDOMDebuggerAgent.h:
* inspector/front-end/DOMBreakpointsSidebarPane.js:
(WebInspector.DOMBreakpointsSidebarPane):
2011-08-16 Pavel Feldman <pfeldman@google.com> 2011-08-16 Pavel Feldman <pfeldman@google.com>
Web Inspector: force pseudo element state when checking it in the styles sidebar. Web Inspector: force pseudo element state when checking it in the styles sidebar.
...@@ -1694,20 +1694,28 @@ ...@@ -1694,20 +1694,28 @@
{ {
"domain": "DOMDebugger", "domain": "DOMDebugger",
"description": "DOM debugging allows setting breakpoints on particular DOM operations and events. JavaScript execution will stop on these operations as if there was a regular breakpoint set.", "description": "DOM debugging allows setting breakpoints on particular DOM operations and events. JavaScript execution will stop on these operations as if there was a regular breakpoint set.",
"types": [
{
"id": "DOMBreakpointType",
"type": "string",
"enum": ["subtree-modified", "attribute-modified", "node-removed"],
"description": "DOM breakpoint type."
}
],
"commands": [ "commands": [
{ {
"name": "setDOMBreakpoint", "name": "setDOMBreakpoint",
"parameters": [ "parameters": [
{ "name": "nodeId", "type": "integer", "description": "Identifier of the node to set breakpoint on." }, { "name": "nodeId", "type": "integer", "description": "Identifier of the node to set breakpoint on." },
{ "name": "type", "type": "integer", "description": "Type of the operation to stop upon." } { "name": "type", "$ref": "DOMBreakpointType", "description": "Type of the operation to stop upon." }
], ],
"description": "Sets breakpoint on particular operation with DOM. " "description": "Sets breakpoint on particular operation with DOM."
}, },
{ {
"name": "removeDOMBreakpoint", "name": "removeDOMBreakpoint",
"parameters": [ "parameters": [
{ "name": "nodeId", "type": "integer", "description": "Identifier of the node to remove breakpoint from." }, { "name": "nodeId", "type": "integer", "description": "Identifier of the node to remove breakpoint from." },
{ "name": "type", "type": "integer", "description": "Type of the breakpoint to remove." } { "name": "type", "$ref": "DOMBreakpointType", "description": "Type of the breakpoint to remove." }
], ],
"description": "Removes DOM breakpoint that was set using <code>setDOMBreakpoint</code>." "description": "Removes DOM breakpoint that was set using <code>setDOMBreakpoint</code>."
}, },
......
...@@ -179,11 +179,34 @@ void InspectorDOMDebuggerAgent::didRemoveDOMNode(Node* node) ...@@ -179,11 +179,34 @@ void InspectorDOMDebuggerAgent::didRemoveDOMNode(Node* node)
} }
} }
void InspectorDOMDebuggerAgent::setDOMBreakpoint(ErrorString*, int nodeId, int type) static int domTypeForName(const String& typeString)
{
if (typeString == "subtree-modified")
return SubtreeModified;
if (typeString == "attribute-modified")
return AttributeModified;
if (typeString == "node-removed")
return NodeRemoved;
return SubtreeModified;
}
static String domTypeName(int type)
{
switch (type) {
case SubtreeModified: return "subtree-modified";
case AttributeModified: return "attribute-modified";
case NodeRemoved: return "node-removed";
default: break;
}
return "";
}
void InspectorDOMDebuggerAgent::setDOMBreakpoint(ErrorString*, int nodeId, const String& typeString)
{ {
Node* node = m_domAgent->nodeForId(nodeId); Node* node = m_domAgent->nodeForId(nodeId);
if (!node) if (!node)
return; return;
int type = domTypeForName(typeString);
uint32_t rootBit = 1 << type; uint32_t rootBit = 1 << type;
m_domBreakpoints.set(node, m_domBreakpoints.get(node) | rootBit); m_domBreakpoints.set(node, m_domBreakpoints.get(node) | rootBit);
...@@ -193,11 +216,12 @@ void InspectorDOMDebuggerAgent::setDOMBreakpoint(ErrorString*, int nodeId, int t ...@@ -193,11 +216,12 @@ void InspectorDOMDebuggerAgent::setDOMBreakpoint(ErrorString*, int nodeId, int t
} }
} }
void InspectorDOMDebuggerAgent::removeDOMBreakpoint(ErrorString*, int nodeId, int type) void InspectorDOMDebuggerAgent::removeDOMBreakpoint(ErrorString*, int nodeId, const String& typeString)
{ {
Node* node = m_domAgent->nodeForId(nodeId); Node* node = m_domAgent->nodeForId(nodeId);
if (!node) if (!node)
return; return;
int type = domTypeForName(typeString);
uint32_t rootBit = 1 << type; uint32_t rootBit = 1 << type;
uint32_t mask = m_domBreakpoints.get(node) & ~rootBit; uint32_t mask = m_domBreakpoints.get(node) & ~rootBit;
...@@ -275,7 +299,7 @@ void InspectorDOMDebuggerAgent::descriptionForDOMEvent(Node* target, int breakpo ...@@ -275,7 +299,7 @@ void InspectorDOMDebuggerAgent::descriptionForDOMEvent(Node* target, int breakpo
int breakpointOwnerNodeId = m_domAgent->boundNodeId(breakpointOwner); int breakpointOwnerNodeId = m_domAgent->boundNodeId(breakpointOwner);
ASSERT(breakpointOwnerNodeId); ASSERT(breakpointOwnerNodeId);
description->setNumber("nodeId", breakpointOwnerNodeId); description->setNumber("nodeId", breakpointOwnerNodeId);
description->setNumber("type", breakpointType); description->setString("type", domTypeName(breakpointType));
} }
bool InspectorDOMDebuggerAgent::hasBreakpoint(Node* node, int type) bool InspectorDOMDebuggerAgent::hasBreakpoint(Node* node, int type)
......
...@@ -67,8 +67,8 @@ public: ...@@ -67,8 +67,8 @@ public:
void removeXHRBreakpoint(ErrorString*, const String& url); void removeXHRBreakpoint(ErrorString*, const String& url);
void setEventListenerBreakpoint(ErrorString*, const String& eventName); void setEventListenerBreakpoint(ErrorString*, const String& eventName);
void removeEventListenerBreakpoint(ErrorString*, const String& eventName); void removeEventListenerBreakpoint(ErrorString*, const String& eventName);
void setDOMBreakpoint(ErrorString*, int nodeId, int type); void setDOMBreakpoint(ErrorString*, int nodeId, const String& type);
void removeDOMBreakpoint(ErrorString*, int nodeId, int type); void removeDOMBreakpoint(ErrorString*, int nodeId, const String& type);
// InspectorInstrumentation API // InspectorInstrumentation API
void willInsertDOMNode(Node*, Node* parent); void willInsertDOMNode(Node*, Node* parent);
......
...@@ -35,20 +35,20 @@ WebInspector.DOMBreakpointsSidebarPane = function() ...@@ -35,20 +35,20 @@ WebInspector.DOMBreakpointsSidebarPane = function()
this._breakpointElements = {}; this._breakpointElements = {};
this._breakpointTypes = { this._breakpointTypes = {
SubtreeModified: 0, SubtreeModified: "subtree-modified",
AttributeModified: 1, AttributeModified: "attribute-modified",
NodeRemoved: 2 NodeRemoved: "node-removed"
}; };
this._breakpointTypeLabels = [ this._breakpointTypeLabels = {};
WebInspector.UIString("Subtree Modified"), this._breakpointTypeLabels[this._breakpointTypes.SubtreeModified] = WebInspector.UIString("Subtree Modified");
WebInspector.UIString("Attribute Modified"), this._breakpointTypeLabels[this._breakpointTypes.AttributeModified] = WebInspector.UIString("Attribute Modified");
WebInspector.UIString("Node Removed") this._breakpointTypeLabels[this._breakpointTypes.NodeRemoved] = WebInspector.UIString("Node Removed");
];
this._contextMenuLabels = [ this._contextMenuLabels = {};
WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Break on subtree modifications" : "Break on Subtree Modifications"), this._contextMenuLabels[this._breakpointTypes.SubtreeModified] = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Break on subtree modifications" : "Break on Subtree Modifications");
WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Break on attributes modifications" : "Break on Attributes Modifications"), this._contextMenuLabels[this._breakpointTypes.AttributeModified] = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Break on attributes modifications" : "Break on Attributes Modifications");
WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Break on node removal" : "Break on Node Removal") this._contextMenuLabels[this._breakpointTypes.NodeRemoved] = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Break on node removal" : "Break on Node Removal");
];
WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this); WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this);
} }
...@@ -78,7 +78,8 @@ WebInspector.DOMBreakpointsSidebarPane.prototype = { ...@@ -78,7 +78,8 @@ WebInspector.DOMBreakpointsSidebarPane.prototype = {
this._saveBreakpoints(); this._saveBreakpoints();
} }
for (var type = 0; type < 3; ++type) { for (var key in this._breakpointTypes) {
var type = this._breakpointTypes[key];
var label = this._contextMenuLabels[type]; var label = this._contextMenuLabels[type];
contextMenu.appendCheckboxItem(label, toggleBreakpoint.bind(this, type), nodeBreakpoints[type]); contextMenu.appendCheckboxItem(label, toggleBreakpoint.bind(this, type), nodeBreakpoints[type]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment