[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

yurys at chromium.org yurys at chromium.org
Wed Dec 22 11:16:42 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4eba224476051d3c3e5226a2289164c567d9fa9c
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jul 16 15:30:32 2010 +0000

    2010-07-16  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            console.trace should show file and line number for each function in the stack
            https://bugs.webkit.org/show_bug.cgi?id=21180
    
            Test: inspector/console-trace.html
    
            * bindings/js/ScriptCallStack.cpp:
            (WebCore::ScriptCallStack::initialize):
            * bindings/v8/ScriptCallFrame.cpp:
            (WebCore::ScriptCallFrame::ScriptCallFrame):
            * bindings/v8/ScriptCallFrame.h:
            * bindings/v8/ScriptCallStack.cpp:
            (WebCore::getFrameLocation):
            (WebCore::toScriptCallFrame):
            (WebCore::ScriptCallStack::create):
            (WebCore::ScriptCallStack::ScriptCallStack):
            (WebCore::ScriptCallStack::at):
            (WebCore::ScriptCallStack::size):
            * bindings/v8/ScriptCallStack.h:
            * bindings/v8/custom/V8ConsoleCustom.cpp:
            (WebCore::V8Console::traceCallback):
            * inspector/ConsoleMessage.cpp:
            (WebCore::ConsoleMessage::CallFrame::CallFrame):
            (WebCore::ConsoleMessage::CallFrame::isEqual):
            (WebCore::ConsoleMessage::CallFrame::createFrontendObject):
            (WebCore::ConsoleMessage::ConsoleMessage):
            (WebCore::ConsoleMessage::addToFrontend):
            (WebCore::ConsoleMessage::isEqual):
            * inspector/ConsoleMessage.h:
            * inspector/front-end/ConsoleView.js:
            (WebInspector.ConsoleMessage.prototype._formatMessage):
            (WebInspector.ConsoleMessage.prototype._createStackTraceElement):
            (WebInspector.ConsoleMessage.prototype._createSourceUrlLink):
            * inspector/front-end/inspector.css:
            (.console-message.expandable > .console-message-text::before):
            (.console-message.expandable.collapsed > .console-message-text::before):
            (.console-message.expandable.collapsed > ol.stack-trace):
            (.console-message > ol.stack-trace):
            (.console-message.repeated-message > ol.stack-trace):
            (.console-message.repeated-message > ol.stack-trace.trace-message):
            * page/Console.idl:
    
    2010-07-16  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            console.trace should show file and line number for each function in the stack
            https://bugs.webkit.org/show_bug.cgi?id=21180
    
            * http/tests/inspector/console-tests.js:
            (frontend_dumpConsoleMessages):
            * inspector/console-trace-expected.txt: Added.
            * inspector/console-trace.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 034d4d0..45458df 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-07-16  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        console.trace should show file and line number for each function in the stack
+        https://bugs.webkit.org/show_bug.cgi?id=21180
+
+        * http/tests/inspector/console-tests.js:
+        (frontend_dumpConsoleMessages):
+        * inspector/console-trace-expected.txt: Added.
+        * inspector/console-trace.html: Added.
+
 2010-07-16  Pavel Podivilov  <podivilov at chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/LayoutTests/http/tests/inspector/console-tests.js b/LayoutTests/http/tests/inspector/console-tests.js
index 7a4d977..5c66321 100644
--- a/LayoutTests/http/tests/inspector/console-tests.js
+++ b/LayoutTests/http/tests/inspector/console-tests.js
@@ -39,85 +39,4 @@ function frontend_dumpConsoleMessages()
     }
     return result;
 }
-// Inspected Page functions.
 
-function dumpConsoleMessages(noNotifyDone) {
-    function callback(result)
-    {
-        for (var i = 0; i < result.length; ++i)
-            output(result[i].text);
-        if (!noNotifyDone)
-            notifyDone();
-    }
-    evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
-}
-
-function dumpConsoleMessagesWithClasses(sortMessages) {
-    function callback(result)
-    {
-        var messages = [];
-        for (var i = 0; i < result.length; ++i)
-            messages.push(result[i].text + " " + result[i].clazz);
-        if (sortMessages)
-            messages.sort();
-        for (var i = 0; i < messages.length; ++i)
-            output(messages[i]);
-        notifyDone();
-    }
-    evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
-}
-
-
-// Frontend functions.
-
-function frontend_dumpConsoleMessages()
-{
-    var result = [];
-    var messages = WebInspector.console.messages;
-    for (var i = 0; i < messages.length; ++i) {
-        var element = messages[i].toMessageElement();
-        result.push({ text: element.textContent.replace(/\u200b/g, ""), clazz: element.getAttribute("class")});
-    }
-    return result;
-}
-// Inspected Page functions.
-
-function dumpConsoleMessages(noNotifyDone) {
-    function callback(result)
-    {
-        for (var i = 0; i < result.length; ++i)
-            output(result[i].text);
-        if (!noNotifyDone)
-            notifyDone();
-    }
-    evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
-}
-
-function dumpConsoleMessagesWithClasses(sortMessages) {
-    function callback(result)
-    {
-        var messages = [];
-        for (var i = 0; i < result.length; ++i)
-            messages.push(result[i].text + " " + result[i].clazz);
-        if (sortMessages)
-            messages.sort();
-        for (var i = 0; i < messages.length; ++i)
-            output(messages[i]);
-        notifyDone();
-    }
-    evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
-}
-
-
-// Frontend functions.
-
-function frontend_dumpConsoleMessages()
-{
-    var result = [];
-    var messages = WebInspector.console.messages;
-    for (var i = 0; i < messages.length; ++i) {
-        var element = messages[i].toMessageElement();
-        result.push({ text: element.textContent.replace(/\u200b/g, ""), clazz: element.getAttribute("class")});
-    }
-    return result;
-}
diff --git a/LayoutTests/inspector/console-trace-expected.txt b/LayoutTests/inspector/console-trace-expected.txt
new file mode 100644
index 0000000..caea9aa
--- /dev/null
+++ b/LayoutTests/inspector/console-trace-expected.txt
@@ -0,0 +1,4 @@
+Tests that console.trace dumps stack trace with source URLs and line numbers.
+
+bconsole-trace.html:9aconsole-trace.html:14
+
diff --git a/LayoutTests/inspector/console-trace.html b/LayoutTests/inspector/console-trace.html
new file mode 100755
index 0000000..2ba843c
--- /dev/null
+++ b/LayoutTests/inspector/console-trace.html
@@ -0,0 +1,32 @@
+<html>
+<head>
+<script src="../http/tests/inspector/inspector-test.js"></script>
+<script src="../http/tests/inspector/console-tests.js"></script>
+<script>
+
+function b()
+{
+    console.trace();
+}
+
+function a()
+{
+    b();
+}
+
+function doit()
+{
+    setTimeout(a, 0);
+    dumpConsoleMessages();
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p>
+Tests that console.trace dumps stack trace with source URLs and line numbers.
+</p>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2b93d30..d3a9c46 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,48 @@
+2010-07-16  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        console.trace should show file and line number for each function in the stack
+        https://bugs.webkit.org/show_bug.cgi?id=21180
+
+        Test: inspector/console-trace.html
+
+        * bindings/js/ScriptCallStack.cpp:
+        (WebCore::ScriptCallStack::initialize):
+        * bindings/v8/ScriptCallFrame.cpp:
+        (WebCore::ScriptCallFrame::ScriptCallFrame):
+        * bindings/v8/ScriptCallFrame.h:
+        * bindings/v8/ScriptCallStack.cpp:
+        (WebCore::getFrameLocation):
+        (WebCore::toScriptCallFrame):
+        (WebCore::ScriptCallStack::create):
+        (WebCore::ScriptCallStack::ScriptCallStack):
+        (WebCore::ScriptCallStack::at):
+        (WebCore::ScriptCallStack::size):
+        * bindings/v8/ScriptCallStack.h:
+        * bindings/v8/custom/V8ConsoleCustom.cpp:
+        (WebCore::V8Console::traceCallback):
+        * inspector/ConsoleMessage.cpp:
+        (WebCore::ConsoleMessage::CallFrame::CallFrame):
+        (WebCore::ConsoleMessage::CallFrame::isEqual):
+        (WebCore::ConsoleMessage::CallFrame::createFrontendObject):
+        (WebCore::ConsoleMessage::ConsoleMessage):
+        (WebCore::ConsoleMessage::addToFrontend):
+        (WebCore::ConsoleMessage::isEqual):
+        * inspector/ConsoleMessage.h:
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleMessage.prototype._formatMessage):
+        (WebInspector.ConsoleMessage.prototype._createStackTraceElement):
+        (WebInspector.ConsoleMessage.prototype._createSourceUrlLink):
+        * inspector/front-end/inspector.css:
+        (.console-message.expandable > .console-message-text::before):
+        (.console-message.expandable.collapsed > .console-message-text::before):
+        (.console-message.expandable.collapsed > ol.stack-trace):
+        (.console-message > ol.stack-trace):
+        (.console-message.repeated-message > ol.stack-trace):
+        (.console-message.repeated-message > ol.stack-trace.trace-message):
+        * page/Console.idl:
+
 2010-07-16  Lucas De Marchi  <lucas.demarchi at profusion.mobi>
 
         Reviewed by Antonio Gomes.
diff --git a/WebCore/bindings/js/ScriptCallStack.cpp b/WebCore/bindings/js/ScriptCallStack.cpp
index c9bb8b0..de61b07 100644
--- a/WebCore/bindings/js/ScriptCallStack.cpp
+++ b/WebCore/bindings/js/ScriptCallStack.cpp
@@ -91,11 +91,21 @@ void ScriptCallStack::initialize()
     if (!m_caller || m_initialized)
         return;
 
-    JSValue func = m_exec->interpreter()->retrieveCaller(m_exec, m_caller);
-    while (!func.isNull()) {
-        JSFunction* jsFunction = asFunction(func);
-        m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), UString(), 0, 0, 0));
-        func = m_exec->interpreter()->retrieveCaller(m_exec, jsFunction);
+    int signedLineNumber;
+    intptr_t sourceID;
+    UString urlString;
+    JSValue function;
+    // callFrame must exist if m_caller is not null.
+    CallFrame* callFrame = m_exec->callerFrame();
+    while (true) {
+        ASSERT(callFrame);
+        m_exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
+        if (!function)
+            break;
+        JSFunction* jsFunction = asFunction(function);
+        unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
+        m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), urlString, lineNumber, m_exec, 0));
+        callFrame = callFrame->callerFrame();
     }
     m_initialized = true;
 }
diff --git a/WebCore/bindings/v8/ScriptCallFrame.cpp b/WebCore/bindings/v8/ScriptCallFrame.cpp
index 4c29814..9554f67 100644
--- a/WebCore/bindings/v8/ScriptCallFrame.cpp
+++ b/WebCore/bindings/v8/ScriptCallFrame.cpp
@@ -45,10 +45,17 @@ ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlSt
     , m_sourceURL(ParsedURLString, urlString)
     , m_lineNumber(lineNumber)
 {
-    for (int i = 0; i < arguments.Length(); ++i)
+    for (int i = skipArgumentCount; i < arguments.Length(); ++i)
         m_arguments.append(ScriptValue(arguments[i]));
 }
 
+ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber)
+    : m_functionName(functionName)
+    , m_sourceURL(ParsedURLString, urlString)
+    , m_lineNumber(lineNumber)
+{
+}
+
 ScriptCallFrame::~ScriptCallFrame()
 {
 }
diff --git a/WebCore/bindings/v8/ScriptCallFrame.h b/WebCore/bindings/v8/ScriptCallFrame.h
index 50357cf..8d1972f 100644
--- a/WebCore/bindings/v8/ScriptCallFrame.h
+++ b/WebCore/bindings/v8/ScriptCallFrame.h
@@ -50,6 +50,7 @@ namespace WebCore {
     class ScriptCallFrame  {
     public:
         ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments&, unsigned skipArgumentCount);
+        ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber);
         ~ScriptCallFrame();
 
         const ScriptString& functionName() const { return m_functionName; }
diff --git a/WebCore/bindings/v8/ScriptCallStack.cpp b/WebCore/bindings/v8/ScriptCallStack.cpp
index cdc9662..7bcab1c 100644
--- a/WebCore/bindings/v8/ScriptCallStack.cpp
+++ b/WebCore/bindings/v8/ScriptCallStack.cpp
@@ -32,68 +32,101 @@
 #include "ScriptCallStack.h"
 
 #include "InspectorValues.h"
-#include "ScriptScope.h"
 #include "ScriptController.h"
 #include "ScriptDebugServer.h"
+#include "ScriptScope.h"
 #include "V8Binding.h"
 
 #include <v8-debug.h>
 
 namespace WebCore {
 
-ScriptCallStack* ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount) {
+static void getFrameLocation(v8::Handle<v8::StackFrame> frame, String* sourceName, int* sourceLineNumber, String* functionName)
+{
+    ASSERT(!frame.IsEmpty());
+    v8::Local<v8::String> sourceNameValue(frame->GetScriptName());
+    v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
+    *sourceName = sourceNameValue.IsEmpty() ? "" : toWebCoreString(sourceNameValue);
+    *functionName = functionNameValue.IsEmpty() ? "" : toWebCoreString(functionNameValue);
+    *sourceLineNumber = frame->GetLineNumber();
+}
+
+static PassOwnPtr<ScriptCallFrame> toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
+{
     String sourceName;
     int sourceLineNumber;
-    String funcName;
-    if (!callLocation(&sourceName, &sourceLineNumber, &funcName))
-      return 0;
-    return new ScriptCallStack(arguments, skipArgumentCount, sourceName, sourceLineNumber, funcName);
+    String functionName;
+    getFrameLocation(frame, &sourceName, &sourceLineNumber, &functionName);
+    return new ScriptCallFrame(functionName, sourceName, sourceLineNumber);
 }
 
-bool ScriptCallStack::callLocation(String* sourceName, int* sourceLineNumber, String* functionName)
+PassOwnPtr<ScriptCallStack> ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount)
 {
     v8::HandleScope scope;
     v8::Context::Scope contextScope(v8::Context::GetCurrent());
     v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(1));
+
     if (stackTrace.IsEmpty())
-        return false;
+        return 0;
+
+    String sourceName;
+    int sourceLineNumber;
+    String functionName;
     if (stackTrace->GetFrameCount() <= 0) {
         // Successfully grabbed stack trace, but there are no frames.
         // Fallback to setting lineNumber to 0, and source and function name to "undefined".
-        *sourceName = toWebCoreString(v8::Undefined());
-        *sourceLineNumber = 0;
-        *functionName = toWebCoreString(v8::Undefined());
-        return true;
+        sourceName = toWebCoreString(v8::Undefined());
+        sourceLineNumber = 0;
+        functionName = toWebCoreString(v8::Undefined());
+    } else {
+        v8::Handle<v8::StackFrame> frame = stackTrace->GetFrame(0);
+        getFrameLocation(frame, &sourceName, &sourceLineNumber, &functionName);
     }
-    v8::Handle<v8::StackFrame> frame = stackTrace->GetFrame(0);
-    // There must be at least one valid frame.
-    ASSERT(!frame.IsEmpty());
-    v8::Local<v8::String> sourceNameValue(frame->GetScriptName());
-    v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
-    *sourceName = sourceNameValue.IsEmpty() ? "" : toWebCoreString(sourceNameValue);
-    *functionName = functionNameValue.IsEmpty() ? "" : toWebCoreString(functionNameValue);
-    *sourceLineNumber = frame->GetLineNumber();
-    return true;
+    return new ScriptCallStack(arguments, skipArgumentCount, sourceName, sourceLineNumber, functionName);
+}
+
+PassOwnPtr<ScriptCallStack> ScriptCallStack::create(ScriptState* state, v8::Handle<v8::StackTrace> stackTrace)
+{
+    return new ScriptCallStack(state, stackTrace);
 }
 
 ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber, String functionName)
-    : m_lastCaller(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount)
+    : m_topFrame(new ScriptCallFrame(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount))
     , m_scriptState(ScriptState::current())
 {
 }
 
+ScriptCallStack::ScriptCallStack(ScriptState* scriptState, v8::Handle<v8::StackTrace> stackTrace)
+    : m_scriptState(scriptState)
+{
+    v8::HandleScope handleScope;
+    v8::Context::Scope contextScope(m_scriptState->context());
+    int frameCount = stackTrace->GetFrameCount();
+    for (int i = 0; i < frameCount; i++) {
+        v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
+        m_scriptCallFrames.append(toScriptCallFrame(stackFrame));
+    }
+}
+
 ScriptCallStack::~ScriptCallStack()
 {
 }
 
-const ScriptCallFrame& ScriptCallStack::at(unsigned index) const
+const ScriptCallFrame& ScriptCallStack::at(unsigned index)
 {
-    // Currently, only one ScriptCallFrame is supported. When we can get
-    // a full stack trace from V8, we can do this right.
-    ASSERT(index == 0);
-    return m_lastCaller;
+    if (!index && m_topFrame)
+        return *m_topFrame;
+    return *m_scriptCallFrames.at(index);
 }
 
+unsigned ScriptCallStack::size()
+{
+    if (m_scriptCallFrames.isEmpty())
+        return 1;
+    return m_scriptCallFrames.size();
+}
+
+
 bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace)
 {
     if (!v8::Context::InContext())
diff --git a/WebCore/bindings/v8/ScriptCallStack.h b/WebCore/bindings/v8/ScriptCallStack.h
index 80d5f76..d21b9f9 100644
--- a/WebCore/bindings/v8/ScriptCallStack.h
+++ b/WebCore/bindings/v8/ScriptCallStack.h
@@ -48,7 +48,8 @@ class InspectorArray;
 
 class ScriptCallStack : public Noncopyable {
 public:
-    static ScriptCallStack* create(const v8::Arguments&, unsigned skipArgumentCount = 0);
+    static PassOwnPtr<ScriptCallStack> create(const v8::Arguments&, unsigned skipArgumentCount = 0);
+    static PassOwnPtr<ScriptCallStack> create(ScriptState*, v8::Handle<v8::StackTrace>);
     ~ScriptCallStack();
 
     // Returns false if there is no running JavaScript or if fetching the stack failed.
@@ -62,20 +63,19 @@ public:
     // }
     static bool stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace);
 
-    const ScriptCallFrame& at(unsigned) const;
-    // FIXME: implement retrieving and storing call stack trace
-    unsigned size() const { return 1; }
+    const ScriptCallFrame& at(unsigned);
+    unsigned size();
 
     ScriptState* state() const { return m_scriptState; }
     ScriptState* globalState() const { return m_scriptState; }
 
 private:
     ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber, String funcName);
+    ScriptCallStack(ScriptState* scriptState, v8::Handle<v8::StackTrace> stackTrace);
 
-    static bool callLocation(String* sourceName, int* sourceLineNumber, String* functionName);
-
-    ScriptCallFrame m_lastCaller;
+    OwnPtr<ScriptCallFrame> m_topFrame;
     ScriptState* m_scriptState;
+    Vector<OwnPtr<ScriptCallFrame> > m_scriptCallFrames;
 };
 
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
index e925f0d..a09e1b3 100644
--- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
@@ -33,6 +33,7 @@
 #include "V8Console.h"
 
 #include "Console.h"
+#include "ScriptCallStack.h"
 #include "ScriptProfile.h"
 #include "V8Binding.h"
 #include "V8Proxy.h"
@@ -57,4 +58,15 @@ v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> na
 }
 #endif
 
+v8::Handle<v8::Value> V8Console::traceCallback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.Console.traceCallback");
+    Console* imp = V8Console::toNative(args.Holder());
+    v8::HandleScope handleScope;
+    ScriptState* scriptState = ScriptState::current();
+    v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(200);
+    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(scriptState, stackTrace));
+    imp->trace(callStack.get());
+    return v8::Handle<v8::Value>();
+}
 } // namespace WebCore
diff --git a/WebCore/inspector/ConsoleMessage.cpp b/WebCore/inspector/ConsoleMessage.cpp
index c458eaa..f6c0961 100644
--- a/WebCore/inspector/ConsoleMessage.cpp
+++ b/WebCore/inspector/ConsoleMessage.cpp
@@ -40,6 +40,34 @@
 
 namespace WebCore {
 
+ConsoleMessage::CallFrame::CallFrame(const ScriptCallFrame& frame)
+    : m_functionName(frame.functionName())
+    , m_sourceURL(frame.sourceURL())
+    , m_lineNumber(frame.lineNumber())
+{
+}
+
+ConsoleMessage::CallFrame::CallFrame()
+    : m_lineNumber(0)
+{
+}
+
+bool ConsoleMessage::CallFrame::isEqual(const ConsoleMessage::CallFrame& o) const
+{
+    return m_functionName == o.m_functionName
+        && m_sourceURL == o.m_sourceURL
+        && m_lineNumber == o.m_lineNumber;
+}
+
+ScriptObject ConsoleMessage::CallFrame::buildObject(InspectorFrontend* frontend) const
+{
+    ScriptObject frame = frontend->newScriptObject();
+    frame.set("functionName", m_functionName);
+    frame.set("sourceURL", m_sourceURL.string());
+    frame.set("lineNumber", m_lineNumber);
+    return frame;
+}
+
 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, unsigned g)
     : m_source(s)
     , m_type(t)
@@ -73,7 +101,7 @@ ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, S
     // frames, refactor to use that, as well.
     if (storeTrace) {
         for (unsigned i = 0; i < callStack->size(); ++i)
-            m_frames[i] = callStack->at(i).functionName();
+            m_frames[i] = ConsoleMessage::CallFrame(callStack->at(i));
     }
 
 #if ENABLE(INSPECTOR)
@@ -107,10 +135,10 @@ void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHo
         jsonObj.set("parameters", jsonArgs);
     }
     if (!m_frames.isEmpty()) {
-        ScriptArray jsonFrames = frontend->newScriptArray();
-        for (unsigned i = 0; i < m_frames.size(); ++i)
-            jsonFrames.set(i, m_frames[i]);
-        jsonObj.set("stackTrace", jsonFrames);
+        ScriptArray frames = frontend->newScriptArray();
+        for (unsigned i = 0; i < m_frames.size(); i++)
+            frames.set(i, m_frames.at(i).buildObject(frontend));
+        jsonObj.set("stackTrace", frames);
     }
     frontend->addConsoleMessage(jsonObj);
 }
@@ -144,7 +172,7 @@ bool ConsoleMessage::isEqual(ScriptState* state, ConsoleMessage* msg) const
         return false;
 
     for (size_t i = 0; i < frameCount; ++i) {
-        if (m_frames[i] != msg->m_frames[i])
+        if (!m_frames[i].isEqual(msg->m_frames[i]))
             return false;
     }
 
diff --git a/WebCore/inspector/ConsoleMessage.h b/WebCore/inspector/ConsoleMessage.h
index 77a010c..d6abc9b 100644
--- a/WebCore/inspector/ConsoleMessage.h
+++ b/WebCore/inspector/ConsoleMessage.h
@@ -40,12 +40,13 @@
 namespace WebCore {
 class InjectedScriptHost;
 class InspectorFrontend;
+class ScriptCallFrame;
 class ScriptCallStack;
 class ScriptString;
 
 class ConsoleMessage : public Noncopyable {
 public:
-    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g);        
+    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g);
     ConsoleMessage(MessageSource, MessageType, MessageLevel, ScriptCallStack*, unsigned g, bool storeTrace = false);
 
 #if ENABLE(INSPECTOR)
@@ -59,6 +60,19 @@ public:
     const String& message() const { return m_message; }
 
 private:
+    class CallFrame {
+    public:
+        explicit CallFrame(const ScriptCallFrame& frame);
+        CallFrame();
+        bool isEqual(const CallFrame& o) const;
+        ScriptObject buildObject(InspectorFrontend* frontend) const;
+
+    private:
+        String m_functionName;
+        KURL m_sourceURL;
+        unsigned m_lineNumber;
+    };
+
     MessageSource m_source;
     MessageType m_type;
     MessageLevel m_level;
@@ -67,7 +81,7 @@ private:
     Vector<ScriptValue> m_arguments;
     ScriptStateProtectedPtr m_scriptState;
 #endif
-    Vector<ScriptString> m_frames;
+    Vector<CallFrame> m_frames;
     unsigned m_line;
     String m_url;
     unsigned m_groupLevel;
diff --git a/WebCore/inspector/front-end/ConsoleView.js b/WebCore/inspector/front-end/ConsoleView.js
index df5a1a2..36e0275 100644
--- a/WebCore/inspector/front-end/ConsoleView.js
+++ b/WebCore/inspector/front-end/ConsoleView.js
@@ -673,13 +673,8 @@ WebInspector.ConsoleMessage.prototype = {
     {
         switch (this.type) {
             case WebInspector.ConsoleMessage.MessageType.Trace:
-                var span = document.createElement("span");
-                span.className = "console-formatted-trace source-code";
-                var funcNames = this._stackTrace.map(function(f) {
-                    return f || WebInspector.UIString("(anonymous function)");
-                });
-                span.appendChild(document.createTextNode(funcNames.join("\n")));
-                this.formattedMessage = span;
+                this.formattedMessage = this._createStackTraceElement();
+                this.formattedMessage.addStyleClass("trace-message");
                 break;
             case WebInspector.ConsoleMessage.MessageType.Object:
                 var obj = this._parameters ? this._parameters[0] : undefined;
@@ -830,36 +825,58 @@ WebInspector.ConsoleMessage.prototype = {
             return element;
         }
 
-        if (this.url && this.url !== "undefined") {
-            var urlElement = document.createElement("a");
-            urlElement.className = "console-message-url webkit-html-resource-link";
-            urlElement.href = this.url;
-            urlElement.lineNumber = this.line;
-
-            if (this.source === WebInspector.ConsoleMessage.MessageSource.JS)
-                urlElement.preferredPanel = "scripts";
+        if (this.type === WebInspector.ConsoleMessage.MessageType.Trace) {
+            element.appendChild(this.formattedMessage);
+        } else {
+            if (this.url && this.url !== "undefined") {
+                var urlElement = WebInspector.linkifyResourceAsNode(this.url, "scripts", this.line, "console-message-url"); 
+                element.appendChild(urlElement);
+            }
 
-            if (this.line > 0)
-                urlElement.textContent = WebInspector.displayNameForURL(this.url) + ":" + this.line;
-            else
-                urlElement.textContent = WebInspector.displayNameForURL(this.url);
+            var messageTextElement = document.createElement("span");
+            messageTextElement.className = "console-message-text source-code";
+            if (this.type === WebInspector.ConsoleMessage.MessageType.Assert)
+                messageTextElement.appendChild(document.createTextNode(WebInspector.UIString("Assertion failed: ")));
+            messageTextElement.appendChild(this.formattedMessage);
+            element.appendChild(messageTextElement);
 
-            element.appendChild(urlElement);
+            if (this._stackTrace) {
+                var ol = this._createStackTraceElement();
+                element.appendChild(ol);
+            }
         }
 
-        var messageTextElement = document.createElement("span");
-        messageTextElement.className = "console-message-text source-code";
-        if (this.type === WebInspector.ConsoleMessage.MessageType.Assert)
-            messageTextElement.appendChild(document.createTextNode(WebInspector.UIString("Assertion failed: ")));
-        messageTextElement.appendChild(this.formattedMessage);
-        element.appendChild(messageTextElement);
-
         if (this.repeatCount > 1)
             this._updateRepeatCount();
 
         return element;
     },
 
+    _createStackTraceElement: function()
+    {
+        var ol = document.createElement("ol");
+        ol.addStyleClass("stack-trace");
+        var treeOutline = new TreeOutline(ol);
+        for (var i = 0; i < this._stackTrace.length; i++) {
+            var frame = this._stackTrace[i];
+
+            var li = document.createElement("li");
+            var messageTextElement = document.createElement("span");
+            messageTextElement.className = "console-message-text source-code";
+            var functionName = frame.functionName || WebInspector.UIString("(anonymous function)");
+            messageTextElement.appendChild(document.createTextNode(functionName));
+            li.appendChild(messageTextElement);
+
+            var urlElement = WebInspector.linkifyResourceAsNode(frame.sourceURL, "scripts", frame.lineNumber, "console-message-url"); 
+            li.appendChild(urlElement);
+
+
+            var treeElement = new TreeElement(li.innerHTML);
+            treeOutline.appendChild(treeElement);
+        }
+        return ol;
+    },
+
     _updateRepeatCount: function() {
         if (!this.repeatCountElement) {
             this.repeatCountElement = document.createElement("span");
diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css
index d8e29e8..d53de5a 100644
--- a/WebCore/inspector/front-end/inspector.css
+++ b/WebCore/inspector/front-end/inspector.css
@@ -711,6 +711,16 @@ body.platform-linux .monospace, body.platform-linux .source-code {
     content: url(Images/treeDownTriangleBlack.png);
 }
 
+.console-message > ol.stack-trace {
+    margin: 5px 0 5px -30px;
+    list-style: none;
+}
+
+.console-message.repeated-message > ol.stack-trace.trace-message {
+    margin-top: -9px;
+    margin-left: -12px;
+}
+
 .console-group-messages .section .header .title {
     color: black;
     font-weight: normal;
diff --git a/WebCore/page/Console.idl b/WebCore/page/Console.idl
index b79ff50..addf635 100644
--- a/WebCore/page/Console.idl
+++ b/WebCore/page/Console.idl
@@ -41,7 +41,7 @@ module window {
         [CustomArgumentHandling] void warn();
         [CustomArgumentHandling] void dir();
         [CustomArgumentHandling] void dirxml();
-        [CustomArgumentHandling] void trace();
+        [V8Custom, CustomArgumentHandling] void trace();
         [CustomArgumentHandling, ImplementationFunction=assertCondition] void assert(in boolean condition);
         [CustomArgumentHandling] void count();
         [CustomArgumentHandling] void markTimeline();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list