Merge branch 'jake' of git://github.com/280north/cappuccino into jake

This commit is contained in:
Randall Luecke committed 2010-01-20 23:19:18 -05:00
commit b5f55100e9
43 files changed
+102 -62

No files matched your search

+10
View File
@@ -569,6 +569,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
return YES;
}
/*!
Text fields require panels to become key window, so this returns \c YES.
*/
- (BOOL)needsPanelToBecomeKey
{
return YES;
}
- (void)mouseDown:(CPEvent)anEvent
{
// Don't track! (ever?)
@@ -1028,6 +1036,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
var view = [[_CPImageAndTextView alloc] initWithFrame:_CGRectMakeZero()];
//[view setImagePosition:CPNoImage];
[view setHitTests:NO];
return view;
}
+8
View File
@@ -1284,6 +1284,14 @@ var CPViewFlags = { },
return self;
}
/*!
Returns \c YES if this view requires a panel to become key. Normally only text fields, so this returns \c NO.
*/
- (BOOL)needsPanelToBecomeKey
{
return NO;
}
/*!
Returns \c YES if mouse events aren't needed by the receiver and can be sent to the superview. The
default implementation returns \c NO if the view is opaque.
+1 -1
View File
@@ -1321,7 +1321,7 @@ CPTexturedBackgroundWindowMask
var theWindow = [anEvent window];
if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded])
if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded] && ![_leftMouseDownView needsPanelToBecomeKey])
return [_leftMouseDownView mouseDown:anEvent];
else
{
+6 -7
View File
@@ -23,8 +23,7 @@
#include "../CoreGraphics/CGGeometry.h"
var DOMIFrameElement = nil,
DOMSpanElement = nil,
var DOMSpanElement = nil,
DefaultFont = nil;
@implementation CPPlatformString : CPBasePlatformString
@@ -48,12 +47,12 @@ var DOMIFrameElement = nil,
DOMIFrameElement.name = name = "iframe_" + FLOOR(RAND() * 10000);
DOMIFrameElement.style.position = "absolute";
DOMIFrameElement.style.left = "-100px";
DOMIFrameElement.style.top = "-100px";
DOMIFrameElement.style.width = "1px";
DOMIFrameElement.style.height = "1px";
DOMIFrameElement.style.left = "-1000px";
DOMIFrameElement.style.top = "-1000px";
// TODO: investigate a better way to make this work in IE:
DOMIFrameElement.style.width = "1000px";
DOMIFrameElement.style.height = "1000px";
DOMIFrameElement.style.borderWidth = "0px";
DOMIFrameElement.style.background = "blue";
DOMIFrameElement.style.overflow = "hidden";
DOMIFrameElement.style.zIndex = 100000000000;
+4 -4
View File
@@ -28,10 +28,10 @@ PREPARE_DOM_OPTIMIZATION();
var displayObjects = [],
displayObjectsByUID = { },
layoutObjects = [],
layoutObjectsByUID = { },
runLoop = [CPRunLoop mainRunLoop];
function _CPDisplayServerAddDisplayObject(anObject)
@@ -44,7 +44,7 @@ function _CPDisplayServerAddDisplayObject(anObject)
var index = displayObjects.length;
displayObjectsByUID[UID] = index;
displayObjects[index] = anObject;
displayObjects[index] = anObject;
}
function _CPDisplayServerAddLayoutObject(anObject)
@@ -100,7 +100,7 @@ function _CPDisplayServerAddLayoutObject(anObject)
displayObjectsByUID = { };
}
else
displayObjects = displayObjects.splice(0, index);
displayObjects.splice(0, index);
}
[runLoop performSelector:@selector(run) target:self argument:nil order:0 modes:[CPDefaultRunLoopMode]];
+16 -3
View File
@@ -1,9 +1,10 @@
#!/usr/bin/env narwhal
var FILE = require("file"),
ENV = require("system").env,
SYSTEM = require("system"),
OS = require("os"),
jake = require("jake");
jake = require("jake"),
stream = require("term").stream;
require(FILE.absolute("common.jake"));
@@ -44,7 +45,19 @@ task ("install", ["CommonJS"], function()
{
// FIXME: require("narwhal/tusk/install").install({}, $COMMONJS);
// Doesn't work due to some weird this.print business.
OS.system(["sudo", "tusk", "install", "--force", $BUILD_CJS_OBJECTIVE_J, $BUILD_CJS_CAPPUCCINO]);
if (OS.system(["tusk", "install", "--force", $BUILD_CJS_OBJECTIVE_J, $BUILD_CJS_CAPPUCCINO])) {
stream.print("\0red(Installation failed, possibly because you do not have permissions.\0)");
stream.print("\0red(Try re-running using '\0yellow(jake sudo-install\0)'.\0)");
OS.exit(1); //rake abort if ($? != 0)
}
});
task ("sudo-install", ["CommonJS"], function()
{
// FIXME: require("narwhal/tusk/install").install({}, $COMMONJS);
// Doesn't work due to some weird this.print business.
if (OS.system(["sudo", "tusk", "install", "--force", $BUILD_CJS_OBJECTIVE_J, $BUILD_CJS_CAPPUCCINO]))
OS.exit(1); //rake abort if ($? != 0)
});
// Documentation
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+6 -7
View File
@@ -13,6 +13,7 @@ var ARGS = require("args");
var FILE = require("file");
var OS = require("os");
var DOM = require("browser/dom");
var INTERPRETER = require("interpreter");
var serializer = new DOM.XMLSerializer();
@@ -148,8 +149,8 @@ function pressEnvironment(rootPath, outputFiles, environment, options) {
CPLog.info("Environment: " + environment);
// get a Rhino context
var ctx = Packages.org.mozilla.javascript.Context.getCurrentContext();
var scope = makeObjjScope(ctx); // "scope" is the same as require("objective-j").window;
var context = new INTERPRETER.Context();
var scope = setupObjectiveJ(context);
scope.OBJJ_INCLUDE_PATHS = frameworks;
scope.OBJJ_ENVIRONMENTS = [environment, "ObjJ"];
@@ -178,11 +179,9 @@ function pressEnvironment(rootPath, outputFiles, environment, options) {
exectuableResponses.push(aResponse);
});
var context = {
ctx : ctx,
scope : scope,
rootPath : rootPath
};
// lets just use the Context object as our con
context.rootPath = rootPath;
context.scope = scope;
// phase 1: get global defines
CPLog.error("PHASE 1: Loading application...");
+51 -40
View File
@@ -2,8 +2,7 @@ var FILE = require("file");
/*
param context includes
scope: a global variable containing objj_files hash
ctx: js context
scope: the objective-j scope
dependencies: hash mapping from paths to an array of global variables defined by that file
[importCallback]: callback function that is called for each imported file (takes importing file path, and imported file path parameters)
[referencedCallback]: callback function that is called for each referenced file (takes referencing file path, referenced file path parameters, and list of tokens)
@@ -199,8 +198,27 @@ function findImportInObjjFiles(scope, fragment)
return importPath;
}
@implementation PressBundleDelgate : CPObject
{
Function didFinishLoadingCallback;
}
- (id)initWithCallback:(Function)aCallback
{
if (self = [super init]) {
didFinishLoadingCallback = aCallback;
}
return self;
}
- (void)bundleDidFinishLoading:(CPBundle)aBundle
{
print("didFinishLoading: "+aBundle);
if (didFinishLoadingCallback)
didFinishLoadingCallback(aBundle);
}
@end
// given a fresh scope and the path to a root source file, determine which files define each global variable
function findGlobalDefines(context, mainPath, evaledFragments)
function findGlobalDefines(context, mainPath, evaledFragments, bundleCallback)
{
var ignore = cloneProperties(context.scope, true);
ignore['bundle'] = true;
@@ -245,17 +263,30 @@ function findGlobalDefines(context, mainPath, evaledFragments)
return result;
}
runWithScope(context, function(importName) {
objj_import(importName, true, function() {
// Doesn't work due to lack of complete browser environment
//[_CPAppBootstrapper loadDefaultTheme];
var themePath = [[CPBundle bundleForClass:[CPApplication class]] pathForResource:[CPApplication defaultThemeName]];
var themeBundle = [[CPBundle alloc] initWithPath:themePath + "/Info.plist"];
[themeBundle loadWithDelegate:nil];
// FIXME: doesn't use objj_search mechanism. need to hook CPBundle or CPURLConnection instead.
});
}, [mainPath]);
var bundleDelegate = [[PressBundleDelgate alloc] initWithCallback:bundleCallback];
var bundlePaths = [];
(context.eval("("+(function(mainPath, bundleDelegate, bundlePaths) {
with (require("objective-j").window) {
objj_import(mainPath, true, function() {
bundlePaths = bundlePaths || [];
// load default theme bundle
var themePath = [[CPBundle bundleForClass:[CPApplication class]] pathForResource:[CPApplication defaultThemeName]];
var themeBundle = [[CPBundle alloc] initWithPath:themePath + "/Info.plist"];
[themeBundle loadWithDelegate:bundleDelegate];
// load additional bundles
bundlePaths.forEach(function(bundlePath) {
var bundle = [[CPBundle alloc] initWithPath:bundlePath];
[bundle loadWithDelegate:bundleDelegate];
});
});
}
})+")"))(mainPath, bundleDelegate, bundlePaths);
// run the "event loop"
context.scope.require('browser/timeout').serviceTimeouts();
return dependencies;
}
@@ -282,26 +313,18 @@ function coalesceGlobalDefines(globals)
}
// create a new scope loaded with Narwhal and Objective-J
function makeObjjScope(ctx, debug)
function setupObjectiveJ(context, debug)
{
// init standard JS scope objects
var scope = ctx.initStandardObjects();
// set these properties required for Narwhal bootstrapping
scope.NARWHAL_HOME = system.prefix;
scope.NARWHAL_ENGINE_HOME = FILE.join(system.prefix, "engines", "rhino");
context.global.NARWHAL_HOME = system.prefix;
context.global.NARWHAL_ENGINE_HOME = FILE.join(system.prefix, "engines", "rhino");
// load the bootstrap.js for narwhal-rhino
var bootstrapPath = FILE.join(scope.NARWHAL_ENGINE_HOME, "bootstrap.js");
ctx.evaluateReader(scope,
new Packages.java.io.FileReader(bootstrapPath),
"bootstrap.js",
1,
null
);
var bootstrapPath = FILE.join(context.global.NARWHAL_ENGINE_HOME, "bootstrap.js");
context.evalFile(bootstrapPath);
// get the Objective-J module from this scope, return the window object.
var OBJJ = scope.require("objective-j");
var OBJJ = context.global.require("objective-j");
addMockBrowserEnvironment(OBJJ.window);
@@ -335,18 +358,6 @@ function addMockBrowserEnvironment(scope)
}
}
// run a function within the given scope (func can be a function object if the source of the function is returned by toString() as it is by default)
function runWithScope(context, func, args)
{
var functionInScope = context.ctx.compileFunction(context.scope, String(func), "<runWithScope>", 1, null);
var result = functionInScope.apply(context.scope, args);
context.scope.require('browser/timeout').serviceTimeouts();
return result;
}
// does a shallow copy of an object. if onlyList is true, it sets each property to "true" instead of the actual value
function cloneProperties(object, onlyList)
{