Compare commits

...
11 changed files with 273 additions and 239 deletions
+4 -5
View File
@@ -860,12 +860,11 @@ CPRunContinuesResponse = -1002;
if ([windowController respondsToSelector:anAction])
return windowController;
var theDocument = [windowController document];
if (theDocument != delegate && [theDocument respondsToSelector:anAction])
if (theDocument !== delegate && [theDocument respondsToSelector:anAction])
return theDocument;
return nil;
}
@@ -1063,7 +1062,7 @@ CPRunContinuesResponse = -1002;
else if ([self mainWindow])
[[self mainWindow] makeKeyAndOrderFront:self];
else
[[[self mainMenu] window] makeKeyWindow]; //FIXME this may not actually work
[[self mainMenu]._menuWindow makeKeyWindow]; //FIXME this may not actually work
_previousKeyWindow = nil;
_previousMainWindow = nil;
+56 -80
View File
@@ -24,26 +24,10 @@
#include "Platform/Platform.h"
/*!
@global
@group Menu tags
*/
CPSearchFieldRecentsTitleMenuItemTag = 1000;
/*!
@global
@group Menu tags
*/
CPSearchFieldRecentsMenuItemTag = 1001;
/*!
@global
@group Menu tags
*/
CPSearchFieldClearRecentsMenuItemTag = 1002;
/*!
@global
@group Menu tags
*/
CPSearchFieldNoRecentsMenuItemTag = 1003;
CPSearchFieldRecentsTitleMenuItemTag = 1000;
CPSearchFieldRecentsMenuItemTag = 1001;
CPSearchFieldClearRecentsMenuItemTag = 1002;
CPSearchFieldNoRecentsMenuItemTag = 1003;
var CPSearchFieldSearchImage = nil,
CPSearchFieldFindImage = nil,
@@ -79,64 +63,49 @@ var CPSearchFieldSearchImage = nil,
return;
var bundle = [CPBundle bundleForClass:self];
CPSearchFieldSearchImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldSearch.png"]];
CPSearchFieldFindImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldFind.png"]];
CPSearchFieldCancelImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancel.png"]];
CPSearchFieldCancelPressedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancelPressed.png"]];
CPSearchFieldSearchImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldSearch.png"] size:CGSizeMake(25, 22)];
CPSearchFieldFindImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldFind.png"] size:CGSizeMake(25, 22)];
CPSearchFieldCancelImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancel.png"] size:CGSizeMake(22, 22)];
CPSearchFieldCancelPressedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSearchField/CPSearchFieldCancelPressed.png"] size:CGSizeMake(22, 22)];
}
- (id)initWithFrame:(CPRect)frame
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil)
if (self = [super initWithFrame:frame])
{
_recentSearches = [CPArray array];
_maximumRecents = 10;
_sendsWholeSearchString = NO;
_sendsSearchStringImmediately = NO;
_recentsAutosaveName = nil;
[self setBezeled:YES];
[self setBezelStyle:CPTextFieldRoundedBezel];
[self setBordered:YES];
[self setEditable:YES];
[self setDelegate:self];
_cancelButton = [[CPButton alloc] initWithFrame:CPMakeRect(frame.size.width - 27,(frame.size.height-22)/2,22,22)];
[self resetCancelButton];
[_cancelButton setHidden:YES];
[_cancelButton setAutoresizingMask:CPViewMinXMargin];
[self addSubview:_cancelButton];
_searchButton = [[CPButton alloc] initWithFrame:CPMakeRect(5,(frame.size.height-25)/2,25,25)];
[self resetSearchButton];
[self addSubview:_searchButton];
[self _initWithFrame:frame];
#if PLATFORM(DOM)
_cancelButton._DOMElement.style.cursor = "default";
_searchButton._DOMElement.style.cursor = "default";
#endif
_cancelButton._DOMElement.style.cursor = "default";
_searchButton._DOMElement.style.cursor = "default";
#endif
}
return self;
}
- (id)copy
- (void)_initWithFrame:(CGRect)frame
{
var copy = [super copy];
[self setBezeled:YES];
[self setBezelStyle:CPTextFieldRoundedBezel];
[self setBordered:YES];
[self setEditable:YES];
[self setDelegate:self];
[copy setCancelButton:[_cancelButton copy]];
[copy setSearchButton:[_searchButton copy]];
[copy setSendsWholeSearchString:[_sendsWholeSearchString copy]];
[copy setSendsSearchStringImmediately:[_sendsSearchStringImmediately copy]];
[copy setMaximumRecents:_maximumRecents];
if (_recentsAutosaveName)
[copy setrecentsAutosaveName:[_recentsAutosaveName copy]];
if (_searchMenuTemplate)
[copy setSearchMenutemplate:[_searchMenuTemplate copy]];
_cancelButton = [[CPButton alloc] initWithFrame:CGRectMake(frame.size.width - 27,(frame.size.height-22)/2,22,22)];
[self resetCancelButton];
[_cancelButton setHidden:YES];
[_cancelButton setAutoresizingMask:CPViewMinXMargin];
[self addSubview:_cancelButton];
return copy;
_searchButton = [[CPButton alloc] initWithFrame:CGRectMake(5,(frame.size.height-25)/2,25,25)];
[self resetSearchButton];
[self addSubview:_searchButton];
}
// Managing Buttons
@@ -695,9 +664,7 @@ var CPSearchFieldSearchImage = nil,
@end
var CPSearchButtonKey = @"CPSearchButtonKey",
CPCancelButtonKey = @"CPCancelButtonKey",
CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
CPSendsWholeSearchStringKey = @"CPSendsWholeSearchStringKey",
CPSendsSearchStringImmediatelyKey = @"CPSendsSearchStringImmediatelyKey",
CPMaximumRecentsKey = @"CPMaximumRecentsKey",
@@ -707,13 +674,20 @@ var CPSearchButtonKey = @"CPSearchButtonKey",
- (void)encodeWithCoder:(CPCoder)coder
{
[super encodeWithCoder:coder];
[coder encodeObject:_searchButton forKey:CPSearchButtonKey];
[coder encodeObject:_cancelButton forKey:CPCancelButtonKey];
[_searchButton removeFromSuperview];
[_cancelButton removeFromSuperview];
[super encodeWithCoder:coder];
if (_searchButton)
[self addSubview:_searchButton];
if (_cancelButton)
[self addSubview:_cancelButton];
[coder encodeBool:_sendsWholeSearchString forKey:CPSendsWholeSearchStringKey];
[coder encodeBool:_sendsSearchStringImmediately forKey:CPSendsSearchStringImmediatelyKey];
[coder encodeInt:_maximumRecents forKey:CPMaximumRecentsKey];
if (_recentsAutosaveName)
[coder encodeObject:_recentsAutosaveName forKey:CPRecentsAutosaveNameKey];
if (_searchMenuTemplate)
@@ -722,21 +696,23 @@ var CPSearchButtonKey = @"CPSearchButtonKey",
- (id)initWithCoder:(CPCoder)coder
{
self = [super initWithCoder:coder];
_searchButton = [coder decodeObjectForKey:CPSearchButtonKey];
_cancelButton = [coder decodeObjectForKey:CPCancelButtonKey];
_recentsAutosaveName = [coder decodeObjectForKey:CPRecentsAutosaveNameKey];
_sendsWholeSearchString = [coder decodeBoolForKey:CPSendsWholeSearchStringKey];
_sendsSearchStringImmediately = [coder decodeBoolForKey:CPSendsSearchStringImmediatelyKey];
_maximumRecents = [coder decodeIntForKey:CPMaximumRecentsKey];
var template = [coder decodeObjectForKey:CPSearchMenuTemplateKey];
if (template)
[self setSearchMenuTemplate:template];
[self setDelegate:self];
if (self = [super initWithCoder:coder])
{
[self _initWithFrame:[self frame]];
_recentsAutosaveName = [coder decodeObjectForKey:CPRecentsAutosaveNameKey];
_sendsWholeSearchString = [coder decodeBoolForKey:CPSendsWholeSearchStringKey];
_sendsSearchStringImmediately = [coder decodeBoolForKey:CPSendsSearchStringImmediatelyKey];
_maximumRecents = [coder decodeIntForKey:CPMaximumRecentsKey];
var template = [coder decodeObjectForKey:CPSearchMenuTemplateKey];
if (template)
[self setSearchMenuTemplate:template];
[self setDelegate:self];
}
return self;
}
@end
@end
+15 -17
View File
@@ -160,21 +160,24 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
CPTableView _tableView @accessors(property=tableView);
}
- (void)initWithFrame:(CGRect)aFrame
- (void)_init
{
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
{
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
[self _init];
return self;
}
@@ -481,12 +484,7 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
{
if (self = [super initWithCoder:aCoder])
{
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
[self _init];
_tableView = [aCoder decodeObjectForKey:CPTableHeaderViewTableViewKey];
}
+5 -1
View File
@@ -194,6 +194,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
SEL _doubleAction;
unsigned _columnAutoResizingStyle;
int _lastTrackedRowIndex;
CGPoint _originalMouseDownPoint;
BOOL _verticalMotionCanDrag;
unsigned _destinationDragStyle;
@@ -2654,8 +2655,11 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
}
_isSelectingSession = YES;
if(row >= 0)
if(row >= 0 && row !== _lastTrackedRowIndex)
{
_lastTrackedRowIndex = row;
[self _updateSelectionWithMouseAtRow:row];
}
if ((_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_)
&& !_trackingPointMovedOutOfClickSlop)
+5 -7
View File
@@ -1497,7 +1497,8 @@ CPTexturedBackgroundWindowMask
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)])
[_firstResponder resignKeyWindow];
CPApp._keyWindow = nil;
if (CPApp._keyWindow === self)
CPApp._keyWindow = nil;
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidResignKeyNotification
@@ -1858,7 +1859,8 @@ CPTexturedBackgroundWindowMask
postNotificationName:CPWindowDidResignMainNotification
object:self];
CPApp._mainWindow = nil;
if (CPApp._mainWindow === self)
CPApp._mainWindow = nil;
}
- (void)_updateMainAndKeyWindows
@@ -1866,9 +1868,6 @@ CPTexturedBackgroundWindowMask
var allWindows = [CPApp orderedWindows],
windowCount = [allWindows count];
if (!windowCount)
return;
if ([self isKeyWindow])
{
var keyWindow = [CPApp keyWindow];
@@ -1893,11 +1892,10 @@ CPTexturedBackgroundWindowMask
}
if (![CPApp keyWindow])
[keyWindow makeKeyWindow];
[menuWindow makeKeyWindow];
}
}
if ([self isMainWindow])
{
var mainWindow = [CPApp mainWindow];
+93 -93
View File
@@ -87,22 +87,7 @@ function main(args)
flattener.load(mainPath);
flattener.finishLoading();
var rootResources = flattener.require("objective-j").StaticResource.rootResources();
var root = rootResources["file:"];
// FIXME: shouldn't have to do this manually
var components = rootPath.split("/").slice(0, -1);
components[0] = "/";
var node = root;
while (components.length) {
node = node.children()[components.shift()];
}
applicationRoot = node;
print(applicationRoot.toString());
var applicationJS = flattener.buildApplicationJS(applicationRoot);
var applicationJS = flattener.buildApplicationJS();
FILE.copyTree(rootPath, outputPath);
@@ -115,7 +100,9 @@ function main(args)
function ObjectiveJFlattener(rootPath) {
ObjectiveJRuntimeAnalyzer.apply(this, arguments);
this.resourceBuffer = [];
this.fileCacheBuffer = [];
this.staticResourceBuffer = [];
this.bundleBuffer = [];
this.functionsBuffer = [];
@@ -124,105 +111,118 @@ function ObjectiveJFlattener(rootPath) {
ObjectiveJFlattener.prototype = Object.create(ObjectiveJRuntimeAnalyzer.prototype);
ObjectiveJFlattener.prototype.buildApplicationJS = function(applicationRoot) {
this.serializeStaticResources(applicationRoot);
this.serializeStaticFileExecutables();
ObjectiveJFlattener.prototype.buildApplicationJS = function() {
var buffer = []
this.serializeFunctions();
this.serializeFileCache();
buffer.push("(function(){");
buffer.push("var appURL = new CFURL('.', ObjectiveJ.pageURL);")
buffer.push(this.bundleBuffer.join("\n"));
buffer.push("var nodeStack = [];");
buffer.push("var applicationRoot = ObjectiveJ.StaticResource.resourceAtURL(appURL, true);");
buffer.push("var currentNode = null;");
buffer.push("var newNode;");
buffer.push(this.resourceBuffer.join("\n"));
buffer.push("})();");
var buffer = [];
buffer.push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
buffer.push(this.fileCacheBuffer.join("\n"))
buffer.push(this.functionsBuffer.join("\n"));
buffer.push("ObjectiveJ.bootstrap();");
return buffer.join("\n");
}
ObjectiveJFlattener.prototype.serializeStaticFileExecutables = function() {
this.require("objective-j").FileExecutable.allFileExecutables().forEach(function(aFileExecutable) {
var deps = aFileExecutable.fileDependencies().map(function(dependency) {
return "new ObjectiveJ.FileDependency(new CFURL("+JSON.stringify(dependency.path())+"),"+JSON.stringify(dependency.isLocal())+")"
}).join(",");
ObjectiveJFlattener.prototype.serializeFunctions = function() {
var inlineFunctions = true;//this.options.inlineFunctions;
var func = aFileExecutable._function.toString();
// HACK
func = func.replace(", require, exports, module, system, print, window", "");
var outputFiles = {};
this.functionsBuffer.push("var path = "+JSON.stringify(this.rootPath.relative(aFileExecutable.path()).toString())+";");
this.functionsBuffer.push("new ObjectiveJ.FileExecutable(path,"+
"new ObjectiveJ.Executable(null, ["+deps+"], path, "+func+"));");
var _cachedExecutableFunctions = {};
this.require("objective-j").FileExecutable.allFileExecutables().forEach(function(executable) {
var path = executable.path();
if (inlineFunctions)
{
// stringify the function, replacing arguments
var functionString = executable._function.toString().replace(", require, exports, module, system, print, window", ""); // HACK
var relative = this.rootPath.relative(path).toString();
this.functionsBuffer.push("ObjectiveJ.FileExecutable._cacheFunction(new CFURL("+JSON.stringify(relative)+", baseURL), "+functionString+");");
}
var bundle = this.context.global.CFBundle.bundleContainingURL(path);
if (bundle && bundle.infoDictionary())
{
var executablePath = bundle.executablePath(),
relativeToBundle = FILE.relative(FILE.join(bundle.path(), ""), path);
if (executablePath)
{
if (inlineFunctions)
{
// remove the code since we're inlining the functions
executable._code = "alert("+JSON.stringify(relativeToBundle)+");";
}
if (!outputFiles[executablePath])
{
outputFiles[executablePath] = [];
outputFiles[executablePath].push("@STATIC;1.0;");
}
var fileContents = executable.toMarkedString();
outputFiles[executablePath].push("p;" + relativeToBundle.length + ";" + relativeToBundle);
outputFiles[executablePath].push("t;" + fileContents.length + ";" + fileContents);
// stream.print("Adding \0green(" + this.rootPath.relative(path) + "\0) to \0cyan(" + this.rootPath.relative(executablePath) + "\0)");
}
}
else
CPLog.warn("No bundle (or info dictionary for) " + rootPath.relative(path));
}, this);
for (var executablePath in outputFiles)
{
var relative = this.rootPath.relative(executablePath).toString();
var contents = outputFiles[executablePath].join("");
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 200, {}, "+JSON.stringify(contents)+");");
}
}
ObjectiveJFlattener.prototype.serializeStaticResources = function(node, depth) {
depth = depth || 0;
var bundle = this.context.global.CFBundle.bundleContainingURL(node.URL());
if (!bundle) {
stream.print("\0yellow(Warning:\0) No bundle for path: \0cyan("+node.URL()+"\0)");
}
else if (!this._outputBundles[bundle.path()]) {
this._outputBundles[bundle.path()] = bundle;
stream.print("Writing bundle: \0cyan("+bundle.path()+"\0)");
print(bundle.infoDictionary())
var relative = this.rootPath.relative(bundle.path()).toString();
this.bundleBuffer.push("var bundle = new CFBundle("+(relative ? JSON.stringify(relative) : "appURL")+");");
this.bundleBuffer.push("bundle._loadStatus = " + (1<<4) + ";");
if (bundle.infoDictionary()) {
this.bundleBuffer.push("bundle._infoDictionary = CFPropertyList.propertyListFromString(" +
JSON.stringify(CPPropertyListCreateData(bundle.infoDictionary()).rawString()) + ");");
ObjectiveJFlattener.prototype.serializeFileCache = function() {
Object.keys(this.requestedURLs).forEach(function(absolute) {
var relative = this.rootPath.relative(absolute).toString();
if (relative.indexOf("..") === 0)
{
print("skipping (parent of app root): " + absolute);
return;
}
}
// not the root node:
if (depth > 0) {
this.resourceBuffer.push("newNode = new ObjectiveJ.StaticResource(" +
JSON.stringify(node.name()) +
", currentNode, " +
JSON.stringify(node.isDirectory()) + ", " +
JSON.stringify(node.isResolved()) + ");");
} else {
this.resourceBuffer.push("newNode = applicationRoot;");
}
if (FILE.isFile(absolute))
{
if (FILE.extension(absolute) === ".sj")
{
print("skipping (bundle executable): " + absolute);
return;
}
// if (this.options.maxCachedSize && FILE.size(absolute) > this.options.maxCachedSize)
// {
// print("skipping (larger than "+this.options.maxCachedSize+" bytes): " + absolute);
// return;
// }
// var contents = node.contents();
// if (contents) {
// this.resourceBuffer.push("newNode._contents = " + JSON.stringify(contents) + ";");
// }
if (!node.children())
return;
this.resourceBuffer.push("nodeStack.push(currentNode);");
this.resourceBuffer.push("currentNode = newNode;");
var children = node.children();
for (var name in children) {
this.serializeStaticResources(children[name], depth+1);
}
this.resourceBuffer.push("currentNode = nodeStack.pop();");
print("caching: " + absolute);
var contents = FILE.read(absolute, { charset : "UTF-8" });
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 200, {}, "+JSON.stringify(contents)+");");
} else {
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 404);");
}
}, this);
}
// "$1" is the matching indentation
var scriptTagsBefore = '$1<script type = "text/javascript">\n$1 OBJJ_AUTO_BOOTSTRAP = false;\n$1</script>';
var scriptTagsAfter = '$1<script type = "text/javascript" src = "Application.js"></script>';
// enable CPLog:
// scriptTagsAfter = '$1<script type = "text/javascript">\n$1 CPLogRegister(CPLogConsole);\n$1</script>\n' + scriptTagsAfter;
function rewriteMainHTML(indexHTMLPath) {
if (indexHTMLPath.isFile()) {
var indexHTML = indexHTMLPath.read();
@@ -5,6 +5,8 @@ var Context = require("interpreter").Context;
ObjectiveJRuntimeAnalyzer = function(rootPath)
{
this.rootPath = rootPath;
this.rootURL = new CFURL(String(rootPath));
this.context = new Context();
this.scope = setupObjectiveJ(this.context);
@@ -28,6 +30,14 @@ ObjectiveJRuntimeAnalyzer = function(rootPath)
var url = this.executableURL();
return url ? url.absoluteURL().path() : null;
}
var requestedURLs = this.requestedURLs = {};
var _lookupCachedRequest = this.context.global.CFHTTPRequest._lookupCachedRequest;
this.context.global.CFHTTPRequest._lookupCachedRequest = function(aURL) {
var path = new CFURL(aURL, this.rootURL).absoluteURL().path();
requestedURLs[path] = true;
return _lookupCachedRequest.apply(null, arguments);
}
}
ObjectiveJRuntimeAnalyzer.prototype.setIncludePaths = function(includePaths) {
+62 -27
View File
@@ -196,9 +196,14 @@ CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType)
return this._nativeRequest.overrideMimeType(aMimeType);
}
CFHTTPRequest.prototype.open = function(/*...*/)
CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boolean*/ async, /*String*/ user, /*String*/ password)
{
return this._nativeRequest.open(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
var cachedRequest = CFHTTPRequest._lookupCachedRequest(url);
if (cachedRequest) {
cachedRequest.onreadystatechange = this._nativeRequest.onreadystatechange;
this._nativeRequest = cachedRequest;
}
return this._nativeRequest.open(method, url, async, user, password);
}
CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
@@ -254,43 +259,73 @@ function determineAndDispatchHTTPRequestEvents(/*CFHTTPRequest*/ aRequest)
function FileRequest(/*CFURL*/ aURL, onsuccess, onfailure)
{
#ifdef BROWSER
var request = new CFHTTPRequest();
request.onsuccess = Asynchronous(onsuccess);
request.onfailure = Asynchronous(onfailure);
if (aURL.pathExtension() === "plist")
request.overrideMimeType("text/xml");
request.open("GET", aURL.absoluteString(), YES);
if (FileRequest.async)
{
request.onsuccess = Asynchronous(onsuccess);
request.onfailure = Asynchronous(onfailure);
}
else
{
request.onsuccess = onsuccess;
request.onfailure = onfailure;
}
request.open("GET", aURL.absoluteString(), FileRequest.async);
request.send("");
}
#ifdef BROWSER
FileRequest.async = YES;
#else
var FILE = require("file"),
filePath = aURL.absoluteURL().path();
if (!FILE.exists(filePath))
return onfailure();
this._responseText = FILE.read(filePath, { charset:"UTF-8" });
onsuccess({ type:"success", request:this });
FileRequest.async = NO;
#endif
var URLCache = { };
CFHTTPRequest._cacheRequest = function(/*CFURL|String*/ aURL, /*Number*/ status, /*Object*/ headers, /*String*/ body)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
URLCache[aURL] = new MockXMLHttpRequest(status, headers, body);
}
#ifdef COMMONJS
FileRequest.prototype.responseText = function()
CFHTTPRequest._lookupCachedRequest = function(/*CFURL|String*/ aURL)
{
return this._responseText;
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
return URLCache[aURL];
}
FileRequest.prototype.responseXML = function()
function MockXMLHttpRequest(status, headers, body)
{
return new DOMParser().parseFromString(anXMLString, "text/xml");
}
FileRequest.prototype.responsePropertyList = function()
this.readyState = CFHTTPRequest.UninitializedState;
this.status = status || 200;
this.statusText = "";
this.responseText = body || "";
this._responseHeaders = headers || {};
};
MockXMLHttpRequest.prototype.open = function(method, url, async, user, password)
{
return CFPropertyList.propertyListFromString(this.responseText());
}
#endif
this.readyState = CFHTTPRequest.LoadingState;
this.async = async;
};
MockXMLHttpRequest.prototype.send = function(body)
{
var self = this;
self.responseText = self.responseText.toString();
function complete() {
for (self.readyState = CFHTTPRequest.LoadedState; self.readyState <= CFHTTPRequest.CompleteState; self.readyState++)
self.onreadystatechange();
}
(self.async ? Asynchronous(complete) : complete)();
};
MockXMLHttpRequest.prototype.onreadystatechange = function() {};
MockXMLHttpRequest.prototype.abort = function() {};
MockXMLHttpRequest.prototype.setRequestHeader = function(header, value) {};
MockXMLHttpRequest.prototype.getAllResponseHeaders = function() { return this._responseHeaders; };
MockXMLHttpRequest.prototype.getResponseHeader = function(header) { return this._responseHeaders[header]; };
MockXMLHttpRequest.prototype.overrideMimeType = function(mimetype) {};
+20 -5
View File
@@ -22,7 +22,7 @@
var FileExecutablesForURLStrings = { };
function FileExecutable(/*CFURL|String*/ aURL, /*Executable*/ anExecutable)
function FileExecutable(/*CFURL|String*/ aURL)
{
aURL = makeAbsoluteURL(aURL);
@@ -38,10 +38,7 @@ function FileExecutable(/*CFURL|String*/ aURL, /*Executable*/ anExecutable)
executable = NULL,
extension = aURL.pathExtension();
if (anExecutable)
executable = anExecutable;
else if (fileContents.match(/^@STATIC;/))
if (fileContents.match(/^@STATIC;/))
executable = decompile(fileContents, aURL);
else if (extension === "j" || !extension)
@@ -117,5 +114,23 @@ function decompile(/*String*/ aString, /*CFURL*/ aURL)
dependencies.push(new FileDependency(new CFURL(text), YES));
}
var fn = FileExecutable._lookupCachedFunction(aURL)
if (fn)
return new Executable(code, dependencies, aURL, fn);
return new Executable(code, dependencies, aURL);
}
var FunctionCache = { };
FileExecutable._cacheFunction = function(/*CFURL|String*/ aURL, /*Function*/ fn)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
FunctionCache[aURL] = fn;
}
FileExecutable._lookupCachedFunction = function(/*CFURL|String*/ aURL)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
return FunctionCache[aURL];
}
+3 -1
View File
@@ -45,7 +45,9 @@
- (id)initWithCoder:(CPCoder)aCoder
{
return [self NS_initWithCoder:aCoder];
self = [self NS_initWithCoder:aCoder];
return self;
}
- (Class)classForKeyedArchiver
-3
View File
@@ -27,10 +27,7 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
if (self = [super NS_initWithCoder:aCoder])
{
_tableView = [aCoder decodeObjectForKey:"NSTableView"];
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
return self;
}