Modified: trunk/Source/WebKit/ChangeLog (107343 => 107344)
--- trunk/Source/WebKit/ChangeLog 2012-02-10 02:47:04 UTC (rev 107343)
+++ trunk/Source/WebKit/ChangeLog 2012-02-10 02:55:42 UTC (rev 107344)
@@ -1,3 +1,15 @@
+2012-02-09 Leo Yang <[email protected]>
+
+ [BlackBerry] Upstream _javascript_DebuggerBlackBerry.{h, cpp}
+ https://bugs.webkit.org/show_bug.cgi?id=78203
+
+ Reviewed by Rob Buis.
+
+ Initial upstream, no new tests.
+
+ * blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.cpp: Added.
+ * blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.h: Added.
+
2012-02-09 Rob Buis <[email protected]>
[BlackBerry] Upstream BlackBerry WebKitSupport WebPageCompositor class
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.cpp (0 => 107344)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.cpp 2012-02-10 02:55:42 UTC (rev 107344)
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
+ * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#if ENABLE(_javascript__DEBUGGER)
+#include "_javascript_DebuggerBlackBerry.h"
+
+#include "_javascript_CallFrame.h"
+#include "PageScriptDebugServer.h"
+#include "PlatformString.h"
+#include "ScriptBreakpoint.h"
+#include "SourceCode.h"
+#include "WebPage_p.h"
+
+namespace WebCore {
+
+_javascript_DebuggerBlackBerry::_javascript_DebuggerBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
+ : m_webPagePrivate(webPagePrivate)
+ , m_debugServer(PageScriptDebugServer::shared())
+{
+ start();
+}
+
+_javascript_DebuggerBlackBerry::~_javascript_DebuggerBlackBerry()
+{
+ stop();
+}
+
+void _javascript_DebuggerBlackBerry::start()
+{
+ m_debugServer.addListener(this, m_webPagePrivate->m_page);
+}
+
+void _javascript_DebuggerBlackBerry::stop()
+{
+ m_debugServer.removeListener(this, m_webPagePrivate->m_page);
+}
+
+void _javascript_DebuggerBlackBerry::addBreakpoint(const unsigned short* url, unsigned urlLength, int lineNumber, const unsigned short* condition, unsigned conditionLength)
+{
+ if (!url || !urlLength)
+ return;
+ if (!m_currentCallFrame)
+ return;
+
+ String sourceString(url, urlLength);
+ String conditionString(condition, conditionLength);
+ int actualLineNumber;
+ m_debugServer.setBreakpoint(sourceString, ScriptBreakpoint(lineNumber, 0, conditionString), &lineNumber, &actualLineNumber);
+}
+
+void _javascript_DebuggerBlackBerry::updateBreakpoint(const unsigned short* url, unsigned urlLength, int lineNumber, const unsigned short* condition, unsigned conditionLength)
+{
+ if (!url || !urlLength)
+ return;
+ if (!m_currentCallFrame)
+ return;
+
+ String sourceString(url, urlLength);
+ String conditionString(condition, conditionLength);
+ int actualLineNumber;
+ m_debugServer.setBreakpoint(sourceString, ScriptBreakpoint(lineNumber, 0, conditionString), &lineNumber, &actualLineNumber);
+}
+
+
+void _javascript_DebuggerBlackBerry::removeBreakpoint(const unsigned short* url, unsigned urlLength, int lineNumber)
+{
+ if (!url || !urlLength)
+ return;
+ if (!m_currentCallFrame)
+ return;
+
+ String sourceString(url, urlLength);
+ sourceString += ":" + lineNumber;
+ m_debugServer.removeBreakpoint(sourceString);
+}
+
+
+bool _javascript_DebuggerBlackBerry::pauseOnExceptions()
+{
+ return m_debugServer.pauseOnExceptionsState() == ScriptDebugServer::PauseOnAllExceptions;
+}
+
+void _javascript_DebuggerBlackBerry::setPauseOnExceptions(bool pause)
+{
+ m_debugServer.setPauseOnExceptionsState(pause ? ScriptDebugServer::PauseOnAllExceptions : ScriptDebugServer::DontPauseOnExceptions);
+}
+
+void _javascript_DebuggerBlackBerry::pauseInDebugger()
+{
+ m_debugServer.setPauseOnNextStatement(true);
+}
+
+void _javascript_DebuggerBlackBerry::resumeDebugger()
+{
+ m_debugServer.continueProgram();
+}
+
+void _javascript_DebuggerBlackBerry::stepOverStatementInDebugger()
+{
+ m_debugServer.stepOverStatement();
+}
+
+void _javascript_DebuggerBlackBerry::stepIntoStatementInDebugger()
+{
+ m_debugServer.stepIntoStatement();
+}
+
+void _javascript_DebuggerBlackBerry::stepOutOfFunctionInDebugger()
+{
+ m_debugServer.stepOutOfFunction();
+}
+
+void _javascript_DebuggerBlackBerry::didParseSource(const String& sourceID, const Script& script)
+{
+ m_webPagePrivate->m_client->_javascript_SourceParsed(script.url.characters(), script.url.length(), script.source.characters(), script.source.length());
+}
+
+void _javascript_DebuggerBlackBerry::failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage)
+{
+ m_webPagePrivate->m_client->_javascript_ParsingFailed(url.impl()->characters(), url.length(), errorMessage.impl()->characters(), errorMessage.length(), errorLine);
+}
+
+void _javascript_DebuggerBlackBerry::didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception)
+{
+ String stacks;
+
+ m_currentCallFrame = m_debugServer.currentCallFrame();
+ _javascript_CallFrame* frame = m_currentCallFrame;
+
+ while (frame && frame->isValid()) {
+ JSC::SourceProvider* provider = reinterpret_cast<JSC::SourceProvider*>(frame->sourceID());
+ String url(provider->url().characters(), provider->url().length());
+ if (url.length())
+ stacks += url;
+ stacks += ": ";
+
+ if (frame->type() == JSC::DebuggerCallFrame::FunctionType) {
+ String name = frame->functionName();
+ if (name.length())
+ stacks += name;
+ }
+ stacks += "(): ";
+
+ String line = String::number(frame->line());
+ stacks += line + "\n";
+
+ frame = frame->caller();
+ }
+
+ m_webPagePrivate->m_client->_javascript_Paused(reinterpret_cast<const unsigned short*>(stacks.characters()), stacks.length());
+}
+
+void _javascript_DebuggerBlackBerry::didContinue()
+{
+ m_currentCallFrame = 0;
+ m_webPagePrivate->m_client->_javascript_Continued();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(_javascript__DEBUGGER)
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.h (0 => 107344)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.h 2012-02-10 02:55:42 UTC (rev 107344)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
+ * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _javascript_DebuggerBlackBerry_h
+#define _javascript_DebuggerBlackBerry_h
+
+#if ENABLE(_javascript__DEBUGGER)
+
+#include "ScriptDebugListener.h"
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+}
+}
+
+namespace WebCore {
+
+class _javascript_CallFrame;
+class PageScriptDebugServer;
+
+class _javascript_DebuggerBlackBerry : public ScriptDebugListener {
+public:
+ _javascript_DebuggerBlackBerry(BlackBerry::WebKit::WebPagePrivate*);
+ ~_javascript_DebuggerBlackBerry();
+
+ void addBreakpoint(const unsigned short* url, unsigned urlLength, int lineNumber, const unsigned short* condition, unsigned conditionLength);
+ void updateBreakpoint(const unsigned short* url, unsigned urlLength, int lineNumber, const unsigned short* condition, unsigned conditionLength);
+ void removeBreakpoint(const unsigned short* url, unsigned urlLength, int lineNumber);
+
+ bool pauseOnExceptions();
+ void setPauseOnExceptions(bool);
+
+ void pauseInDebugger();
+ void resumeDebugger();
+
+ void stepOverStatementInDebugger();
+ void stepIntoStatementInDebugger();
+ void stepOutOfFunctionInDebugger();
+
+ // From ScriptDebugListener
+ virtual void didParseSource(const String& sourceID, const Script&);
+ virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
+ virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception);
+ virtual void didContinue();
+
+protected:
+ void start();
+ void stop();
+
+private:
+ BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
+ PageScriptDebugServer& m_debugServer;
+
+ _javascript_CallFrame* m_currentCallFrame;
+};
+
+} // WebCore
+
+#endif // ENABLE(_javascript__DEBUGGER)
+#endif // _javascript_DebuggerBlackBerry_h