Commit a67a0078 authored by aroben@apple.com's avatar aroben@apple.com

Neuter WebScriptDebugServer

        Some upcoming changes to JavaScriptDebugServer and
        JavaScriptDebugListener will break WebScriptDebugServer. Since Drosera
        is being replaced by the Inspector's debugger, and Drosera is the only
        client of WebScriptDebugServer, it makes more sense to get rid of
        WebScriptDebugServer than to update it to keep it working.

        We can't actually remove WebScriptDebugServer entirely yet, so I've
        just made it non-functional. This will completely break Drosera, but
        as stated above, Drosera's days are numbered anyway.

        Reviewed by Tim Hatcher and Kevin McCullough.

        * WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebFrameLoaderClient::dispatchDidLoadMainResource): Removed all code
        in this function.
        * WebKitDLL.cpp:
        (LocalServerDidDie): Ditto.
        * WebScriptDebugServer.cpp: Made all IWebScriptDebugServer functions
        return E_NOTIMPL.
        * WebScriptDebugServer.h: Removed everything but the
        IWebScriptDebugServer functions.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33394 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a7365617
2008-05-13 Adam Roben <aroben@apple.com>
Neuter WebScriptDebugServer
Some upcoming changes to JavaScriptDebugServer and
JavaScriptDebugListener will break WebScriptDebugServer. Since Drosera
is being replaced by the Inspector's debugger, and Drosera is the only
client of WebScriptDebugServer, it makes more sense to get rid of
WebScriptDebugServer than to update it to keep it working.
We can't actually remove WebScriptDebugServer entirely yet, so I've
just made it non-functional. This will completely break Drosera, but
as stated above, Drosera's days are numbered anyway.
Reviewed by Tim Hatcher and Kevin McCullough.
* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchDidLoadMainResource): Removed all code
in this function.
* WebKitDLL.cpp:
(LocalServerDidDie): Ditto.
* WebScriptDebugServer.cpp: Made all IWebScriptDebugServer functions
return E_NOTIMPL.
* WebScriptDebugServer.h: Removed everything but the
IWebScriptDebugServer functions.
2008-05-12 Dan Bernstein <mitz@apple.com>
- build fix
......
......@@ -328,16 +328,8 @@ void WebFrameLoaderClient::dispatchShow()
ui->webViewShow(webView);
}
void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader* loader)
void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
{
if (WebScriptDebugServer::listenerCount() <= 0)
return;
Frame* coreFrame = core(m_webFrame);
if (!coreFrame)
return;
WebScriptDebugServer::sharedWebScriptDebugServer()->didLoadMainResourceForDataSource(kit(coreFrame->page()), getWebDataSource(loader));
}
void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error)
......
......@@ -271,7 +271,6 @@ STDAPI RunAsLocalServer()
STDAPI LocalServerDidDie()
{
WebScriptDebugServer::sharedWebScriptDebugServer()->serverDidDie();
return 0;
}
......
......@@ -28,50 +28,10 @@
#include "WebKitDLL.h"
#include "WebScriptDebugServer.h"
#include "WebScriptCallFrame.h"
#include "WebView.h"
#pragma warning(push, 0)
#include <WebCore/DOMWindow.h>
#include <WebCore/JSDOMWindow.h>
#include <WebCore/JavaScriptDebugServer.h>
#pragma warning(pop)
#include <kjs/ExecState.h>
#include <wtf/Assertions.h>
#include <wtf/Vector.h>
using namespace KJS;
using namespace WebCore;
typedef HashSet<COMPtr<IWebScriptDebugListener> > ListenerSet;
static ListenerSet s_Listeners;
static unsigned s_ListenerCount = 0;
static bool s_dying = false;
static Frame* frame(ExecState* exec)
{
JSDOMWindow* window = static_cast<JSDOMWindow*>(exec->dynamicGlobalObject());
return window->impl()->frame();
}
static WebFrame* webFrame(ExecState* exec)
{
return kit(frame(exec));
}
static WebView* webView(ExecState* exec)
{
return kit(frame(exec)->page());
}
unsigned WebScriptDebugServer::listenerCount() { return s_ListenerCount; };
// WebScriptDebugServer ------------------------------------------------------------
WebScriptDebugServer::WebScriptDebugServer()
: m_refCount(0)
, m_paused(false)
, m_step(false)
{
gClassCount++;
}
......@@ -88,18 +48,6 @@ WebScriptDebugServer* WebScriptDebugServer::createInstance()
return instance;
}
WebScriptDebugServer* WebScriptDebugServer::sharedWebScriptDebugServer()
{
static WebScriptDebugServer* server;
if (!server) {
s_dying = false;
server = WebScriptDebugServer::createInstance();
}
return server;
}
// IUnknown -------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE WebScriptDebugServer::QueryInterface(REFIID riid, void** ppvObject)
......@@ -133,232 +81,40 @@ ULONG STDMETHODCALLTYPE WebScriptDebugServer::Release()
// IWebScriptDebugServer -----------------------------------------------------------
HRESULT STDMETHODCALLTYPE WebScriptDebugServer::sharedWebScriptDebugServer(
/* [retval][out] */ IWebScriptDebugServer** server)
/* [retval][out] */ IWebScriptDebugServer**)
{
if (!server)
return E_POINTER;
*server = sharedWebScriptDebugServer();
(*server)->AddRef();
return S_OK;
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebScriptDebugServer::addListener(
/* [in] */ IWebScriptDebugListener* listener)
/* [in] */ IWebScriptDebugListener*)
{
if (s_dying)
return E_FAIL;
if (!listener)
return E_POINTER;
if (!s_ListenerCount)
JavaScriptDebugServer::shared().addListener(this);
++s_ListenerCount;
s_Listeners.add(listener);
return S_OK;
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebScriptDebugServer::removeListener(
/* [in] */ IWebScriptDebugListener* listener)
/* [in] */ IWebScriptDebugListener*)
{
if (s_dying)
return S_OK;
if (!listener)
return E_POINTER;
if (!s_Listeners.contains(listener))
return S_OK;
s_Listeners.remove(listener);
ASSERT(s_ListenerCount >= 1);
if (--s_ListenerCount == 0) {
JavaScriptDebugServer::shared().removeListener(this);
resume();
}
return S_OK;
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebScriptDebugServer::step()
{
m_step = true;
m_paused = false;
return S_OK;
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebScriptDebugServer::pause()
{
m_paused = true;
m_step = false;
return S_OK;
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebScriptDebugServer::resume()
{
m_paused = false;
m_step = false;
return S_OK;
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebScriptDebugServer::isPaused(
/* [out, retval] */ BOOL* isPaused)
/* [out, retval] */ BOOL*)
{
if (!isPaused)
return E_POINTER;
*isPaused = m_paused;
return S_OK;
}
static HWND comMessageWindow()
{
static bool initialized;
static HWND window;
if (initialized)
return window;
initialized = true;
static LPCTSTR windowClass = TEXT("OleMainThreadWndClass");
static LPCTSTR windowText = TEXT("OleMainThreadWndName");
static const DWORD currentProcess = GetCurrentProcessId();
window = 0;
DWORD windowProcess = 0;
do {
window = FindWindowEx(HWND_MESSAGE, window, windowClass, windowText);
GetWindowThreadProcessId(window, &windowProcess);
} while (window && windowProcess != currentProcess);
return window;
}
void WebScriptDebugServer::suspendProcessIfPaused()
{
static bool alreadyHere = false;
if (alreadyHere)
return;
alreadyHere = true;
// We only deliver messages to COM's message window to pause the process while still allowing RPC to work.
// FIXME: It would be nice if we could keep delivering WM_[NC]PAINT messages to all windows to keep them painting on XP.
HWND messageWindow = comMessageWindow();
MSG msg;
while (m_paused && GetMessage(&msg, messageWindow, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (m_step) {
m_step = false;
m_paused = true;
}
alreadyHere = false;
}
void WebScriptDebugServer::didLoadMainResourceForDataSource(IWebView* webView, IWebDataSource* dataSource)
{
if (!webView || !dataSource)
return;
ListenerSet listenersCopy = s_Listeners;
ListenerSet::iterator end = listenersCopy.end();
for (ListenerSet::iterator it = listenersCopy.begin(); it != end; ++it)
(**it).didLoadMainResourceForDataSource(webView, dataSource);
}
void WebScriptDebugServer::didParseSource(ExecState* exec, const UString& source, int startingLineNumber, const UString& sourceURL, int sourceID)
{
BString bSource = source;
BString bSourceURL = sourceURL;
ListenerSet listenersCopy = s_Listeners;
ListenerSet::iterator end = listenersCopy.end();
for (ListenerSet::iterator it = listenersCopy.begin(); it != end; ++it)
(**it).didParseSource(webView(exec), bSource, startingLineNumber, bSourceURL, sourceID, webFrame(exec));
}
void WebScriptDebugServer::failedToParseSource(ExecState* exec, const UString& source, int startingLineNumber, const UString& sourceURL, int errorLine, const UString& errorMessage)
{
BString bSource = source;
BString bSourceURL = sourceURL;
// FIXME: the error var should be made with the information in the errorMsg. It is not a simple
// UString to BSTR conversion there is some logic involved that I don't fully understand yet.
BString error(L"An Error Occurred.");
ListenerSet listenersCopy = s_Listeners;
ListenerSet::iterator end = listenersCopy.end();
for (ListenerSet::iterator it = listenersCopy.begin(); it != end; ++it)
(**it).failedToParseSource(webView(exec), bSource, startingLineNumber, bSourceURL, error, webFrame(exec));
}
void WebScriptDebugServer::didEnterCallFrame(ExecState* exec, int sourceID, int lineNumber)
{
COMPtr<WebScriptCallFrame> callFrame(AdoptCOM, WebScriptCallFrame::createInstance(exec));
ListenerSet listenersCopy = s_Listeners;
ListenerSet::iterator end = listenersCopy.end();
for (ListenerSet::iterator it = listenersCopy.begin(); it != end; ++it)
(**it).didEnterCallFrame(webView(exec), callFrame.get(), sourceID, lineNumber, webFrame(exec));
suspendProcessIfPaused();
}
void WebScriptDebugServer::willExecuteStatement(ExecState* exec, int sourceID, int lineNumber)
{
COMPtr<WebScriptCallFrame> callFrame(AdoptCOM, WebScriptCallFrame::createInstance(exec));
ListenerSet listenersCopy = s_Listeners;
ListenerSet::iterator end = listenersCopy.end();
for (ListenerSet::iterator it = listenersCopy.begin(); it != end; ++it)
(**it).willExecuteStatement(webView(exec), callFrame.get(), sourceID, lineNumber, webFrame(exec));
suspendProcessIfPaused();
}
void WebScriptDebugServer::willLeaveCallFrame(ExecState* exec, int sourceID, int lineNumber)
{
COMPtr<WebScriptCallFrame> callFrame(AdoptCOM, WebScriptCallFrame::createInstance(exec->callingExecState()));
ListenerSet listenersCopy = s_Listeners;
ListenerSet::iterator end = listenersCopy.end();
for (ListenerSet::iterator it = listenersCopy.begin(); it != end; ++it)
(**it).willLeaveCallFrame(webView(exec), callFrame.get(), sourceID, lineNumber, webFrame(exec));
suspendProcessIfPaused();
}
void WebScriptDebugServer::exceptionWasRaised(ExecState* exec, int sourceID, int lineNumber)
{
COMPtr<WebScriptCallFrame> callFrame(AdoptCOM, WebScriptCallFrame::createInstance(exec));
ListenerSet listenersCopy = s_Listeners;
ListenerSet::iterator end = listenersCopy.end();
for (ListenerSet::iterator it = listenersCopy.begin(); it != end; ++it)
(**it).exceptionWasRaised(webView(exec), callFrame.get(), sourceID, lineNumber, webFrame(exec));
suspendProcessIfPaused();
}
void WebScriptDebugServer::serverDidDie()
{
s_dying = true;
ListenerSet listenersCopy = s_Listeners;
ListenerSet::iterator end = listenersCopy.end();
for (ListenerSet::iterator it = listenersCopy.begin(); it != end; ++it) {
(**it).serverDidDie();
s_Listeners.remove((*it).get());
}
return E_NOTIMPL;
}
......@@ -27,20 +27,12 @@
#define WebScriptDebugServer_H
#include "WebKit.h"
#pragma warning(push, 0)
#include <WebCore/JavaScriptDebugListener.h>
#pragma warning(pop)
namespace WebCore {
class Page;
}
// FIXME: <rdar://5932722> Remove this class entirely once we stop exporting progIDForClass.
interface IWebView;
class WebScriptDebugServer : public IWebScriptDebugServer, WebCore::JavaScriptDebugListener {
class WebScriptDebugServer : public IWebScriptDebugServer {
public:
static WebScriptDebugServer* createInstance();
static WebScriptDebugServer* sharedWebScriptDebugServer();
// IUnknown
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
......@@ -70,29 +62,10 @@ public:
virtual HRESULT STDMETHODCALLTYPE isPaused(
/* [out, retval] */ BOOL* isPaused);
void didLoadMainResourceForDataSource(IWebView*, IWebDataSource*);
void serverDidDie();
static unsigned listenerCount();
private:
WebScriptDebugServer();
~WebScriptDebugServer();
void suspendProcessIfPaused();
// JavaScriptDebugListener
virtual void didParseSource(KJS::ExecState*, const KJS::UString& source, int startingLineNumber, const KJS::UString& sourceURL, int sourceID);
virtual void failedToParseSource(KJS::ExecState*, const KJS::UString& source, int startingLineNumber, const KJS::UString& sourceURL, int errorLine, const KJS::UString& errorMessage);
virtual void didEnterCallFrame(KJS::ExecState*, int sourceID, int lineNumber);
virtual void willExecuteStatement(KJS::ExecState*, int sourceID, int lineNumber);
virtual void willLeaveCallFrame(KJS::ExecState*, int sourceID, int lineNumber);
virtual void exceptionWasRaised(KJS::ExecState*, int sourceID, int lineNumber);
bool m_paused;
bool m_step;
bool m_callingListeners;
ULONG m_refCount;
};
......
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