[webkit-changes] cvs commit: WebCore/kwq WebCoreScriptDebugger.h
WebCoreScriptDebugger.mm
Maciej
mjs at opensource.apple.com
Fri Jul 29 20:00:35 PDT 2005
mjs 05/07/29 20:00:34
Modified: . ChangeLog
WebCoreSupport.subproj WebBridge.m WebSubresourceLoader.m
WebKit.xcodeproj project.pbxproj
WebView.subproj WebFrame.m WebFramePrivate.h WebView.h
WebView.m WebViewInternal.h WebViewPrivate.h
. ChangeLog
Added: WebView.subproj WebDefaultScriptDebugDelegate.h
WebDefaultScriptDebugDelegate.m
WebScriptDebugDelegate.h WebScriptDebugDelegate.m
WebScriptDebugDelegatePrivate.h
kwq WebCoreScriptDebugger.h WebCoreScriptDebugger.mm
Log:
WebCore:
Changes by Michael Kahl, reviewed by me.
Test cases added: No tests, this code only affects debugging.
- fixed <rdar://problem/4164112> MASTER: JavaScript debugging support
* kwq/WebCoreScriptDebugger.h: Added.
* kwq/WebCoreScriptDebugger.mm: Added.
(toNSString):
(WebCoreScriptDebuggerImp::WebCoreScriptDebuggerImp):
(WebCoreScriptDebuggerImp::sourceParsed):
(WebCoreScriptDebuggerImp::callEvent):
(WebCoreScriptDebuggerImp::atStatement):
(WebCoreScriptDebuggerImp::returnEvent):
(-[WebCoreScriptDebugger initWithDelegate:]):
(-[WebCoreScriptDebugger dealloc]):
(-[WebCoreScriptDebugger delegate]):
(-[WebCoreScriptCallFrame _initWithGlobalObject:caller:state:]):
(-[WebCoreScriptCallFrame _setWrapper:]):
(-[WebCoreScriptCallFrame _convertValueToObjcValue:]):
(-[WebCoreScriptCallFrame dealloc]):
(-[WebCoreScriptCallFrame wrapper]):
(-[WebCoreScriptCallFrame caller]):
(-[WebCoreScriptCallFrame scopeChain]):
(-[WebCoreScriptCallFrame functionName]):
(-[WebCoreScriptCallFrame exception]):
(-[WebCoreScriptCallFrame evaluateWebScript:]):
WebKit:
Changes by Michael Kahl, reviewed by me.
- fixed <rdar://problem/4164112> MASTER: JavaScript debugging support
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge windowObjectCleared]):
* WebCoreSupport.subproj/WebSubresourceLoader.m:
* WebKit.xcodeproj/project.pbxproj:
* WebView.subproj/WebDefaultScriptDebugDelegate.h: Added.
* WebView.subproj/WebDefaultScriptDebugDelegate.m: Added.
(+[WebDefaultScriptDebugDelegate sharedScriptDebugDelegate]):
(-[WebDefaultScriptDebugDelegate webView:didParseSource:fromURL:sourceId:forWebFrame:]):
(-[WebDefaultScriptDebugDelegate webView:didEnterCallFrame:sourceId:line:forWebFrame:]):
(-[WebDefaultScriptDebugDelegate webView:willExecuteStatement:sourceId:line:forWebFrame:]):
(-[WebDefaultScriptDebugDelegate webView:willLeaveCallFrame:sourceId:line:forWebFrame:]):
* WebView.subproj/WebFrame.m:
(-[WebFramePrivate dealloc]):
(-[WebFrame _attachScriptDebugger]):
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebScriptDebugDelegate.h: Added.
* WebView.subproj/WebScriptDebugDelegate.m: Added.
(-[WebScriptDebugger initWithWebFrame:]):
(-[WebScriptDebugger dealloc]):
(-[WebScriptDebugger globalObject]):
(-[WebScriptDebugger newWrapperForFrame:]):
(-[WebScriptDebugger parsedSource:fromURL:sourceId:]):
(-[WebScriptDebugger enteredFrame:sourceId:line:]):
(-[WebScriptDebugger hitStatement:sourceId:line:]):
(-[WebScriptDebugger leavingFrame:sourceId:line:]):
(-[WebScriptCallFrame _initWithFrame:]):
(-[WebScriptCallFrame dealloc]):
(-[WebScriptCallFrame setUserInfo:]):
(-[WebScriptCallFrame userInfo]):
(-[WebScriptCallFrame caller]):
(-[WebScriptCallFrame scopeChain]):
(-[WebScriptCallFrame functionName]):
(-[WebScriptCallFrame exception]):
(-[WebScriptCallFrame evaluateWebScript:]):
* WebView.subproj/WebScriptDebugDelegatePrivate.h: Added.
* WebView.subproj/WebView.h:
* WebView.subproj/WebView.m:
(-[WebViewPrivate dealloc]):
(-[WebView _scriptDebugDelegateForwarder]):
(-[WebView setScriptDebugDelegate:]):
(-[WebView scriptDebugDelegate]):
* WebView.subproj/WebViewInternal.h:
* WebView.subproj/WebViewPrivate.h:
Revision Changes Path
1.3269 +50 -1 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3268
retrieving revision 1.3269
diff -u -r1.3268 -r1.3269
--- ChangeLog 30 Jul 2005 02:33:56 -0000 1.3268
+++ ChangeLog 30 Jul 2005 03:00:24 -0000 1.3269
@@ -1,3 +1,53 @@
+2005-07-29 Maciej Stachowiak <mjs at apple.com>
+
+ Changes by Michael Kahl, reviewed by me.
+
+ - fixed <rdar://problem/4164112> MASTER: JavaScript debugging support
+
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge windowObjectCleared]):
+ * WebCoreSupport.subproj/WebSubresourceLoader.m:
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebView.subproj/WebDefaultScriptDebugDelegate.h: Added.
+ * WebView.subproj/WebDefaultScriptDebugDelegate.m: Added.
+ (+[WebDefaultScriptDebugDelegate sharedScriptDebugDelegate]):
+ (-[WebDefaultScriptDebugDelegate webView:didParseSource:fromURL:sourceId:forWebFrame:]):
+ (-[WebDefaultScriptDebugDelegate webView:didEnterCallFrame:sourceId:line:forWebFrame:]):
+ (-[WebDefaultScriptDebugDelegate webView:willExecuteStatement:sourceId:line:forWebFrame:]):
+ (-[WebDefaultScriptDebugDelegate webView:willLeaveCallFrame:sourceId:line:forWebFrame:]):
+ * WebView.subproj/WebFrame.m:
+ (-[WebFramePrivate dealloc]):
+ (-[WebFrame _attachScriptDebugger]):
+ * WebView.subproj/WebFramePrivate.h:
+ * WebView.subproj/WebScriptDebugDelegate.h: Added.
+ * WebView.subproj/WebScriptDebugDelegate.m: Added.
+ (-[WebScriptDebugger initWithWebFrame:]):
+ (-[WebScriptDebugger dealloc]):
+ (-[WebScriptDebugger globalObject]):
+ (-[WebScriptDebugger newWrapperForFrame:]):
+ (-[WebScriptDebugger parsedSource:fromURL:sourceId:]):
+ (-[WebScriptDebugger enteredFrame:sourceId:line:]):
+ (-[WebScriptDebugger hitStatement:sourceId:line:]):
+ (-[WebScriptDebugger leavingFrame:sourceId:line:]):
+ (-[WebScriptCallFrame _initWithFrame:]):
+ (-[WebScriptCallFrame dealloc]):
+ (-[WebScriptCallFrame setUserInfo:]):
+ (-[WebScriptCallFrame userInfo]):
+ (-[WebScriptCallFrame caller]):
+ (-[WebScriptCallFrame scopeChain]):
+ (-[WebScriptCallFrame functionName]):
+ (-[WebScriptCallFrame exception]):
+ (-[WebScriptCallFrame evaluateWebScript:]):
+ * WebView.subproj/WebScriptDebugDelegatePrivate.h: Added.
+ * WebView.subproj/WebView.h:
+ * WebView.subproj/WebView.m:
+ (-[WebViewPrivate dealloc]):
+ (-[WebView _scriptDebugDelegateForwarder]):
+ (-[WebView setScriptDebugDelegate:]):
+ (-[WebView scriptDebugDelegate]):
+ * WebView.subproj/WebViewInternal.h:
+ * WebView.subproj/WebViewPrivate.h:
+
2005-07-26 Maciej Stachowiak <mjs at apple.com>
Reviewed by Dave Hyatt.
@@ -36,7 +86,6 @@
(ceilCurrentWidth):
(widthForNextCharacter):
->>>>>>> 1.3267
2005-07-29 John Sullivan <sullivan at apple.com>
Reviewed by Dave Hyatt.
1.365 +3 -0 WebKit/WebCoreSupport.subproj/WebBridge.m
Index: WebBridge.m
===================================================================
RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebBridge.m,v
retrieving revision 1.364
retrieving revision 1.365
diff -u -r1.364 -r1.365
--- WebBridge.m 26 Jul 2005 17:37:24 -0000 1.364
+++ WebBridge.m 30 Jul 2005 03:00:27 -0000 1.365
@@ -1465,6 +1465,9 @@
{
WebView *wv = [_frame webView];
[[wv _frameLoadDelegateForwarder] webView:wv windowScriptObjectAvailable:[self windowScriptObject]];
+ if ([wv scriptDebugDelegate]) {
+ [_frame _attachScriptDebugger];
+ }
}
- (int)spellCheckerDocumentTag
1.113 +1 -1 WebKit/WebCoreSupport.subproj/WebSubresourceLoader.m
Index: WebSubresourceLoader.m
===================================================================
RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.m,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- WebSubresourceLoader.m 1 Jul 2005 05:20:47 -0000 1.112
+++ WebSubresourceLoader.m 30 Jul 2005 03:00:27 -0000 1.113
@@ -138,7 +138,7 @@
NSURL *oldURL = [request URL];
NSURLRequest *clientRequest = [super willSendRequest:newRequest redirectResponse:redirectResponse];
- if (clientRequest != nil && ![oldURL isEqual:[clientRequest URL]]) {
+ if (clientRequest != nil && oldURL != [clientRequest URL] && ![oldURL isEqual:[clientRequest URL]]) {
[coreLoader redirectedToURL:[clientRequest URL]];
}
1.3 +20 -0 WebKit/WebKit.xcodeproj/project.pbxproj
Index: project.pbxproj
===================================================================
RCS file: /cvs/root/WebKit/WebKit.xcodeproj/project.pbxproj,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- project.pbxproj 27 Jul 2005 21:36:43 -0000 1.2
+++ project.pbxproj 30 Jul 2005 03:00:28 -0000 1.3
@@ -18,6 +18,11 @@
65EEDE54084FFB920002DB25 /* WebNSCalendarDateExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 65EEDE52084FFB920002DB25 /* WebNSCalendarDateExtras.m */; };
65EEDE57084FFC9E0002DB25 /* WebNSFileManagerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EEDE55084FFC9E0002DB25 /* WebNSFileManagerExtras.h */; };
65EEDE58084FFC9E0002DB25 /* WebNSFileManagerExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 65EEDE56084FFC9E0002DB25 /* WebNSFileManagerExtras.m */; };
+ 7E6FEF0108985A3E00C44C3F /* WebDefaultScriptDebugDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E6FEEFF08985A3E00C44C3F /* WebDefaultScriptDebugDelegate.h */; };
+ 7E6FEF0208985A3E00C44C3F /* WebDefaultScriptDebugDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E6FEF0008985A3E00C44C3F /* WebDefaultScriptDebugDelegate.m */; };
+ 7E6FEF0808985A7200C44C3F /* WebScriptDebugDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E6FEF0508985A7200C44C3F /* WebScriptDebugDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7E6FEF0908985A7200C44C3F /* WebScriptDebugDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E6FEF0608985A7200C44C3F /* WebScriptDebugDelegate.m */; };
+ 7E6FEF0A08985A7200C44C3F /* WebScriptDebugDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E6FEF0708985A7200C44C3F /* WebScriptDebugDelegatePrivate.h */; };
9398100E0824BF01008DF038 /* WebDOMDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = F57D194B034E734901A80180 /* WebDOMDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
9398100F0824BF01008DF038 /* WebDOMElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F57D194D034E734901A80180 /* WebDOMElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
939810100824BF01008DF038 /* WebDOMNode.h in Headers */ = {isa = PBXBuildFile; fileRef = F57D1951034E734901A80180 /* WebDOMNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -417,6 +422,11 @@
70BC9ED804144FC500A80182 /* WebDefaultFrameLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebDefaultFrameLoadDelegate.h; sourceTree = "<group>"; };
70ECD6CC043B727400A80181 /* WebDataProtocol.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebDataProtocol.h; sourceTree = "<group>"; };
70ECD6CD043B727400A80181 /* WebDataProtocol.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = WebDataProtocol.m; sourceTree = "<group>"; };
+ 7E6FEEFF08985A3E00C44C3F /* WebDefaultScriptDebugDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDefaultScriptDebugDelegate.h; sourceTree = "<group>"; };
+ 7E6FEF0008985A3E00C44C3F /* WebDefaultScriptDebugDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebDefaultScriptDebugDelegate.m; sourceTree = "<group>"; };
+ 7E6FEF0508985A7200C44C3F /* WebScriptDebugDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptDebugDelegate.h; sourceTree = "<group>"; };
+ 7E6FEF0608985A7200C44C3F /* WebScriptDebugDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebScriptDebugDelegate.m; sourceTree = "<group>"; };
+ 7E6FEF0708985A7200C44C3F /* WebScriptDebugDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptDebugDelegatePrivate.h; sourceTree = "<group>"; };
830E81830585375700AD0891 /* WebKeyGeneration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKeyGeneration.h; sourceTree = "<group>"; };
830E81840585375700AD0891 /* WebKeyGeneration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKeyGeneration.cpp; sourceTree = "<group>"; };
830E81E005853AC000AD0891 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
@@ -855,6 +865,8 @@
5152FAE0033FC50400CA2ACD /* WebDefaultPolicyDelegate.m */,
700BC50B04144DA100A80182 /* WebDefaultResourceLoadDelegate.h */,
700BC50C04144DA100A80182 /* WebDefaultResourceLoadDelegate.m */,
+ 7E6FEEFF08985A3E00C44C3F /* WebDefaultScriptDebugDelegate.h */,
+ 7E6FEF0008985A3E00C44C3F /* WebDefaultScriptDebugDelegate.m */,
515E27CF0458CA4B00CA2D3A /* WebDefaultUIDelegate.h */,
515E27D00458CA4B00CA2D3A /* WebDefaultUIDelegate.m */,
35081DAE02B6D4F50ACA2ACA /* WebDocument.h */,
@@ -890,6 +902,9 @@
84311A1305EAAAF00088EDA4 /* WebResource.m */,
84311AF105EAB12B0088EDA4 /* WebResourcePrivate.h */,
513D422E034CF55A00CA2ACD /* WebResourceLoadDelegate.h */,
+ 7E6FEF0508985A7200C44C3F /* WebScriptDebugDelegate.h */,
+ 7E6FEF0608985A7200C44C3F /* WebScriptDebugDelegate.m */,
+ 7E6FEF0708985A7200C44C3F /* WebScriptDebugDelegatePrivate.h */,
515E27CC0458C86500CA2D3A /* WebUIDelegate.h */,
65A7D44A0568AB2600E70EF6 /* WebUIDelegatePrivate.h */,
51A8B579042834F700CA2D3A /* WebView.h */,
@@ -1246,6 +1261,9 @@
65E0F88408500917007E5CB9 /* WebNSURLRequestExtras.h in Headers */,
65E0F9E608500F23007E5CB9 /* WebNSUserDefaultsExtras.h in Headers */,
ED6BE2E7088C32B50044DEDC /* WebNSAttributedStringExtras.h in Headers */,
+ 7E6FEF0108985A3E00C44C3F /* WebDefaultScriptDebugDelegate.h in Headers */,
+ 7E6FEF0808985A7200C44C3F /* WebScriptDebugDelegate.h in Headers */,
+ 7E6FEF0A08985A7200C44C3F /* WebScriptDebugDelegatePrivate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1786,6 +1804,8 @@
65E0F88508500917007E5CB9 /* WebNSURLRequestExtras.m in Sources */,
65E0F9E708500F23007E5CB9 /* WebNSUserDefaultsExtras.m in Sources */,
ED6BE2E8088C32B50044DEDC /* WebNSAttributedStringExtras.m in Sources */,
+ 7E6FEF0208985A3E00C44C3F /* WebDefaultScriptDebugDelegate.m in Sources */,
+ 7E6FEF0908985A7200C44C3F /* WebScriptDebugDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1.248 +9 -0 WebKit/WebView.subproj/WebFrame.m
Index: WebFrame.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebFrame.m,v
retrieving revision 1.247
retrieving revision 1.248
diff -u -r1.247 -r1.248
--- WebFrame.m 30 Jul 2005 02:34:01 -0000 1.247
+++ WebFrame.m 30 Jul 2005 03:00:28 -0000 1.248
@@ -212,6 +212,8 @@
[provisionalItem release];
[previousItem release];
+ [scriptDebugger release];
+
ASSERT(listener == nil);
ASSERT(policyRequest == nil);
ASSERT(policyFrameName == nil);
@@ -2582,6 +2584,13 @@
return _private->children;
}
+- (void)_attachScriptDebugger
+{
+ if (!_private->scriptDebugger) {
+ _private->scriptDebugger = [[WebScriptDebugger alloc] initWithWebFrame:self];
+ }
+}
+
@end
@implementation WebFrame (WebInternal)
1.158 +4 -0 WebKit/WebView.subproj/WebFramePrivate.h
Index: WebFramePrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebFramePrivate.h,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -r1.157 -r1.158
--- WebFramePrivate.h 27 Jul 2005 21:36:44 -0000 1.157
+++ WebFramePrivate.h 30 Jul 2005 03:00:28 -0000 1.158
@@ -45,6 +45,7 @@
@class WebFrameView;
@class WebHistoryItem;
@class WebPolicyDecisionListener;
+ at class WebScriptDebugger;
@class WebView;
typedef enum {
@@ -115,6 +116,7 @@
BOOL delegateIsHandlingUnimplementablePolicy;
id internalLoadDelegate;
+ WebScriptDebugger *scriptDebugger;
}
- (void)setName:(NSString *)name;
@@ -234,4 +236,6 @@
- (BOOL)_isDescendantOfFrame:(WebFrame *)frame;
- (BOOL)_isFrameSet;
+- (void)_attachScriptDebugger;
+
@end
1.160 +14 -0 WebKit/WebView.subproj/WebView.h
Index: WebView.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebView.h,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -r1.159 -r1.160
--- WebView.h 5 Jun 2005 17:54:48 -0000 1.159
+++ WebView.h 30 Jul 2005 03:00:28 -0000 1.160
@@ -249,6 +249,20 @@
- (id)policyDelegate;
/*!
+ @method setScriptDebugDelegate:
+ @abstract Set the WebView's WebScriptDebugDelegate delegate.
+ @param delegate The WebScriptDebugDelegate to set as the delegate.
+*/
+- (void)setScriptDebugDelegate:(id)delegate;
+
+/*!
+ @method scriptDebugDelegate
+ @abstract Return the WebView's WebScriptDebugDelegate.
+ @result The WebView's WebScriptDebugDelegate.
+*/
+- (id)scriptDebugDelegate;
+
+/*!
@method mainFrame
@abstract Return the top level frame.
@discussion Note that even document that are not framesets will have a
1.300 +22 -0 WebKit/WebView.subproj/WebView.m
Index: WebView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
retrieving revision 1.299
retrieving revision 1.300
diff -u -r1.299 -r1.300
--- WebView.m 27 Jul 2005 22:35:53 -0000 1.299
+++ WebView.m 30 Jul 2005 03:00:28 -0000 1.300
@@ -42,6 +42,7 @@
#import <WebKit/WebDefaultFrameLoadDelegate.h>
#import <WebKit/WebDefaultPolicyDelegate.h>
#import <WebKit/WebDefaultResourceLoadDelegate.h>
+#import <WebKit/WebDefaultScriptDebugDelegate.h>
#import <WebKit/WebDefaultUIDelegate.h>
#import <WebKit/WebDOMOperationsPrivate.h>
#import <WebKit/WebDocument.h>
@@ -74,6 +75,7 @@
#import <WebKit/WebPolicyDelegate.h>
#import <WebKit/WebPreferencesPrivate.h>
#import <WebKit/WebResourceLoadDelegate.h>
+#import <WebKit/WebScriptDebugDelegatePrivate.h>
#import <WebKit/WebTextView.h>
#import <WebKit/WebTextRepresentation.h>
#import <WebKit/WebTextRenderer.h>
@@ -303,6 +305,7 @@
[UIDelegateForwarder release];
[frameLoadDelegateForwarder release];
[editingDelegateForwarder release];
+ [scriptDebugDelegateForwarder release];
[progressItems release];
@@ -845,6 +848,13 @@
return _private->editingDelegateForwarder;
}
+- _scriptDebugDelegateForwarder
+{
+ if (!_private->scriptDebugDelegateForwarder)
+ _private->scriptDebugDelegateForwarder = [[_WebSafeForwarder alloc] initWithTarget: [self scriptDebugDelegate] defaultTarget: [WebDefaultScriptDebugDelegate sharedScriptDebugDelegate] templateClass: [WebDefaultScriptDebugDelegate class]];
+ return _private->scriptDebugDelegateForwarder;
+}
+
- (WebFrame *)_frameForDataSource: (WebDataSource *)dataSource fromFrame: (WebFrame *)frame
{
NSArray *frames;
@@ -1786,6 +1796,18 @@
{
return _private->frameLoadDelegate;
}
+- (void)setScriptDebugDelegate:delegate
+{
+ _private->scriptDebugDelegate = delegate;
+ [_private->scriptDebugDelegateForwarder release];
+ _private->scriptDebugDelegateForwarder = nil;
+}
+
+- scriptDebugDelegate
+{
+ return _private->scriptDebugDelegate;
+}
+
- (WebFrame *)mainFrame
{
1.20 +2 -0 WebKit/WebView.subproj/WebViewInternal.h
Index: WebViewInternal.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebViewInternal.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WebViewInternal.h 20 Jul 2005 00:50:23 -0000 1.19
+++ WebViewInternal.h 30 Jul 2005 03:00:29 -0000 1.20
@@ -52,6 +52,8 @@
id <WebFormDelegate> formDelegate;
id editingDelegate;
id editingDelegateForwarder;
+ id scriptDebugDelegate;
+ id scriptDebugDelegateForwarder;
WebBackForwardList *backForwardList;
BOOL useBackForwardList;
1.145 +1 -0 WebKit/WebView.subproj/WebViewPrivate.h
Index: WebViewPrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebViewPrivate.h,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -r1.144 -r1.145
--- WebViewPrivate.h 20 Jul 2005 18:30:15 -0000 1.144
+++ WebViewPrivate.h 30 Jul 2005 03:00:29 -0000 1.145
@@ -188,6 +188,7 @@
- (id)_policyDelegateForwarder;
- (id)_UIDelegateForwarder;
- (id)_editingDelegateForwarder;
+- (id)_scriptDebugDelegateForwarder;
- (void)_closeWindow;
1.1 WebKit/WebView.subproj/WebDefaultScriptDebugDelegate.h
Index: WebDefaultScriptDebugDelegate.h
===================================================================
/*
* Copyright (C) 2005 Apple Computer, 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.
*/
#import <Foundation/Foundation.h>
@interface WebDefaultScriptDebugDelegate : NSObject
+ (WebDefaultScriptDebugDelegate *)sharedScriptDebugDelegate;
@end
1.1 WebKit/WebView.subproj/WebDefaultScriptDebugDelegate.m
Index: WebDefaultScriptDebugDelegate.m
===================================================================
/*
* Copyright (C) 2005 Apple Computer, 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.
*/
#import <WebKit/WebScriptDebugDelegate.h>
#import "WebDefaultScriptDebugDelegate.h"
@implementation WebDefaultScriptDebugDelegate
static WebDefaultScriptDebugDelegate *sharedDelegate = nil;
+ (WebDefaultScriptDebugDelegate *)sharedScriptDebugDelegate
{
if (!sharedDelegate) {
sharedDelegate = [[WebDefaultScriptDebugDelegate alloc] init];
}
return sharedDelegate;
}
- (void)webView:(WebView *)webView didParseSource:(NSString *)source
fromURL:(NSString *)url
sourceId:(int)sid
forWebFrame:(WebFrame *)webFrame
{
}
- (void)webView:(WebView *)webView didEnterCallFrame:(WebScriptCallFrame *)frame
sourceId:(int)sid
line:(int)lineno
forWebFrame:(WebFrame *)webFrame
{
}
- (void)webView:(WebView *)webView willExecuteStatement:(WebScriptCallFrame *)frame
sourceId:(int)sid
line:(int)lineno
forWebFrame:(WebFrame *)webFrame
{
}
- (void)webView:(WebView *)webView willLeaveCallFrame:(WebScriptCallFrame *)frame
sourceId:(int)sid
line:(int)lineno
forWebFrame:(WebFrame *)webFrame
{
}
@end
1.1 WebKit/WebView.subproj/WebScriptDebugDelegate.h
Index: WebScriptDebugDelegate.h
===================================================================
/*
* Copyright (C) 2005 Apple Computer, 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.
*/
#import <Foundation/Foundation.h>
@class WebView;
@class WebFrame;
@class WebScriptCallFrame;
@class WebCoreScriptCallFrame;
// WebScriptDebugDelegate messages
@interface NSObject (WebScriptDebugDelegate)
// some source was parsed, establishing a "source ID" (>= 0) for future reference
- (void)webView:(WebView *)webView didParseSource:(NSString *)source
fromURL:(NSString *)url
sourceId:(int)sid
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
line:(int)lineno
forWebFrame:(WebFrame *)webFrame;
// about to execute some code
- (void)webView:(WebView *)webView willExecuteStatement:(WebScriptCallFrame *)frame
sourceId:(int)sid
line:(int)lineno
forWebFrame:(WebFrame *)webFrame;
// about to leave a stack frame (i.e. return from a function)
- (void)webView:(WebView *)webView willLeaveCallFrame:(WebScriptCallFrame *)frame
sourceId:(int)sid
line:(int)lineno
forWebFrame:(WebFrame *)webFrame;
@end
// WebScriptCallFrame interface
//
// These objects are passed as arguments to the debug delegate.
@interface WebScriptCallFrame : NSObject
{
@private
WebCoreScriptCallFrame *_private;
id _userInfo;
}
// associate user info with frame
- (void)setUserInfo:(id)userInfo;
// retrieve user info
- (id)userInfo;
// get next frame on call stack (or nil if this is already the "global" frame)
- (WebScriptCallFrame *)caller;
// get array of WebScriptObjects for each scope (innermost first, last is always global object)
- (NSArray *)scopeChain;
// get name of function (if available) or nil
- (NSString *)functionName;
// get pending exception (if any) or nil
- (id)exception;
// evaluate a script (as if by "eval") in the context of this frame
- (id)evaluateWebScript:(NSString *)script;
@end
1.1 WebKit/WebView.subproj/WebScriptDebugDelegate.m
Index: WebScriptDebugDelegate.m
===================================================================
/*
* Copyright (C) 2005 Apple Computer, 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.
*/
#import <WebKit/WebViewPrivate.h>
#import <WebCore/WebCoreScriptDebugger.h>
#import "WebScriptDebugDelegatePrivate.h"
@interface WebScriptCallFrame (WebScriptDebugDelegateInternal)
- (WebScriptCallFrame *)_initWithFrame:(WebCoreScriptCallFrame *)frame;
@end
@implementation WebScriptDebugger
- (WebScriptDebugger *)initWithWebFrame:(WebFrame *)webFrame
{
if ((self = [super init])) {
_webView = [webFrame webView];
_webFrame = webFrame;
_debugger = [[WebCoreScriptDebugger alloc] initWithDelegate:self];
}
return self;
}
- (void)dealloc
{
[_debugger release];
[super dealloc];
}
- (WebScriptObject *)globalObject
{
return [[_webFrame _bridge] windowScriptObject];
}
- (id)newWrapperForFrame:(WebCoreScriptCallFrame *)frame
{
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];
}
- (void)enteredFrame:(WebCoreScriptCallFrame *)frame sourceId:(int)sid line:(int)lineno
{
[[_webView _scriptDebugDelegateForwarder] webView:_webView didEnterCallFrame:[frame wrapper] sourceId:sid line:lineno forWebFrame:_webFrame];
}
- (void)hitStatement:(WebCoreScriptCallFrame *)frame sourceId:(int)sid line:(int)lineno
{
[[_webView _scriptDebugDelegateForwarder] webView:_webView willExecuteStatement:[frame wrapper] sourceId:sid line:lineno forWebFrame:_webFrame];
}
- (void)leavingFrame:(WebCoreScriptCallFrame *)frame sourceId:(int)sid line:(int)lineno
{
[[_webView _scriptDebugDelegateForwarder] webView:_webView willLeaveCallFrame:[frame wrapper] sourceId:sid line:lineno forWebFrame:_webFrame];
}
@end
@implementation WebScriptCallFrame (WebScriptDebugDelegateInternal)
- (WebScriptCallFrame *)_initWithFrame:(WebCoreScriptCallFrame *)frame
{
if ((self = [super init])) {
_private = frame;
}
return self;
}
@end
@implementation WebScriptCallFrame
- (void) dealloc
{
[_userInfo release];
[super dealloc];
}
- (void)setUserInfo:(id)userInfo
{
if (userInfo != _userInfo) {
[_userInfo release];
_userInfo = [userInfo retain];
}
}
- (id)userInfo
{
return _userInfo;
}
- (WebScriptCallFrame *)caller
{
return [[_private caller] wrapper];
}
- (NSArray *)scopeChain
{
return [_private scopeChain];
}
- (NSString *)functionName
{
return [_private functionName];
}
- (id)exception
{
return [_private exception];
}
- (id)evaluateWebScript:(NSString *)script
{
return [_private evaluateWebScript:script];
}
@end
1.1 WebKit/WebView.subproj/WebScriptDebugDelegatePrivate.h
Index: WebScriptDebugDelegatePrivate.h
===================================================================
/*
* Copyright (C) 2005 Apple Computer, 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.
*/
#import <WebKit/WebScriptDebugDelegate.h>
@class WebCoreScriptDebugger;
@protocol WebScriptDebugger;
@interface WebScriptDebugger : NSObject <WebScriptDebugger>
{
@private
WebView *_webView;
WebFrame *_webFrame;
WebCoreScriptDebugger *_debugger;
}
- (WebScriptDebugger *)initWithWebFrame:(WebFrame *)webFrame;
@end
1.4502 +30 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4501
retrieving revision 1.4502
diff -u -r1.4501 -r1.4502
--- ChangeLog 30 Jul 2005 02:33:02 -0000 1.4501
+++ ChangeLog 30 Jul 2005 03:00:30 -0000 1.4502
@@ -1,5 +1,35 @@
2005-07-29 Maciej Stachowiak <mjs at apple.com>
+ Changes by Michael Kahl, reviewed by me.
+
+ Test cases added: No tests, this code only affects debugging.
+
+ - fixed <rdar://problem/4164112> MASTER: JavaScript debugging support
+
+ * kwq/WebCoreScriptDebugger.h: Added.
+ * kwq/WebCoreScriptDebugger.mm: Added.
+ (toNSString):
+ (WebCoreScriptDebuggerImp::WebCoreScriptDebuggerImp):
+ (WebCoreScriptDebuggerImp::sourceParsed):
+ (WebCoreScriptDebuggerImp::callEvent):
+ (WebCoreScriptDebuggerImp::atStatement):
+ (WebCoreScriptDebuggerImp::returnEvent):
+ (-[WebCoreScriptDebugger initWithDelegate:]):
+ (-[WebCoreScriptDebugger dealloc]):
+ (-[WebCoreScriptDebugger delegate]):
+ (-[WebCoreScriptCallFrame _initWithGlobalObject:caller:state:]):
+ (-[WebCoreScriptCallFrame _setWrapper:]):
+ (-[WebCoreScriptCallFrame _convertValueToObjcValue:]):
+ (-[WebCoreScriptCallFrame dealloc]):
+ (-[WebCoreScriptCallFrame wrapper]):
+ (-[WebCoreScriptCallFrame caller]):
+ (-[WebCoreScriptCallFrame scopeChain]):
+ (-[WebCoreScriptCallFrame functionName]):
+ (-[WebCoreScriptCallFrame exception]):
+ (-[WebCoreScriptCallFrame evaluateWebScript:]):
+
+2005-07-29 Maciej Stachowiak <mjs at apple.com>
+
Reviewed by hyatt (concept and a few manual parts), large part
done by script and not really reviewed in detail.
1.1 WebCore/kwq/WebCoreScriptDebugger.h
Index: WebCoreScriptDebugger.h
===================================================================
/*
* Copyright (C) 2005 Apple Computer, 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.
*/
#import <Foundation/Foundation.h>
@class WebScriptObject; // from JavaScriptCore
@class WebCoreScriptCallFrame; // below
#ifdef __cplusplus
class WebCoreScriptDebuggerImp;
namespace KJS { class ExecState; }
using KJS::ExecState;
#else
@class WebCoreScriptDebuggerImp;
@class ExecState;
#endif
// "WebScriptDebugger" protocol - must be implemented by a delegate
@protocol WebScriptDebugger
- (WebScriptObject *)globalObject; // return the WebView's windowScriptObject
- (id)newWrapperForFrame:(WebCoreScriptCallFrame *)frame; // return a (retained) stack-frame object
// debugger callbacks
- (void)parsedSource:(NSString *)source fromURL:(NSString *)url sourceId:(int)sid;
- (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;
@end
@interface WebCoreScriptDebugger : NSObject
{
@private
id<WebScriptDebugger> _delegate; // interface to WebKit (not retained)
WebScriptObject *_globalObj; // the global object's proxy (not retained)
WebCoreScriptCallFrame *_current; // top of stack
WebCoreScriptDebuggerImp *_debugger; // [KJS::Debugger]
}
- (WebCoreScriptDebugger *)initWithDelegate:(id<WebScriptDebugger>)delegate;
- (id<WebScriptDebugger>)delegate;
@end
@interface WebCoreScriptCallFrame : NSObject
{
@private
id _wrapper; // WebKit's version of this object
WebScriptObject *_globalObj; // the global object's proxy (not retained)
WebCoreScriptCallFrame *_caller; // previous stack frame
ExecState *_state; // [KJS::ExecState]
}
- (id)wrapper;
- (WebCoreScriptCallFrame *)caller;
- (NSArray *)scopeChain;
- (NSString *)functionName;
- (id)exception;
- (id)evaluateWebScript:(NSString *)script;
@end
1.1 WebCore/kwq/WebCoreScriptDebugger.mm
Index: WebCoreScriptDebugger.mm
===================================================================
/*
* Copyright (C) 2005 Apple Computer, 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.
*/
#import <WebCore/WebCoreScriptDebugger.h>
#import <JavaScriptCore/WebScriptObjectPrivate.h>
#import <JavaScriptCore/debugger.h>
#import <JavaScriptCore/context.h>
using namespace KJS;
@interface WebCoreScriptDebugger (WebCoreScriptDebuggerInternal)
- (WebCoreScriptCallFrame *)_enterFrame:(ExecState *)state;
- (WebCoreScriptCallFrame *)_leaveFrame;
@end
@interface WebCoreScriptCallFrame (WebCoreScriptDebuggerInternal)
- (WebCoreScriptCallFrame *)_initWithGlobalObject:(WebScriptObject *)globalObj caller:(WebCoreScriptCallFrame *)caller state:(ExecState *)state;
- (void)_setWrapper:(id)wrapper;
- (id)_convertValueToObjcValue:(Value)value;
@end
// convert UString to NSString
static NSString *toNSString(const UString &s)
{
if (s.isEmpty()) return nil;
return [NSString stringWithCharacters:(const unichar *)s.data() length:s.size()];
}
// C++ interface to KJS debugger callbacks
class WebCoreScriptDebuggerImp : public KJS::Debugger {
private:
WebCoreScriptDebugger *_objc; // our ObjC half
bool _nested; // true => this is a nested call
WebCoreScriptCallFrame *_current; // top stack frame (copy of same field from ObjC side)
public:
// constructor
WebCoreScriptDebuggerImp(WebCoreScriptDebugger *objc, Interpreter *interp) : _objc(objc) {
_nested = true;
_current = [_objc _enterFrame:interp->globalExec()];
attach(interp);
[[_objc delegate] enteredFrame:_current sourceId:-1 line:-1];
_nested = false;
}
// callbacks - relay to delegate
virtual bool sourceParsed(ExecState *state, int sid, const UString &url, const UString &source, int errorLine) {
if (!_nested && errorLine == -1) {
_nested = true;
[[_objc delegate] parsedSource:toNSString(source) fromURL:toNSString(url) sourceId:sid];
_nested = false;
}
return true;
}
virtual bool callEvent(ExecState *state, int sid, int lineno, Object &func, const List &args) {
if (!_nested) {
_nested = true;
_current = [_objc _enterFrame:state];
[[_objc delegate] enteredFrame:_current sourceId:sid line:lineno];
_nested = false;
}
return true;
}
virtual bool atStatement(ExecState *state, int sid, int lineno, int lastLine) {
if (!_nested) {
_nested = true;
[[_objc delegate] hitStatement:_current sourceId:sid line:lineno];
_nested = false;
}
return true;
}
virtual bool returnEvent(ExecState *state, int sid, int lineno, Object &func) {
if (!_nested) {
_nested = true;
[[_objc delegate] leavingFrame:_current sourceId:sid line:lineno];
_current = [_objc _leaveFrame];
_nested = false;
}
return true;
}
};
// WebCoreScriptDebugger
//
// This is the main (behind-the-scenes) debugger class in WebCore.
//
// The WebCoreScriptDebugger has two faces, one for Objective-C (this class), and another (WebCoreScriptDebuggerImp)
// for C++. The ObjC side creates the C++ side, which does the real work of attaching to the interpreter and
// forwarding the KJS debugger callbacks to the delegate.
@implementation WebCoreScriptDebugger
- (WebCoreScriptDebugger *)initWithDelegate:(id<WebScriptDebugger>)delegate
{
if ((self = [super init])) {
_delegate = delegate;
_globalObj = [_delegate globalObject];
_debugger = new WebCoreScriptDebuggerImp(self, [_globalObj _executionContext]->interpreter());
}
return self;
}
- (void)dealloc
{
[_current release];
delete _debugger;
[super dealloc];
}
- (id<WebScriptDebugger>)delegate
{
return _delegate;
}
@end
@implementation WebCoreScriptDebugger (WebCoreScriptDebuggerInternal)
- (WebCoreScriptCallFrame *)_enterFrame:(ExecState *)state;
{
WebCoreScriptCallFrame *callee = [[WebCoreScriptCallFrame alloc] _initWithGlobalObject:_globalObj caller:_current state:state];
[callee _setWrapper:[_delegate newWrapperForFrame:callee]];
return _current = callee;
}
- (WebCoreScriptCallFrame *)_leaveFrame;
{
WebCoreScriptCallFrame *caller = [[_current caller] retain];
[_current release];
return _current = caller;
}
@end
// WebCoreScriptCallFrame
//
// One of these is created to represent each stack frame. Additionally, there is a "global"
// frame to represent the outermost scope. This global frame is always the last frame in
// the chain of callers.
//
// The delegate can assign a "wrapper" to each frame object so it can relay calls through its
// own exported interface. This class is private to WebCore (and the delegate).
@implementation WebCoreScriptCallFrame (WebCoreScriptDebuggerInternal)
- (WebCoreScriptCallFrame *)_initWithGlobalObject:(WebScriptObject *)globalObj caller:(WebCoreScriptCallFrame *)caller state:(ExecState *)state
{
if ((self = [super init])) {
_globalObj = globalObj;
_caller = caller; // (already retained)
_state = state;
}
return self;
}
- (void)_setWrapper:(id)wrapper
{
_wrapper = wrapper; // (already retained)
}
- (id)_convertValueToObjcValue:(Value)value
{
if (value.isNull()) {
return nil;
}
if (value.type() == ObjectType && value.imp() == [_globalObj _imp]) {
return _globalObj;
}
const Bindings::RootObject *root1 = [_globalObj _originExecutionContext];
const Bindings::RootObject *root2 = [_globalObj _executionContext];
return [WebScriptObject _convertValueToObjcValue:value originExecutionContext:root1 executionContext:root2];
}
@end
@implementation WebCoreScriptCallFrame
- (void)dealloc
{
[_wrapper release];
[_caller release];
[super dealloc];
}
- (id)wrapper
{
return _wrapper;
}
- (WebCoreScriptCallFrame *)caller
{
return _caller;
}
// Returns an array of scope objects (most local first).
// The properties of each scope object are the variables for that scope.
// Note that the last entry in the array will _always_ be the global object (windowScriptObject),
// whose properties are the global variables.
- (NSArray *)scopeChain
{
ContextImp *context = _state->context().imp();
if (!context) { // global frame
return [NSArray arrayWithObject:_globalObj];
}
ScopeChain chain = context->scopeChain();
NSMutableArray *scopes = [[NSMutableArray alloc] init];
while (!chain.isEmpty()) {
Object scope(chain.top());
[scopes addObject:[self _convertValueToObjcValue:scope]];
chain.pop();
}
NSArray *result = [NSArray arrayWithArray:scopes];
[scopes release];
return result;
}
// Returns the name of the function for this frame, if available.
// Returns nil for anonymous functions and for the global frame.
- (NSString *)functionName
{
ContextImp *context = _state->context().imp();
if (context) {
FunctionImp *func = context->function();
if (func) {
Identifier fn = func->name();
return toNSString(fn.ustring());
}
}
return nil;
}
// Returns the pending exception for this frame (nil if none).
- (id)exception
{
if (!_state->hadException()) return nil;
return [self _convertValueToObjcValue:_state->exception()];
}
// Evaluate some JavaScript code in the context of this frame.
// The code is evaluated as if by "eval", and the result is returned.
// If there is an (uncaught) exception, it is returned as though _it_ were the result.
// Calling this method on the global frame is not quite the same as calling the WebScriptObject
// method of the same name, due to the treatment of exceptions.
- (id)evaluateWebScript:(NSString *)script
{
UString code([script UTF8String]);
ExecState *state = _state;
Interpreter *interp = state->interpreter();
Object globObj = interp->globalObject();
// find "eval"
Object eval;
if (state->context().imp()) { // "eval" won't work without context (i.e. at global scope)
Object o = Object::dynamicCast(globObj.get(state, "eval"));
if (!o.isNull() && o.implementsCall()) {
eval = o;
}
else {
// no "eval" - fallback operates on global exec state
state = interp->globalExec();
}
}
Value savedException = state->exception();
state->clearException();
// evaluate
Value result;
if (!eval.isNull()) {
Interpreter::lock();
Object dummy;
List args;
args.append(String(code));
result = eval.call(state, dummy, args);
Interpreter::unlock();
}
else {
// no "eval", or no context (i.e. global scope) - use global fallback
result = interp->imp()->evaluate(code, globObj, UString(), 0).value();
}
if (state->hadException()) {
result = state->exception(); // (may be redundant depending on which eval path was used)
}
state->setException(savedException);
return [self _convertValueToObjcValue:result];
}
@end
More information about the webkit-changes
mailing list