Commit 0c47cc7c authored by podivilov@chromium.org's avatar podivilov@chromium.org
Browse files

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

        Reviewed by Yury Semikhatsky.

        Web Inspector: [JSC] scripts have incorrect starting line (always 1).
        https://bugs.webkit.org/show_bug.cgi?id=52721

        * inspector/debugger-scripts-expected.txt: Added.
        * inspector/debugger-scripts.html: Added.
2011-01-19  Pavel Podivilov  <podivilov@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: [JSC] scripts have incorrect starting line (always 1).
        https://bugs.webkit.org/show_bug.cgi?id=52721

        * debugger/Debugger.cpp:
        (JSC::Debugger::recompileAllJSFunctions):
        * debugger/Debugger.h:
        * parser/Parser.h:
        (JSC::Parser::parse):
        * parser/SourceCode.h:
        (JSC::SourceCode::SourceCode):
        * parser/SourceProvider.h:
        (JSC::SourceProvider::startPosition):
2011-01-19  Pavel Podivilov  <podivilov@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: [JSC] scripts have incorrect starting line (always 1).
        https://bugs.webkit.org/show_bug.cgi?id=52721

        Test: inspector/debugger-scripts.html

        * bindings/js/ScriptDebugServer.cpp:
        (WebCore::ScriptDebugServer::dispatchDidParseSource):
        (WebCore::ScriptDebugServer::dispatchFailedToParseSource):
        (WebCore::ScriptDebugServer::sourceParsed):
        * bindings/js/ScriptDebugServer.h:
        * bindings/js/ScriptSourceCode.h:
        (WebCore::ScriptSourceCode::ScriptSourceCode):
        * bindings/js/StringSourceProvider.h:
        (WebCore::StringSourceProvider::create):
        (WebCore::StringSourceProvider::startPosition):
        (WebCore::StringSourceProvider::StringSourceProvider):
2011-01-19  Pavel Podivilov  <podivilov@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: [JSC] scripts have incorrect starting line (always 1).
        https://bugs.webkit.org/show_bug.cgi?id=52721

        * WebView/WebScriptDebugger.h:
        * WebView/WebScriptDebugger.mm:
        (toNSString):
        (WebScriptDebugger::sourceParsed):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76129 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 87e47799
2011-01-19 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: [JSC] scripts have incorrect starting line (always 1).
https://bugs.webkit.org/show_bug.cgi?id=52721
* inspector/debugger-scripts-expected.txt: Added.
* inspector/debugger-scripts.html: Added.
2011-01-19 Jeremy Orlow <jorlow@chromium.org>
 
This test changed slightly, so rebaseline it. The offsets seem off
......
Tests that valid parsed script notifications are received by front-end. Bug 52721
Debugger was enabled.
script 1:
offset: 5:8
length: 1096
script 2:
offset: 38:21
length: 50
Debugger was disabled.
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
<script src="../http/tests/inspector/debugger-test2.js"></script>
<script>
var test = function()
{
var scripts = [];
InspectorTest.startDebuggerTest(step1);
function step1()
{
WebInspector.debuggerModel.queryScripts(function(script) { step2({ data: script.sourceID }) });
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, step2);
}
function step2(event)
{
var script = WebInspector.debuggerModel.scriptForSourceID(event.data);
if (script.sourceURL !== WebInspector.mainResource.url)
return;
scripts.push(script);
if (scripts.length === 2)
step3();
}
function step3()
{
scripts.sort(function(x, y) { return x.lineOffset - y.lineOffset });
for (var i = 0; i < scripts.length; ++i) {
InspectorTest.addResult("script " + (i + 1) + ":");
InspectorTest.addResult(" offset: " + scripts[i].lineOffset + ":" + scripts[i].columnOffset);
InspectorTest.addResult(" length: " + scripts[i].length);
}
InspectorTest.completeDebuggerTest();
}
}
</script> <script>
function doStuff()
{
}
window.onload = runTest;
</script>
</head>
<p>
Tests that valid parsed script notifications are received by front-end.
<a href="https://bugs.webkit.org/show_bug.cgi?id=52721">Bug 52721</a>
</p>
</html>
2011-01-19 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: [JSC] scripts have incorrect starting line (always 1).
https://bugs.webkit.org/show_bug.cgi?id=52721
* debugger/Debugger.cpp:
(JSC::Debugger::recompileAllJSFunctions):
* debugger/Debugger.h:
* parser/Parser.h:
(JSC::Parser::parse):
* parser/SourceCode.h:
(JSC::SourceCode::SourceCode):
* parser/SourceProvider.h:
(JSC::SourceProvider::startPosition):
2011-01-19 Csaba Osztrogonác <ossy@webkit.org>
 
Reviewed by Laszlo Gombos and Tor Arne Vestbø.
......
......@@ -94,7 +94,7 @@ void Debugger::recompileAllJSFunctions(JSGlobalData* globalData)
// JavaScript in the inspector.
SourceProviderMap::const_iterator end = sourceProviders.end();
for (SourceProviderMap::const_iterator iter = sourceProviders.begin(); iter != end; ++iter)
sourceParsed(iter->second, SourceCode(iter->first), -1, UString());
sourceParsed(iter->second, iter->first, -1, UString());
}
JSValue evaluateInGlobalCallFrame(const UString& script, JSValue& exception, JSGlobalObject* globalObject)
......
......@@ -31,7 +31,7 @@ namespace JSC {
class JSGlobalData;
class JSGlobalObject;
class JSValue;
class SourceCode;
class SourceProvider;
class UString;
class Debugger {
......@@ -41,7 +41,7 @@ namespace JSC {
void attach(JSGlobalObject*);
virtual void detach(JSGlobalObject*);
virtual void sourceParsed(ExecState*, const SourceCode&, int errorLineNumber, const UString& errorMessage) = 0;
virtual void sourceParsed(ExecState*, SourceProvider*, int errorLineNumber, const UString& errorMessage) = 0;
virtual void exception(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber, bool hasHandler) = 0;
virtual void atStatement(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
virtual void callEvent(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
......
......@@ -119,7 +119,7 @@ namespace JSC {
m_funcDeclarations = 0;
if (debugger && !ParsedNode::scopeIsFunction)
debugger->sourceParsed(debuggerExecState, source, errLine, errMsg);
debugger->sourceParsed(debuggerExecState, source.provider(), errLine, errMsg);
return result.release();
}
......
......@@ -31,7 +31,6 @@
#include "SourceProvider.h"
#include <wtf/RefPtr.h>
#include <wtf/text/TextPosition.h>
namespace JSC {
......@@ -42,34 +41,22 @@ namespace JSC {
, m_startChar(0)
, m_endChar(0)
, m_firstLine(0)
, m_firstColumn(0)
{
}
SourceCode(PassRefPtr<SourceProvider> provider, int firstLine = 1, int firstColumn = 1)
SourceCode(PassRefPtr<SourceProvider> provider, int firstLine = 1)
: m_provider(provider)
, m_startChar(0)
, m_endChar(m_provider->length())
, m_firstLine(std::max(firstLine, 1))
, m_firstColumn(std::max(firstColumn, 1))
{
}
SourceCode(PassRefPtr<SourceProvider> provider, int start, int end, int firstLine, int firstColumn = 1)
SourceCode(PassRefPtr<SourceProvider> provider, int start, int end, int firstLine)
: m_provider(provider)
, m_startChar(start)
, m_endChar(end)
, m_firstLine(std::max(firstLine, 1))
, m_firstColumn(std::max(firstColumn, 1))
{
}
SourceCode(PassRefPtr<SourceProvider> provider, const TextPosition1& startPosition)
: m_provider(provider)
, m_startChar(0)
, m_endChar(m_provider->length())
, m_firstLine(startPosition.m_line.oneBasedInt())
, m_firstColumn(startPosition.m_column.oneBasedInt())
{
}
......@@ -83,7 +70,6 @@ namespace JSC {
bool isNull() const { return !m_provider; }
SourceProvider* provider() const { return m_provider.get(); }
int firstLine() const { return m_firstLine; }
int firstColumn() const { return m_firstColumn; }
int startOffset() const { return m_startChar; }
int endOffset() const { return m_endChar; }
const UChar* data() const { return m_provider->data() + m_startChar; }
......@@ -94,7 +80,6 @@ namespace JSC {
int m_startChar;
int m_endChar;
int m_firstLine;
int m_firstColumn;
};
inline SourceCode makeSource(const UString& source, const UString& url = UString(), int firstLine = 1)
......
......@@ -31,6 +31,7 @@
#include "UString.h"
#include <wtf/RefCounted.h>
#include <wtf/text/TextPosition.h>
namespace JSC {
......@@ -48,6 +49,7 @@ namespace JSC {
virtual int length() const = 0;
const UString& url() { return m_url; }
virtual TextPosition1 startPosition() const { return TextPosition1::minimumPosition(); }
intptr_t asID() { return reinterpret_cast<intptr_t>(this); }
bool isValid() const { return m_validated; }
......
2011-01-19 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: [JSC] scripts have incorrect starting line (always 1).
https://bugs.webkit.org/show_bug.cgi?id=52721
Test: inspector/debugger-scripts.html
* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::dispatchDidParseSource):
(WebCore::ScriptDebugServer::dispatchFailedToParseSource):
(WebCore::ScriptDebugServer::sourceParsed):
* bindings/js/ScriptDebugServer.h:
* bindings/js/ScriptSourceCode.h:
(WebCore::ScriptSourceCode::ScriptSourceCode):
* bindings/js/StringSourceProvider.h:
(WebCore::StringSourceProvider::create):
(WebCore::StringSourceProvider::startPosition):
(WebCore::StringSourceProvider::StringSourceProvider):
2011-01-19 Satish Sampath <satish@chromium.org>
 
Reviewed by Jeremy Orlow.
......@@ -48,7 +48,7 @@
#include "ScrollView.h"
#include "Widget.h"
#include <debugger/DebuggerCallFrame.h>
#include <parser/SourceCode.h>
#include <parser/SourceProvider.h>
#include <runtime/JSLock.h>
#include <wtf/text/StringConcatenate.h>
#include <wtf/MainThread.h>
......@@ -282,23 +282,25 @@ void ScriptDebugServer::dispatchDidContinue(ScriptDebugListener* listener)
listener->didContinue();
}
void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, ScriptWorldType worldType)
void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, ScriptWorldType worldType)
{
String sourceID = ustringToString(JSC::UString::number(source.provider()->asID()));
String url = ustringToString(source.provider()->url());
String data = ustringToString(JSC::UString(source.data(), source.length()));
String sourceID = ustringToString(JSC::UString::number(sourceProvider->asID()));
String url = ustringToString(sourceProvider->url());
String data = ustringToString(JSC::UString(sourceProvider->data(), sourceProvider->length()));
int lineOffset = sourceProvider->startPosition().m_line.convertAsZeroBasedInt();
int columnOffset = sourceProvider->startPosition().m_column.convertAsZeroBasedInt();
Vector<ScriptDebugListener*> copy;
copyToVector(listeners, copy);
for (size_t i = 0; i < copy.size(); ++i)
copy[i]->didParseSource(sourceID, url, data, source.firstLine() - 1, source.firstColumn() - 1, worldType);
copy[i]->didParseSource(sourceID, url, data, lineOffset, columnOffset, worldType);
}
void ScriptDebugServer::dispatchFailedToParseSource(const ListenerSet& listeners, const SourceCode& source, int errorLine, const String& errorMessage)
void ScriptDebugServer::dispatchFailedToParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, int errorLine, const String& errorMessage)
{
String url = ustringToString(source.provider()->url());
String data = ustringToString(JSC::UString(source.data(), source.length()));
int firstLine = source.firstLine();
String url = ustringToString(sourceProvider->url());
String data = ustringToString(JSC::UString(sourceProvider->data(), sourceProvider->length()));
int firstLine = sourceProvider->startPosition().m_line.oneBasedInt();
Vector<ScriptDebugListener*> copy;
copyToVector(listeners, copy);
......@@ -335,7 +337,7 @@ void ScriptDebugServer::detach(JSGlobalObject* globalObject)
Debugger::detach(globalObject);
}
void ScriptDebugServer::sourceParsed(ExecState* exec, const SourceCode& source, int errorLine, const UString& errorMessage)
void ScriptDebugServer::sourceParsed(ExecState* exec, SourceProvider* sourceProvider, int errorLine, const UString& errorMessage)
{
if (m_callingListeners)
return;
......@@ -353,9 +355,9 @@ void ScriptDebugServer::sourceParsed(ExecState* exec, const SourceCode& source,
if (ListenerSet* pageListeners = m_pageListenersMap.get(page)) {
ASSERT(!pageListeners->isEmpty());
if (isError)
dispatchFailedToParseSource(*pageListeners, source, errorLine, ustringToString(errorMessage));
dispatchFailedToParseSource(*pageListeners, sourceProvider, errorLine, ustringToString(errorMessage));
else
dispatchDidParseSource(*pageListeners, source, worldType);
dispatchDidParseSource(*pageListeners, sourceProvider, worldType);
}
m_callingListeners = false;
......
......@@ -115,8 +115,8 @@ private:
void dispatchFunctionToListeners(const ListenerSet& listeners, JavaScriptExecutionCallback callback);
void dispatchDidPause(ScriptDebugListener*);
void dispatchDidContinue(ScriptDebugListener*);
void dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, enum ScriptWorldType);
void dispatchFailedToParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, int errorLine, const String& errorMessage);
void dispatchDidParseSource(const ListenerSet& listeners, JSC::SourceProvider*, enum ScriptWorldType);
void dispatchFailedToParseSource(const ListenerSet& listeners, JSC::SourceProvider*, int errorLine, const String& errorMessage);
void createCallFrameAndPauseIfNeeded(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
void updateCallFrameAndPauseIfNeeded(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
......@@ -124,7 +124,7 @@ private:
virtual void detach(JSC::JSGlobalObject*);
virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int errorLine, const JSC::UString& errorMsg);
virtual void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const JSC::UString& errorMsg);
virtual void callEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
virtual void atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int firstLine);
virtual void returnEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
......
......@@ -43,8 +43,8 @@ namespace WebCore {
class ScriptSourceCode {
public:
ScriptSourceCode(const String& source, const KURL& url = KURL(), const TextPosition1& startPosition = TextPosition1::minimumPosition())
: m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string()))
, m_code(m_provider, startPosition)
: m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string(), startPosition))
, m_code(m_provider, startPosition.m_line.oneBasedInt())
, m_url(url)
{
}
......
......@@ -37,20 +37,26 @@ namespace WebCore {
class StringSourceProvider : public ScriptSourceProvider {
public:
static PassRefPtr<StringSourceProvider> create(const String& source, const String& url) { return adoptRef(new StringSourceProvider(source, url)); }
static PassRefPtr<StringSourceProvider> create(const String& source, const String& url, const TextPosition1& startPosition = TextPosition1::minimumPosition())
{
return adoptRef(new StringSourceProvider(source, url, startPosition));
}
virtual TextPosition1 startPosition() const { return m_startPosition; }
JSC::UString getRange(int start, int end) const { return JSC::UString(m_source.characters() + start, end - start); }
const UChar* data() const { return m_source.characters(); }
int length() const { return m_source.length(); }
const String& source() const { return m_source; }
private:
StringSourceProvider(const String& source, const String& url)
StringSourceProvider(const String& source, const String& url, const TextPosition1& startPosition)
: ScriptSourceProvider(stringToUString(url))
, m_startPosition(startPosition)
, m_source(source)
{
}
TextPosition1 m_startPosition;
String m_source;
};
......
2011-01-19 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: [JSC] scripts have incorrect starting line (always 1).
https://bugs.webkit.org/show_bug.cgi?id=52721
* WebView/WebScriptDebugger.h:
* WebView/WebScriptDebugger.mm:
(toNSString):
(WebScriptDebugger::sourceParsed):
2011-01-19 Levi Weintraub <leviw@google.com>
Reviewed by Ryosuke Niwa.
......
......@@ -53,7 +53,7 @@ public:
void initGlobalCallFrame(const JSC::DebuggerCallFrame&);
virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int errorLine, const JSC::UString& errorMsg);
virtual void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const JSC::UString& errorMsg);
virtual void callEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
virtual void atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
virtual void returnEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
......
......@@ -34,7 +34,7 @@
#import "WebViewInternal.h"
#import <JavaScriptCore/DebuggerCallFrame.h>
#import <JavaScriptCore/JSGlobalObject.h>
#import <JavaScriptCore/SourceCode.h>
#import <JavaScriptCore/SourceProvider.h>
#import <WebCore/DOMWindow.h>
#import <WebCore/Frame.h>
#import <WebCore/JSDOMWindow.h>
......@@ -57,11 +57,11 @@ NSString *toNSString(const UString& s)
return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s.characters()) length:s.length()];
}
static NSString *toNSString(const SourceCode& s)
static NSString *toNSString(SourceProvider* s)
{
if (!s.length())
if (!s->length())
return nil;
return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s.data()) length:s.length()];
return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s->data()) length:s->length()];
}
// convert UString to NSURL
......@@ -104,15 +104,16 @@ void WebScriptDebugger::initGlobalCallFrame(const DebuggerCallFrame& debuggerCal
}
// callbacks - relay to delegate
void WebScriptDebugger::sourceParsed(ExecState* exec, const SourceCode& source, int errorLine, const UString& errorMsg)
void WebScriptDebugger::sourceParsed(ExecState* exec, SourceProvider* sourceProvider, int errorLine, const UString& errorMsg)
{
if (m_callingDelegate)
return;
m_callingDelegate = true;
NSString *nsSource = toNSString(source);
NSURL *nsURL = toNSURL(source.provider()->url());
NSString *nsSource = toNSString(sourceProvider);
NSURL *nsURL = toNSURL(sourceProvider->url());
int firstLine = sourceProvider->startPosition().m_line.oneBasedInt();
WebFrame *webFrame = toWebFrame(exec->dynamicGlobalObject());
WebView *webView = [webFrame webView];
......@@ -121,9 +122,9 @@ void WebScriptDebugger::sourceParsed(ExecState* exec, const SourceCode& source,
if (errorLine == -1) {
if (implementations->didParseSourceFunc) {
if (implementations->didParseSourceExpectsBaseLineNumber)
CallScriptDebugDelegate(implementations->didParseSourceFunc, webView, @selector(webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:), nsSource, source.firstLine(), nsURL, source.provider()->asID(), webFrame);
CallScriptDebugDelegate(implementations->didParseSourceFunc, webView, @selector(webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:), nsSource, firstLine, nsURL, sourceProvider->asID(), webFrame);
else
CallScriptDebugDelegate(implementations->didParseSourceFunc, webView, @selector(webView:didParseSource:fromURL:sourceId:forWebFrame:), nsSource, [nsURL absoluteString], source.provider()->asID(), webFrame);
CallScriptDebugDelegate(implementations->didParseSourceFunc, webView, @selector(webView:didParseSource:fromURL:sourceId:forWebFrame:), nsSource, [nsURL absoluteString], sourceProvider->asID(), webFrame);
}
} else {
NSString* nsErrorMessage = toNSString(errorMsg);
......@@ -131,7 +132,7 @@ void WebScriptDebugger::sourceParsed(ExecState* exec, const SourceCode& source,
NSError *error = [[NSError alloc] initWithDomain:WebScriptErrorDomain code:WebScriptGeneralErrorCode userInfo:info];
if (implementations->failedToParseSourceFunc)
CallScriptDebugDelegate(implementations->failedToParseSourceFunc, webView, @selector(webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:), nsSource, source.firstLine(), nsURL, error, webFrame);
CallScriptDebugDelegate(implementations->failedToParseSourceFunc, webView, @selector(webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:), nsSource, firstLine, nsURL, error, webFrame);
[error release];
[info release];
......
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