mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-20 21:49:22 +00:00
Merge branch 'master' into tableview
Conflicts: AppKit/CPView.j
This commit is contained in:
commit
369e02fb37
5 files changed
+88
-39
No files matched your search
+12
-17
@@ -684,11 +684,6 @@ var _CPMenuBarVisible = NO,
|
||||
|
||||
[_CPMenuWindow poolMenuWindow:aMenuWindow];
|
||||
|
||||
var delegate = [menu delegate];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(menuDidClose:)])
|
||||
[delegate menuDidClose:menu];
|
||||
|
||||
if([aMenuItem isEnabled])
|
||||
[CPApp sendAction:[aMenuItem action] to:[aMenuItem target] from:aMenuItem];
|
||||
}
|
||||
@@ -1259,23 +1254,23 @@ var STICKY_TIME_INTERVAL = 500,
|
||||
|
||||
[menu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
// Clear these now so its faster next time around.
|
||||
[_menuView setMenu:nil];
|
||||
|
||||
[self orderOut:self];
|
||||
|
||||
if (_sessionDelegate && _didEndSelector)
|
||||
objj_msgSend(_sessionDelegate, _didEndSelector, self, highlightedItem);
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPMenuDidEndTrackingNotification
|
||||
object:menu];
|
||||
|
||||
|
||||
var delegate = [menu delegate];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(menuDidClose:)])
|
||||
[delegate menuDidClose:menu];
|
||||
|
||||
|
||||
if (_sessionDelegate && _didEndSelector)
|
||||
objj_msgSend(_sessionDelegate, _didEndSelector, self, highlightedItem);
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPMenuDidEndTrackingNotification
|
||||
object:menu];
|
||||
|
||||
// Clear these now so its faster next time around.
|
||||
[_menuView setMenu:nil];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+11
-2
@@ -570,6 +570,15 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
element.style.font = [[self currentValueForThemeAttribute:@"font"] cssString];
|
||||
element.style.zIndex = 1000;
|
||||
|
||||
switch ([self alignment])
|
||||
{
|
||||
case CPCenterTextAlignment: element.style.textAlign = "center";
|
||||
break;
|
||||
case CPRightTextAlignment: element.style.textAlign = "right";
|
||||
break;
|
||||
default: element.style.textAlign = "left";
|
||||
}
|
||||
|
||||
var contentRect = [self contentRectForBounds:[self bounds]];
|
||||
|
||||
element.style.top = _CGRectGetMinY(contentRect) + "px";
|
||||
@@ -763,8 +772,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
#if PLATFORM(DOM)
|
||||
var element = [self _inputElement];
|
||||
|
||||
if (element.parentNode == _DOMElement && ([self isEditable] || [self isSelectable]))
|
||||
element.select();
|
||||
if (element.parentNode === _DOMElement && ([self isEditable] || [self isSelectable]))
|
||||
window.setTimeout(function() { element.select(); }, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -233,6 +233,11 @@ var CPViewFlags = { },
|
||||
_viewClassFlags = CPViewFlags[classUID];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingFrame
|
||||
{
|
||||
return [CPSet setWithObjects:@"frameOrigin", @"frameSize"];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithFrame:CGRectMakeZero()];
|
||||
@@ -649,6 +654,16 @@ var CPViewFlags = { },
|
||||
return _CGRectMakeCopy(_frame);
|
||||
}
|
||||
|
||||
- (CGPoint)frameOrigin
|
||||
{
|
||||
return _CGPointMakeCopy(_frame.origin);
|
||||
}
|
||||
|
||||
- (CGSize)frameSize
|
||||
{
|
||||
return _CGSizeMakeCopy(_frame.size);
|
||||
}
|
||||
|
||||
/*!
|
||||
Moves the center of the receiver's frame to the provided point. The point is defined in the superview's coordinate system.
|
||||
The method posts a CPViewFrameDidChangeNotification to the default notification center if the receiver
|
||||
|
||||
@@ -68,8 +68,8 @@
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingValueForKey:(CPString)aKey
|
||||
{
|
||||
var capitalizedKey = aKey.charAt(0).toUpperCase()+aKey.substring(1);
|
||||
selector = "keyPathsForValuesAffectingValueFor"+capitalizedKey;
|
||||
var capitalizedKey = aKey.charAt(0).toUpperCase() + aKey.substring(1);
|
||||
selector = "keyPathsForValuesAffecting" + capitalizedKey;
|
||||
|
||||
if ([[self class] respondsToSelector:selector])
|
||||
return objj_msgSend([self class], selector);
|
||||
@@ -202,17 +202,12 @@ var KVOProxyMap = [CPDictionary dictionary],
|
||||
var theMethod = class_getInstanceMethod(_nativeClass, theSelector);
|
||||
|
||||
class_addMethod(_targetObject.isa, theSelector, theReplacementMethod(aKey, theMethod), "");
|
||||
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
return;
|
||||
var affectingKeys = [[_nativeClass keyPathsForValuesAffectingValueForKey:aKey] allObjects];
|
||||
|
||||
var composedOfKeys = [[_nativeClass keyPathsForValuesAffectingValueForKey:aKey] allObjects];
|
||||
|
||||
if (!composedOfKeys)
|
||||
if (![affectingKeys count])
|
||||
return;
|
||||
|
||||
var dependentKeysForClass = [DependentKeysMap objectForKey:[_nativeClass UID]];
|
||||
@@ -223,19 +218,21 @@ var KVOProxyMap = [CPDictionary dictionary],
|
||||
[DependentKeysMap setObject:dependentKeysForClass forKey:[_nativeClass UID]];
|
||||
}
|
||||
|
||||
for (var i=0, count=composedOfKeys.length; i<count; i++)
|
||||
{
|
||||
var componentKey = composedOfKeys[i],
|
||||
keysComposedOfKey = [dependentKeysForClass objectForKey:componentKey];
|
||||
var count = [affectingKeys count];
|
||||
|
||||
if (!keysComposedOfKey)
|
||||
while (count--)
|
||||
{
|
||||
var affectingKey = affectingKeys[count],
|
||||
affectedKeys = [dependentKeysForClass objectForKey:affectingKey];
|
||||
|
||||
if (!affectedKeys)
|
||||
{
|
||||
keysComposedOfKey = [CPSet new];
|
||||
[dependentKeysForClass setObject:keysComposedOfKey forKey:componentKey];
|
||||
affectedKeys = [CPSet new];
|
||||
[dependentKeysForClass setObject:affectedKeys forKey:affectingKey];
|
||||
}
|
||||
|
||||
[keysComposedOfKey addObject:aKey];
|
||||
[self _replaceSetterForKey:componentKey];
|
||||
[affectedKeys addObject:aKey];
|
||||
[self _replaceSetterForKey:affectingKey];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
id obj;
|
||||
id cs101;
|
||||
id focus;
|
||||
|
||||
CPInteger observationCount;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
@@ -361,6 +363,21 @@
|
||||
//[self assertTrue: (secondTotal < total*4) message: "Overhead of one observer exceeded 400%. first: "+total+" second: "+secondTotal+" %"+FLOOR(secondTotal/total*100)];
|
||||
}
|
||||
|
||||
- (void)testDependentKeysPaths
|
||||
{
|
||||
var object = [[TestObject alloc] init];
|
||||
|
||||
[object addObserver:self forKeyPath:@"key" options:0 context:"testDependentKeysPaths"];
|
||||
|
||||
observationCount = 0;
|
||||
|
||||
[object setKey:@"value"];
|
||||
[object setAffectingKey:@"value"];
|
||||
[object setOtherAffectingKey:@"value"];
|
||||
|
||||
[self assert:observationCount equals:3];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(CPString)aKeyPath ofObject:(id)anObject change:(CPDictionary)changes context:(id)aContext
|
||||
{
|
||||
var oldValue = [changes objectForKey:CPKeyValueChangeOldKey],
|
||||
@@ -368,6 +385,8 @@
|
||||
|
||||
switch (aContext)
|
||||
{
|
||||
case "testDependentKeysPaths": ++observationCount;
|
||||
break;
|
||||
case "testAddObserver":
|
||||
[self assertTrue: newValue == "set_bob" message: "newValue should be: set_bob was: "+newValue];
|
||||
[self assertTrue: oldValue == [CPNull null] message: "oldValue should be CPNull was: "+oldValue];
|
||||
@@ -522,7 +541,7 @@
|
||||
CarTester car;
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingValueForBobName
|
||||
+ (CPSet)keyPathsForValuesAffectingBobName
|
||||
{
|
||||
return [CPSet setWithObject:"name"];
|
||||
}
|
||||
@@ -621,4 +640,18 @@
|
||||
{
|
||||
id g;
|
||||
}
|
||||
@end
|
||||
@end
|
||||
|
||||
@implementation TestObject : CPObject
|
||||
{
|
||||
CPString key @accessors;
|
||||
CPString affectingKey @accessors;
|
||||
CPString otherAffectingKey @accessors;
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingKey
|
||||
{
|
||||
return [CPSet setWithObjects:@"affectingKey", @"otherAffectingKey"];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user