Web Inspector: Switch to type-safe JSON ConsoleMessage.cpp, InspectorDOMAgent.cpp...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Dec 2011 15:05:58 +0000 (15:05 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Dec 2011 15:05:58 +0000 (15:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=74549

Patch by Peter Rybin <peter.rybin@gmail.com> on 2011-12-18
Reviewed by Pavel Feldman.

Source/WebCore:

Work with InspectorObject is replaced with type-safe generated API
usage.
Inspector.json and Inspector-0.1.json are also changed to better
reflect data types that are actually being transmitted.

* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::addToFrontend):
* inspector/Inspector-0.1.json:
* inspector/Inspector.json:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForNode):
(WebCore::InspectorDOMAgent::buildObjectForEventListener):
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::resolveBreakpoint):
* inspector/ScriptCallFrame.cpp:
(WebCore::ScriptCallFrame::buildInspectorObject):

LayoutTests:

Expected file modified as JSON properties are now in different
order.

* inspector/protocol/console-agent-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103174 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/protocol/console-agent-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/inspector/ConsoleMessage.cpp
Source/WebCore/inspector/Inspector-0.1.json
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/ScriptCallFrame.cpp

index 433df3abb15ae81284699b8bca40357b68739c44..ea3022bcbeef472c510e7f9aa11fd7944d2436bc 100644 (file)
@@ -1,3 +1,15 @@
+2011-12-18  Peter Rybin  <peter.rybin@gmail.com>
+
+        Web Inspector: Switch to type-safe JSON ConsoleMessage.cpp, InspectorDOMAgent.cpp, InspectorDebuggerAgent.cpp, ScriptCallFrame.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=74549
+
+        Reviewed by Pavel Feldman.
+
+        Expected file modified as JSON properties are now in different
+        order.
+
+        * inspector/protocol/console-agent-expected.txt:
+
 2011-12-18  Alexandru Chiculita  <achicu@adobe.com>
 
         [CSS Shaders] Add FECustomFilter that renders custom filters
index 27fa5dccc2765573373017464c9d470c78ccec0f..f0f5676d0140468a2ccf6f447a52761000832a80 100644 (file)
@@ -54,12 +54,12 @@ event ConsoleAgent.messageAdded
     params : {
         message : {
             source : "console-api"
-            type : "log"
             level : "log"
+            text : "test"
+            type : "log"
             line : 1
             url : ""
             repeatCount : 1
-            text : "test"
             parameters : [
                 {
                     type : "string"
index 4b1f96ac6f01ce4b1ca2e3f3e8a2db97f692af7d..b2c68aada97566ca17c496b2ab76ee74df7b6ac8 100644 (file)
@@ -1,3 +1,27 @@
+2011-12-18  Peter Rybin  <peter.rybin@gmail.com>
+
+        Web Inspector: Switch to type-safe JSON ConsoleMessage.cpp, InspectorDOMAgent.cpp, InspectorDebuggerAgent.cpp, ScriptCallFrame.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=74549
+
+        Reviewed by Pavel Feldman.
+
+        Work with InspectorObject is replaced with type-safe generated API
+        usage.
+        Inspector.json and Inspector-0.1.json are also changed to better
+        reflect data types that are actually being transmitted.
+
+        * inspector/ConsoleMessage.cpp:
+        (WebCore::ConsoleMessage::addToFrontend):
+        * inspector/Inspector-0.1.json:
+        * inspector/Inspector.json:
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::buildObjectForNode):
+        (WebCore::InspectorDOMAgent::buildObjectForEventListener):
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::resolveBreakpoint):
+        * inspector/ScriptCallFrame.cpp:
+        (WebCore::ScriptCallFrame::buildInspectorObject):
+
 2011-12-18  Peter Rybin  <peter.rybin@gmail.com>
 
         Web Inspector: CodeGeneratorInspector.py: use generated types in method parameters
index e16a72ea666505c773c4e18be25fce4be40cdfa4..8d353f6f0665b95a733b033e61e1c0ff3f86f9d0 100644 (file)
@@ -134,17 +134,17 @@ static String messageLevelValue(MessageLevel level)
 
 void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager)
 {
-    RefPtr<InspectorObject> jsonObj = InspectorObject::create();
-    jsonObj->setString("source", messageSourceValue(m_source));
+    RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create()
+        .setSource(messageSourceValue(m_source))
+        .setLevel(messageLevelValue(m_level))
+        .setText(m_message);
     // FIXME: only send out type for ConsoleAPI source messages.
-    jsonObj->setString("type", messageTypeValue(m_type));
-    jsonObj->setString("level", messageLevelValue(m_level));
-    jsonObj->setNumber("line", static_cast<int>(m_line));
-    jsonObj->setString("url", m_url);
-    jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
-    jsonObj->setString("text", m_message);
+    jsonObj->setType(messageTypeValue(m_type));
+    jsonObj->setLine(static_cast<int>(m_line));
+    jsonObj->setUrl(m_url);
+    jsonObj->setRepeatCount(static_cast<int>(m_repeatCount));
     if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
-        jsonObj->setString("networkRequestId", m_requestId);
+        jsonObj->setNetworkRequestId(m_requestId);
     if (m_arguments && m_arguments->argumentCount()) {
         InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
         if (!injectedScript.hasNoValue()) {
@@ -157,11 +157,11 @@ void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, Injecte
                 }
                 jsonArgs->pushValue(inspectorValue);
             }
-            jsonObj->setArray("parameters", jsonArgs);
+            jsonObj->setParameters(jsonArgs);
         }
     }
     if (m_callStack)
-        jsonObj->setArray("stackTrace", m_callStack->buildInspectorArray());
+        jsonObj->setStackTrace(m_callStack->buildInspectorArray());
     frontend->messageAdded(jsonObj);
 }
 
index 3a1eb7a2eb5cfbf5b3995c98922bc1aaedb7096c..b5789ae5fa44faafed59fd394b3bed7885cf3117 100644 (file)
                 "properties": [
                     { "name": "functionName", "type": "string", "description": "JavaScript function name." },
                     { "name": "url", "type": "string", "description": "JavaScript script name or url." },
-                    { "name": "lineNumber", "type": "string", "description": "JavaScript script line number." },
-                    { "name": "columnNumber", "type": "string", "description": "JavaScript script column number." }
+                    { "name": "lineNumber", "type": "integer", "description": "JavaScript script line number." },
+                    { "name": "columnNumber", "type": "integer", "description": "JavaScript script column number." }
                 ]
             },
             {
index f9ff7606e4b6d75519306f20e7cd02260369cbca..7f0bf29a573395a060647839ad6e978e964099eb 100644 (file)
                 "properties": [
                     { "name": "functionName", "type": "string", "description": "JavaScript function name." },
                     { "name": "url", "type": "string", "description": "JavaScript script name or url." },
-                    { "name": "lineNumber", "type": "string", "description": "JavaScript script line number." },
-                    { "name": "columnNumber", "type": "string", "description": "JavaScript script column number." }
+                    { "name": "lineNumber", "type": "integer", "description": "JavaScript script line number." },
+                    { "name": "columnNumber", "type": "integer", "description": "JavaScript script column number." }
                 ]
             },
             {
index cf42314802cacaab6c48f8f41447d57feb88ed26..bf08f3c4f1cb5bae72706fcf3aed0b25057912e9 100644 (file)
@@ -1125,8 +1125,6 @@ String InspectorDOMAgent::documentURLString(Document* document)
 
 PassRefPtr<InspectorObject> InspectorDOMAgent::buildObjectForNode(Node* node, int depth, NodeToIdMap* nodesMap)
 {
-    RefPtr<InspectorObject> value = InspectorObject::create();
-
     int id = bind(node, nodesMap);
     String nodeName;
     String localName;
@@ -1155,15 +1153,16 @@ PassRefPtr<InspectorObject> InspectorDOMAgent::buildObjectForNode(Node* node, in
         break;
     }
 
-    value->setNumber("nodeId", id);
-    value->setNumber("nodeType", node->nodeType());
-    value->setString("nodeName", nodeName);
-    value->setString("localName", localName);
-    value->setString("nodeValue", nodeValue);
+    RefPtr<TypeBuilder::DOM::Node> value = TypeBuilder::DOM::Node::create()
+        .setNodeId(id)
+        .setNodeType(node->nodeType())
+        .setNodeName(nodeName)
+        .setLocalName(localName)
+        .setNodeValue(nodeValue);
 
     if (node->nodeType() == Node::ELEMENT_NODE || node->nodeType() == Node::DOCUMENT_NODE || node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE) {
         int nodeCount = innerChildNodeCount(node);
-        value->setNumber("childNodeCount", nodeCount);
+        value->setChildNodeCount(nodeCount);
         RefPtr<InspectorArray> children = buildArrayForContainerChildren(node, depth, nodesMap);
         if (children->length() > 0)
             value->setArray("children", children.release());
@@ -1173,22 +1172,22 @@ PassRefPtr<InspectorObject> InspectorDOMAgent::buildObjectForNode(Node* node, in
             value->setArray("attributes", buildArrayForElementAttributes(element));
             if (node->isFrameOwnerElement()) {
                 HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(node);
-                value->setString("documentURL", documentURLString(frameOwner->contentDocument()));
+                value->setDocumentURL(documentURLString(frameOwner->contentDocument()));
             }
         } else if (node->nodeType() == Node::DOCUMENT_NODE) {
             Document* document = static_cast<Document*>(node);
-            value->setString("documentURL", documentURLString(document));
-            value->setString("xmlVersion", document->xmlVersion());
+            value->setDocumentURL(documentURLString(document));
+            value->setXmlVersion(document->xmlVersion());
         }
     } else if (node->nodeType() == Node::DOCUMENT_TYPE_NODE) {
         DocumentType* docType = static_cast<DocumentType*>(node);
-        value->setString("publicId", docType->publicId());
-        value->setString("systemId", docType->systemId());
-        value->setString("internalSubset", docType->internalSubset());
+        value->setPublicId(docType->publicId());
+        value->setSystemId(docType->systemId());
+        value->setInternalSubset(docType->internalSubset());
     } else if (node->nodeType() == Node::ATTRIBUTE_NODE) {
         Attr* attribute = static_cast<Attr*>(node);
-        value->setString("name", attribute->name());
-        value->setString("value", attribute->value());
+        value->setName(attribute->name());
+        value->setValue(attribute->value());
     }
     return value.release();
 }
@@ -1235,19 +1234,19 @@ PassRefPtr<InspectorArray> InspectorDOMAgent::buildArrayForContainerChildren(Nod
 PassRefPtr<InspectorObject> InspectorDOMAgent::buildObjectForEventListener(const RegisteredEventListener& registeredEventListener, const AtomicString& eventType, Node* node)
 {
     RefPtr<EventListener> eventListener = registeredEventListener.listener;
-    RefPtr<InspectorObject> value = InspectorObject::create();
-    value->setString("type", eventType);
-    value->setBoolean("useCapture", registeredEventListener.useCapture);
-    value->setBoolean("isAttribute", eventListener->isAttribute());
-    value->setNumber("nodeId", pushNodePathToFrontend(node));
-    value->setString("handlerBody", eventListenerHandlerBody(node->document(), eventListener.get()));
+    RefPtr<TypeBuilder::DOM::EventListener> value = TypeBuilder::DOM::EventListener::create()
+        .setType(eventType)
+        .setUseCapture(registeredEventListener.useCapture)
+        .setIsAttribute(eventListener->isAttribute())
+        .setNodeId(pushNodePathToFrontend(node))
+        .setHandlerBody(eventListenerHandlerBody(node->document(), eventListener.get()));
     String sourceName;
     int lineNumber;
     if (eventListenerHandlerLocation(node->document(), eventListener.get(), sourceName, lineNumber)) {
-        RefPtr<InspectorObject> location = InspectorObject::create();
-        location->setString("scriptId", sourceName);
-        location->setNumber("lineNumber", lineNumber);
-        value->setObject("location", location);
+        RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Location::create()
+            .setScriptId(sourceName)
+            .setLineNumber(lineNumber);
+        value->setLocation(location);
     }
     return value.release();
 }
index 2221ec2529d10649dcbd022e5755cf952fb1a041..e9049caa8827058db847fdd208da93d0af0e0986 100644 (file)
@@ -318,10 +318,10 @@ PassRefPtr<InspectorObject> InspectorDebuggerAgent::resolveBreakpoint(const Stri
         debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.set(breakpointId, Vector<String>()).first;
     debugServerBreakpointIdsIterator->second.append(debugServerBreakpointId);
 
-    RefPtr<InspectorObject> location = InspectorObject::create();
-    location->setString("scriptId", scriptId);
-    location->setNumber("lineNumber", actualLineNumber);
-    location->setNumber("columnNumber", actualColumnNumber);
+    RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Location::create()
+        .setScriptId(scriptId)
+        .setLineNumber(actualLineNumber);
+    location->setColumnNumber(actualColumnNumber);
     return location;
 }
 
index 641d1923e227dc9087a39774735b223989d2422c..fd8fcefdb3d3b90e5cf3d4f5a3cca7d73801ba1c 100644 (file)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "ScriptCallFrame.h"
 
+#include "InspectorFrontend.h"
 #include "InspectorValues.h"
 #include <wtf/RefPtr.h>
 
@@ -58,11 +59,11 @@ bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const
 #if ENABLE(INSPECTOR)
 PassRefPtr<InspectorObject> ScriptCallFrame::buildInspectorObject() const
 {
-    RefPtr<InspectorObject> frame = InspectorObject::create();
-    frame->setString("functionName", m_functionName);
-    frame->setString("url", m_scriptName);
-    frame->setNumber("lineNumber", m_lineNumber);
-    frame->setNumber("columnNumber", m_column);
+    RefPtr<TypeBuilder::Console::CallFrame> frame = TypeBuilder::Console::CallFrame::create()
+        .setFunctionName(m_functionName)
+        .setUrl(m_scriptName)
+        .setLineNumber(m_lineNumber)
+        .setColumnNumber(m_column);
     return frame;
 }
 #endif