[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:46:43 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit cb381b8f8b992914220c75540d130339a48b929a
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Aug 6 14:00:41 2010 +0000
2010-08-06 Yury Semikhatsky <yurys at chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: extract debugger implementation into InspectorDebuggerAgent
https://bugs.webkit.org/show_bug.cgi?id=42340
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* inspector/CodeGeneratorInspector.pm:
* inspector/Inspector.idl:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::connectFrontend):
(WebCore::InspectorController::didCommitLoad):
(WebCore::InspectorController::enableDebuggerFromFrontend):
(WebCore::InspectorController::disableDebugger):
(WebCore::InspectorController::resume):
(WebCore::InspectorController::loadBreakpoints):
(WebCore::InspectorController::saveBreakpoints):
* inspector/InspectorController.h:
(WebCore::InspectorController::debuggerAgent):
* inspector/InspectorDebuggerAgent.cpp: Added.
(WebCore::md5Base16):
(WebCore::formatBreakpointId):
(WebCore::InspectorDebuggerAgent::create):
(WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent):
(WebCore::InspectorDebuggerAgent::~InspectorDebuggerAgent):
(WebCore::InspectorDebuggerAgent::isDebuggerAlwaysEnabled):
(WebCore::InspectorDebuggerAgent::activateBreakpoints):
(WebCore::InspectorDebuggerAgent::deactivateBreakpoints):
(WebCore::InspectorDebuggerAgent::setBreakpoint):
(WebCore::InspectorDebuggerAgent::removeBreakpoint):
(WebCore::InspectorDebuggerAgent::editScriptSource):
(WebCore::InspectorDebuggerAgent::getScriptSource):
(WebCore::InspectorDebuggerAgent::pause):
(WebCore::InspectorDebuggerAgent::resume):
(WebCore::InspectorDebuggerAgent::stepOverStatement):
(WebCore::InspectorDebuggerAgent::stepIntoStatement):
(WebCore::InspectorDebuggerAgent::stepOutOfFunction):
(WebCore::InspectorDebuggerAgent::setPauseOnExceptionsState):
(WebCore::InspectorDebuggerAgent::clearForPageNavigation):
(WebCore::InspectorDebuggerAgent::currentCallFrames):
(WebCore::InspectorDebuggerAgent::loadBreakpoints):
(WebCore::InspectorDebuggerAgent::saveBreakpoints):
(WebCore::InspectorDebuggerAgent::didParseSource):
(WebCore::InspectorDebuggerAgent::failedToParseSource):
(WebCore::InspectorDebuggerAgent::didPause):
(WebCore::InspectorDebuggerAgent::didContinue):
(WebCore::InspectorDebuggerAgent::remoteFrontend):
* inspector/InspectorDebuggerAgent.h: Added.
* inspector/InspectorFrontend.cpp:
* inspector/InspectorFrontend.h:
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64846 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 6b18a2b..1a93b0b 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1058,6 +1058,7 @@ SET(WebCore_SOURCES
inspector/InspectorDOMAgent.cpp
inspector/InspectorDOMStorageResource.cpp
inspector/InspectorDatabaseResource.cpp
+ inspector/InspectorDebuggerAgent.cpp
inspector/InspectorFrontend.cpp
inspector/InspectorFrontendClientLocal.cpp
inspector/InspectorFrontendHost.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 69d9f32..07ae173 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,63 @@
+2010-08-06 Yury Semikhatsky <yurys at chromium.org>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: extract debugger implementation into InspectorDebuggerAgent
+ https://bugs.webkit.org/show_bug.cgi?id=42340
+
+ * CMakeLists.txt:
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * inspector/CodeGeneratorInspector.pm:
+ * inspector/Inspector.idl:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ (WebCore::InspectorController::connectFrontend):
+ (WebCore::InspectorController::didCommitLoad):
+ (WebCore::InspectorController::enableDebuggerFromFrontend):
+ (WebCore::InspectorController::disableDebugger):
+ (WebCore::InspectorController::resume):
+ (WebCore::InspectorController::loadBreakpoints):
+ (WebCore::InspectorController::saveBreakpoints):
+ * inspector/InspectorController.h:
+ (WebCore::InspectorController::debuggerAgent):
+ * inspector/InspectorDebuggerAgent.cpp: Added.
+ (WebCore::md5Base16):
+ (WebCore::formatBreakpointId):
+ (WebCore::InspectorDebuggerAgent::create):
+ (WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent):
+ (WebCore::InspectorDebuggerAgent::~InspectorDebuggerAgent):
+ (WebCore::InspectorDebuggerAgent::isDebuggerAlwaysEnabled):
+ (WebCore::InspectorDebuggerAgent::activateBreakpoints):
+ (WebCore::InspectorDebuggerAgent::deactivateBreakpoints):
+ (WebCore::InspectorDebuggerAgent::setBreakpoint):
+ (WebCore::InspectorDebuggerAgent::removeBreakpoint):
+ (WebCore::InspectorDebuggerAgent::editScriptSource):
+ (WebCore::InspectorDebuggerAgent::getScriptSource):
+ (WebCore::InspectorDebuggerAgent::pause):
+ (WebCore::InspectorDebuggerAgent::resume):
+ (WebCore::InspectorDebuggerAgent::stepOverStatement):
+ (WebCore::InspectorDebuggerAgent::stepIntoStatement):
+ (WebCore::InspectorDebuggerAgent::stepOutOfFunction):
+ (WebCore::InspectorDebuggerAgent::setPauseOnExceptionsState):
+ (WebCore::InspectorDebuggerAgent::clearForPageNavigation):
+ (WebCore::InspectorDebuggerAgent::currentCallFrames):
+ (WebCore::InspectorDebuggerAgent::loadBreakpoints):
+ (WebCore::InspectorDebuggerAgent::saveBreakpoints):
+ (WebCore::InspectorDebuggerAgent::didParseSource):
+ (WebCore::InspectorDebuggerAgent::failedToParseSource):
+ (WebCore::InspectorDebuggerAgent::didPause):
+ (WebCore::InspectorDebuggerAgent::didContinue):
+ (WebCore::InspectorDebuggerAgent::remoteFrontend):
+ * inspector/InspectorDebuggerAgent.h: Added.
+ * inspector/InspectorFrontend.cpp:
+ * inspector/InspectorFrontend.h:
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel):
+
2010-08-06 Dean Jackson <dino at apple.com>
Reviewed by Simon Fraser and Steve Block.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index b684ca2..8406170 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1602,6 +1602,8 @@ webcore_sources += \
WebCore/inspector/InspectorCSSStore.h \
WebCore/inspector/InspectorDatabaseResource.cpp \
WebCore/inspector/InspectorDatabaseResource.h \
+ WebCore/inspector/InspectorDebuggerAgent.cpp \
+ WebCore/inspector/InspectorDebuggerAgent.h \
WebCore/inspector/InspectorDOMAgent.cpp \
WebCore/inspector/InspectorDOMAgent.h \
WebCore/inspector/InspectorDOMStorageResource.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index fe0f369..c1e59fe 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1750,6 +1750,8 @@
'inspector/InspectorCSSStore.h',
'inspector/InspectorDatabaseResource.cpp',
'inspector/InspectorDatabaseResource.h',
+ 'inspector/InspectorDebuggerAgent.cpp',
+ 'inspector/InspectorDebuggerAgent.h',
'inspector/InspectorDOMAgent.cpp',
'inspector/InspectorDOMAgent.h',
'inspector/InspectorDOMStorageResource.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 4072b41..967e330 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -745,6 +745,7 @@ SOURCES += \
inspector/InspectorCSSStore.cpp \
inspector/InspectorController.cpp \
inspector/InspectorDatabaseResource.cpp \
+ inspector/InspectorDebuggerAgent.cpp \
inspector/InspectorDOMAgent.cpp \
inspector/InspectorDOMStorageResource.cpp \
inspector/InspectorFrontend.cpp \
@@ -1505,6 +1506,7 @@ HEADERS += \
inspector/InspectorBackend.h \
inspector/InspectorController.h \
inspector/InspectorDatabaseResource.h \
+ inspector/InspectorDebuggerAgent.h \
inspector/InspectorDOMStorageResource.h \
inspector/InspectorFrontend.h \
inspector/InspectorFrontendClient.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 50dceec..18a8d92 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -50993,6 +50993,14 @@
>
</File>
<File
+ RelativePath="..\inspector\InspectorDebuggerAgent.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\inspector\InspectorDebuggerAgent.h"
+ >
+ </File>
+ <File
RelativePath="..\inspector\InspectorDOMAgent.cpp"
>
</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 37f9933..fa2c51f 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -5209,6 +5209,8 @@
EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = EDE3A4FF0C7A430600956A37 /* ColorMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
EDEC98030AED7E170059137F /* WebCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = EDEC98020AED7E170059137F /* WebCorePrefix.h */; };
F33F0282120947F200E5743A /* ScriptProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F33F0281120947F200E5743A /* ScriptProfile.cpp */; };
+ F33F053D120B0DA500E5743A /* InspectorDebuggerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F33F053B120B0DA500E5743A /* InspectorDebuggerAgent.cpp */; };
+ F33F053E120B0DA500E5743A /* InspectorDebuggerAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = F33F053C120B0DA500E5743A /* InspectorDebuggerAgent.h */; };
F344C7141125B82C00F26EEE /* InspectorFrontendClient.h in Headers */ = {isa = PBXBuildFile; fileRef = F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */ = {isa = PBXBuildFile; fileRef = F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */; settings = {ATTRIBUTES = (Private, ); }; };
F344C75811294FF600F26EEE /* InspectorFrontendClientLocal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F344C75711294FF600F26EEE /* InspectorFrontendClientLocal.cpp */; };
@@ -10967,6 +10969,8 @@
EDE3A4FF0C7A430600956A37 /* ColorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorMac.h; sourceTree = "<group>"; };
EDEC98020AED7E170059137F /* WebCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCorePrefix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
F33F0281120947F200E5743A /* ScriptProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptProfile.cpp; sourceTree = "<group>"; };
+ F33F053B120B0DA500E5743A /* InspectorDebuggerAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDebuggerAgent.cpp; sourceTree = "<group>"; };
+ F33F053C120B0DA500E5743A /* InspectorDebuggerAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDebuggerAgent.h; sourceTree = "<group>"; };
F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendClient.h; sourceTree = "<group>"; };
F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendClientLocal.h; sourceTree = "<group>"; };
F344C75711294FF600F26EEE /* InspectorFrontendClientLocal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorFrontendClientLocal.cpp; sourceTree = "<group>"; };
@@ -11612,6 +11616,8 @@
82B658971189E39200E052A1 /* InspectorCSSStore.h */,
41F062130F5F192600A07EAC /* InspectorDatabaseResource.cpp */,
41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */,
+ F33F053B120B0DA500E5743A /* InspectorDebuggerAgent.cpp */,
+ F33F053C120B0DA500E5743A /* InspectorDebuggerAgent.h */,
7A2458791021EAF4000A00AA /* InspectorDOMAgent.cpp */,
7A24587A1021EAF4000A00AA /* InspectorDOMAgent.h */,
41F061730F5F00AC00A07EAC /* InspectorDOMStorageResource.cpp */,
@@ -18724,6 +18730,7 @@
41F062140F5F192600A07EAC /* InspectorDatabaseResource.h in Headers */,
7A24587C1021EAF4000A00AA /* InspectorDOMAgent.h in Headers */,
41F061740F5F00AC00A07EAC /* InspectorDOMStorageResource.h in Headers */,
+ F33F053E120B0DA500E5743A /* InspectorDebuggerAgent.h in Headers */,
7AED3E060FBB1EAA00D2B03C /* InspectorFrontend.h in Headers */,
F344C7141125B82C00F26EEE /* InspectorFrontendClient.h in Headers */,
F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */,
@@ -21156,6 +21163,7 @@
41F062150F5F192600A07EAC /* InspectorDatabaseResource.cpp in Sources */,
7A24587B1021EAF4000A00AA /* InspectorDOMAgent.cpp in Sources */,
41F061750F5F00AC00A07EAC /* InspectorDOMStorageResource.cpp in Sources */,
+ F33F053D120B0DA500E5743A /* InspectorDebuggerAgent.cpp in Sources */,
7AED3E050FBB1EAA00D2B03C /* InspectorFrontend.cpp in Sources */,
F344C75811294FF600F26EEE /* InspectorFrontendClientLocal.cpp in Sources */,
7A0E770E10C00A8800A0276E /* InspectorFrontendHost.cpp in Sources */,
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm
index dcec6c9..46879ab 100644
--- a/WebCore/inspector/CodeGeneratorInspector.pm
+++ b/WebCore/inspector/CodeGeneratorInspector.pm
@@ -24,9 +24,9 @@ $typeTransform{"Controller"} = {
"handlerAccessor" => "m_inspectorController",
};
$typeTransform{"Debug"} = {
- "forward" => "ScriptDebugServer",
- "header" => "ScriptDebugServer.h",
- "handlerAccessor" => "(&ScriptDebugServer::shared())",
+ "forward" => "InspectorDebuggerAgent",
+ "header" => "InspectorDebuggerAgent.h",
+ "handlerAccessor" => "m_inspectorController->debuggerAgent()",
};
$typeTransform{"DOM"} = {
"forward" => "InspectorDOMAgent",
diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl
index 099f184..1dbf56b 100644
--- a/WebCore/inspector/Inspector.idl
+++ b/WebCore/inspector/Inspector.idl
@@ -47,8 +47,12 @@ module core {
[notify] void updateResource(out Value resource);
[notify] void removeResource(out unsigned long resourceId);
#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
+ [notify] void parsedScriptSource(out String sourceID, out String url, out String data, out int firstLine, out int scriptWorldType);
+ [notify] void failedToParseScriptSource(out String url, out String data, out int firstLine, out int errorLine, out String errorMessage);
[notify] void pausedScript(out Value callFrames);
[notify] void resumedScript();
+ [notify] void restoredBreakpoint(out String sourceID, out String url, out int line, out boolean enabled, out String condition);
+ [notify] void updatePauseOnExceptionsState(out long state);
[notify] void addProfileHeader(out Object header);
#endif
#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
@@ -88,22 +92,22 @@ module core {
[handler=Backend] void enableDebugger(in boolean always);
[handler=Controller] void disableDebugger(in boolean always);
- [handler=Controller] void setBreakpoint(in long callId, in String sourceID, in unsigned int lineNumber, in boolean enabled, in String condition, out boolean success, out unsigned int actualLineNumber);
- [handler=Controller] void removeBreakpoint(in String sourceID, in unsigned long lineNumber);
+ [handler=Debug] void setBreakpoint(in long callId, in String sourceID, in unsigned int lineNumber, in boolean enabled, in String condition, out boolean success, out unsigned int actualLineNumber);
+ [handler=Debug] void removeBreakpoint(in String sourceID, in unsigned long lineNumber);
[handler=Debug] void activateBreakpoints();
[handler=Debug] void deactivateBreakpoints();
[handler=Debug] void pause();
- [handler=Controller] void resume();
+ [handler=Debug] void resume();
[handler=Debug] void stepOverStatement();
[handler=Debug] void stepIntoStatement();
[handler=Debug] void stepOutOfFunction();
- [handler=Controller] void setPauseOnExceptionsState(in long pauseOnExceptionsState);
+ [handler=Debug] void setPauseOnExceptionsState(in long pauseOnExceptionsState);
- [handler=Controller] void editScriptSource(in long callId, in String sourceID, in String newContent, out boolean success, out String result, out Value newCallFrames);
- [handler=Controller] void getScriptSource(in long callId, in String sourceID, out String scriptSource);
+ [handler=Debug] void editScriptSource(in long callId, in String sourceID, in String newContent, out boolean success, out String result, out Value newCallFrames);
+ [handler=Debug] void getScriptSource(in long callId, in String sourceID, out String scriptSource);
[handler=Controller] void enableProfiler(in boolean always);
[handler=Controller] void disableProfiler(in boolean always);
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index b8d7bdf..d21aedd 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -61,6 +61,7 @@
#include "InspectorFrontendClient.h"
#include "InspectorDOMStorageResource.h"
#include "InspectorDatabaseResource.h"
+#include "InspectorDebuggerAgent.h"
#include "InspectorFrontend.h"
#include "InspectorResource.h"
#include "InspectorValues.h"
@@ -73,7 +74,6 @@
#include "RenderInline.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
-#include "ScriptBreakpoint.h"
#include "ScriptCallStack.h"
#include "ScriptFunctionCall.h"
#include "ScriptObject.h"
@@ -89,7 +89,6 @@
#include <wtf/text/CString.h>
#include <wtf/CurrentTime.h>
#include <wtf/ListHashSet.h>
-#include <wtf/MD5.h>
#include <wtf/RefCounted.h>
#include <wtf/StdLibExtras.h>
@@ -145,32 +144,6 @@ static const unsigned expireConsoleMessagesStep = 100;
static unsigned s_inspectorControllerCount;
-namespace {
-
-String md5Base16(const String& string)
-{
- static const char digits[] = "0123456789abcdef";
-
- MD5 md5;
- md5.addBytes(reinterpret_cast<const uint8_t*>(string.characters()), string.length() * 2);
- Vector<uint8_t, 16> digest;
- md5.checksum(digest);
-
- Vector<char, 32> result;
- for (int i = 0; i < 16; ++i) {
- result.append(digits[(digest[i] >> 4) & 0xf]);
- result.append(digits[digest[i] & 0xf]);
- }
- return String(result.data(), result.size());
-}
-
-String formatBreakpointId(const String& sourceID, unsigned lineNumber)
-{
- return String::format("%s:%d", sourceID.utf8().data(), lineNumber);
-}
-
-}
-
InspectorController::InspectorController(Page* page, InspectorClient* client)
: m_inspectedPage(page)
, m_client(client)
@@ -189,10 +162,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
, m_inspectorBackendDispatcher(new InspectorBackendDispatcher(this))
, m_injectedScriptHost(InjectedScriptHost::create(this))
#if ENABLE(JAVASCRIPT_DEBUGGER)
- , m_debuggerEnabled(false)
, m_attachDebuggerWhenShown(false)
- , m_pausedScriptState(0)
- , m_breakpointsLoaded(false)
, m_profilerEnabled(!WTF_USE_JSC)
, m_recordingUserInitiatedProfile(false)
, m_currentUserInitiatedProfileNumber(-1)
@@ -230,6 +200,9 @@ void InspectorController::inspectedPageDestroyed()
hideHighlight();
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+ m_debuggerAgent.clear();
+#endif
ASSERT(m_inspectedPage);
m_inspectedPage = 0;
@@ -510,7 +483,7 @@ void InspectorController::connectFrontend(const ScriptObject& webInspector)
populateScriptObjects();
#if ENABLE(JAVASCRIPT_DEBUGGER)
- if (ScriptDebugServer::shared().isDebuggerAlwaysEnabled()) {
+ if (InspectorDebuggerAgent::isDebuggerAlwaysEnabled()) {
// FIXME (40364): This will force pushing script sources to frontend even if script
// panel is inactive.
enableDebuggerFromFrontend(false);
@@ -598,7 +571,7 @@ void InspectorController::disconnectFrontend()
// If the window is being closed with the debugger enabled,
// remember this state to re-enable debugger on the next window
// opening.
- bool debuggerWasEnabled = m_debuggerEnabled;
+ bool debuggerWasEnabled = debuggerEnabled();
disableDebugger();
m_attachDebuggerWhenShown = debuggerWasEnabled;
#endif
@@ -666,7 +639,7 @@ void InspectorController::populateScriptObjects()
m_consoleMessages[i]->addToFrontend(m_remoteFrontend.get(), m_injectedScriptHost.get());
#if ENABLE(JAVASCRIPT_DEBUGGER)
- if (m_debuggerEnabled)
+ if (debuggerEnabled())
m_frontend->updatePauseOnExceptionsState(ScriptDebugServer::shared().pauseOnExceptionsState());
#endif
#if ENABLE(DATABASE)
@@ -750,11 +723,8 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
m_times.clear();
m_counts.clear();
#if ENABLE(JAVASCRIPT_DEBUGGER)
- m_sourceIDToURL.clear();
- m_scriptIDToContent.clear();
- m_stickyBreakpoints.clear();
- m_breakpointsMapping.clear();
- m_breakpointsLoaded = false;
+ if (m_debuggerAgent)
+ m_debuggerAgent->clearForPageNavigation();
#endif
#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
m_profiles.clear();
@@ -1646,16 +1616,14 @@ void InspectorController::disableProfiler(bool always)
#if ENABLE(JAVASCRIPT_DEBUGGER)
void InspectorController::enableDebuggerFromFrontend(bool always)
{
- ASSERT(!m_debuggerEnabled);
+ ASSERT(!debuggerEnabled());
if (always)
setSetting(debuggerEnabledSettingName, "true");
ASSERT(m_inspectedPage);
- ScriptDebugServer::shared().clearBreakpoints();
- ScriptDebugServer::shared().addListener(this, m_inspectedPage);
+ m_debuggerAgent = InspectorDebuggerAgent::create(this);
- m_debuggerEnabled = true;
m_frontend->debuggerWasEnabled();
}
@@ -1664,7 +1632,7 @@ void InspectorController::enableDebugger()
if (!enabled())
return;
- if (m_debuggerEnabled)
+ if (debuggerEnabled())
return;
if (!m_frontend)
@@ -1685,148 +1653,19 @@ void InspectorController::disableDebugger(bool always)
ASSERT(m_inspectedPage);
- ScriptDebugServer::shared().removeListener(this, m_inspectedPage);
+ m_debuggerAgent.clear();
- m_debuggerEnabled = false;
m_attachDebuggerWhenShown = false;
- m_pausedScriptState = 0;
if (m_frontend)
m_frontend->debuggerWasDisabled();
}
-void InspectorController::editScriptSource(long, const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames)
-{
- if (*success = ScriptDebugServer::shared().editScriptSource(sourceID, newContent, *result))
- *newCallFrames = currentCallFrames();
-}
-
-void InspectorController::getScriptSource(long, const String& sourceID, String* scriptSource)
-{
- *scriptSource = m_scriptIDToContent.get(sourceID);
-}
-
void InspectorController::resume()
{
- if (!m_debuggerEnabled)
- return;
- ScriptDebugServer::shared().continueProgram();
-}
-
-void InspectorController::setPauseOnExceptionsState(long pauseState)
-{
- ScriptDebugServer::shared().setPauseOnExceptionsState(static_cast<ScriptDebugServer::PauseOnExceptionsState>(pauseState));
- if (m_frontend)
- m_frontend->updatePauseOnExceptionsState(ScriptDebugServer::shared().pauseOnExceptionsState());
-}
-
-PassRefPtr<InspectorValue> InspectorController::currentCallFrames()
-{
- if (!m_pausedScriptState)
- return InspectorValue::null();
- InjectedScript injectedScript = m_injectedScriptHost->injectedScriptFor(m_pausedScriptState);
- if (injectedScript.hasNoValue()) {
- ASSERT_NOT_REACHED();
- return InspectorValue::null();
- }
- return injectedScript.callFrames();
-}
-
-void InspectorController::setBreakpoint(long, const String& sourceID, unsigned lineNumber, bool enabled, const String& condition, bool* success, unsigned int* actualLineNumber)
-{
- ScriptBreakpoint breakpoint(enabled, condition);
- *success = ScriptDebugServer::shared().setBreakpoint(sourceID, breakpoint, lineNumber, actualLineNumber);
- if (!*success)
- return;
-
- String url = m_sourceIDToURL.get(sourceID);
- if (url.isEmpty())
- return;
-
- String breakpointId = formatBreakpointId(sourceID, *actualLineNumber);
- m_breakpointsMapping.set(breakpointId, *actualLineNumber);
-
- String key = md5Base16(url);
- HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(key);
- if (it == m_stickyBreakpoints.end())
- it = m_stickyBreakpoints.set(key, SourceBreakpoints()).first;
- it->second.set(*actualLineNumber, breakpoint);
- saveBreakpoints();
+ if (m_debuggerAgent)
+ m_debuggerAgent->resume();
}
-
-void InspectorController::removeBreakpoint(const String& sourceID, unsigned lineNumber)
-{
- ScriptDebugServer::shared().removeBreakpoint(sourceID, lineNumber);
-
- String url = m_sourceIDToURL.get(sourceID);
- if (url.isEmpty())
- return;
-
- String breakpointId = formatBreakpointId(sourceID, lineNumber);
- HashMap<String, unsigned>::iterator mappingIt = m_breakpointsMapping.find(breakpointId);
- if (mappingIt == m_breakpointsMapping.end())
- return;
- unsigned stickyLine = mappingIt->second;
- m_breakpointsMapping.remove(mappingIt);
-
- HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
- if (it == m_stickyBreakpoints.end())
- return;
-
- it->second.remove(stickyLine);
- saveBreakpoints();
-}
-
-// JavaScriptDebugListener functions
-
-void InspectorController::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType worldType)
-{
- // Don't send script content to the front end until it's really needed.
- m_frontend->parsedScriptSource(sourceID, url, "", firstLine, worldType);
-
- m_scriptIDToContent.set(sourceID, data);
-
- if (url.isEmpty())
- return;
-
- loadBreakpoints();
- HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
- if (it != m_stickyBreakpoints.end()) {
- for (SourceBreakpoints::iterator breakpointIt = it->second.begin(); breakpointIt != it->second.end(); ++breakpointIt) {
- int lineNumber = breakpointIt->first;
- if (firstLine > lineNumber)
- continue;
- unsigned actualLineNumber = 0;
- bool success = ScriptDebugServer::shared().setBreakpoint(sourceID, breakpointIt->second, lineNumber, &actualLineNumber);
- if (!success)
- continue;
- m_frontend->restoredBreakpoint(sourceID, url, actualLineNumber, breakpointIt->second.enabled, breakpointIt->second.condition);
- String breakpointId = formatBreakpointId(sourceID, actualLineNumber);
- m_breakpointsMapping.set(breakpointId, lineNumber);
- }
- }
- m_sourceIDToURL.set(sourceID, url);
-}
-
-void InspectorController::failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage)
-{
- m_frontend->failedToParseScriptSource(url, data, firstLine, errorLine, errorMessage);
-}
-
-void InspectorController::didPause(ScriptState* scriptState)
-{
- ASSERT(scriptState && !m_pausedScriptState);
- m_pausedScriptState = scriptState;
- RefPtr<InspectorValue> callFrames = currentCallFrames();
- m_remoteFrontend->pausedScript(callFrames.get());
-}
-
-void InspectorController::didContinue()
-{
- m_pausedScriptState = 0;
- m_remoteFrontend->resumedScript();
-}
-
#endif
void InspectorController::evaluateForTestInFrontend(long callId, const String& script)
@@ -1852,39 +1691,16 @@ void InspectorController::didEvaluateForTestInFrontend(long callId, const String
String InspectorController::breakpointsSettingKey()
{
DEFINE_STATIC_LOCAL(String, keyPrefix, ("breakpoints:"));
- return keyPrefix + md5Base16(m_mainResource->requestURL());
+ return keyPrefix + InspectorDebuggerAgent::md5Base16(m_mainResource->requestURL());
}
-void InspectorController::loadBreakpoints()
+PassRefPtr<InspectorValue> InspectorController::loadBreakpoints()
{
- if (m_breakpointsLoaded)
- return;
- m_breakpointsLoaded = true;
-
- RefPtr<InspectorValue> parsedSetting = InspectorValue::parseJSON(setting(breakpointsSettingKey()));
- if (!parsedSetting)
- return;
- RefPtr<InspectorObject> breakpoints = parsedSetting->asObject();
- if (!breakpoints)
- return;
- for (InspectorObject::iterator it = breakpoints->begin(); it != breakpoints->end(); ++it) {
- RefPtr<InspectorObject> breakpointsForURL = it->second->asObject();
- if (!breakpointsForURL)
- continue;
- HashMap<String, SourceBreakpoints>::iterator sourceBreakpointsIt = m_stickyBreakpoints.set(it->first, SourceBreakpoints()).first;
- ScriptBreakpoint::sourceBreakpointsFromInspectorObject(breakpointsForURL, &sourceBreakpointsIt->second);
- }
+ return InspectorValue::parseJSON(setting(breakpointsSettingKey()));
}
-void InspectorController::saveBreakpoints()
+void InspectorController::saveBreakpoints(PassRefPtr<InspectorObject> breakpoints)
{
- RefPtr<InspectorObject> breakpoints = InspectorObject::create();
- for (HashMap<String, SourceBreakpoints>::iterator it(m_stickyBreakpoints.begin()); it != m_stickyBreakpoints.end(); ++it) {
- if (it->second.isEmpty())
- continue;
- RefPtr<InspectorObject> breakpointsForURL = ScriptBreakpoint::inspectorObjectFromSourceBreakpoints(it->second);
- breakpoints->set(it->first, breakpointsForURL);
- }
setSetting(breakpointsSettingKey(), breakpoints->toJSONString());
}
#endif
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index 7d1f828..8dbab6a 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -33,7 +33,6 @@
#include "Cookie.h"
#include "InspectorDOMAgent.h"
#include "PlatformString.h"
-#include "ScriptBreakpoint.h"
#include "ScriptProfile.h"
#include "ScriptState.h"
#include "StringHash.h"
@@ -44,10 +43,6 @@
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-#include "ScriptDebugListener.h"
-#endif
-
namespace WebCore {
class CachedResource;
@@ -60,12 +55,14 @@ class GraphicsContext;
class HitTestResult;
class InjectedScript;
class InjectedScriptHost;
+class InspectorArray;
class InspectorBackend;
class InspectorBackendDispatcher;
class InspectorClient;
class InspectorCSSStore;
class InspectorDOMStorageResource;
class InspectorDatabaseResource;
+class InspectorDebuggerAgent;
class InspectorFrontend;
class InspectorFrontendClient;
class InspectorResource;
@@ -90,13 +87,7 @@ class StorageArea;
class InspectorApplicationCacheAgent;
#endif
-class InspectorController
-#if ENABLE(JAVASCRIPT_DEBUGGER)
- : ScriptDebugListener, public Noncopyable
-#else
- : public Noncopyable
-#endif
- {
+class InspectorController : public Noncopyable {
public:
typedef HashMap<unsigned long, RefPtr<InspectorResource> > ResourcesMap;
typedef HashMap<RefPtr<Frame>, ResourcesMap*> FrameResourcesMap;
@@ -261,18 +252,9 @@ public:
void enableDebugger();
void disableDebugger(bool always = false);
- bool debuggerEnabled() const { return m_debuggerEnabled; }
-
- void editScriptSource(long callId, const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames);
- void getScriptSource(long callId, const String& sourceID, String* scriptSource);
-
+ bool debuggerEnabled() const { return m_debuggerAgent; }
+ InspectorDebuggerAgent* debuggerAgent() const { return m_debuggerAgent.get(); }
void resume();
- void setPauseOnExceptionsState(long pauseState);
-
- virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType);
- virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
- virtual void didPause(ScriptState*);
- virtual void didContinue();
#endif
void evaluateForTestInFrontend(long callId, const String& script);
@@ -307,11 +289,6 @@ private:
void releaseFrontendLifetimeAgents();
#if ENABLE(JAVASCRIPT_DEBUGGER)
- PassRefPtr<InspectorValue> currentCallFrames();
-
- void setBreakpoint(long callId, const String& sourceID, unsigned lineNumber, bool enabled, const String& condition, bool* success, unsigned int* actualLineNumber);
- void removeBreakpoint(const String& sourceID, unsigned lineNumber);
-
typedef HashMap<unsigned int, RefPtr<ScriptProfile> > ProfilesMap;
void startUserInitiatedProfilingSoon();
@@ -351,9 +328,10 @@ private:
void didEvaluateForTestInFrontend(long callId, const String& jsonResult);
#if ENABLE(JAVASCRIPT_DEBUGGER)
+ friend class InspectorDebuggerAgent;
String breakpointsSettingKey();
- void loadBreakpoints();
- void saveBreakpoints();
+ PassRefPtr<InspectorValue> loadBreakpoints();
+ void saveBreakpoints(PassRefPtr<InspectorObject> breakpoints);
#endif
Page* m_inspectedPage;
@@ -407,14 +385,8 @@ private:
Vector<String> m_scriptsToEvaluateOnLoad;
String m_inspectorExtensionAPI;
#if ENABLE(JAVASCRIPT_DEBUGGER)
- bool m_debuggerEnabled;
bool m_attachDebuggerWhenShown;
- ScriptState* m_pausedScriptState;
- HashMap<String, String> m_sourceIDToURL;
- HashMap<String, String> m_scriptIDToContent;
- HashMap<String, SourceBreakpoints> m_stickyBreakpoints;
- HashMap<String, unsigned> m_breakpointsMapping;
- bool m_breakpointsLoaded;
+ OwnPtr<InspectorDebuggerAgent> m_debuggerAgent;
bool m_profilerEnabled;
bool m_recordingUserInitiatedProfile;
diff --git a/WebCore/inspector/InspectorDebuggerAgent.cpp b/WebCore/inspector/InspectorDebuggerAgent.cpp
new file mode 100644
index 0000000..6732b08
--- /dev/null
+++ b/WebCore/inspector/InspectorDebuggerAgent.cpp
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InspectorDebuggerAgent.h"
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+#include "InjectedScript.h"
+#include "InjectedScriptHost.h"
+#include "InspectorValues.h"
+#include "PlatformString.h"
+#include "RemoteInspectorFrontend.h"
+#include "ScriptDebugServer.h"
+#include <wtf/MD5.h>
+
+namespace WebCore {
+
+static String formatBreakpointId(const String& sourceID, unsigned lineNumber)
+{
+ return String::format("%s:%d", sourceID.utf8().data(), lineNumber);
+}
+
+PassOwnPtr<InspectorDebuggerAgent> InspectorDebuggerAgent::create(InspectorController* inspectorController)
+{
+ OwnPtr<InspectorDebuggerAgent> agent = adoptPtr(new InspectorDebuggerAgent(inspectorController));
+ ScriptDebugServer::shared().clearBreakpoints();
+ ScriptDebugServer::shared().addListener(agent.get(), inspectorController->inspectedPage());
+ return agent.release();
+}
+
+InspectorDebuggerAgent::InspectorDebuggerAgent(InspectorController* inspectorController)
+ : m_inspectorController(inspectorController)
+ , m_pausedScriptState(0)
+ , m_breakpointsLoaded(false)
+{
+}
+
+InspectorDebuggerAgent::~InspectorDebuggerAgent()
+{
+ ScriptDebugServer::shared().removeListener(this, m_inspectorController->inspectedPage());
+ m_pausedScriptState = 0;
+}
+
+bool InspectorDebuggerAgent::isDebuggerAlwaysEnabled()
+{
+ return ScriptDebugServer::shared().isDebuggerAlwaysEnabled();
+}
+
+void InspectorDebuggerAgent::activateBreakpoints()
+{
+ ScriptDebugServer::shared().activateBreakpoints();
+}
+
+void InspectorDebuggerAgent::deactivateBreakpoints()
+{
+ ScriptDebugServer::shared().deactivateBreakpoints();
+}
+
+void InspectorDebuggerAgent::setBreakpoint(long, const String& sourceID, unsigned lineNumber, bool enabled, const String& condition, bool* success, unsigned int* actualLineNumber)
+{
+ ScriptBreakpoint breakpoint(enabled, condition);
+ *success = ScriptDebugServer::shared().setBreakpoint(sourceID, breakpoint, lineNumber, actualLineNumber);
+ if (!*success)
+ return;
+
+ String url = m_sourceIDToURL.get(sourceID);
+ if (url.isEmpty())
+ return;
+
+ String breakpointId = formatBreakpointId(sourceID, *actualLineNumber);
+ m_breakpointsMapping.set(breakpointId, *actualLineNumber);
+
+ String key = md5Base16(url);
+ HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(key);
+ if (it == m_stickyBreakpoints.end())
+ it = m_stickyBreakpoints.set(key, SourceBreakpoints()).first;
+ it->second.set(*actualLineNumber, breakpoint);
+ saveBreakpoints();
+}
+
+void InspectorDebuggerAgent::removeBreakpoint(const String& sourceID, unsigned lineNumber)
+{
+ ScriptDebugServer::shared().removeBreakpoint(sourceID, lineNumber);
+
+ String url = m_sourceIDToURL.get(sourceID);
+ if (url.isEmpty())
+ return;
+
+ String breakpointId = formatBreakpointId(sourceID, lineNumber);
+ HashMap<String, unsigned>::iterator mappingIt = m_breakpointsMapping.find(breakpointId);
+ if (mappingIt == m_breakpointsMapping.end())
+ return;
+ unsigned stickyLine = mappingIt->second;
+ m_breakpointsMapping.remove(mappingIt);
+
+ HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
+ if (it == m_stickyBreakpoints.end())
+ return;
+
+ it->second.remove(stickyLine);
+ saveBreakpoints();
+}
+
+void InspectorDebuggerAgent::editScriptSource(long, const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames)
+{
+ if (*success = ScriptDebugServer::shared().editScriptSource(sourceID, newContent, *result))
+ *newCallFrames = currentCallFrames();
+}
+
+void InspectorDebuggerAgent::getScriptSource(long, const String& sourceID, String* scriptSource)
+{
+ *scriptSource = m_scriptIDToContent.get(sourceID);
+}
+
+void InspectorDebuggerAgent::pause()
+{
+ ScriptDebugServer::shared().pause();
+}
+
+void InspectorDebuggerAgent::resume()
+{
+ ScriptDebugServer::shared().continueProgram();
+}
+
+void InspectorDebuggerAgent::stepOverStatement()
+{
+ ScriptDebugServer::shared().stepOverStatement();
+}
+
+void InspectorDebuggerAgent::stepIntoStatement()
+{
+ ScriptDebugServer::shared().stepIntoStatement();
+}
+
+void InspectorDebuggerAgent::stepOutOfFunction()
+{
+ ScriptDebugServer::shared().stepOutOfFunction();
+}
+
+void InspectorDebuggerAgent::setPauseOnExceptionsState(long pauseState)
+{
+ ScriptDebugServer::shared().setPauseOnExceptionsState(static_cast<ScriptDebugServer::PauseOnExceptionsState>(pauseState));
+ if (remoteFrontend())
+ remoteFrontend()->updatePauseOnExceptionsState(ScriptDebugServer::shared().pauseOnExceptionsState());
+}
+
+void InspectorDebuggerAgent::clearForPageNavigation()
+{
+ m_sourceIDToURL.clear();
+ m_scriptIDToContent.clear();
+ m_stickyBreakpoints.clear();
+ m_breakpointsMapping.clear();
+ m_breakpointsLoaded = false;
+}
+
+String InspectorDebuggerAgent::md5Base16(const String& string)
+{
+ static const char digits[] = "0123456789abcdef";
+
+ MD5 md5;
+ md5.addBytes(reinterpret_cast<const uint8_t*>(string.characters()), string.length() * 2);
+ Vector<uint8_t, 16> digest;
+ md5.checksum(digest);
+
+ Vector<char, 32> result;
+ for (int i = 0; i < 16; ++i) {
+ result.append(digits[(digest[i] >> 4) & 0xf]);
+ result.append(digits[digest[i] & 0xf]);
+ }
+ return String(result.data(), result.size());
+}
+
+PassRefPtr<InspectorValue> InspectorDebuggerAgent::currentCallFrames()
+{
+ if (!m_pausedScriptState)
+ return InspectorValue::null();
+ InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(m_pausedScriptState);
+ if (injectedScript.hasNoValue()) {
+ ASSERT_NOT_REACHED();
+ return InspectorValue::null();
+ }
+ return injectedScript.callFrames();
+}
+
+void InspectorDebuggerAgent::loadBreakpoints()
+{
+ if (m_breakpointsLoaded)
+ return;
+ m_breakpointsLoaded = true;
+
+ RefPtr<InspectorValue> parsedSetting = m_inspectorController->loadBreakpoints();
+ if (!parsedSetting)
+ return;
+ RefPtr<InspectorObject> breakpoints = parsedSetting->asObject();
+ if (!breakpoints)
+ return;
+ for (InspectorObject::iterator it = breakpoints->begin(); it != breakpoints->end(); ++it) {
+ RefPtr<InspectorObject> breakpointsForURL = it->second->asObject();
+ if (!breakpointsForURL)
+ continue;
+ HashMap<String, SourceBreakpoints>::iterator sourceBreakpointsIt = m_stickyBreakpoints.set(it->first, SourceBreakpoints()).first;
+ ScriptBreakpoint::sourceBreakpointsFromInspectorObject(breakpointsForURL, &sourceBreakpointsIt->second);
+ }
+}
+
+void InspectorDebuggerAgent::saveBreakpoints()
+{
+ RefPtr<InspectorObject> breakpoints = InspectorObject::create();
+ for (HashMap<String, SourceBreakpoints>::iterator it(m_stickyBreakpoints.begin()); it != m_stickyBreakpoints.end(); ++it) {
+ if (it->second.isEmpty())
+ continue;
+ RefPtr<InspectorObject> breakpointsForURL = ScriptBreakpoint::inspectorObjectFromSourceBreakpoints(it->second);
+ breakpoints->set(it->first, breakpointsForURL);
+ }
+ m_inspectorController->saveBreakpoints(breakpoints);
+}
+
+// JavaScriptDebugListener functions
+
+void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType worldType)
+{
+ // Don't send script content to the front end until it's really needed.
+ remoteFrontend()->parsedScriptSource(sourceID, url, "", firstLine, worldType);
+
+ m_scriptIDToContent.set(sourceID, data);
+
+ if (url.isEmpty())
+ return;
+
+ loadBreakpoints();
+ HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
+ if (it != m_stickyBreakpoints.end()) {
+ for (SourceBreakpoints::iterator breakpointIt = it->second.begin(); breakpointIt != it->second.end(); ++breakpointIt) {
+ int lineNumber = breakpointIt->first;
+ if (firstLine > lineNumber)
+ continue;
+ unsigned actualLineNumber = 0;
+ bool success = ScriptDebugServer::shared().setBreakpoint(sourceID, breakpointIt->second, lineNumber, &actualLineNumber);
+ if (!success)
+ continue;
+ remoteFrontend()->restoredBreakpoint(sourceID, url, actualLineNumber, breakpointIt->second.enabled, breakpointIt->second.condition);
+ String breakpointId = formatBreakpointId(sourceID, actualLineNumber);
+ m_breakpointsMapping.set(breakpointId, lineNumber);
+ }
+ }
+ m_sourceIDToURL.set(sourceID, url);
+}
+
+void InspectorDebuggerAgent::failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage)
+{
+ remoteFrontend()->failedToParseScriptSource(url, data, firstLine, errorLine, errorMessage);
+}
+
+void InspectorDebuggerAgent::didPause(ScriptState* scriptState)
+{
+ ASSERT(scriptState && !m_pausedScriptState);
+ m_pausedScriptState = scriptState;
+ RefPtr<InspectorValue> callFrames = currentCallFrames();
+ remoteFrontend()->pausedScript(callFrames.get());
+}
+
+void InspectorDebuggerAgent::didContinue()
+{
+ m_pausedScriptState = 0;
+ remoteFrontend()->resumedScript();
+}
+
+RemoteInspectorFrontend* InspectorDebuggerAgent::remoteFrontend() const
+{
+ return m_inspectorController->remoteInspectorFrontend();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
diff --git a/WebCore/inspector/InspectorDebuggerAgent.h b/WebCore/inspector/InspectorDebuggerAgent.h
new file mode 100644
index 0000000..b15ae90
--- /dev/null
+++ b/WebCore/inspector/InspectorDebuggerAgent.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorDebuggerAgent_h
+#define InspectorDebuggerAgent_h
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+#include "ScriptBreakpoint.h"
+#include "ScriptDebugListener.h"
+#include "ScriptState.h"
+#include "StringHash.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+class InjectedScriptHost;
+class InspectorController;
+class InspectorValue;
+class RemoteInspectorFrontend;
+class String;
+
+class InspectorDebuggerAgent : public ScriptDebugListener, public Noncopyable {
+public:
+ static PassOwnPtr<InspectorDebuggerAgent> create(InspectorController*);
+ virtual ~InspectorDebuggerAgent();
+
+ static bool isDebuggerAlwaysEnabled();
+
+ void activateBreakpoints();
+ void deactivateBreakpoints();
+ void setBreakpoint(long callId, const String& sourceID, unsigned lineNumber, bool enabled, const String& condition, bool* success, unsigned int* actualLineNumber);
+ void removeBreakpoint(const String& sourceID, unsigned lineNumber);
+
+ void editScriptSource(long callId, const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames);
+ void getScriptSource(long callId, const String& sourceID, String* scriptSource);
+
+ void pause();
+ void resume();
+ void stepOverStatement();
+ void stepIntoStatement();
+ void stepOutOfFunction();
+
+ void setPauseOnExceptionsState(long pauseState);
+
+ void clearForPageNavigation();
+
+ static String md5Base16(const String& string);
+
+private:
+ InspectorDebuggerAgent(InspectorController*);
+
+ PassRefPtr<InspectorValue> currentCallFrames();
+
+ void loadBreakpoints();
+ void saveBreakpoints();
+
+ virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType);
+ virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
+ virtual void didPause(ScriptState*);
+ virtual void didContinue();
+
+ RemoteInspectorFrontend* remoteFrontend() const;
+
+ InspectorController* m_inspectorController;
+ ScriptState* m_pausedScriptState;
+ HashMap<String, String> m_sourceIDToURL;
+ HashMap<String, String> m_scriptIDToContent;
+ HashMap<String, SourceBreakpoints> m_stickyBreakpoints;
+ HashMap<String, unsigned> m_breakpointsMapping;
+ bool m_breakpointsLoaded;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
+
+#endif // !defined(InspectorDebuggerAgent_h)
diff --git a/WebCore/inspector/InspectorFrontend.cpp b/WebCore/inspector/InspectorFrontend.cpp
index 994f4dc..7f21440 100644
--- a/WebCore/inspector/InspectorFrontend.cpp
+++ b/WebCore/inspector/InspectorFrontend.cpp
@@ -221,52 +221,6 @@ void InspectorFrontend::debuggerWasDisabled()
callSimpleFunction("debuggerWasDisabled");
}
-void InspectorFrontend::didSetBreakpoint(long callId, bool success, unsigned line)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didSetBreakpoint");
- function.appendArgument(callId);
- function.appendArgument(success);
- function.appendArgument(line);
- function.call();
-}
-
-void InspectorFrontend::parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine, int scriptWorldType)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("parsedScriptSource");
- function.appendArgument(sourceID);
- function.appendArgument(url);
- function.appendArgument(data);
- function.appendArgument(firstLine);
- function.appendArgument(scriptWorldType);
- function.call();
-}
-
-void InspectorFrontend::restoredBreakpoint(const String& sourceID, const String& url, int line, bool enabled, const String& condition)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("restoredBreakpoint");
- function.appendArgument(sourceID);
- function.appendArgument(url);
- function.appendArgument(line);
- function.appendArgument(enabled);
- function.appendArgument(condition);
- function.call();
-}
-
-void InspectorFrontend::failedToParseScriptSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("failedToParseScriptSource");
- function.appendArgument(url);
- function.appendArgument(data);
- function.appendArgument(firstLine);
- function.appendArgument(errorLine);
- function.appendArgument(errorMessage);
- function.call();
-}
-
void InspectorFrontend::profilerWasEnabled()
{
callSimpleFunction("profilerWasEnabled");
diff --git a/WebCore/inspector/InspectorFrontend.h b/WebCore/inspector/InspectorFrontend.h
index d7cef04..6e0620a 100644
--- a/WebCore/inspector/InspectorFrontend.h
+++ b/WebCore/inspector/InspectorFrontend.h
@@ -79,12 +79,6 @@ namespace WebCore {
void debuggerWasEnabled();
void debuggerWasDisabled();
- void didSetBreakpoint(long callId, bool success, unsigned line);
-
- void parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine, int scriptWorldType);
- void restoredBreakpoint(const String& sourceID, const String& url, int line, bool enabled, const String& condition);
- void failedToParseScriptSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
-
void profilerWasEnabled();
void profilerWasDisabled();
void setRecordingProfile(bool isProfiling);
diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
index dff4853..7826d2e 100644
--- a/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/WebCore/inspector/front-end/ScriptsPanel.js
@@ -103,11 +103,11 @@ WebInspector.ScriptsPanel = function()
this.stepOutButton.appendChild(document.createElement("img"));
this.sidebarButtonsElement.appendChild(this.stepOutButton);
- this.toggleBreakpointsButton = new WebInspector.StatusBarButton("", "toggle-breakpoints");
+ this.toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Deactivate all breakpoints."), "toggle-breakpoints");
+ // Breakpoints should be activated by default, so emulate a click to toggle on.
+ this.toggleBreakpointsButton.toggled = true;
this.toggleBreakpointsButton.addEventListener("click", this.toggleBreakpointsClicked.bind(this), false);
this.sidebarButtonsElement.appendChild(this.toggleBreakpointsButton.element);
- // Breakpoints should be activated by default, so emulate a click to toggle on.
- this.toggleBreakpointsClicked();
this.debuggerStatusElement = document.createElement("div");
this.debuggerStatusElement.id = "scripts-debugger-status";
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list