Commit 8496c91d authored by podivilov@chromium.org's avatar podivilov@chromium.org
Browse files

2011-01-24 Pavel Podivilov <podivilov@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: debugger and browser debugger agents should manage sticky breakpoints independently.
        https://bugs.webkit.org/show_bug.cgi?id=52999

        * inspector/Inspector.idl:
        * inspector/InspectorAgent.cpp:
        (WebCore::InspectorAgent::didCommitLoad):
        (WebCore::InspectorAgent::enableDebugger):
        (WebCore::InspectorAgent::inspectedURLWithoutFragment):
        * inspector/InspectorAgent.h:
        * inspector/InspectorBrowserDebuggerAgent.cpp:
        (WebCore::InspectorBrowserDebuggerAgent::setAllBrowserBreakpoints):
        (WebCore::InspectorBrowserDebuggerAgent::inspectedURLChanged):
        (WebCore::InspectorBrowserDebuggerAgent::restoreStickyBreakpoint):
        * inspector/InspectorBrowserDebuggerAgent.h:
        * inspector/InspectorDebuggerAgent.cpp:
        (WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent):
        (WebCore::InspectorDebuggerAgent::setAllJavaScriptBreakpoints):
        (WebCore::InspectorDebuggerAgent::inspectedURLChanged):
        (WebCore::InspectorDebuggerAgent::restoreBreakpoints):
        * inspector/InspectorDebuggerAgent.h:
        * inspector/InspectorState.cpp:
        (WebCore::InspectorState::InspectorState):
        * inspector/InspectorState.h:
        * inspector/front-end/BreakpointManager.js:
        (WebInspector.BreakpointManager):
        (WebInspector.BreakpointManager.prototype._projectChanged):
        (WebInspector.BreakpointManager.prototype._saveBreakpoints):
        (WebInspector.BreakpointManager.prototype._pushBreakpointsToBackend):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76581 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 886efd06
2011-01-24 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: debugger and browser debugger agents should manage sticky breakpoints independently.
https://bugs.webkit.org/show_bug.cgi?id=52999
* inspector/Inspector.idl:
* inspector/InspectorAgent.cpp:
(WebCore::InspectorAgent::didCommitLoad):
(WebCore::InspectorAgent::enableDebugger):
(WebCore::InspectorAgent::inspectedURLWithoutFragment):
* inspector/InspectorAgent.h:
* inspector/InspectorBrowserDebuggerAgent.cpp:
(WebCore::InspectorBrowserDebuggerAgent::setAllBrowserBreakpoints):
(WebCore::InspectorBrowserDebuggerAgent::inspectedURLChanged):
(WebCore::InspectorBrowserDebuggerAgent::restoreStickyBreakpoint):
* inspector/InspectorBrowserDebuggerAgent.h:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent):
(WebCore::InspectorDebuggerAgent::setAllJavaScriptBreakpoints):
(WebCore::InspectorDebuggerAgent::inspectedURLChanged):
(WebCore::InspectorDebuggerAgent::restoreBreakpoints):
* inspector/InspectorDebuggerAgent.h:
* inspector/InspectorState.cpp:
(WebCore::InspectorState::InspectorState):
* inspector/InspectorState.h:
* inspector/front-end/BreakpointManager.js:
(WebInspector.BreakpointManager):
(WebInspector.BreakpointManager.prototype._projectChanged):
(WebInspector.BreakpointManager.prototype._saveBreakpoints):
(WebInspector.BreakpointManager.prototype._pushBreakpointsToBackend):
2011-01-25 Carlos Garcia Campos <cgarcia@igalia.com>
 
Reviewed by Martin Robinson.
......@@ -242,8 +242,6 @@ module core {
[domain=Inspector] void enableDebugger(in boolean always);
[domain=Inspector] void disableDebugger(in boolean always);
[domain=Inspector] void setAllBrowserBreakpoints(in Object breakpoints);
[notify, domain=Debugger] void debuggerWasEnabled();
[notify, domain=Debugger] void debuggerWasDisabled();
......@@ -253,9 +251,11 @@ module core {
[domain=Debugger] void activateBreakpoints();
[domain=Debugger] void deactivateBreakpoints();
[domain=Debugger] void setAllJavaScriptBreakpoints(in Object breakpoints);
[domain=Debugger] void setBreakpoint(in Object breakpoint, out String breakpointId, out long actualLineNumber, out long actualColumnNumber);
[domain=Debugger] void removeBreakpoint(in String breakpointId);
[domain=BrowserDebugger] void setAllBrowserBreakpoints(in Object breakpoints);
[domain=BrowserDebugger] void setDOMBreakpoint(in long nodeId, in long type);
[domain=BrowserDebugger] void removeDOMBreakpoint(in long nodeId, in long type);
[domain=BrowserDebugger] void setEventListenerBreakpoint(in String eventName);
......
......@@ -644,9 +644,10 @@ void InspectorAgent::didCommitLoad(DocumentLoader* loader)
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (m_debuggerAgent) {
m_debuggerAgent->clearForPageNavigation();
KURL url = inspectedURLWithoutFragment();
m_debuggerAgent->inspectedURLChanged(url);
if (m_browserDebuggerAgent)
m_browserDebuggerAgent->inspectedURLChanged(inspectedURL());
m_browserDebuggerAgent->inspectedURLChanged(url);
}
#endif
......@@ -1052,7 +1053,6 @@ void InspectorAgent::enableDebugger(bool always)
m_debuggerAgent = InspectorDebuggerAgent::create(this, m_frontend.get());
m_browserDebuggerAgent = InspectorBrowserDebuggerAgent::create(this);
m_browserDebuggerAgent->inspectedURLChanged(inspectedURL());
m_frontend->debuggerWasEnabled();
}
......@@ -1390,6 +1390,13 @@ KURL InspectorAgent::inspectedURL() const
return m_inspectedPage->mainFrame()->loader()->url();
}
KURL InspectorAgent::inspectedURLWithoutFragment() const
{
KURL url = inspectedURL();
url.removeFragmentIdentifier();
return url;
}
void InspectorAgent::reloadPage()
{
// FIXME: Why do we set the user gesture indicator here?
......
......@@ -128,6 +128,7 @@ public:
Page* inspectedPage() const { return m_inspectedPage; }
KURL inspectedURL() const;
KURL inspectedURLWithoutFragment() const;
void reloadPage();
void restoreInspectorStateFromCookie(const String& inspectorCookie);
......
......@@ -71,16 +71,20 @@ InspectorBrowserDebuggerAgent::~InspectorBrowserDebuggerAgent()
{
}
void InspectorBrowserDebuggerAgent::inspectedURLChanged(const KURL& url)
void InspectorBrowserDebuggerAgent::setAllBrowserBreakpoints(PassRefPtr<InspectorObject> breakpoints)
{
m_inspectorAgent->state()->setObject(InspectorState::browserBreakpoints, breakpoints);
inspectedURLChanged(m_inspectorAgent->inspectedURLWithoutFragment());
}
void InspectorBrowserDebuggerAgent::inspectedURLChanged(const String& url)
{
m_eventListenerBreakpoints.clear();
m_XHRBreakpoints.clear();
m_hasXHRBreakpointWithEmptyURL = false;
RefPtr<InspectorObject> allBreakpoints = m_inspectorAgent->state()->getObject(InspectorState::browserBreakpoints);
KURL urlCopy = url;
urlCopy.removeFragmentIdentifier();
RefPtr<InspectorArray> breakpoints = allBreakpoints->getArray(urlCopy);
RefPtr<InspectorArray> breakpoints = allBreakpoints->getArray(url);
if (!breakpoints)
return;
for (unsigned i = 0; i < breakpoints->length(); ++i)
......@@ -89,10 +93,6 @@ void InspectorBrowserDebuggerAgent::inspectedURLChanged(const KURL& url)
void InspectorBrowserDebuggerAgent::restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint)
{
DEFINE_STATIC_LOCAL(String, eventListenerBreakpointType, ("EventListener"));
DEFINE_STATIC_LOCAL(String, javaScriptBreakpointType, ("JS"));
DEFINE_STATIC_LOCAL(String, xhrBreakpointType, ("XHR"));
if (!breakpoint)
return;
String type;
......@@ -105,28 +105,14 @@ void InspectorBrowserDebuggerAgent::restoreStickyBreakpoint(PassRefPtr<Inspector
if (!condition)
return;
if (type == eventListenerBreakpointType) {
if (type == eventListenerNativeBreakpointType) {
if (!enabled)
return;
String eventName;
if (!condition->getString("eventName", &eventName))
return;
setEventListenerBreakpoint(eventName);
} else if (type == javaScriptBreakpointType && m_inspectorAgent->debuggerAgent()) {
String url;
if (!condition->getString("url", &url))
return;
double lineNumber;
if (!condition->getNumber("lineNumber", &lineNumber))
return;
double columnNumber;
if (!condition->getNumber("columnNumber", &columnNumber))
return;
String javaScriptCondition;
if (!condition->getString("condition", &javaScriptCondition))
return;
m_inspectorAgent->debuggerAgent()->setStickyBreakpoint(url, ScriptBreakpoint(long(lineNumber), long(columnNumber), javaScriptCondition, enabled));
} else if (type == xhrBreakpointType) {
} else if (type == xhrNativeBreakpointType) {
if (!enabled)
return;
String url;
......
......@@ -46,7 +46,6 @@ namespace WebCore {
class Element;
class InspectorAgent;
class InspectorObject;
class KURL;
class Node;
class InspectorBrowserDebuggerAgent {
......@@ -59,7 +58,8 @@ public:
virtual ~InspectorBrowserDebuggerAgent();
void inspectedURLChanged(const KURL&);
void setAllBrowserBreakpoints(PassRefPtr<InspectorObject>);
void inspectedURLChanged(const String& url);
// BrowserDebugger API for InspectorFrontend
void setXHRBreakpoint(const String& url);
......
......@@ -34,6 +34,7 @@
#include "InjectedScript.h"
#include "InjectedScriptHost.h"
#include "InspectorFrontend.h"
#include "InspectorState.h"
#include "InspectorValues.h"
#include "PlatformString.h"
#include "ScriptDebugServer.h"
......@@ -55,6 +56,7 @@ InspectorDebuggerAgent::InspectorDebuggerAgent(InspectorAgent* inspectorAgent, I
, m_frontend(frontend)
, m_pausedScriptState(0)
, m_javaScriptPauseScheduled(false)
, m_breakpointsRestored(false)
{
}
......@@ -79,6 +81,54 @@ void InspectorDebuggerAgent::deactivateBreakpoints()
ScriptDebugServer::shared().deactivateBreakpoints();
}
void InspectorDebuggerAgent::setAllJavaScriptBreakpoints(PassRefPtr<InspectorObject> breakpoints)
{
m_inspectorAgent->state()->setObject(InspectorState::javaScriptBreakpoints, breakpoints);
if (!m_breakpointsRestored) {
restoreBreakpoints(m_inspectorAgent->inspectedURLWithoutFragment());
m_breakpointsRestored = true;
}
}
void InspectorDebuggerAgent::inspectedURLChanged(const String& url)
{
m_scriptIDToContent.clear();
m_urlToSourceIDs.clear();
restoreBreakpoints(url);
}
void InspectorDebuggerAgent::restoreBreakpoints(const String& inspectedURL)
{
m_stickyBreakpoints.clear();
RefPtr<InspectorObject> allBreakpoints = m_inspectorAgent->state()->getObject(InspectorState::javaScriptBreakpoints);
RefPtr<InspectorArray> breakpoints = allBreakpoints->getArray(inspectedURL);
if (!breakpoints)
return;
for (unsigned i = 0; i < breakpoints->length(); ++i) {
RefPtr<InspectorObject> breakpoint = breakpoints->get(i)->asObject();
if (!breakpoint)
continue;
String url;
if (!breakpoint->getString("url", &url))
continue;
double lineNumber;
if (!breakpoint->getNumber("lineNumber", &lineNumber))
continue;
double columnNumber;
if (!breakpoint->getNumber("columnNumber", &columnNumber))
return;
String condition;
if (!breakpoint->getString("condition", &condition))
continue;
bool enabled;
if (!breakpoint->getBoolean("enabled", &enabled))
continue;
ScriptBreakpoint scriptBreakpoint((long) lineNumber, (long) columnNumber, condition, enabled);
setStickyBreakpoint(url, scriptBreakpoint);
}
}
void InspectorDebuggerAgent::setStickyBreakpoint(const String& url, const ScriptBreakpoint& breakpoint)
{
InspectedURLToBreakpointsMap::iterator it = m_stickyBreakpoints.find(url);
......@@ -213,13 +263,6 @@ void InspectorDebuggerAgent::getCompletionsOnCallFrame(PassRefPtr<InspectorObjec
injectedScript.getCompletionsOnCallFrame(callFrameId, expression, includeInspectorCommandLineAPI, result);
}
void InspectorDebuggerAgent::clearForPageNavigation()
{
m_scriptIDToContent.clear();
m_urlToSourceIDs.clear();
m_stickyBreakpoints.clear();
}
PassRefPtr<InspectorValue> InspectorDebuggerAgent::currentCallFrames()
{
if (!m_pausedScriptState)
......
......@@ -62,6 +62,9 @@ public:
static bool isDebuggerAlwaysEnabled();
void setAllJavaScriptBreakpoints(PassRefPtr<InspectorObject>);
void inspectedURLChanged(const String& url);
// Part of the protocol.
void activateBreakpoints();
void deactivateBreakpoints();
......@@ -82,8 +85,6 @@ public:
void evaluateOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result);
void getCompletionsOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result);
void clearForPageNavigation();
private:
InspectorDebuggerAgent(InspectorAgent*, InspectorFrontend*);
......@@ -94,6 +95,7 @@ private:
virtual void didPause(ScriptState*);
virtual void didContinue();
void restoreBreakpoints(const String& inspectedURL);
void restoreBreakpoint(const String& sourceID, const ScriptBreakpoint&);
typedef HashMap<String, Vector<String> > URLToSourceIDsMap;
......@@ -109,6 +111,7 @@ private:
InspectedURLToBreakpointsMap m_stickyBreakpoints;
RefPtr<InspectorObject> m_breakProgramDetails;
bool m_javaScriptPauseScheduled;
bool m_breakpointsRestored;
};
} // namespace WebCore
......
......@@ -42,6 +42,7 @@ InspectorState::InspectorState(InspectorClient* client)
registerBoolean(userInitiatedProfiling, false);
registerBoolean(timelineProfilerEnabled, false);
registerBoolean(searchingForNode, false);
registerObject(javaScriptBreakpoints);
registerObject(browserBreakpoints);
registerBoolean(consoleMessagesEnabled, false);
registerBoolean(monitoringXHR, false);
......
......@@ -49,6 +49,7 @@ public:
searchingForNode,
consoleMessagesEnabled,
userInitiatedProfiling,
javaScriptBreakpoints,
browserBreakpoints,
resourceAgentEnabled,
lastPropertyId
......
......@@ -34,7 +34,6 @@ WebInspector.BreakpointManager = function()
var breakpoints = WebInspector.settings.findSettingForAllProjects("nativeBreakpoints");
for (var projectId in breakpoints)
this._stickyBreakpoints[projectId] = this._validateBreakpoints(breakpoints[projectId]);
InspectorBackend.setAllBrowserBreakpoints(this._stickyBreakpoints);
this._breakpoints = {};
this._domBreakpointsRestored = false;
......@@ -245,6 +244,11 @@ WebInspector.BreakpointManager.prototype = {
else if (breakpoint.type === WebInspector.BreakpointManager.BreakpointTypes.XHR)
this._createXHRBreakpoint(breakpoint.condition.url, breakpoint.enabled, true);
}
if (!this._breakpointsPushedToFrontend) {
this._pushBreakpointsToBackend();
this._breakpointsPushedToFrontend = true;
}
},
restoreDOMBreakpoints: function()
......@@ -303,7 +307,34 @@ WebInspector.BreakpointManager.prototype = {
WebInspector.settings.nativeBreakpoints = breakpoints;
this._stickyBreakpoints[WebInspector.settings.projectId] = breakpoints;
InspectorBackend.setAllBrowserBreakpoints(this._stickyBreakpoints);
this._pushBreakpointsToBackend();
},
_pushBreakpointsToBackend: function()
{
var allJavaScriptBreakpoints = {};
var allBrowserBreakpoints = {};
for (var projectId in this._stickyBreakpoints) {
var breakpoints = this._stickyBreakpoints[projectId];
var javaScriptBreakpoints = [];
var browserBreakpoints = [];
for (var i = 0; i < breakpoints.length; ++i) {
if (breakpoints[i].type == WebInspector.BreakpointManager.BreakpointTypes.JS) {
var data = {};
data.enabled = breakpoints[i].enabled;
for (var p in breakpoints[i].condition)
data[p] = breakpoints[i].condition[p];
javaScriptBreakpoints.push(data);
} else
browserBreakpoints.push(breakpoints[i]);
}
if (javaScriptBreakpoints.length)
allJavaScriptBreakpoints[projectId] = javaScriptBreakpoints;
if (browserBreakpoints.length)
allBrowserBreakpoints[projectId] = browserBreakpoints;
}
InspectorBackend.setAllJavaScriptBreakpoints(allJavaScriptBreakpoints);
InspectorBackend.setAllBrowserBreakpoints(allBrowserBreakpoints);
},
_validateBreakpoints: function(persistentBreakpoints)
......
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