Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'titanium_pr2' of git@github.com:marshall/webkit_titaniu…
…m into titanium_pr2
- Loading branch information
Showing
7 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// WebScriptElement.h | ||
// WebKit | ||
// | ||
// Created by Marshall on 2/9/09. | ||
// Copyright 2009 Appcelerator, Inc. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
|
||
@interface WebScriptElement : NSObject { | ||
|
||
} | ||
|
||
+(void) addScriptEvaluator:(id)evaluator; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// WebScriptElement.mm | ||
// WebKit | ||
// | ||
// Created by Marshall on 2/9/09. | ||
// Copyright 2009 Appcelerator, Inc. All rights reserved. | ||
// | ||
|
||
#import "WebScriptElement.h" | ||
#import <WebKit/WebKit.h> | ||
#import <JavaScriptCore/JSContextRef.h> | ||
|
||
#import "ScriptElement.h" | ||
#import "ScriptEvaluator.h" | ||
#import "ScriptSourceCode.h" | ||
|
||
class EvaluatorAdapter : public WebCore::ScriptEvaluator | ||
{ | ||
protected: | ||
id object; | ||
|
||
public: | ||
EvaluatorAdapter(id object) : object(object) {} | ||
virtual ~EvaluatorAdapter() {} | ||
|
||
virtual bool matchesMimeType(const WebCore::String& mimeType) | ||
{ | ||
if ([object respondsToSelector:@selector(matchesMimeType:)]) { | ||
NSString *str = mimeType; | ||
|
||
BOOL result = (BOOL) (intptr_t) [object performSelector:@selector(matchesMimeType:) withObject:str]; | ||
return result; | ||
} | ||
return false; | ||
} | ||
|
||
virtual void evaluate(const WebCore::String& mimeType, | ||
const WebCore::ScriptSourceCode& sourceCode, void *context) | ||
{ | ||
NSString *mimeTypeStr = mimeType; | ||
WebCore::String webCoreSourceCodeStr = sourceCode.jsSourceCode().toString(); | ||
NSString *sourceCodeStr = webCoreSourceCodeStr; | ||
|
||
SEL evalSelector; | ||
evalSelector = @selector(evaluate:sourceCode:context:); | ||
if ([object respondsToSelector:evalSelector]) { | ||
|
||
|
||
NSMethodSignature *sig = [object methodSignatureForSelector:evalSelector]; | ||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig]; | ||
[invocation setTarget:object]; | ||
[invocation setSelector:evalSelector]; | ||
[invocation setArgument:&mimeTypeStr atIndex:2]; | ||
[invocation setArgument:&sourceCodeStr atIndex:3]; | ||
[invocation setArgument:&context atIndex:4]; | ||
[invocation retainArguments]; | ||
[invocation invoke]; | ||
} | ||
} | ||
}; | ||
|
||
@implementation WebScriptElement | ||
|
||
+(void) addScriptEvaluator:(id)evaluator | ||
{ | ||
WebCore::ScriptElement::addScriptEvaluator(new EvaluatorAdapter(evaluator)); | ||
} | ||
|
||
|
||
@end |