webengine/osswebengine/WebKit/WebView/WebScriptDebugDelegate.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
       
     3  *
       
     4  * Redistribution and use in source and binary forms, with or without
       
     5  * modification, are permitted provided that the following conditions
       
     6  * are met:
       
     7  *
       
     8  * 1.  Redistributions of source code must retain the above copyright
       
     9  *     notice, this list of conditions and the following disclaimer. 
       
    10  * 2.  Redistributions in binary form must reproduce the above copyright
       
    11  *     notice, this list of conditions and the following disclaimer in the
       
    12  *     documentation and/or other materials provided with the distribution. 
       
    13  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
       
    14  *     its contributors may be used to endorse or promote products derived
       
    15  *     from this software without specific prior written permission. 
       
    16  *
       
    17  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
       
    18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
    19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    20  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
       
    21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       
    22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
    24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
       
    26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    27  */
       
    28 
       
    29 #import <Foundation/Foundation.h>
       
    30 
       
    31 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
       
    32 #define WebNSUInteger unsigned int
       
    33 #else
       
    34 #define WebNSUInteger NSUInteger
       
    35 #endif
       
    36 
       
    37 @class WebView;
       
    38 @class WebFrame;
       
    39 @class WebScriptCallFrame;
       
    40 @class WebCoreScriptCallFrame;
       
    41 
       
    42 extern NSString * const WebScriptErrorDomain;
       
    43 extern NSString * const WebScriptErrorDescriptionKey;
       
    44 extern NSString * const WebScriptErrorLineNumberKey;
       
    45 
       
    46 enum {
       
    47     WebScriptGeneralErrorCode = -100
       
    48 };
       
    49 
       
    50 // WebScriptDebugDelegate messages
       
    51 
       
    52 @interface NSObject (WebScriptDebugDelegate)
       
    53 
       
    54 // some source was parsed, establishing a "source ID" (>= 0) for future reference
       
    55 // this delegate method is deprecated, please switch to the new version below
       
    56 - (void)webView:(WebView *)webView       didParseSource:(NSString *)source
       
    57                                                 fromURL:(NSString *)url
       
    58                                                sourceId:(int)sid
       
    59                                             forWebFrame:(WebFrame *)webFrame;
       
    60 
       
    61 // some source was parsed, establishing a "source ID" (>= 0) for future reference
       
    62 - (void)webView:(WebView *)webView       didParseSource:(NSString *)source
       
    63                                          baseLineNumber:(WebNSUInteger)lineNumber
       
    64                                                 fromURL:(NSURL *)url
       
    65                                                sourceId:(int)sid
       
    66                                             forWebFrame:(WebFrame *)webFrame;
       
    67 
       
    68 // some source failed to parse
       
    69 - (void)webView:(WebView *)webView  failedToParseSource:(NSString *)source
       
    70                                          baseLineNumber:(WebNSUInteger)lineNumber
       
    71                                                 fromURL:(NSURL *)url
       
    72                                               withError:(NSError *)error
       
    73                                             forWebFrame:(WebFrame *)webFrame;
       
    74 
       
    75 // just entered a stack frame (i.e. called a function, or started global scope)
       
    76 - (void)webView:(WebView *)webView    didEnterCallFrame:(WebScriptCallFrame *)frame
       
    77                                                sourceId:(int)sid
       
    78                                                    line:(int)lineno
       
    79                                             forWebFrame:(WebFrame *)webFrame;
       
    80 
       
    81 // about to execute some code
       
    82 - (void)webView:(WebView *)webView willExecuteStatement:(WebScriptCallFrame *)frame
       
    83                                                sourceId:(int)sid
       
    84                                                    line:(int)lineno
       
    85                                             forWebFrame:(WebFrame *)webFrame;
       
    86 
       
    87 // about to leave a stack frame (i.e. return from a function)
       
    88 - (void)webView:(WebView *)webView   willLeaveCallFrame:(WebScriptCallFrame *)frame
       
    89                                                sourceId:(int)sid
       
    90                                                    line:(int)lineno
       
    91                                             forWebFrame:(WebFrame *)webFrame;
       
    92 
       
    93 // exception is being thrown
       
    94 - (void)webView:(WebView *)webView   exceptionWasRaised:(WebScriptCallFrame *)frame
       
    95                                                sourceId:(int)sid
       
    96                                                    line:(int)lineno
       
    97                                             forWebFrame:(WebFrame *)webFrame;
       
    98 @end
       
    99 
       
   100 
       
   101 
       
   102 // WebScriptCallFrame interface
       
   103 //
       
   104 // These objects are passed as arguments to the debug delegate.
       
   105 
       
   106 @interface WebScriptCallFrame : NSObject
       
   107 {
       
   108 @private
       
   109     WebCoreScriptCallFrame *_private;
       
   110     id                      _userInfo;
       
   111 }
       
   112 
       
   113 // associate user info with frame
       
   114 - (void)setUserInfo:(id)userInfo;
       
   115 
       
   116 // retrieve user info
       
   117 - (id)userInfo;
       
   118 
       
   119 // get next frame on call stack (or nil if this is already the "global" frame)
       
   120 - (WebScriptCallFrame *)caller;
       
   121 
       
   122 // get array of WebScriptObjects for each scope (innermost first, last is always global object)
       
   123 - (NSArray *)scopeChain;
       
   124 
       
   125 // get name of function (if available) or nil
       
   126 - (NSString *)functionName;
       
   127 
       
   128 // get pending exception (if any) or nil
       
   129 - (id)exception;
       
   130 
       
   131 // evaluate a script (as if by "eval") in the context of this frame
       
   132 - (id)evaluateWebScript:(NSString *)script;
       
   133 
       
   134 @end
       
   135 
       
   136 #undef WebNSUInteger