Reviewed by Darin.
Bug 9574: Drosera should show inline scripts within the original HTML
http://bugzilla.opendarwin.org/show_bug.cgi?id=9574
Pass the starting line number and error message to the debugger.
* kjs/debugger.cpp:
(Debugger::sourceParsed):
* kjs/debugger.h:
* kjs/function.cpp:
(KJS::GlobalFuncImp::callAsFunction):
* kjs/function_object.cpp:
(FunctionObjectImp::construct):
* kjs/interpreter.cpp:
(KJS::Interpreter::evaluate):
WebCore:
Reviewed by Darin.
Bug 9574: Drosera should show inline scripts within the original HTML
http://bugzilla.opendarwin.org/show_bug.cgi?id=9574
* Pass the starting line number and error message to the debugger.
* Call parsedSource even if there was a script parse error so the
debugger can show the parse error.
* Pass NSURL objects to the ObjC delegate for the script URLs.
* bridge/mac/WebCoreScriptDebugger.h:
* bridge/mac/WebCoreScriptDebugger.mm:
(toNSURL):
(WebCoreScriptDebuggerImp::sourceParsed):
WebKit:
Reviewed by Darin.
Bug 9574: Drosera should show inline scripts within the original HTML
http://bugzilla.opendarwin.org/show_bug.cgi?id=9574
* Adds a new version of the didParseSource delegate callback with base line number.
* Adds a new delegate callback for when a script fails to parse.
* These new callbacks use NSURLs for the url parameter.
* Adds a new script listener callback to notify when the main resource loads.
* Adds a WebScriptErrorDomian and other keys for use with NSError.
* DefaultDelegates/WebDefaultScriptDebugDelegate.m:
(-[WebDefaultScriptDebugDelegate webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]):
(-[WebDefaultScriptDebugDelegate webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
* DefaultDelegates/WebScriptDebugServer.h:
* DefaultDelegates/WebScriptDebugServer.m:
(-[WebScriptDebugServer webView:didLoadMainResourceForDataSource:]):
(-[WebScriptDebugServer webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]):
(-[WebScriptDebugServer webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
* DefaultDelegates/WebScriptDebugServerPrivate.h:
* WebKit.exp:
* WebView/WebDataSource.m:
(-[WebDataSource _setPrimaryLoadComplete:]):
* WebView/WebScriptDebugDelegate.h:
* WebView/WebScriptDebugDelegate.m:
(-[WebScriptCallFrame parsedSource:fromURL:sourceId:startLine:errorLine:errorMessage:]):
WebKitTools:
Reviewed by Darin.
Bug 9574: Drosera should show inline scripts within the original HTML
http://bugzilla.opendarwin.org/show_bug.cgi?id=9574
Refactor the JavaScript code to have a distinction between files
and scripts. Show the script in the context of the HTML file if
it's URL is the same as the frame's main resource. At the time of
the disParseScript callback the main resource might not be completely
loaded, but Drosera needs to show whatever we have at the time. Once
the main resource is finished, update the file source and reload the file.
* Drosera/DebuggerDocument.m:
(-[DebuggerDocument pause]):
(-[DebuggerDocument webView:didLoadMainResourceForDataSource:]):
(-[DebuggerDocument webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]):
(-[DebuggerDocument webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
* Drosera/debugger.css:
* Drosera/debugger.js:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15026
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-06-25 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Darin.
+
+ Bug 9574: Drosera should show inline scripts within the original HTML
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=9574
+
+ Pass the starting line number and error message to the debugger.
+
+ * kjs/debugger.cpp:
+ (Debugger::sourceParsed):
+ * kjs/debugger.h:
+ * kjs/function.cpp:
+ (KJS::GlobalFuncImp::callAsFunction):
+ * kjs/function_object.cpp:
+ (FunctionObjectImp::construct):
+ * kjs/interpreter.cpp:
+ (KJS::Interpreter::evaluate):
+
2006-06-24 Alexey Proskuryakov <ap@nypop.com>
Rubber-stamped by Eric.
}
bool Debugger::sourceParsed(ExecState */*exec*/, int /*sourceId*/, const UString &/*sourceURL*/,
- const UString &/*source*/, int /*errorLine*/)
+ const UString &/*source*/, int /*startingLineNumber*/, int /*errorLine*/, const UString & /*errorMsg*/)
{
return true;
}
* sourceId supplied in other functions such as atStatement()
* @param sourceURL Where the source code that was parsed came from
* @param source The source code that was parsed
+ * @param startingLineNumber The line number at which parsing started
* @param errorLine The line number at which parsing encountered an
* error, or -1 if the source code was valid and parsed successfully
+ * @param errorMsg The error description, or null if the source code
+ was valid and parsed successfully
* @return true if execution should be continue, false if it should
* be aborted
*/
virtual bool sourceParsed(ExecState *exec, int sourceId, const UString &sourceURL,
- const UString &source, int errorLine);
+ const UString &source, int startingLineNumber, int errorLine, const UString &errorMsg);
/**
* Called when all functions/programs associated with a particular
Debugger *dbg = exec->dynamicInterpreter()->debugger();
if (dbg) {
- bool cont = dbg->sourceParsed(exec, sid, UString(), s, errLine);
+ bool cont = dbg->sourceParsed(exec, sid, UString(), s, 0, errLine, errMsg);
if (!cont)
return jsUndefined();
}
Debugger *dbg = exec->dynamicInterpreter()->debugger();
if (dbg) {
// send empty sourceURL to indicate constructed code
- bool cont = dbg->sourceParsed(exec,sid,UString(),body,errLine);
+ bool cont = dbg->sourceParsed(exec, sid, UString(), body, lineNumber, errLine, errMsg);
if (!cont) {
dbg->imp()->abort();
return new JSObject();
// notify debugger that source has been parsed
if (m_debugger) {
- bool cont = m_debugger->sourceParsed(&m_globalExec, sid, sourceURL, UString(code, codeLength), errLine);
+ bool cont = m_debugger->sourceParsed(&m_globalExec, sid, sourceURL, UString(code, codeLength), startingLineNumber, errLine, errMsg);
if (!cont)
return Completion(Break);
}
+2006-06-25 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Darin.
+
+ Bug 9574: Drosera should show inline scripts within the original HTML
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=9574
+
+ * Pass the starting line number and error message to the debugger.
+ * Call parsedSource even if there was a script parse error so the
+ debugger can show the parse error.
+ * Pass NSURL objects to the ObjC delegate for the script URLs.
+
+ * bridge/mac/WebCoreScriptDebugger.h:
+ * bridge/mac/WebCoreScriptDebugger.mm:
+ (toNSURL):
+ (WebCoreScriptDebuggerImp::sourceParsed):
+
2006-06-24 David Kilzer <ddkilzer@kilzer.net>
Build fix. Reviewed by NOBODY.
- (id)newWrapperForFrame:(WebCoreScriptCallFrame *)frame; // return a (retained) stack-frame object
// debugger callbacks
-- (void)parsedSource:(NSString *)source fromURL:(NSString *)url sourceId:(int)sid;
+- (void)parsedSource:(NSString *)source fromURL:(NSURL *)url sourceId:(int)sid startLine:(int)startLine errorLine:(int)errorLine errorMessage:(NSString *)errorMessage;
- (void)enteredFrame:(WebCoreScriptCallFrame *)frame sourceId:(int)sid line:(int)lineno;
- (void)hitStatement:(WebCoreScriptCallFrame *)frame sourceId:(int)sid line:(int)lineno;
- (void)leavingFrame:(WebCoreScriptCallFrame *)frame sourceId:(int)sid line:(int)lineno;
#import <JavaScriptCore/context.h>
#import "DeprecatedString.h"
+#import "KURL.h"
using namespace KJS;
return [NSString stringWithCharacters:(const unichar *)s.data() length:s.size()];
}
+// convert UString to NSURL
+static NSURL *toNSURL(const UString &s)
+{
+ if (s.isEmpty()) return nil;
+ return KURL(DeprecatedString(s)).getNSURL();
+}
// C++ interface to KJS debugger callbacks
}
// callbacks - relay to delegate
- virtual bool sourceParsed(ExecState *state, int sid, const UString &url, const UString &source, int errorLine) {
- if (!_nested && errorLine == -1) {
+ virtual bool sourceParsed(ExecState *state, int sid, const UString &url, const UString &source, int lineNumber, int errorLine, const UString &errorMsg) {
+ if (!_nested) {
_nested = true;
- [[_objc delegate] parsedSource:toNSString(source) fromURL:toNSString(url) sourceId:sid];
+ [[_objc delegate] parsedSource:toNSString(source) fromURL:toNSURL(url) sourceId:sid startLine:lineNumber errorLine:errorLine errorMessage:toNSString(errorMsg)];
_nested = false;
}
return true;
+2006-06-25 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Darin.
+
+ Bug 9574: Drosera should show inline scripts within the original HTML
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=9574
+
+ * Adds a new version of the didParseSource delegate callback with base line number.
+ * Adds a new delegate callback for when a script fails to parse.
+ * These new callbacks use NSURLs for the url parameter.
+ * Adds a new script listener callback to notify when the main resource loads.
+ * Adds a WebScriptErrorDomian and other keys for use with NSError.
+
+ * DefaultDelegates/WebDefaultScriptDebugDelegate.m:
+ (-[WebDefaultScriptDebugDelegate webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]):
+ (-[WebDefaultScriptDebugDelegate webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
+ * DefaultDelegates/WebScriptDebugServer.h:
+ * DefaultDelegates/WebScriptDebugServer.m:
+ (-[WebScriptDebugServer webView:didLoadMainResourceForDataSource:]):
+ (-[WebScriptDebugServer webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]):
+ (-[WebScriptDebugServer webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
+ * DefaultDelegates/WebScriptDebugServerPrivate.h:
+ * WebKit.exp:
+ * WebView/WebDataSource.m:
+ (-[WebDataSource _setPrimaryLoadComplete:]):
+ * WebView/WebScriptDebugDelegate.h:
+ * WebView/WebScriptDebugDelegate.m:
+ (-[WebScriptCallFrame parsedSource:fromURL:sourceId:startLine:errorLine:errorMessage:]):
+
2006-06-24 David Kilzer <ddkilzer@kilzer.net>
Reviewed by Timothy.
{
}
+- (void)webView:(WebView *)webView didParseSource:(NSString *)source
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
+ sourceId:(int)sid
+ forWebFrame:(WebFrame *)webFrame
+{
+}
+
+- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
+ withError:(NSError *)error
+ forWebFrame:(WebFrame *)webFrame
+{
+}
+
- (void)webView:(WebView *)webView didEnterCallFrame:(WebScriptCallFrame *)frame
sourceId:(int)sid
line:(int)lineno
extern NSString *WebScriptDebugServerDidLoadNotification;
extern NSString *WebScriptDebugServerWillUnloadNotification;
+@class WebDataSource;
+
@protocol WebScriptDebugListener <NSObject>
+- (void)webView:(WebView *)webView didLoadMainResourceForDataSource:(WebDataSource *)dataSource;
+
- (void)webView:(WebView *)webView didParseSource:(NSString *)source
- fromURL:(NSString *)url
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
sourceId:(int)sid
forWebFrame:(WebFrame *)webFrame;
+- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
+ withError:(NSError *)error
+ forWebFrame:(WebFrame *)webFrame;
+
- (void)webView:(WebView *)webView didEnterCallFrame:(WebScriptCallFrame *)frame
sourceId:(int)sid
line:(int)lineno
}
}
+- (void)webView:(WebView *)webView didLoadMainResourceForDataSource:(WebDataSource *)dataSource
+{
+ if (![listeners count])
+ return;
+
+ NSEnumerator *enumerator = [listeners objectEnumerator];
+ NSDistantObject <WebScriptDebugListener> *listener = nil;
+
+ while ((listener = [enumerator nextObject])) {
+ if ([[listener connectionForProxy] isValid])
+ [listener webView:webView didLoadMainResourceForDataSource:dataSource];
+ }
+}
+
- (void)webView:(WebView *)webView didParseSource:(NSString *)source
- fromURL:(NSString *)url
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
sourceId:(int)sid
forWebFrame:(WebFrame *)webFrame
{
while ((listener = [enumerator nextObject])) {
if ([[listener connectionForProxy] isValid])
- [listener webView:webView didParseSource:source fromURL:url sourceId:sid forWebFrame:webFrame];
+ [listener webView:webView didParseSource:source baseLineNumber:lineNumber fromURL:url sourceId:sid forWebFrame:webFrame];
+ }
+}
+
+- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
+ withError:(NSError *)error
+ forWebFrame:(WebFrame *)webFrame
+{
+ if (![listeners count])
+ return;
+
+ NSEnumerator *enumerator = [listeners objectEnumerator];
+ NSDistantObject <WebScriptDebugListener> *listener = nil;
+
+ while ((listener = [enumerator nextObject])) {
+ if ([[listener connectionForProxy] isValid])
+ [listener webView:webView failedToParseSource:source baseLineNumber:lineNumber fromURL:url withError:error forWebFrame:webFrame];
}
}
- (void)attachScriptDebuggerToAllWebViews;
- (void)detachScriptDebuggerFromAllWebViews;
+- (void)webView:(WebView *)webView didLoadMainResourceForDataSource:(WebDataSource *)dataSource;
+
- (void)webView:(WebView *)webView didParseSource:(NSString *)source
- fromURL:(NSString *)url
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
sourceId:(int)sid
forWebFrame:(WebFrame *)webFrame;
+- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
+ withError:(NSError *)error
+ forWebFrame:(WebFrame *)webFrame;
+
- (void)webView:(WebView *)webView didEnterCallFrame:(WebScriptCallFrame *)frame
sourceId:(int)sid
line:(int)lineno
_WebScriptDebugServerQueryReplyNotification
_WebScriptDebugServerDidLoadNotification
_WebScriptDebugServerWillUnloadNotification
+_WebScriptErrorDomain
+_WebScriptErrorDescriptionKey
+_WebScriptErrorLineNumberKey
##
## Carbon Support
#import "WebPreferences.h"
#import "WebResourceLoadDelegate.h"
#import "WebResourcePrivate.h"
+#import "WebScriptDebugServerPrivate.h"
#import "WebUnarchivingState.h"
#import "WebViewInternal.h"
#import <Foundation/NSURLConnection.h>
[_private->frameLoader releaseMainResourceLoader];
[self _updateLoading];
+
+ if ([WebScriptDebugServer listenerCount])
+ [[WebScriptDebugServer sharedScriptDebugServer] webView:[[self webFrame] webView] didLoadMainResourceForDataSource:self];
}
}
@class WebScriptCallFrame;
@class WebCoreScriptCallFrame;
+extern NSString * const WebScriptErrorDomain;
+extern NSString * const WebScriptErrorDescriptionKey;
+extern NSString * const WebScriptErrorLineNumberKey;
+enum {
+ WebScriptGeneralErrorCode = -100
+};
// WebScriptDebugDelegate messages
@interface NSObject (WebScriptDebugDelegate)
// some source was parsed, establishing a "source ID" (>= 0) for future reference
+// this delegate method is deprecated, please switch to the new version below
- (void)webView:(WebView *)webView didParseSource:(NSString *)source
fromURL:(NSString *)url
sourceId:(int)sid
forWebFrame:(WebFrame *)webFrame;
+// some source was parsed, establishing a "source ID" (>= 0) for future reference
+- (void)webView:(WebView *)webView didParseSource:(NSString *)source
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
+ sourceId:(int)sid
+ forWebFrame:(WebFrame *)webFrame;
+
+// some source failed to parse
+- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source
+ baseLineNumber:(unsigned)lineNumber
+ fromURL:(NSURL *)url
+ withError:(NSError *)error
+ forWebFrame:(WebFrame *)webFrame;
+
// just entered a stack frame (i.e. called a function, or started global scope)
- (void)webView:(WebView *)webView didEnterCallFrame:(WebScriptCallFrame *)frame
sourceId:(int)sid
#import "WebScriptDebugDelegatePrivate.h"
#import "WebScriptDebugServerPrivate.h"
+#import "WebDataSource.h"
+#import "WebDataSourceInternal.h"
#import <WebKit/WebFrameBridge.h>
#import <WebKit/WebViewInternal.h>
#import <WebCore/WebCoreScriptDebugger.h>
-
+// FIXME: these error strings should be public for future use by WebScriptObject and in WebScriptObject.h
+NSString * const WebScriptErrorDomain = @"WebScriptErrorDomain";
+NSString * const WebScriptErrorDescriptionKey = @"WebScriptErrorDescription";
+NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber";
@interface WebScriptCallFrame (WebScriptDebugDelegateInternal)
return [[WebScriptCallFrame alloc] _initWithFrame:frame];
}
-- (void)parsedSource:(NSString *)source fromURL:(NSString *)url sourceId:(int)sid
-{
- [[_webView _scriptDebugDelegateForwarder] webView:_webView didParseSource:source fromURL:url sourceId:sid forWebFrame:_webFrame];
- if ([WebScriptDebugServer listenerCount])
- [[WebScriptDebugServer sharedScriptDebugServer] webView:_webView didParseSource:source fromURL:url sourceId:sid forWebFrame:_webFrame];
+- (void)parsedSource:(NSString *)source fromURL:(NSURL *)url sourceId:(int)sid startLine:(int)startLine errorLine:(int)errorLine errorMessage:(NSString *)errorMessage
+{
+ if (errorLine == -1) {
+ [[_webView _scriptDebugDelegateForwarder] webView:_webView didParseSource:source baseLineNumber:startLine fromURL:url sourceId:sid forWebFrame:_webFrame];
+ [[_webView _scriptDebugDelegateForwarder] webView:_webView didParseSource:source fromURL:[url absoluteString] sourceId:sid forWebFrame:_webFrame]; // deprecated delegate method
+ if ([WebScriptDebugServer listenerCount])
+ [[WebScriptDebugServer sharedScriptDebugServer] webView:_webView didParseSource:source baseLineNumber:startLine fromURL:url sourceId:sid forWebFrame:_webFrame];
+ } else {
+ NSDictionary *info = [[NSDictionary alloc] initWithObjectsAndKeys:errorMessage, WebScriptErrorDescriptionKey, [NSNumber numberWithUnsignedInt:errorLine], WebScriptErrorLineNumberKey, nil];
+ NSError *error = [[NSError alloc] initWithDomain:WebScriptErrorDomain code:WebScriptGeneralErrorCode userInfo:info];
+ [[_webView _scriptDebugDelegateForwarder] webView:_webView failedToParseSource:source baseLineNumber:startLine fromURL:url withError:error forWebFrame:_webFrame];
+ if ([WebScriptDebugServer listenerCount])
+ [[WebScriptDebugServer sharedScriptDebugServer] webView:_webView failedToParseSource:source baseLineNumber:startLine fromURL:url withError:error forWebFrame:_webFrame];
+ [error release];
+ [info release];
+ }
}
- (void)enteredFrame:(WebCoreScriptCallFrame *)frame sourceId:(int)sid line:(int)lineno
+2006-06-25 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Darin.
+
+ Bug 9574: Drosera should show inline scripts within the original HTML
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=9574
+
+ Refactor the JavaScript code to have a distinction between files
+ and scripts. Show the script in the context of the HTML file if
+ it's URL is the same as the frame's main resource. At the time of
+ the disParseScript callback the main resource might not be completely
+ loaded, but Drosera needs to show whatever we have at the time. Once
+ the main resource is finished, update the file source and reload the file.
+
+ * Drosera/DebuggerDocument.m:
+ (-[DebuggerDocument pause]):
+ (-[DebuggerDocument webView:didLoadMainResourceForDataSource:]):
+ (-[DebuggerDocument webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]):
+ (-[DebuggerDocument webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
+ * Drosera/debugger.css:
+ * Drosera/debugger.js:
+
2006-06-24 David Kilzer <ddkilzer@kilzer.net>
Reviewed by Darin.
paused = YES;
if ([[(NSDistantObject *)server connectionForProxy] isValid])
[server pause];
+ [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
- (void)resume
#pragma mark -
#pragma mark Debug Listener Callbacks
-- (void)webView:(WebView *)view didParseSource:(NSString *)source fromURL:(NSString *)url sourceId:(int)sid forWebFrame:(WebFrame *)webFrame
+- (void)webView:(WebView *)view didLoadMainResourceForDataSource:(WebDataSource *)dataSource
+{
+ NSString *documentSourceCopy = nil;
+ id <WebDocumentRepresentation> rep = [dataSource representation];
+ if ([rep canProvideDocumentSource])
+ documentSourceCopy = [[rep documentSource] copy];
+
+ if (!documentSourceCopy)
+ return;
+
+ NSString *urlCopy = [[[[dataSource response] URL] absoluteString] copy];
+ NSArray *args = [NSArray arrayWithObjects:(documentSourceCopy ? documentSourceCopy : @""), (urlCopy ? urlCopy : @""), [NSNumber numberWithBool:NO], nil];
+ [[webView windowScriptObject] callWebScriptMethod:@"updateFileSource" withArguments:args];
+
+ [documentSourceCopy release];
+ [urlCopy release];
+}
+
+- (void)webView:(WebView *)view didParseSource:(NSString *)source baseLineNumber:(unsigned)baseLine fromURL:(NSURL *)url sourceId:(int)sid forWebFrame:(WebFrame *)webFrame
{
if (!webViewLoaded)
return;
NSString *sourceCopy = [source copy];
- NSString *urlCopy = [url copy];
+ if (!sourceCopy)
+ return;
+
+ NSString *documentSourceCopy = nil;
+ NSString *urlCopy = [[url absoluteString] copy];
+
+ WebDataSource *dataSource = [webFrame dataSource];
+ if (!url || [[[dataSource response] URL] isEqual:url]) {
+ id <WebDocumentRepresentation> rep = [dataSource representation];
+ if ([rep canProvideDocumentSource])
+ documentSourceCopy = [[rep documentSource] copy];
+ if (!urlCopy)
+ urlCopy = [[[[dataSource response] URL] absoluteString] copy];
+ }
- NSArray *args = [NSArray arrayWithObjects:sourceCopy, (urlCopy ? urlCopy : @""), [NSNumber numberWithInt:sid], nil];
+ NSArray *args = [NSArray arrayWithObjects:sourceCopy, (documentSourceCopy ? documentSourceCopy : @""), (urlCopy ? urlCopy : @""), [NSNumber numberWithInt:sid], [NSNumber numberWithUnsignedInt:baseLine], nil];
[[webView windowScriptObject] callWebScriptMethod:@"didParseScript" withArguments:args];
[sourceCopy release];
+ [documentSourceCopy release];
[urlCopy release];
}
+- (void)webView:(WebView *)view failedToParseSource:(NSString *)source baseLineNumber:(unsigned)baseLine fromURL:(NSURL *)url withError:(NSError *)error forWebFrame:(WebFrame *)webFrame
+{
+}
+
- (void)webView:(WebView *)view didEnterCallFrame:(WebScriptCallFrame *)frame sourceId:(int)sid line:(int)lineno forWebFrame:(WebFrame *)webFrame
{
if (!webViewLoaded)
#main { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }
#info { position: absolute; top: 0; height: 175px; left: 0; right: 0; }
-#divider { cursor: move; position: absolute; bottom: 0; left: 0; right: 0; background: url(splitterDimple.tif) 50% no-repeat, url(splitterBar.tif) repeat-x; height: 10px }
+#divider { cursor: row-resize; position: absolute; bottom: 0; left: 0; right: 0; background: url(splitterDimple.tif) 50% no-repeat, url(splitterBar.tif) repeat-x; height: 10px }
#body { position: absolute; top: 175px; left: 0; right: 0; bottom: 0; }
#sourcesContainer { position: absolute; top: 16px; left: 0; right: 0; bottom: 21px; background-color: white; }
#sources { width: 100%; height: 100% }
#header { vertical-align: top; height: 16px; box-sizing: border-box; border-bottom: 1px solid #aaa; background: url(glossyHeader.png) repeat-x; position: absolute; top: 0; left: 0; right: 0; }
#header > * { vertical-align: top; }
#footer { height: 21px; box-sizing: border-box; border-top: 1px solid #aaa; background: url(glossyFooterFill.tif) repeat-x; position: absolute; bottom: 0; left: 0; right: 0; }
-#infoDivider { position: absolute; z-index: 10; right: 0; left: 0; top: 0; bottom: 9px; width: 10px; cursor: move; background: url(verticalSplitterDimple.tiff) 50% no-repeat, url(verticalSplitterBar.tiff) repeat-y; width: 10px; }
+#infoDivider { position: absolute; z-index: 10; right: 0; left: 0; top: 0; bottom: 9px; width: 10px; cursor: col-resize; background: url(verticalSplitterDimple.tiff) 50% no-repeat, url(verticalSplitterBar.tiff) repeat-y; width: 10px; }
#files {
opacity: 0;
left: 168px;
width: 4px;
height: 16px;
- cursor: move;
+ cursor: col-resize;
}
.column th {
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-var sourceFiles = new Array();
-var currentSourceId = -1;
+var files = new Array();
+var filesLookup = new Object();
+var scripts = new Array();
+var currentFile = -1;
var currentRow = null;
var currentStack = null;
var previousFiles = new Array();
DebuggerDocument.stepInto();
}
-function hasStyleClass(element,className)
+function hasStyleClass(element, className)
{
return ( element.className.indexOf(className) != -1 );
}
-function addStyleClass(element,className)
+function addStyleClass(element, className)
{
- if (!hasStyleClass(element,className))
- element.className += ( element.className.length ? " " + className : className );
+ if (!hasStyleClass(element, className))
+ element.className += (element.className.length ? " " + className : className);
}
-function removeStyleClass(element,className)
+function removeStyleClass(element, className)
{
- if (hasStyleClass(element,className))
+ if (hasStyleClass(element, className))
element.className = element.className.replace(className, "");
}
if (hasStyleClass(row, "breakpoint")) {
if (hasStyleClass(row, "disabled")) {
removeStyleClass(row, "disabled");
- sourceFiles[currentSourceId].breakpoints[parseInt(event.target.title)] = 1;
+ files[currentFile].breakpoints[parseInt(event.target.title)] = 1;
} else {
addStyleClass(row, "disabled");
- sourceFiles[currentSourceId].breakpoints[parseInt(event.target.title)] = -1;
+ files[currentFile].breakpoints[parseInt(event.target.title)] = -1;
}
} else {
addStyleClass(row, "breakpoint");
removeStyleClass(row, "disabled");
- sourceFiles[currentSourceId].breakpoints[parseInt(event.target.title)] = 1;
+ files[currentFile].breakpoints[parseInt(event.target.title)] = 1;
}
}
-function totalOffsetTop(element,stop)
+function totalOffsetTop(element, stop)
{
var currentTop = 0;
if (element.offsetParent) {
function switchFile()
{
- var files = document.getElementById("files");
- loadSource(files.options[files.selectedIndex].value,true);
+ var filesSelect = document.getElementById("files");
+ loadFile(filesSelect.options[filesSelect.selectedIndex].value, true);
}
function syntaxHighlight(code)
echoChar(cNext);
for (i += 2; i < code.length; i++) {
c = code.charAt(i);
- if (c == "\n")
+ if (c == "\n" || c == "\r")
result += "</span>";
echoChar(c);
- if (c == "\n")
+ if (c == "\n" || c == "\r")
result += "<span class=\"comment\">";
if (cPrev == "*" && c == "/")
break;
echoChar(cNext);
for (i += 2; i < code.length; i++) {
c = code.charAt(i);
- if (c == "\n")
+ if (c == "\n" || c == "\r")
break;
echoChar(c);
}
{
if (element.disabled)
return;
- var lastSource = previousFiles.pop();
- if (currentSourceId != -1)
- nextFiles.unshift(currentSourceId);
- loadSource(lastSource, false);
+ var lastFile = previousFiles.pop();
+ if (currentFile != -1)
+ nextFiles.unshift(currentFile);
+ loadFile(lastFile, false);
}
function navFileNext(element)
{
if (element.disabled)
return;
- var lastSource = nextFiles.shift();
- if (currentSourceId != -1)
- previousFiles.push(currentSourceId);
- loadSource(lastSource, false);
+ var lastFile = nextFiles.shift();
+ if (currentFile != -1)
+ previousFiles.push(currentFile);
+ loadFile(lastFile, false);
}
function updateFunctionStack()
stackframeTable.appendChild(tr);
}
-function loadSource(sourceId,manageNavLists)
+function loadFile(fileIndex, manageNavLists)
{
- if (!sourceFiles[sourceId])
+ var file = files[fileIndex];
+ if (!file)
return;
- if (currentSourceId != -1 && sourceFiles[currentSourceId] && sourceFiles[currentSourceId].element)
- sourceFiles[currentSourceId].element.style.display = "none";
+ if (currentFile != -1 && files[currentFile] && files[currentFile].element)
+ files[currentFile].element.style.display = "none";
- if (!sourceFiles[sourceId].loaded) {
- sourceFiles[sourceId].lines = sourceFiles[sourceId].source.split("\n");
+ if (!file.loaded) {
+ file.lines = file.source.split(/[\n\r]/);
var sourcesDocument = document.getElementById("sources").contentDocument;
var sourcesDiv = sourcesDocument.body;
var sourceDiv = sourcesDocument.createElement("div");
- sourceDiv.id = "source" + sourceId;
+ sourceDiv.id = "file" + fileIndex;
sourcesDiv.appendChild(sourceDiv);
- sourceFiles[sourceId].element = sourceDiv;
+ file.element = sourceDiv;
var table = sourcesDocument.createElement("table");
sourceDiv.appendChild(table);
- var lines = syntaxHighlight(sourceFiles[sourceId].source).split("\n");
+ var lines = syntaxHighlight(file.source).split(/[\n\r]/);
for( var i = 0; i < lines.length; i++ ) {
var tr = sourcesDocument.createElement("tr");
var td = sourcesDocument.createElement("td");
table.appendChild(tr);
}
- sourceFiles[sourceId].loaded = true;
+ file.loaded = true;
}
- sourceFiles[sourceId].element.style.display = null;
+ file.element.style.display = null;
- document.getElementById("filesPopupButtonContent").innerText = sourceFiles[sourceId].url;
+ document.getElementById("filesPopupButtonContent").innerText = (file.url ? file.url : "(unknown script)");
- var files = document.getElementById("files");
- for (var i = 0; i < files.childNodes.length; i++) {
- if (files.childNodes[i].value == sourceId) {
- files.selectedIndex = i;
+ var filesSelect = document.getElementById("files");
+ for (var i = 0; i < filesSelect.childNodes.length; i++) {
+ if (filesSelect.childNodes[i].value == fileIndex) {
+ filesSelect.selectedIndex = i;
break;
}
}
if (manageNavLists) {
nextFiles = new Array();
- if (currentSourceId != -1)
- previousFiles.push(currentSourceId);
+ if (currentFile != -1)
+ previousFiles.push(currentFile);
}
document.getElementById("navFileLeftButton").disabled = (previousFiles.length == 0);
document.getElementById("navFileRightButton").disabled = (nextFiles.length == 0);
- currentSourceId = sourceId;
+ currentFile = fileIndex;
}
-function didParseScript(source,url,sourceId)
+function updateFileSource(source, url, force)
{
- sourceFiles[sourceId] = new Object();
- sourceFiles[sourceId].source = source;
- sourceFiles[sourceId].url = url;
- sourceFiles[sourceId].loaded = false;
- sourceFiles[sourceId].breakpoints = new Array();
+ var fileIndex = filesLookup[url];
+ if (!fileIndex || !source.length)
+ return;
+
+ var file = files[fileIndex];
+ if (force || file.source.length != source.length || file.source != source) {
+ file.source = source;
+ file.loaded = false;
+ file.lines = null;
- var files = document.getElementById("files");
- var option = document.createElement("option");
- sourceFiles[sourceId].menuOption = option;
- option.value = sourceId;
- option.text = url;
- files.appendChild(option);
+ if (file.element) {
+ file.element.parentNode.removeChild(file.element);
+ file.element = null;
+ }
- if (currentSourceId == -1)
- loadSource(sourceId,true);
- return true;
+ if (currentFile == fileIndex)
+ loadFile(fileIndex, false);
+ }
}
-function willExecuteStatement(sourceId,line)
+function didParseScript(source, fileSource, url, sourceId, baseLineNumber)
{
- if (line <= 0 || !sourceFiles[sourceId])
+ var fileIndex = filesLookup[url];
+ var file = files[fileIndex];
+ var firstLoad = false;
+ if (!fileIndex || !file) {
+ fileIndex = files.length + 1;
+ if (url.length)
+ filesLookup[url] = fileIndex;
+
+ file = new Object();
+ file.scripts = new Array();
+ file.breakpoints = new Array();
+ file.source = (fileSource.length ? fileSource : source);
+ file.url = (url.length ? url : null);
+ file.loaded = false;
+
+ files[fileIndex] = file;
+
+ var filesSelect = document.getElementById("files");
+ var option = document.createElement("option");
+ files[fileIndex].menuOption = option;
+ option.value = fileIndex;
+ option.text = (file.url ? file.url : "(unknown script)");
+ filesSelect.appendChild(option);
+ firstLoad = true;
+ }
+
+ var sourceObj = new Object();
+ sourceObj.source = source;
+ sourceObj.file = fileIndex;
+ sourceObj.baseLineNumber = baseLineNumber;
+ file.scripts.push(sourceId);
+ scripts[sourceId] = sourceObj;
+
+ if (!firstLoad)
+ updateFileSource((fileSource.length ? fileSource : source), url, false);
+
+ if (currentFile == -1)
+ loadFile(fileIndex, true);
+}
+
+function willExecuteStatement(sourceId, line)
+{
+ var script = scripts[sourceId];
+ if (line <= 0 || !script)
+ return;
+
+ var file = files[script.file];
+ if (!file)
return;
- if (sourceFiles[sourceId].breakpoints[line] == 1)
+ if (file.breakpoints[line] == 1)
pause();
if (isPaused()) {
- if (currentSourceId != sourceId)
- loadSource(sourceId,true);
+ if (currentFile != script.file)
+ loadFile(script.file, true);
if (currentRow)
removeStyleClass(currentRow, "current");
- if (!sourceFiles[sourceId].element)
+ if (!file.element)
return;
- if (sourceFiles[sourceId].element.firstChild.childNodes.length < line)
+ if (file.element.firstChild.childNodes.length < line)
return;
updateFunctionStack();
- currentRow = sourceFiles[sourceId].element.firstChild.childNodes.item(line - 1);
+ currentRow = file.element.firstChild.childNodes.item(line - 1);
addStyleClass(currentRow, "current");
var sourcesDiv = document.getElementById("sources");
}
}
-function didEnterCallFrame(sourceId,line)
+function didEnterCallFrame(sourceId, line)
{
- willExecuteStatement(sourceId,line);
+ willExecuteStatement(sourceId, line);
}
-function willLeaveCallFrame(sourceId,line)
+function willLeaveCallFrame(sourceId, line)
{
- willExecuteStatement(sourceId,line);
+ willExecuteStatement(sourceId, line);
}