Diff
Modified: trunk/Source/WebCore/ChangeLog (86755 => 86756)
--- trunk/Source/WebCore/ChangeLog 2011-05-18 13:42:24 UTC (rev 86755)
+++ trunk/Source/WebCore/ChangeLog 2011-05-18 13:50:56 UTC (rev 86756)
@@ -1,3 +1,21 @@
+2011-05-16 Pavel Podivilov <[email protected]>
+
+ Reviewed by Yury Semikhatsky.
+
+ Web Inspector: refactoring: ScriptDebugListener::didParseSource has too many parameters.
+ https://bugs.webkit.org/show_bug.cgi?id=60900
+
+ * bindings/js/ScriptDebugServer.cpp:
+ (WebCore::ScriptDebugServer::dispatchDidParseSource):
+ * bindings/v8/ScriptDebugServer.cpp:
+ (WebCore::ScriptDebugServer::dispatchDidParseSource):
+ * inspector/InspectorDebuggerAgent.cpp:
+ (WebCore::InspectorDebuggerAgent::getScriptSource):
+ (WebCore::InspectorDebuggerAgent::didParseSource):
+ * inspector/InspectorDebuggerAgent.h:
+ * inspector/ScriptDebugListener.h:
+ (WebCore::ScriptDebugListener::Script::Script):
+
2011-05-18 Alexander Pavlov <[email protected]>
Reviewed by Pavel Feldman.
Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp (86755 => 86756)
--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp 2011-05-18 13:42:24 UTC (rev 86755)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp 2011-05-18 13:50:56 UTC (rev 86756)
@@ -221,31 +221,34 @@
void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, bool isContentScript)
{
String sourceID = ustringToString(JSC::UString::number(sourceProvider->asID()));
- String url = ""
- String data = "" sourceProvider->length()));
- int lineOffset = sourceProvider->startPosition().m_line.convertAsZeroBasedInt();
- int columnOffset = sourceProvider->startPosition().m_column.convertAsZeroBasedInt();
+ ScriptDebugListener::Script script;
+ script.url = ""
+ script.source = ustringToString(JSC::UString(sourceProvider->data(), sourceProvider->length()));
+ script.startLine = sourceProvider->startPosition().m_line.convertAsZeroBasedInt();
+ script.startColumn = sourceProvider->startPosition().m_column.convertAsZeroBasedInt();
+ script.isContentScript = isContentScript;
+
+ int sourceLength = script.source.length();
int lineCount = 1;
int lastLineStart = 0;
- for (size_t i = 0; i < data.length() - 1; ++i) {
- if (data[i] == '\n') {
+ for (int i = 0; i < sourceLength - 1; ++i) {
+ if (script.source[i] == '\n') {
lineCount += 1;
lastLineStart = i + 1;
}
}
- int endLine = lineOffset + lineCount - 1;
- int endColumn;
+ script.endLine = script.startLine + lineCount - 1;
if (lineCount == 1)
- endColumn = data.length() + columnOffset;
+ script.endColumn = script.startColumn + sourceLength;
else
- endColumn = data.length() - lastLineStart;
+ script.endColumn = sourceLength - lastLineStart;
Vector<ScriptDebugListener*> copy;
copyToVector(listeners, copy);
for (size_t i = 0; i < copy.size(); ++i)
- copy[i]->didParseSource(sourceID, url, data, lineOffset, columnOffset, endLine, endColumn, isContentScript);
+ copy[i]->didParseSource(sourceID, script);
}
void ScriptDebugServer::dispatchFailedToParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, int errorLine, const String& errorMessage)
Modified: trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp (86755 => 86756)
--- trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp 2011-05-18 13:42:24 UTC (rev 86755)
+++ trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp 2011-05-18 13:50:56 UTC (rev 86756)
@@ -352,15 +352,19 @@
void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> object)
{
- listener->didParseSource(
- toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("id"))),
- toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("name"))),
- toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("source"))),
- object->Get(v8::String::New("startLine"))->ToInteger()->Value(),
- object->Get(v8::String::New("startColumn"))->ToInteger()->Value(),
- object->Get(v8::String::New("endLine"))->ToInteger()->Value(),
- object->Get(v8::String::New("endColumn"))->ToInteger()->Value(),
- object->Get(v8::String::New("isContentScript"))->ToBoolean()->Value());
+ String sourceID = toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("id")));
+
+ ScriptDebugListener::Script script;
+ script.url = ""
+ script.source = toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("source")));
+ script.sourceMappingURL = toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("sourceMappingURL")));
+ script.startLine = object->Get(v8::String::New("startLine"))->ToInteger()->Value();
+ script.startColumn = object->Get(v8::String::New("startColumn"))->ToInteger()->Value();
+ script.endLine = object->Get(v8::String::New("endLine"))->ToInteger()->Value();
+ script.endColumn = object->Get(v8::String::New("endColumn"))->ToInteger()->Value();
+ script.isContentScript = object->Get(v8::String::New("isContentScript"))->ToBoolean()->Value();
+
+ listener->didParseSource(sourceID, script);
}
void ScriptDebugServer::ensureDebuggerScriptCompiled()
Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp (86755 => 86756)
--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp 2011-05-18 13:42:24 UTC (rev 86755)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp 2011-05-18 13:50:56 UTC (rev 86756)
@@ -293,7 +293,7 @@
void InspectorDebuggerAgent::getScriptSource(ErrorString*, const String& sourceId, String* scriptSource)
{
- *scriptSource = m_scripts.get(sourceId).data;
+ *scriptSource = m_scripts.get(sourceId).source;
}
void InspectorDebuggerAgent::schedulePauseOnNextStatement(DebuggerEventType type, PassRefPtr<InspectorValue> data)
@@ -383,14 +383,14 @@
// _javascript_DebugListener functions
-void InspectorDebuggerAgent::didParseSource(const String& sourceId, const String& url, const String& data, int startLine, int startColumn, int endLine, int endColumn, bool isContentScript)
+void InspectorDebuggerAgent::didParseSource(const String& sourceId, const Script& script)
{
// Don't send script content to the front end until it's really needed.
- m_frontend->scriptParsed(sourceId, url, startLine, startColumn, endLine, endColumn, isContentScript);
+ m_frontend->scriptParsed(sourceId, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, script.isContentScript);
- m_scripts.set(sourceId, Script(url, data, startLine, startColumn, endLine, endColumn));
+ m_scripts.set(sourceId, script);
- if (url.isEmpty())
+ if (script.url.isEmpty())
return;
RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::_javascript_Breakpoints);
@@ -398,7 +398,7 @@
RefPtr<InspectorObject> breakpointObject = it->second->asObject();
String breakpointURL;
breakpointObject->getString("url", &breakpointURL);
- if (breakpointURL != url)
+ if (breakpointURL != script.url)
continue;
ScriptBreakpoint breakpoint;
breakpointObject->getNumber("lineNumber", &breakpoint.lineNumber);
Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h (86755 => 86756)
--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h 2011-05-18 13:42:24 UTC (rev 86755)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h 2011-05-18 13:50:56 UTC (rev 86756)
@@ -120,7 +120,7 @@
PassRefPtr<InspectorArray> currentCallFrames();
- virtual void didParseSource(const String& sourceId, const String& url, const String& data, int startLine, int startColumn, int endLine, int endColumn, bool isContentScript);
+ 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();
@@ -128,35 +128,6 @@
PassRefPtr<InspectorObject> resolveBreakpoint(const String& breakpointId, const String& sourceId, const ScriptBreakpoint&);
void clear();
- class Script {
- public:
- Script()
- : startLine(0)
- , startColumn(0)
- , endLine(0)
- , endColumn(0)
- {
- }
-
- Script(const String& url, const String& data, int startLine, int startColumn, int endLine, int endColumn)
- : url(url)
- , data(data)
- , startLine(startLine)
- , startColumn(startColumn)
- , endLine(endLine)
- , endColumn(endColumn)
- {
- }
-
- String url;
- String data;
- int startLine;
- int startColumn;
- int endLine;
- int endColumn;
- int linesCount;
- };
-
typedef HashMap<String, Script> ScriptsMap;
typedef HashMap<String, Vector<String> > BreakpointIdToDebugServerBreakpointIdsMap;
Modified: trunk/Source/WebCore/inspector/ScriptDebugListener.h (86755 => 86756)
--- trunk/Source/WebCore/inspector/ScriptDebugListener.h 2011-05-18 13:42:24 UTC (rev 86755)
+++ trunk/Source/WebCore/inspector/ScriptDebugListener.h 2011-05-18 13:50:56 UTC (rev 86756)
@@ -32,6 +32,7 @@
#if ENABLE(_javascript__DEBUGGER)
+#include "PlatformString.h"
#include "ScriptState.h"
#include <wtf/Forward.h>
@@ -40,9 +41,30 @@
class ScriptDebugListener {
public:
+ class Script {
+ public:
+ Script()
+ : startLine(0)
+ , startColumn(0)
+ , endLine(0)
+ , endColumn(0)
+ , isContentScript(false)
+ {
+ }
+
+ String url;
+ String source;
+ String sourceMappingURL;
+ int startLine;
+ int startColumn;
+ int endLine;
+ int endColumn;
+ bool isContentScript;
+ };
+
virtual ~ScriptDebugListener() { }
- virtual void didParseSource(const String& sourceId, const String& url, const String& data, int startLine, int startColumn, int endLine, int endColumn, bool isContentScript) = 0;
+ virtual void didParseSource(const String& sourceId, const Script&) = 0;
virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) = 0;
virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception) = 0;
virtual void didContinue() = 0;