Reviewed by Adam.
authorkmccullo <kmccullo@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Oct 2007 01:38:57 +0000 (01:38 +0000)
committerkmccullo <kmccullo@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Oct 2007 01:38:57 +0000 (01:38 +0000)
        - Implemented the WebScriptDebugListener functions now that the
        WebScriptDebugServer exists

        * Drosera/win/ServerConnection.cpp: Implemented WebScriptDebugListener
        functions.
        (ServerConnection::currentFrame):
        (ServerConnection::didLoadMainResourceForDataSource):
        (ServerConnection::didParseSource):
        (ServerConnection::failedToParseSource):
        (ServerConnection::didEnterCallFrame):
        (ServerConnection::willExecuteStatement):
        (ServerConnection::willLeaveCallFrame):
        (ServerConnection::exceptionWasRaised):
        * Drosera/win/ServerConnection.h: Removed unused arguments from the
        members arguments list.

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

WebKitTools/ChangeLog
WebKitTools/Drosera/win/ServerConnection.cpp
WebKitTools/Drosera/win/ServerConnection.h

index ed2858b6f32f92ca08cbbd831e21cb2e50504001..074121db0d5f0266f7eaea29eef060d781777a46 100644 (file)
@@ -1,3 +1,23 @@
+2007-10-26  Kevin McCullough  <kmccullough@apple.com>
+
+        Reviewed by Adam.
+
+        - Implemented the WebScriptDebugListener functions now that the
+        WebScriptDebugServer exists
+
+        * Drosera/win/ServerConnection.cpp: Implemented WebScriptDebugListener
+        functions.
+        (ServerConnection::currentFrame):
+        (ServerConnection::didLoadMainResourceForDataSource):
+        (ServerConnection::didParseSource):
+        (ServerConnection::failedToParseSource):
+        (ServerConnection::didEnterCallFrame):
+        (ServerConnection::willExecuteStatement):
+        (ServerConnection::willLeaveCallFrame):
+        (ServerConnection::exceptionWasRaised):
+        * Drosera/win/ServerConnection.h: Removed unused arguments from the
+        members arguments list.
+
 2007-10-26  David Kilzer  <ddkilzer@webkit.org>
 
         prepare-ChangeLog and update-webkit create needless ChangeLog conflicts
index 5a7242f2df3993eea6d2f340cf0f0e8966299985..89388831222609db4f143bc5bc7b440ef00a57ba 100644 (file)
 
 #include <JavaScriptCore/JSContextRef.h>
 #include <JavaScriptCore/JSRetainPtr.h>
-#include <JavaScriptCore/JSStringRefCF.h>
+#include <JavaScriptCore/JSStringRefCOM.h>
 #include <JavaScriptCore/RetainPtr.h>
 #include <WebKit/WebKit.h>
 
-// FIXME: Some of the below functionality cannot be implemented until the WebScriptDebug Server works on windows.
 ServerConnection::ServerConnection()
     : m_globalContext(0)
 {
@@ -95,7 +94,7 @@ void ServerConnection::serverConnectionDidDie()
 
 // Stack & Variables
 
-WebScriptCallFrame* ServerConnection::currentFrame() const
+IWebScriptCallFrame* ServerConnection::currentFrame() const
 {
     return m_currentFrame;
 }
@@ -129,70 +128,202 @@ ULONG STDMETHODCALLTYPE ServerConnection::Release(void)
 }
 // IWebScriptDebugListener -----------------------------------
 HRESULT STDMETHODCALLTYPE ServerConnection::didLoadMainResourceForDataSource(
-    /* [in] */ IWebView* /*view*/,
-    /* [in] */ IWebDataSource* /*dataSource*/)
+    /* [in] */ IWebView*,
+    /* [in] */ IWebDataSource* dataSource)
 {
+    // Get document source
+    COMPtr<IWebDocumentRepresentation> rep;
+    HRESULT ret = dataSource->representation(&rep);
+    if (FAILED(ret))
+        return ret;
+
+    BOOL canProvideDocumentSource = FALSE;
+    ret = rep->canProvideDocumentSource(&canProvideDocumentSource);
+    if (FAILED(ret))
+        return ret;
+
+    BSTR documentSource = 0;
+    if (canProvideDocumentSource)
+        ret = rep->documentSource(&documentSource);
+
+    if (FAILED(ret) || !documentSource)
+        return ret;
+
+    JSRetainPtr<JSStringRef> documentSourceJS(Adopt, JSStringCreateWithBSTR(documentSource));
+    SysFreeString(documentSource);
+
+    // Get URL
+    COMPtr<IWebURLResponse> response;
+    ret = dataSource->response(&response);
+    if (FAILED(ret))
+        return ret;
+
+    BSTR url = 0;
+    ret = response->URL(&url);
+    if (FAILED(ret))
+        return ret;
+
+    JSRetainPtr<JSStringRef> urlJS(Adopt, JSStringCreateWithBSTR(url));
+    SysFreeString(url);
+
+    DebuggerDocument::updateFileSource(m_globalContext, documentSourceJS.get(), urlJS.get());
+
     return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE ServerConnection::didParseSource(
-    /* [in] */ IWebView* /*view*/,
-    /* [in] */ BSTR /*sourceCode*/,
-    /* [in] */ UINT /*baseLineNumber*/,
-    /* [in] */ BSTR /*url*/,
-    /* [in] */ int /*sourceID*/,
-    /* [in] */ IWebFrame* /*forWebFrame*/)
+    /* [in] */ IWebView*,
+    /* [in] */ BSTR sourceCode,
+    /* [in] */ UINT baseLineNumber,
+    /* [in] */ BSTR url,
+    /* [in] */ int sourceID,
+    /* [in] */ IWebFrame* webFrame)
 {
+    HRESULT ret = S_OK;
+    if (!m_globalContext || !sourceCode)\r
+        return ret;\r
+\r
+    COMPtr<IWebDataSource> dataSource;\r
+    ret = webFrame->dataSource(&dataSource);\r
+    if (FAILED(ret))\r
+        return ret;\r
+\r
+    COMPtr<IWebURLResponse> response;\r
+    ret = dataSource->response(&response);\r
+    if (FAILED(ret))\r
+        return ret;\r
+\r
+    BSTR responseURL;\r
+    ret = response->URL(&responseURL);\r
+    if (FAILED(ret))\r
+        return ret;\r
+\r
+    BSTR documentSource = 0;\r
+    if (!url || !wcscmp(responseURL, url)) {\r
+        COMPtr<IWebDocumentRepresentation> rep;\r
+        ret = dataSource->representation(&rep);\r
+        if (FAILED(ret))\r
+            return ret;\r
+\r
+        BOOL canProvideDocumentSource;\r
+        rep->canProvideDocumentSource(&canProvideDocumentSource);\r
+        if (FAILED(ret))\r
+            return ret;\r
+\r
+        if (canProvideDocumentSource) {\r
+            ret = rep->documentSource(&documentSource);\r
+            if (FAILED(ret))\r
+                return ret;\r
+        }\r
+\r
+        if (!url) {\r
+            ret = response->URL(&url);\r
+            if (FAILED(ret))\r
+                return ret;\r
+        }\r
+    }\r
+    SysFreeString(responseURL);\r
+\r
+    JSRetainPtr<JSStringRef> sourceJS(Adopt, JSStringCreateWithBSTR(sourceCode));\r
+    JSRetainPtr<JSStringRef> documentSourceJS(Adopt, JSStringCreateWithBSTR(documentSource));\r
+    SysFreeString(documentSource);\r
+    JSRetainPtr<JSStringRef> urlJS(Adopt, JSStringCreateWithBSTR(url));\r
+    JSValueRef sidJS = JSValueMakeNumber(m_globalContext, sourceID);\r
+    JSValueRef baseLineJS = JSValueMakeNumber(m_globalContext, baseLineNumber);\r
+\r
+    DebuggerDocument::didParseScript(m_globalContext, sourceJS.get(), documentSourceJS.get(), urlJS.get(), sidJS, baseLineJS);\r
+
     return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE ServerConnection::failedToParseSource(
-    /* [in] */ IWebView* /*view*/,
-    /* [in] */ BSTR /*sourceCode*/,
-    /* [in] */ UINT /*baseLineNumber*/,
-    /* [in] */ BSTR /*url*/,
-    /* [in] */ BSTR /*error*/,
-    /* [in] */ IWebFrame* /*forWebFrame*/)
+    /* [in] */ IWebView*,
+    /* [in] */ BSTR,
+    /* [in] */ UINT,
+    /* [in] */ BSTR,
+    /* [in] */ BSTR,
+    /* [in] */ IWebFrame*)
 {
     return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE ServerConnection::didEnterCallFrame(
-    /* [in] */ IWebView* /*view*/,
-    /* [in] */ IWebScriptCallFrame* /*frame*/,
-    /* [in] */ int /*sourceID*/,
-    /* [in] */ int /*lineNumber*/,
-    /* [in] */ IWebFrame* /*forWebFrame*/)
+    /* [in] */ IWebView*,
+    /* [in] */ IWebScriptCallFrame* frame,
+    /* [in] */ int sourceID,
+    /* [in] */ int lineNumber,
+    /* [in] */ IWebFrame*)
 {
-    return S_OK;
+    HRESULT ret = S_OK;
+    if (!m_globalContext)\r
+        return ret;\r
+\r
+    // FIXME: This won't be relevant until IWebScriptCallFrame is implemented on Windows\r
+    m_currentFrame = frame;\r
+\r
+    JSValueRef sidJS = JSValueMakeNumber(m_globalContext, sourceID);\r
+    JSValueRef linenoJS = JSValueMakeNumber(m_globalContext, lineNumber);\r
+\r
+    DebuggerDocument::didEnterCallFrame(m_globalContext, sidJS, linenoJS);\r
+
+    return ret;
 }
 
 HRESULT STDMETHODCALLTYPE ServerConnection::willExecuteStatement(
-    /* [in] */ IWebView* /*view*/,
-    /* [in] */ IWebScriptCallFrame* /*frame*/,
-    /* [in] */ int /*sourceID*/,
-    /* [in] */ int /*lineNumber*/,
-    /* [in] */ IWebFrame* /*forWebFrame*/)
+    /* [in] */ IWebView*,
+    /* [in] */ IWebScriptCallFrame*,
+    /* [in] */ int sourceID,
+    /* [in] */ int lineNumber,
+    /* [in] */ IWebFrame*)
 {
-    return S_OK;
+    HRESULT ret = S_OK;
+    if (!m_globalContext)\r
+        return ret;\r
+\r
+    JSValueRef sidJS = JSValueMakeNumber(m_globalContext, sourceID);\r
+    JSValueRef linenoJS = JSValueMakeNumber(m_globalContext, lineNumber);\r
+\r
+    DebuggerDocument::willExecuteStatement(m_globalContext, sidJS, linenoJS);
+    return ret;
 }
 
 HRESULT STDMETHODCALLTYPE ServerConnection::willLeaveCallFrame(
-    /* [in] */ IWebView* /*view*/,
-    /* [in] */ IWebScriptCallFrame* /*frame*/,
-    /* [in] */ int /*sourceID*/,
-    /* [in] */ int /*lineNumber*/,
-    /* [in] */ IWebFrame* /*forWebFrame*/)
+    /* [in] */ IWebView*,
+    /* [in] */ IWebScriptCallFrame* frame,
+    /* [in] */ int sourceID,
+    /* [in] */ int lineNumber,
+    /* [in] */ IWebFrame*)
 {
+    HRESULT ret = S_OK;
+    if (!m_globalContext)\r
+        return ret;\r
+\r
+    JSValueRef sidJS = JSValueMakeNumber(m_globalContext, sourceID);\r
+    JSValueRef linenoJS = JSValueMakeNumber(m_globalContext, lineNumber);\r
+\r
+    DebuggerDocument::willLeaveCallFrame(m_globalContext, sidJS, linenoJS);\r
+\r
+    // FIXME: This won't be relevant until IWebScriptCallFrame is implemented on Windows\r
+    m_currentFrame = frame;\r
+
     return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE ServerConnection::exceptionWasRaised(
-    /* [in] */ IWebView* /*view*/,
-    /* [in] */ IWebScriptCallFrame* /*frame*/,
-    /* [in] */ int /*sourceID*/,
-    /* [in] */ int /*lineNumber*/,
-    /* [in] */ IWebFrame* /*forWebFrame*/)
+    /* [in] */ IWebView*,
+    /* [in] */ IWebScriptCallFrame*,
+    /* [in] */ int sourceID,
+    /* [in] */ int lineNumber,
+    /* [in] */ IWebFrame*)
 {
-    return S_OK;
+    HRESULT ret = S_OK;
+    if (!m_globalContext)\r
+        return ret;\r
+\r
+    JSValueRef sidJS = JSValueMakeNumber(m_globalContext, sourceID);\r
+    JSValueRef linenoJS = JSValueMakeNumber(m_globalContext, lineNumber);\r
+\r
+    DebuggerDocument::exceptionWasRaised(m_globalContext, sidJS, linenoJS);
+
+    return ret;
 }
index 2beea4a22ca1e1ca789f3740d4ea00f04517f65e..4b6bb3ac385d8691ab62902c52f4b82147f2f780 100644 (file)
@@ -36,7 +36,7 @@
 #include <WebKit/IWebScriptDebugServer.h>
 
 class DebuggerClient;
-class WebScriptCallFrame;
+interface IWebScriptCallFrame;
 
 typedef struct OpaqueJSContext* JSGlobalContextRef;
 
@@ -52,7 +52,7 @@ public:
 
     void applicationTerminating();
     void serverConnectionDidDie();
-    WebScriptCallFrame* currentFrame() const;
+    IWebScriptCallFrame* currentFrame() const;
 
     // IUnknown
     HRESULT STDMETHODCALLTYPE QueryInterface(
@@ -64,57 +64,58 @@ public:
 
     // IWebScriptDebugListener
     HRESULT STDMETHODCALLTYPE didLoadMainResourceForDataSource(
-        /* [in] */ IWebView* view,
+        /* [in] */ IWebView*,
         /* [in] */ IWebDataSource* dataSource);
 
     HRESULT STDMETHODCALLTYPE didParseSource(
-        /* [in] */ IWebView* view,
+        /* [in] */ IWebView*,
         /* [in] */ BSTR sourceCode,
         /* [in] */ UINT baseLineNumber,
         /* [in] */ BSTR url,
         /* [in] */ int sourceID,
-        /* [in] */ IWebFrame* forWebFrame);
+        /* [in] */ IWebFrame* webFrame);
 
     HRESULT STDMETHODCALLTYPE failedToParseSource(
-        /* [in] */ IWebView* view,
+        /* [in] */ IWebView*,
         /* [in] */ BSTR sourceCode,
         /* [in] */ UINT baseLineNumber,
         /* [in] */ BSTR url,
         /* [in] */ BSTR error,
-        /* [in] */ IWebFrame* forWebFrame);
+        /* [in] */ IWebFrame*);
 
     HRESULT STDMETHODCALLTYPE didEnterCallFrame(
-        /* [in] */ IWebView* view,
+        /* [in] */ IWebView*,
         /* [in] */ IWebScriptCallFrame* frame,
         /* [in] */ int sourceID,
         /* [in] */ int lineNumber,
-        /* [in] */ IWebFrame* forWebFrame);
+        /* [in] */ IWebFrame*);
 
     HRESULT STDMETHODCALLTYPE willExecuteStatement(
-        /* [in] */ IWebView* view,
-        /* [in] */ IWebScriptCallFrame* frame,
+        /* [in] */ IWebView*,
+        /* [in] */ IWebScriptCallFrame*,
         /* [in] */ int sourceID,
         /* [in] */ int lineNumber,
-        /* [in] */ IWebFrame* forWebFrame);
+        /* [in] */ IWebFrame*);
 
     HRESULT STDMETHODCALLTYPE willLeaveCallFrame(
-        /* [in] */ IWebView* view,
+        /* [in] */ IWebView*,
         /* [in] */ IWebScriptCallFrame* frame,
         /* [in] */ int sourceID,
         /* [in] */ int lineNumber,
-        /* [in] */ IWebFrame* forWebFrame);
+        /* [in] */ IWebFrame*);
 
     HRESULT STDMETHODCALLTYPE exceptionWasRaised(
-        /* [in] */ IWebView* view,
-        /* [in] */ IWebScriptCallFrame* frame,
+        /* [in] */ IWebView*,
+        /* [in] */ IWebScriptCallFrame*,
         /* [in] */ int sourceID,
         /* [in] */ int lineNumber,
-        /* [in] */ IWebFrame* forWebFrame);
+        /* [in] */ IWebFrame*);
 
 private:
     std::wstring m_currentServerName;
 
-    WebScriptCallFrame* m_currentFrame;
+    // FIXME: make this a COMPtr when the Interface exists and the destructor can be called.
+    IWebScriptCallFrame* m_currentFrame;
     COMPtr<IWebScriptDebugServer> m_server;
     JSGlobalContextRef m_globalContext;
 };