diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index ef77ea021..619c12d08 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -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; } diff --git a/AppKit/CPView.j b/AppKit/CPView.j index e865737b2..a112d62ca 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -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. diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 07d9f38f4..84fff9816 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -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 { diff --git a/AppKit/Platform/DOM/CPPlatformString.j b/AppKit/Platform/DOM/CPPlatformString.j index 4e3920aa3..595ae184c 100644 --- a/AppKit/Platform/DOM/CPPlatformString.j +++ b/AppKit/Platform/DOM/CPPlatformString.j @@ -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; diff --git a/AppKit/_CPDisplayServer.j b/AppKit/_CPDisplayServer.j index c2dfb3e1e..294e06898 100644 --- a/AppKit/_CPDisplayServer.j +++ b/AppKit/_CPDisplayServer.j @@ -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]]; diff --git a/Jakefile b/Jakefile index d6e0210a5..54161d8b7 100644 --- a/Jakefile +++ b/Jakefile @@ -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 diff --git a/Tests/AttachedSheet/AppController.j b/Tests/Manual/AttachedSheet/AppController.j similarity index 100% rename from Tests/AttachedSheet/AppController.j rename to Tests/Manual/AttachedSheet/AppController.j diff --git a/Tests/AttachedSheet/Info.plist b/Tests/Manual/AttachedSheet/Info.plist similarity index 100% rename from Tests/AttachedSheet/Info.plist rename to Tests/Manual/AttachedSheet/Info.plist diff --git a/Tests/AttachedSheet/Rakefile b/Tests/Manual/AttachedSheet/Rakefile similarity index 100% rename from Tests/AttachedSheet/Rakefile rename to Tests/Manual/AttachedSheet/Rakefile diff --git a/Tests/AttachedSheet/Resources/spinner.gif b/Tests/Manual/AttachedSheet/Resources/spinner.gif similarity index 100% rename from Tests/AttachedSheet/Resources/spinner.gif rename to Tests/Manual/AttachedSheet/Resources/spinner.gif diff --git a/Tests/AttachedSheet/index-debug.html b/Tests/Manual/AttachedSheet/index-debug.html similarity index 100% rename from Tests/AttachedSheet/index-debug.html rename to Tests/Manual/AttachedSheet/index-debug.html diff --git a/Tests/AttachedSheet/index.html b/Tests/Manual/AttachedSheet/index.html similarity index 100% rename from Tests/AttachedSheet/index.html rename to Tests/Manual/AttachedSheet/index.html diff --git a/Tests/AttachedSheet/main.j b/Tests/Manual/AttachedSheet/main.j similarity index 100% rename from Tests/AttachedSheet/main.j rename to Tests/Manual/AttachedSheet/main.j diff --git a/Tests/CPCursor/AppController.j b/Tests/Manual/CPCursor/AppController.j similarity index 100% rename from Tests/CPCursor/AppController.j rename to Tests/Manual/CPCursor/AppController.j diff --git a/Tests/CPCursor/Info.plist b/Tests/Manual/CPCursor/Info.plist similarity index 100% rename from Tests/CPCursor/Info.plist rename to Tests/Manual/CPCursor/Info.plist diff --git a/Tests/CPCursor/Jakefile b/Tests/Manual/CPCursor/Jakefile similarity index 100% rename from Tests/CPCursor/Jakefile rename to Tests/Manual/CPCursor/Jakefile diff --git a/Tests/CPCursor/Resources/spinner.gif b/Tests/Manual/CPCursor/Resources/spinner.gif similarity index 100% rename from Tests/CPCursor/Resources/spinner.gif rename to Tests/Manual/CPCursor/Resources/spinner.gif diff --git a/Tests/CPCursor/index-debug.html b/Tests/Manual/CPCursor/index-debug.html similarity index 100% rename from Tests/CPCursor/index-debug.html rename to Tests/Manual/CPCursor/index-debug.html diff --git a/Tests/CPCursor/index.html b/Tests/Manual/CPCursor/index.html similarity index 100% rename from Tests/CPCursor/index.html rename to Tests/Manual/CPCursor/index.html diff --git a/Tests/CPCursor/main.j b/Tests/Manual/CPCursor/main.j similarity index 100% rename from Tests/CPCursor/main.j rename to Tests/Manual/CPCursor/main.j diff --git a/Tests/CPSearchField/AppController.j b/Tests/Manual/CPSearchField/AppController.j similarity index 100% rename from Tests/CPSearchField/AppController.j rename to Tests/Manual/CPSearchField/AppController.j diff --git a/Tests/CPSearchField/Info.plist b/Tests/Manual/CPSearchField/Info.plist similarity index 100% rename from Tests/CPSearchField/Info.plist rename to Tests/Manual/CPSearchField/Info.plist diff --git a/Tests/CPSearchField/index-debug.html b/Tests/Manual/CPSearchField/index-debug.html similarity index 100% rename from Tests/CPSearchField/index-debug.html rename to Tests/Manual/CPSearchField/index-debug.html diff --git a/Tests/CPSearchField/index.html b/Tests/Manual/CPSearchField/index.html similarity index 100% rename from Tests/CPSearchField/index.html rename to Tests/Manual/CPSearchField/index.html diff --git a/Tests/CPSearchField/main.j b/Tests/Manual/CPSearchField/main.j similarity index 100% rename from Tests/CPSearchField/main.j rename to Tests/Manual/CPSearchField/main.j diff --git a/Tests/TableCibTest/AppController.j b/Tests/Manual/TableCibTest/AppController.j similarity index 100% rename from Tests/TableCibTest/AppController.j rename to Tests/Manual/TableCibTest/AppController.j diff --git a/Tests/TableCibTest/Info.plist b/Tests/Manual/TableCibTest/Info.plist similarity index 100% rename from Tests/TableCibTest/Info.plist rename to Tests/Manual/TableCibTest/Info.plist diff --git a/Tests/TableCibTest/Rakefile b/Tests/Manual/TableCibTest/Rakefile similarity index 100% rename from Tests/TableCibTest/Rakefile rename to Tests/Manual/TableCibTest/Rakefile diff --git a/Tests/TableCibTest/Resources/MainMenu.cib b/Tests/Manual/TableCibTest/Resources/MainMenu.cib similarity index 100% rename from Tests/TableCibTest/Resources/MainMenu.cib rename to Tests/Manual/TableCibTest/Resources/MainMenu.cib diff --git a/Tests/TableCibTest/Resources/MainMenu.xib b/Tests/Manual/TableCibTest/Resources/MainMenu.xib similarity index 100% rename from Tests/TableCibTest/Resources/MainMenu.xib rename to Tests/Manual/TableCibTest/Resources/MainMenu.xib diff --git a/Tests/TableCibTest/Resources/spinner.gif b/Tests/Manual/TableCibTest/Resources/spinner.gif similarity index 100% rename from Tests/TableCibTest/Resources/spinner.gif rename to Tests/Manual/TableCibTest/Resources/spinner.gif diff --git a/Tests/TableCibTest/index-debug.html b/Tests/Manual/TableCibTest/index-debug.html similarity index 100% rename from Tests/TableCibTest/index-debug.html rename to Tests/Manual/TableCibTest/index-debug.html diff --git a/Tests/TableCibTest/index.html b/Tests/Manual/TableCibTest/index.html similarity index 100% rename from Tests/TableCibTest/index.html rename to Tests/Manual/TableCibTest/index.html diff --git a/Tests/TableCibTest/main.j b/Tests/Manual/TableCibTest/main.j similarity index 100% rename from Tests/TableCibTest/main.j rename to Tests/Manual/TableCibTest/main.j diff --git a/Tests/TableTest/AppController.j b/Tests/Manual/TableTest/AppController.j similarity index 100% rename from Tests/TableTest/AppController.j rename to Tests/Manual/TableTest/AppController.j diff --git a/Tests/TableTest/Info.plist b/Tests/Manual/TableTest/Info.plist similarity index 100% rename from Tests/TableTest/Info.plist rename to Tests/Manual/TableTest/Info.plist diff --git a/Tests/TableTest/Rakefile b/Tests/Manual/TableTest/Rakefile similarity index 100% rename from Tests/TableTest/Rakefile rename to Tests/Manual/TableTest/Rakefile diff --git a/Tests/TableTest/Resources/spinner.gif b/Tests/Manual/TableTest/Resources/spinner.gif similarity index 100% rename from Tests/TableTest/Resources/spinner.gif rename to Tests/Manual/TableTest/Resources/spinner.gif diff --git a/Tests/TableTest/index-debug.html b/Tests/Manual/TableTest/index-debug.html similarity index 100% rename from Tests/TableTest/index-debug.html rename to Tests/Manual/TableTest/index-debug.html diff --git a/Tests/TableTest/index.html b/Tests/Manual/TableTest/index.html similarity index 100% rename from Tests/TableTest/index.html rename to Tests/Manual/TableTest/index.html diff --git a/Tests/TableTest/main.j b/Tests/Manual/TableTest/main.j similarity index 100% rename from Tests/TableTest/main.j rename to Tests/Manual/TableTest/main.j diff --git a/Tools/press/main.j b/Tools/press/main.j index 2b9e57f13..f92270a50 100644 --- a/Tools/press/main.j +++ b/Tools/press/main.j @@ -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..."); diff --git a/Tools/press/objj-analysis-tools.j b/Tools/press/objj-analysis-tools.j index 8c6c68523..344148bc8 100644 --- a/Tools/press/objj-analysis-tools.j +++ b/Tools/press/objj-analysis-tools.j @@ -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), "", 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) {