diff --git a/AppKit/CPAlert.j b/AppKit/CPAlert.j index 6e41f149b..75b63ce9d 100644 --- a/AppKit/CPAlert.j +++ b/AppKit/CPAlert.j @@ -149,7 +149,7 @@ var CPAlertWarningImage, [_alertPanel setFloatingPanel:YES]; [_alertPanel center]; - [_messageLabel setTextColor:(styleMask == CPHUDBackgroundWindowMask) ? [CPColor whiteColor] : [CPColor blackColor]]; + [_messageLabel setTextColor:(styleMask & CPHUDBackgroundWindowMask) ? [CPColor whiteColor] : [CPColor blackColor]]; var count = [_buttons count]; for(var i=0; i < count; i++) @@ -157,7 +157,7 @@ var CPAlertWarningImage, var button = _buttons[i]; [button setFrameSize:CGSizeMake([button frame].size.width, (styleMask == CPHUDBackgroundWindowMask) ? 20.0 : 24.0)]; - [button setBezelStyle:(styleMask == CPHUDBackgroundWindowMask) ? CPHUDBezelStyle : CPRoundedBezelStyle]; + [button setBezelStyle:(styleMask & CPHUDBackgroundWindowMask) ? CPHUDBezelStyle : CPRoundedBezelStyle]; [[_alertPanel contentView] addSubview:button]; } diff --git a/AppKit/CPBox.j b/AppKit/CPBox.j index 2a0f45ff2..05500b550 100644 --- a/AppKit/CPBox.j +++ b/AppKit/CPBox.j @@ -58,7 +58,9 @@ CPGrooveBorder = 3; - (id)initWithFrame:(CPRect)frameRect { - if (self = [super initWithFrame:frameRect]) + self = [super initWithFrame:frameRect]; + + if (self) { _fillColor = [CPColor clearColor]; _borderColor = [CPColor blackColor]; diff --git a/AppKit/CPCompatibility.j b/AppKit/CPCompatibility.j index b381cd359..2539b2ab1 100644 --- a/AppKit/CPCompatibility.j +++ b/AppKit/CPCompatibility.j @@ -114,7 +114,7 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1) majorVersion = parseInt(versionString.substring(0, versionDivision)), minorVersion = parseInt(versionString.substr(versionDivision + 1)); - if((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion >= 525 && minorVersion > 14)) || USER_AGENT.indexOf("Chrome") !== CPNotFound) + if((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion > 525 || (majorVersion === 525 && minorVersion > 14))) || USER_AGENT.indexOf("Chrome") !== CPNotFound) PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport; } diff --git a/AppKit/CPImage.j b/AppKit/CPImage.j index e42bf35b1..bd9e746fa 100644 --- a/AppKit/CPImage.j +++ b/AppKit/CPImage.j @@ -90,6 +90,11 @@ function CPImageInBundle(aFilename, aSize, aBundle) Image _image; } +- (id)init +{ + return [self initByReferencingFile:@"" size:CGSizeMake(-1, -1)]; +} + /*! Initializes the image, by associating it with a filename. The image denoted in \c aFilename is not actually loaded. It will @@ -98,7 +103,7 @@ function CPImageInBundle(aFilename, aSize, aBundle) @param aSize the image's size @return the initialized image */ -- (CPImage)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize +- (id)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize { self = [super init]; @@ -118,7 +123,7 @@ function CPImageInBundle(aFilename, aSize, aBundle) @param aSize the size of the image @return the initialized image. */ -- (CPImage)initWithContentsOfFile:(CPString)aFilename size:(CGSize)aSize +- (id)initWithContentsOfFile:(CPString)aFilename size:(CGSize)aSize { self = [self initByReferencingFile:aFilename size:aSize]; @@ -134,9 +139,9 @@ function CPImageInBundle(aFilename, aSize, aBundle) @param aFilename the file name of the image @return the initialized image */ -- (CPImage)initWithContentsOfFile:(CPString)aFilename +- (id)initWithContentsOfFile:(CPString)aFilename { - self = [self initByReferencingFile:aFilename size: CGSizeMake(-1, -1)]; + self = [self initByReferencingFile:aFilename size:CGSizeMake(-1, -1)]; if (self) [self load]; diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j index b738729ed..2a35aceb2 100644 --- a/AppKit/CPMenuItem.j +++ b/AppKit/CPMenuItem.j @@ -78,6 +78,11 @@ _CPMenuItemView _menuItemView; } +- (id)init +{ + return [self initWithTitle:@"" action:nil keyEquivalent:nil]; +} + /*! Initializes the menu item with a title, action, and keyboard equivalent. @param aTitle the menu item's title diff --git a/AppKit/CPTabViewItem.j b/AppKit/CPTabViewItem.j index 0ebc4a5e0..356f4f1af 100644 --- a/AppKit/CPTabViewItem.j +++ b/AppKit/CPTabViewItem.j @@ -60,6 +60,11 @@ CPPressedTab = 2; CPView _auxiliaryView; } +- (id)init +{ + return [self initWithIdentifier:@""]; +} + /*! Initializes the tab view item with the specified identifier. @return the initialized CPTabViewItem diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index aaf50090b..9653af630 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -62,6 +62,11 @@ CPTableColumnUserResizingMask = 2; CPString _headerToolTip; } +- (id)init +{ + return [self initWithIdentifier:@""]; +} + - (id)initWithIdentifier:(id)anIdentifier { self = [super init]; diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index b4dc02792..0303ee1bb 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -239,11 +239,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); return true; } - CPTextFieldKeyDownFunction = function(anEvent) + CPTextFieldKeyDownFunction = function(aDOMEvent) { CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue]; - CPTextFieldKeyPressFunction(anEvent); + aDOMEvent = aDOMEvent || window.event; + + if (aDOMEvent.keyCode == CPReturnKeyCode || aDOMEvent.keyCode == CPTabKeyCode) + CPTextFieldKeyPressFunction(aDOMEvent); return true; } @@ -252,6 +255,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); { aDOMEvent = aDOMEvent || window.event; + CPTextFieldKeyUpFunction(); + if (aDOMEvent.keyCode == CPReturnKeyCode || aDOMEvent.keyCode == CPTabKeyCode) { if (aDOMEvent.preventDefault) @@ -274,19 +279,19 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); else [[owner window] selectPreviousKeyView:owner]; } - } + } [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; } CPTextFieldKeyUpFunction = function() { - [CPTextFieldInputOwner setStringValue:CPTextFieldDOMInputElement.value]; + [CPTextFieldInputOwner _setStringValue:CPTextFieldDOMInputElement.value]; if ([CPTextFieldInputOwner stringValue] !== CPTextFieldTextDidChangeValue) { - CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue]; [CPTextFieldInputOwner textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:CPTextFieldInputOwner userInfo:nil]]; + CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue]; } [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; @@ -551,8 +556,10 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); /* @ignore */ - (BOOL)becomeFirstResponder { +#if PLATFORM(DOM) if (CPTextFieldInputOwner && [CPTextFieldInputOwner window] !== [self window]) [[CPTextFieldInputOwner window] makeFirstResponder:nil]; +#endif [self setThemeState:CPThemeStateEditing]; @@ -590,7 +597,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); window.setTimeout(function() { - element.focus(); + element.value = [self stringValue]; + element.focus(); CPTextFieldInputOwner = self; }, 0.0); @@ -681,10 +689,21 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); /* @ignore */ +- (void)_setStringValue:(id)aValue +{ + [super setObjectValue:String(aValue)]; + [self _updatePlaceholderState]; +} + - (void)setObjectValue:(id)aValue { [super setObjectValue:aValue]; +#if PLATFORM(DOM) + if (CPTextFieldInputOwner === self) + [self _inputElement].value = aValue; +#endif + [self _updatePlaceholderState]; } diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index 6bcff4a60..8f019a2f8 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -128,6 +128,11 @@ var CPToolbarConfigurationsByIdentifier = nil; [toolbarsSharingIdentifier addObject:toolbar]; } +- (id)init +{ + return [self initWithIdentifier:@""]; +} + /*! Initializes the toolbar with the specified identifier. @param anIdentifier the identifier for the toolbar diff --git a/AppKit/CPToolbarItem.j b/AppKit/CPToolbarItem.j index 64c4aea7c..7c1ac52bc 100644 --- a/AppKit/CPToolbarItem.j +++ b/AppKit/CPToolbarItem.j @@ -86,6 +86,11 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; int _visibilityPriority; } +- (id)init +{ + return [self initWithItemIdentifier:@""]; +} + // Creating a Toolbar Item /*! Initializes the toolbar item with a specified identifier. diff --git a/Objective-J/evaluate.js b/Objective-J/evaluate.js index 50a902d63..02e33aaf3 100644 --- a/Objective-J/evaluate.js +++ b/Objective-J/evaluate.js @@ -159,7 +159,7 @@ function fragment_evaluate_code(aFragment) { #if RHINO var functionText = "function(){"+GET_CODE(aFragment)+"/**/\n}"; - if (system.engine === "rhino") + if (typeof system !== "undefined" && system.engine === "rhino") compiled = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, functionText, GET_FILE(aFragment).path, 0, null); else compiled = eval(functionText);