+2007-11-08 Kevin McCullough <kmccullough@apple.com>
+
+ Reviewed by Adam.
+
+ - This patch does two main things.
+ 1) It adds pragma warning guards around WebCore includes in WebKit files
+ that were previously overlooked.
+ 2) It implements almost the entireity of WebScriptDebugger. Only one
+ function remains and that implementation is dependent on finishing the
+ implementation of WebScriptScope.
+
+ * WebScriptCallFrame.h:
+ * WebScriptDebugServer.h:
+ * WebScriptDebugger.cpp:
+ (WebScriptDebugger::WebScriptDebugger):
+ (WebScriptDebugger::sourceParsed):
+ (WebScriptDebugger::callEvent):
+ (WebScriptDebugger::atStatement):
+ (WebScriptDebugger::returnEvent):
+ (WebScriptDebugger::exception):
+ (WebScriptDebugger::enterFrame):
+ (WebScriptDebugger::leaveFrame):
+ * WebScriptDebugger.h:
+
2007-11-08 Steve Falkenburg <sfalken@apple.com>
<rdar://problem/5491463> Wrong dates shown in History menu.
#include "WebFrame.h"
#include "WebScriptDebugServer.h"
+#pragma warning(push, 0)
#include <WebCore/BString.h>
#include <WebCore/kjs_binding.h>
#include <WebCore/kjs_proxy.h>
#include <WebCore/PlatformString.h>
-
-#include <WebCore/COMPtr.h>
+#pragma warning(pop)
using namespace WebCore;
+using namespace KJS;
WebScriptDebugger::WebScriptDebugger(WebFrame* frame)
: m_frame(frame)
{
ASSERT(m_frame);
- if (KJSProxy* proxy = core(m_frame)->scriptProxy())
- attach(static_cast<KJS::Interpreter*>(proxy->interpreter()));
+
+ KJSProxy* proxy = core(m_frame)->scriptProxy();
+ if (!proxy)
+ return;
+
+ Interpreter* interp(proxy->interpreter());
+ attach(interp);
+
+ m_frame->webView(&m_webView);
+ ASSERT(m_webView);
+
+ callEvent(interp->globalExec(), -1, -1, 0, List());
}
-bool WebScriptDebugger::sourceParsed(KJS::ExecState*, int sourceId, const KJS::UString& sourceURL,
- const KJS::UString& source, int startingLineNumber, int errorLine, const KJS::UString& /*errorMsg*/)
+bool WebScriptDebugger::sourceParsed(ExecState*, int sourceId, const UString& sourceURL,
+ const UString& source, int startingLineNumber, int errorLine, const UString& /*errorMsg*/)
{
if (WebScriptDebugServer::listenerCount() <= 0)
return true;
- COMPtr<IWebView> webView;
- if (FAILED(m_frame->webView(&webView)))
- return false;
-
BString bSource = String(source);
BString bSourceURL = String(sourceURL);
if (errorLine == -1) {
- WebScriptDebugServer::sharedWebScriptDebugServer()->didParseSource(webView.get(),
+ WebScriptDebugServer::sharedWebScriptDebugServer()->didParseSource(m_webView.get(),
bSource,
startingLineNumber,
bSourceURL,
// 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.");
- WebScriptDebugServer::sharedWebScriptDebugServer()->failedToParseSource(webView.get(),
+ WebScriptDebugServer::sharedWebScriptDebugServer()->failedToParseSource(m_webView.get(),
bSource,
startingLineNumber,
bSourceURL,
return true;
}
+bool WebScriptDebugger::callEvent(ExecState* state, int sourceId, int lineno, JSObject* /*function*/, const List &/*args*/)\r
+{\r
+ enterFrame(state);\r
+ WebScriptDebugServer::sharedWebScriptDebugServer()->didEnterCallFrame(m_webView.get(), m_topStackFrame.get(), sourceId, lineno, m_frame);\r
+\r
+ return true;\r
+}\r
+\r
+bool WebScriptDebugger::atStatement(ExecState*, int sourceId, int firstLine, int /*lastLine*/)\r
+{\r
+ WebScriptDebugServer::sharedWebScriptDebugServer()->willExecuteStatement(m_webView.get(), m_topStackFrame.get(), sourceId, firstLine, m_frame);\r
+\r
+ return true;\r
+}\r
+\r
+bool WebScriptDebugger::returnEvent(ExecState*, int sourceId, int lineno, JSObject* /*function*/)
+{\r
+ WebScriptDebugServer::sharedWebScriptDebugServer()->willLeaveCallFrame(m_webView.get(), m_topStackFrame.get(), sourceId, lineno, m_frame);\r
+ leaveFrame();\r
+ return true;\r
+}\r
+\r
+bool WebScriptDebugger::exception(ExecState*, int sourceId, int lineno, JSValue* /*exception */)\r
+{\r
+ WebScriptDebugServer::sharedWebScriptDebugServer()->exceptionWasRaised(m_webView.get(), m_topStackFrame.get(), sourceId, lineno, m_frame);\r
+\r
+ return true;\r
+}\r
+\r
+void WebScriptDebugger::enterFrame(ExecState*)\r
+{\r
+ // FIXME: the implementation of this is dependent on finishing the implementation of WebScriptScope.\r
+}\r
+\r
+void WebScriptDebugger::leaveFrame()\r
+{\r
+ if (!m_topStackFrame)\r
+ return;\r
+\r
+ COMPtr<IWebScriptCallFrame> caller;\r
+ if (FAILED(m_topStackFrame->caller(&caller)))\r
+ return;\r
+\r
+ m_topStackFrame = caller;\r
+}\r
#ifndef WebScriptDebugger_H
#define WebScriptDebugger_H
+#include "IWebView.h"
+#include "IWebScriptCallFrame.h"
+
#include <JavaScriptCore/debugger.h>
+#pragma warning(push, 0)
+#include <WebCore/COMPtr.h>
+#pragma warning(pop)
class WebFrame;
+interface IWebScriptCallFrame;
namespace KJS {
class ExecState;
+ class JSObject;
+ class JSValue;
+ class List;
}
class WebScriptDebugger : public KJS::Debugger {
bool sourceParsed(KJS::ExecState*, int sourceId, const KJS::UString& sourceURL,
const KJS::UString& source, int startingLineNumber, int errorLine, const KJS::UString& errorMsg);
+ bool callEvent(KJS::ExecState*, int sourceId, int lineno, KJS::JSObject* function, const KJS::List& args);
+ bool atStatement(KJS::ExecState*, int sourceId, int firstLine, int lastLine);
+ bool returnEvent(KJS::ExecState*, int sourceId, int lineno, KJS::JSObject* function);
+ bool exception(KJS::ExecState*, int sourceId, int lineno, KJS::JSValue* exception);
+
private:
+ void enterFrame(KJS::ExecState*);
+ void leaveFrame();
+
WebFrame* m_frame;
+ COMPtr<IWebView> m_webView;
+ COMPtr<IWebScriptCallFrame> m_topStackFrame;
};
#endif