diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
commit | 635860845790a19bf50bbc51ba8fb66a96dde068 (patch) | |
tree | ef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebKit/mac/WebView/WebScriptDebugDelegate.mm | |
parent | 8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff) | |
download | external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2 |
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebKit/mac/WebView/WebScriptDebugDelegate.mm')
-rw-r--r-- | WebKit/mac/WebView/WebScriptDebugDelegate.mm | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/WebKit/mac/WebView/WebScriptDebugDelegate.mm b/WebKit/mac/WebView/WebScriptDebugDelegate.mm index be0a0d5..0b47e26 100644 --- a/WebKit/mac/WebView/WebScriptDebugDelegate.mm +++ b/WebKit/mac/WebView/WebScriptDebugDelegate.mm @@ -26,22 +26,24 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#import "WebScriptDebugger.h" #import "WebDataSource.h" #import "WebDataSourceInternal.h" #import "WebFrameInternal.h" #import "WebScriptDebugDelegate.h" +#import "WebScriptDebugger.h" #import "WebViewInternal.h" -#import <debugger/DebuggerCallFrame.h> -#import <runtime/ExecState.h> -#import <runtime/JSGlobalObject.h> -#import <runtime/JSFunction.h> -#import <runtime/JSLock.h> -#import <kjs/interpreter.h> #import <WebCore/Frame.h> -#import <WebCore/WebScriptObjectPrivate.h> #import <WebCore/ScriptController.h> +#import <WebCore/WebScriptObjectPrivate.h> #import <WebCore/runtime_root.h> +#import <debugger/Debugger.h> +#import <debugger/DebuggerActivation.h> +#import <debugger/DebuggerCallFrame.h> +#import <interpreter/CallFrame.h> +#import <runtime/Completion.h> +#import <runtime/JSFunction.h> +#import <runtime/JSGlobalObject.h> +#import <runtime/JSLock.h> using namespace JSC; using namespace WebCore; @@ -53,7 +55,7 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; @interface WebScriptCallFrame (WebScriptDebugDelegateInternal) -- (id)_convertValueToObjcValue:(JSValue*)value; +- (id)_convertValueToObjcValue:(JSValuePtr)value; @end @@ -62,6 +64,7 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; WebScriptObject *globalObject; // the global object's proxy (not retained) WebScriptCallFrame *caller; // previous stack frame DebuggerCallFrame* debuggerCallFrame; + WebScriptDebugger* debugger; } @end @@ -85,12 +88,13 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; @implementation WebScriptCallFrame (WebScriptDebugDelegateInternal) -- (WebScriptCallFrame *)_initWithGlobalObject:(WebScriptObject *)globalObj caller:(WebScriptCallFrame *)caller debuggerCallFrame:(const DebuggerCallFrame&)debuggerCallFrame +- (WebScriptCallFrame *)_initWithGlobalObject:(WebScriptObject *)globalObj debugger:(WebScriptDebugger *)debugger caller:(WebScriptCallFrame *)caller debuggerCallFrame:(const DebuggerCallFrame&)debuggerCallFrame { if ((self = [super init])) { _private = [[WebScriptCallFramePrivate alloc] init]; _private->globalObject = globalObj; _private->caller = [caller retain]; + _private->debugger = debugger; } return self; } @@ -109,7 +113,7 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; _private->debuggerCallFrame = 0; } -- (id)_convertValueToObjcValue:(JSValue*)value +- (id)_convertValueToObjcValue:(JSValuePtr)value { if (!value) return nil; @@ -177,8 +181,12 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; NSMutableArray *scopes = [[NSMutableArray alloc] init]; ScopeChainIterator end = scopeChain->end(); - for (ScopeChainIterator it = scopeChain->begin(); it != end; ++it) - [scopes addObject:[self _convertValueToObjcValue:(*it)]]; + for (ScopeChainIterator it = scopeChain->begin(); it != end; ++it) { + JSObject* object = *it; + if (object->isActivationObject()) + object = new (scopeChain->globalData) DebuggerActivation(object); + [scopes addObject:[self _convertValueToObjcValue:object]]; + } NSArray *result = [NSArray arrayWithArray:scopes]; [scopes release]; @@ -204,7 +212,7 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; if (!_private->debuggerCallFrame) return nil; - JSValue* exception = _private->debuggerCallFrame->exception(); + JSValuePtr exception = _private->debuggerCallFrame->exception(); return exception ? [self _convertValueToObjcValue:exception] : nil; } @@ -221,8 +229,25 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; JSLock lock(false); - JSValue* exception = noValue(); - JSValue* result = _private->debuggerCallFrame->evaluate(String(script), exception); + // If this is the global call frame and there is no dynamic global object, + // Dashcode is attempting to execute JS in the evaluator using a stale + // WebScriptCallFrame. Instead, we need to set the dynamic global object + // and evaluate the JS in the global object's global call frame. + JSGlobalObject* globalObject = _private->debugger->globalObject(); + if (self == _private->debugger->globalCallFrame() && !globalObject->globalData()->dynamicGlobalObject) { + JSGlobalObject* globalObject = _private->debugger->globalObject(); + + DynamicGlobalObjectScope globalObjectScope(globalObject->globalExec(), globalObject); + + JSValuePtr exception = noValue(); + JSValuePtr result = evaluateInGlobalCallFrame(String(script), exception, globalObject); + if (exception) + return [self _convertValueToObjcValue:exception]; + return result ? [self _convertValueToObjcValue:result] : nil; + } + + JSValuePtr exception = noValue(); + JSValuePtr result = _private->debuggerCallFrame->evaluate(String(script), exception); if (exception) return [self _convertValueToObjcValue:exception]; return result ? [self _convertValueToObjcValue:result] : nil; |