From b1c99a5f0a1826bce63c9126c36fae47f7c4d0f8 Mon Sep 17 00:00:00 2001 From: Will Larson Date: Sun, 7 Sep 2008 09:43:28 -0400 Subject: [PATCH 01/20] Added placeholder and setPlaceholder methods to CPTextField, to facilitate displaying placeholder text for textfields before user has entered text. May want to consider changing text color while displaying placeholder text. --- AppKit/CPTextField.j | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 67064bb9e..23cddb8f3 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -66,6 +66,7 @@ var _CPTextFieldSquareBezelColor = nil; BOOL _isSelectable; id _value; + id _placeholderString; CPLineBreakMode _lineBreakMode; #if PLATFORM(DOM) @@ -104,7 +105,8 @@ var _CPTextFieldSquareBezelColor = nil; if (self) { _value = @""; - + _placeholderValue = @""; + #if PLATFORM(DOM) _DOMTextElement = document.createElement("div"); _DOMTextElement.style.position = "absolute"; @@ -245,6 +247,12 @@ var _CPTextFieldSquareBezelColor = nil; [[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES]; + // If current value is the placeholder value, remove it to + // allow user to update. + if ([_value caseInsensitiveCompare:[self placeholderString]]==0) { + [self setStringValue:@""]; + } + return YES; } @@ -254,6 +262,11 @@ var _CPTextFieldSquareBezelColor = nil; _DOMElement.removeChild(element); [self setStringValue:element.value]; + + // If textfield has no value, then display the placeholderValue + if ([_value caseInsensitiveCompare:@""]==0) { + [self setStringValue:[self placeholderString]]; + } return YES; } @@ -354,6 +367,24 @@ var _CPTextFieldSquareBezelColor = nil; #endif } +- (CPString)placeholderString +{ + return [_placeholderString string]; +} + +-(void)setPlaceholderString:(CPString)aStringValue +{ + _placeholderString = aStringValue; +#if PLATFORM(DOM) + var cssString = _value ? [_value cssString] : @""; + + if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature)) + _DOMTextElement.innerText = cssString; + else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature)) + _DOMTextElement.textContent = cssString; +#endif +} + - (void)sizeToFit { #if PLATFORM(DOM) From c5415eae0503db309b8692b1854246372a22268e Mon Sep 17 00:00:00 2001 From: Will Larson Date: Sun, 7 Sep 2008 10:35:17 -0400 Subject: [PATCH 02/20] In attempt to mimic existing code, inadvertantly mimicked too much. Removing unnecessary lines. --- AppKit/CPTextField.j | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 23cddb8f3..03d724284 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -8,7 +8,7 @@ * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. +c * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -375,14 +375,6 @@ var _CPTextFieldSquareBezelColor = nil; -(void)setPlaceholderString:(CPString)aStringValue { _placeholderString = aStringValue; -#if PLATFORM(DOM) - var cssString = _value ? [_value cssString] : @""; - - if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature)) - _DOMTextElement.innerText = cssString; - else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature)) - _DOMTextElement.textContent = cssString; -#endif } - (void)sizeToFit From 05811ca9658ea0af9b3820574338f4c37e4089e1 Mon Sep 17 00:00:00 2001 From: Vijay Duvvuri Date: Wed, 10 Sep 2008 19:40:54 +0200 Subject: [PATCH 03/20] - Added method rangeOfString:options:range: - Updated rangeOfString:options to call rangeOfString:options:range - Updated rangeOfString: to call rangeOfString:options --- Foundation/CPString.j | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index d52d3df7f..821668ee6 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -125,14 +125,17 @@ var CPStringHashes = new objj_dictionary(); - (CPRange)rangeOfString:(CPString)aString { - var location = indexOf(aString); - - return CPMakeRange(location, location == CPNotFound ? 0 : aString.length); + return [self rangeOfString:aString options:0]; } - (CPRange)rangeOfString:(CPString)aString options:(int)aMask { - var string = self, + return [self rangeOfString:aString options:aMask range:nil]; +} + +- (CPRange)rangeOfString:(CPString)aString options:(int)aMask range:(CPrange)aRange +{ + var string = (aRange == nil)?self:[self substringWithRange:aRange], location = CPNotFound; if (aMask & CPCaseInsensitiveSearch) @@ -141,9 +144,9 @@ var CPStringHashes = new objj_dictionary(); aString = aString.toLowerCase(); } - if (CPBackwardsSearch) location = lastIndexOf(aString, aMask & CPAnchoredSearch ? length - aString.length : 0); - else if (aMask & CPAnchoredSearch) location = substr(0, aString.length).indexOf(aString) != CPNotFound ? 0 : CPNotFound; - else location = indexOf(aString); + if (aMask & CPBackwardsSearch) location = string.lastIndexOf(aString, aMask & CPAnchoredSearch ? length - aString.length : 0); + else if (aMask & CPAnchoredSearch) location = string.substr(0, aString.length).indexOf(aString) != CPNotFound ? 0 : CPNotFound; + else location = string.indexOf(aString); return CPMakeRange(location, location == CPNotFound ? 0 : aString.length); } From 8aed3787fd5a1caf1ecd7c17cf5ce26ca7f095ac Mon Sep 17 00:00:00 2001 From: Vijay Duvvuri Date: Sat, 13 Sep 2008 11:09:09 +0200 Subject: [PATCH 04/20] - Added new line after if/else/else if --- Foundation/CPString.j | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index 821668ee6..ec431ea63 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -144,9 +144,12 @@ var CPStringHashes = new objj_dictionary(); aString = aString.toLowerCase(); } - if (aMask & CPBackwardsSearch) location = string.lastIndexOf(aString, aMask & CPAnchoredSearch ? length - aString.length : 0); - else if (aMask & CPAnchoredSearch) location = string.substr(0, aString.length).indexOf(aString) != CPNotFound ? 0 : CPNotFound; - else location = string.indexOf(aString); + if (aMask & CPBackwardsSearch) + location = string.lastIndexOf(aString, aMask & CPAnchoredSearch ? length - aString.length : 0); + else if (aMask & CPAnchoredSearch) + location = string.substr(0, aString.length).indexOf(aString) != CPNotFound ? 0 : CPNotFound; + else + location = string.indexOf(aString); return CPMakeRange(location, location == CPNotFound ? 0 : aString.length); } @@ -268,7 +271,7 @@ var CPStringHashes = new objj_dictionary(); - (CPString)stringByDeletingLastPathComponent { - // FIMXE: this is wrong: a/a/ returns a/a/. + // FIXME: this is wrong: a/a/ returns a/a/. return substr(0, lastIndexOf('/') + 1); } From bae8e1c6b0c337e6108208120d727faecb027bd0 Mon Sep 17 00:00:00 2001 From: Vijay Duvvuri Date: Sat, 13 Sep 2008 11:22:04 +0200 Subject: [PATCH 05/20] Added method doc for rangeOfString:options:range: --- Foundation/CPString.j | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index b6a849d7f..cec4f9bbb 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -294,6 +294,24 @@ CPNumericSearch return [self rangeOfString:aString options:aMask range:nil]; } +/* + Finds the range of characters in the receiver + where the specified string exists in the given range + of the receiver.The search is subject to the options specified in the + specified mask which can be a combination of: +
+CPCaseInsensitiveSearch
+CPLiteralSearch
+CPBackwardsSearch
+CPAnchoredSearch
+CPNumericSearch
+
+ @param aString the string to search for + @param aMask the options to use in the search + @param aRange the range of the receiver in which to search for + @return the range of characters in the receiver. If the string was not found, + the length of the range will be 0. +*/ - (CPRange)rangeOfString:(CPString)aString options:(int)aMask range:(CPrange)aRange { var string = (aRange == nil)?self:[self substringWithRange:aRange], From 2eae5373bc31988eb43d76b3445444285749f8e2 Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Sun, 14 Sep 2008 10:51:59 +0200 Subject: [PATCH 06/20] - Updated correct method names in the exception --- Foundation/CPString.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index cec4f9bbb..b054903d2 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -128,7 +128,7 @@ var CPStringHashes = new objj_dictionary(); { if (!format) [CPException raise:CPInvalidArgumentException - reason:"stringWithString: the format can't be 'nil'"]; + reason:"initWithFormat: the format can't be 'nil'"]; self = sprintf.apply(this, Array.prototype.slice.call(arguments, 2)); return self; @@ -143,7 +143,7 @@ var CPStringHashes = new objj_dictionary(); { if (!format) [CPException raise:CPInvalidArgumentException - reason:"stringWithString: the format can't be 'nil'"]; + reason:"initWithFormat: the format can't be 'nil'"]; return sprintf.apply(this, Array.prototype.slice.call(arguments, 2)); } From 1b2aadc6f0b30dce17f93332c5e2ba09e6d368c2 Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Sun, 14 Sep 2008 11:35:28 +0200 Subject: [PATCH 07/20] Added boolValue method to CPString --- Foundation/CPString.j | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index b054903d2..18270f307 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -460,6 +460,19 @@ CPNumericSearch return eval(self); } +/* +Returns YES on encountering one of "Y", "y", "T", "t", or +a digit 1-9. Returns NO otherwise. This method skips the initial +whitespace characters, +,- followed by Zeroes. +*/ +- (BOOL)boolValue +{ + aString = self.replace(/^\s+[\+,-]*0*/,""); + if(aString.match(/[Y,y,t,T,[1-9]/) != null) + return YES; + return NO; +} + /* Returns the text as a float point value. */ From ffa91e0f59af0a040771e57b6954dcccbc4a006b Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Mon, 15 Sep 2008 20:35:26 +0200 Subject: [PATCH 08/20] updated according to coding guidelines --- Foundation/CPString.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index 18270f307..e70459789 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -467,8 +467,8 @@ whitespace characters, +,- followed by Zeroes. */ - (BOOL)boolValue { - aString = self.replace(/^\s+[\+,-]*0*/,""); - if(aString.match(/[Y,y,t,T,[1-9]/) != null) + var aString = self.replace(/^\s+[\+,-]*0*/,""); + if (aString.match(/[Y,y,t,T,[1-9]/) != null) return YES; return NO; } From ec6c08e9ea1f901e1affbeefa3963b997f412cd2 Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Tue, 16 Sep 2008 18:40:15 +0200 Subject: [PATCH 09/20] Fixed [CPString boolvalue] method with RegExps --- Foundation/CPString.j | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index e70459789..06cc03895 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -135,7 +135,8 @@ var CPStringHashes = new objj_dictionary(); } /* - Creates a new string using C printf-style formatting. First argument should be a constant format string, like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated. + Creates a new string using C printf-style formatting. First argument should be a constant format string, + like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated. @param format the format to be used, printf-style @return the initialized CPString */ @@ -174,6 +175,7 @@ var CPStringHashes = new objj_dictionary(); } // Combining strings + /* Creates a new CPString from the concatenation of the receiver and the specified string. @param aString the string to append to the receiver @@ -459,18 +461,16 @@ CPNumericSearch { return eval(self); } - /* -Returns YES on encountering one of "Y", "y", "T", "t", or -a digit 1-9. Returns NO otherwise. This method skips the initial -whitespace characters, +,- followed by Zeroes. + Returns YES on encountering one of "Y", "y", "T", "t", or + a digit 1-9. Returns NO otherwise. This method skips the initial + whitespace characters, +,- followed by Zeroes. */ + - (BOOL)boolValue { - var aString = self.replace(/^\s+[\+,-]*0*/,""); - if (aString.match(/[Y,y,t,T,[1-9]/) != null) - return YES; - return NO; + var replaceRegExp = new RegExp("^\\s*[\\+,\\-]*0*"); + return RegExp("^[Y,y,t,T,1-9]").test(self.replace(replaceRegExp, '')); } /* From 33c0dcd48212f97fb31da11bbb9dabaeee582706 Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Tue, 16 Sep 2008 18:59:07 +0200 Subject: [PATCH 10/20] First unit test for CPString for method boolValue --- Tests/Foundation/CPStringTest.j | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Tests/Foundation/CPStringTest.j diff --git a/Tests/Foundation/CPStringTest.j b/Tests/Foundation/CPStringTest.j new file mode 100644 index 000000000..d62682894 --- /dev/null +++ b/Tests/Foundation/CPStringTest.j @@ -0,0 +1,42 @@ +import + +@implementation CPStringTest : OJTestCase + +- (void) testBoolValue +{ + var testString = @" 090"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" YES"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" true"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" True"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" tTR"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" +98"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" -98"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" +08"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" -98"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" NO"; + [self assertFalse:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" -N00"; + [self assertFalse:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; +} + + +@end From 34f58026dfad4b93e5175d2fc28376b256ea0b15 Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Wed, 17 Sep 2008 11:56:57 +0200 Subject: [PATCH 11/20] Updated assertFalse message in CPStringTest Converted tabs to spaces according to coding guidelines --- Foundation/CPString.j | 54 ++++++++++++++--------------- Tests/Foundation/CPStringTest.j | 60 +++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 53 deletions(-) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index 06cc03895..91794494e 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -136,7 +136,7 @@ var CPStringHashes = new objj_dictionary(); /* Creates a new string using C printf-style formatting. First argument should be a constant format string, - like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated. + like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated. @param format the format to be used, printf-style @return the initialized CPString */ @@ -279,13 +279,13 @@ var CPStringHashes = new objj_dictionary(); where the specified string exists. The search is subject to the options specified in the specified mask which can be a combination of: -
-CPCaseInsensitiveSearch
-CPLiteralSearch
-CPBackwardsSearch
-CPAnchoredSearch
-CPNumericSearch
-
+
+    CPCaseInsensitiveSearch
+    CPLiteralSearch
+    CPBackwardsSearch
+    CPAnchoredSearch
+    CPNumericSearch
+    
@param aString the string to search for @param aMask the options to use in the search @return the range of characters in the receiver. If the string was not found, @@ -293,30 +293,30 @@ CPNumericSearch */ - (CPRange)rangeOfString:(CPString)aString options:(int)aMask { - return [self rangeOfString:aString options:aMask range:nil]; + return [self rangeOfString:aString options:aMask range:nil]; } /* Finds the range of characters in the receiver where the specified string exists in the given range - of the receiver.The search is subject to the options specified in the + of the receiver.The search is subject to the options specified in the specified mask which can be a combination of: -
-CPCaseInsensitiveSearch
-CPLiteralSearch
-CPBackwardsSearch
-CPAnchoredSearch
-CPNumericSearch
-
+
+    CPCaseInsensitiveSearch
+    CPLiteralSearch
+    CPBackwardsSearch
+    CPAnchoredSearch
+    CPNumericSearch
+    
@param aString the string to search for @param aMask the options to use in the search - @param aRange the range of the receiver in which to search for + @param aRange the range of the receiver in which to search for @return the range of characters in the receiver. If the string was not found, the length of the range will be 0. */ - (CPRange)rangeOfString:(CPString)aString options:(int)aMask range:(CPrange)aRange { - var string = (aRange == nil)?self:[self substringWithRange:aRange], + var string = (aRange == nil)?self:[self substringWithRange:aRange], location = CPNotFound; if (aMask & CPCaseInsensitiveSearch) @@ -326,11 +326,11 @@ CPNumericSearch } if (aMask & CPBackwardsSearch) - location = string.lastIndexOf(aString, aMask & CPAnchoredSearch ? length - aString.length : 0); + location = string.lastIndexOf(aString, aMask & CPAnchoredSearch ? length - aString.length : 0); else if (aMask & CPAnchoredSearch) - location = string.substr(0, aString.length).indexOf(aString) != CPNotFound ? 0 : CPNotFound; + location = string.substr(0, aString.length).indexOf(aString) != CPNotFound ? 0 : CPNotFound; else - location = string.indexOf(aString); + location = string.indexOf(aString); return CPMakeRange(location, location == CPNotFound ? 0 : aString.length); } @@ -462,15 +462,15 @@ CPNumericSearch return eval(self); } /* - Returns YES on encountering one of "Y", "y", "T", "t", or - a digit 1-9. Returns NO otherwise. This method skips the initial - whitespace characters, +,- followed by Zeroes. + Returns YES on encountering one of "Y", "y", "T", "t", or + a digit 1-9. Returns NO otherwise. This method skips the initial + whitespace characters, +,- followed by Zeroes. */ - (BOOL)boolValue { - var replaceRegExp = new RegExp("^\\s*[\\+,\\-]*0*"); - return RegExp("^[Y,y,t,T,1-9]").test(self.replace(replaceRegExp, '')); + var replaceRegExp = new RegExp("^\\s*[\\+,\\-]*0*"); + return RegExp("^[Y,y,t,T,1-9]").test(self.replace(replaceRegExp, '')); } /* diff --git a/Tests/Foundation/CPStringTest.j b/Tests/Foundation/CPStringTest.j index d62682894..75b4d1269 100644 --- a/Tests/Foundation/CPStringTest.j +++ b/Tests/Foundation/CPStringTest.j @@ -4,39 +4,47 @@ import - (void) testBoolValue { - var testString = @" 090"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - - testString = @" YES"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - - testString = @" true"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - - testString = @" True"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + var testString = @" 090"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" YES"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" true"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + + testString = @" True"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - testString = @" tTR"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + testString = @" tTR"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - testString = @" +98"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + testString = @" +98"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - testString = @" -98"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + testString = @" -98"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - testString = @" +08"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + testString = @" +08"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - testString = @" -98"; - [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + testString = @" -98"; + [self assertTrue:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - testString = @" NO"; - [self assertFalse:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; - - testString = @" -N00"; - [self assertFalse:[testString boolValue] message:"boolValue for the string " + testString + " should return true"]; + testString = @" NO"; + [self assertFalse:[testString boolValue] message:"boolValue for the string " + testString + " should return false"]; + + testString = @" -N00"; + [self assertFalse:[testString boolValue] message:"boolValue for the string " + testString + " should return false"]; + + testString = @" 00"; + [self assertFalse:[testString boolValue] message:"boolValue for the string " + testString + " should return false"]; + + testString = @" -00"; + [self assertFalse:[testString boolValue] message:"boolValue for the string " + testString + " should return false"]; + } + @end From 6c2a50f76738c802c821639b7167c82eec5bf516 Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Wed, 17 Sep 2008 22:52:11 +0200 Subject: [PATCH 12/20] Added method stringByAppendingFormat and a simple test case for the method --- Foundation/CPString.j | 27 ++++++++++++++++++++++++--- Tests/Foundation/CPStringTest.j | 10 ++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index 91794494e..4809679b2 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -176,6 +176,22 @@ var CPStringHashes = new objj_dictionary(); // Combining strings +/* + Returns a string made by appending to the reciever a string constructed from a given format + string and the floowing arguments + @param format the format string in printf-style. + @return the initialized CPString +*/ +- (CPString)stringByAppendingFormat:(CPString)format, ... +{ + if (!format) + [CPException raise:CPInvalidArgumentException + reason:"initWithFormat: the format can't be 'nil'"]; + + + return self + sprintf.apply(this, Array.prototype.slice.call(arguments, 2)); +} + /* Creates a new CPString from the concatenation of the receiver and the specified string. @param aString the string to append to the receiver @@ -491,7 +507,7 @@ var CPStringHashes = new objj_dictionary(); /* Returns an the path components of this string. This - method assumes that the string's contents is a '/' + method assumes that the string's content is a '/' separated file system path. */ - (CPArray)pathComponents @@ -509,6 +525,11 @@ var CPStringHashes = new objj_dictionary(); return substr(lastIndexOf('.')+1); } +/* + Returns the last component of this string. + This method assumes that the string's content is a '/' + separated file system path. +*/ - (CPString)lastPathComponent { var components = [self pathComponents]; @@ -546,11 +567,11 @@ String.prototype.isa = CPString; var sprintfFormatRegex = new RegExp("([^%]+|%[\\+\\-\\ \\#0]*[0-9\\*]*(.[0-9\\*]+)?[hlL]?[cdieEfgGosuxXpn%])", "g"); var sprintfTagRegex = new RegExp("(%)([\\+\\-\\ \\#0]*)([0-9\\*]*)((.[0-9\\*]+)?)([hlL]?)([cdieEfgGosuxXpn%])"); -/** +/* Creates a new string using C printf-style formatting. First argument should be a constant format string, like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated. @param format the format to be used, printf-style @return the initialized CPString - */ +*/ function sprintf(format) { var format = arguments[0], diff --git a/Tests/Foundation/CPStringTest.j b/Tests/Foundation/CPStringTest.j index 75b4d1269..d61a08f5a 100644 --- a/Tests/Foundation/CPStringTest.j +++ b/Tests/Foundation/CPStringTest.j @@ -2,6 +2,16 @@ import @implementation CPStringTest : OJTestCase +- (void)testStringByAppendingFormat +{ + var format = @"%d X %d = %d"; + var expectedString = "2 X 3 = 6"; + var dummyString = @""; + var actualString = [dummyString stringByAppendingFormat:format ,2 ,3 ,6]; + [self assertTrue:(expectedString === actualString) + message:"stringByAppendingFormat: expected:" + expectedString + " actual:" + actualString]; + +} - (void) testBoolValue { var testString = @" 090"; From 9a397bf03fba2673930fbf7e2ebf908f5992edaf Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Wed, 17 Sep 2008 23:17:56 +0200 Subject: [PATCH 13/20] Added method stringByReplacingOccurrencesOfStringWithString and testcase for the same. --- Foundation/CPString.j | 31 +++++++++++++++++++++++++++++++ Tests/Foundation/CPStringTest.j | 12 ++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index 4809679b2..c5ade8ee7 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -232,6 +232,7 @@ var CPStringHashes = new objj_dictionary(); if (difference) string += substring.substr(difference + substring.length); } +//Dividing Strings /* Tokenizes the receiver string using the specified delimiter. For example, if the receiver is: @@ -351,6 +352,36 @@ var CPStringHashes = new objj_dictionary(); return CPMakeRange(location, location == CPNotFound ? 0 : aString.length); } +//Replacing Substrings + +/* + Returns a new string in which all occurrences of a target string in the reciever are replaced by + another given string. + @param target The string to replace. + @param replacement the string with which to replace the
target
+*/
+
+- (CPString)stringByReplacingOccurrencesOfString:(CPString)target withString:(CPString)replacement
+{
+    return self.replace(new RegExp(target, "g"), replacement);
+}
+/*
+- (CPString)stringByReplacingOccurrencesOfString:(CPString)target 
+                                      withString:(CPString)replacement 
+                                         options:(int)options 
+                                           range:(CPRange)searchRange
+{
+    //TODO :Vijay implement the method
+
+}
+
+- (CPString)stringByReplacingCharactersInRange:(CPRange)range withString:(CPString)replacement
+{
+    //TODO :Vijay implement the method
+}
+*/
+
+
 // Identifying and comparing strings
 /*
     Compares the receiver to the specified string.
diff --git a/Tests/Foundation/CPStringTest.j b/Tests/Foundation/CPStringTest.j
index d61a08f5a..289663cdc 100644
--- a/Tests/Foundation/CPStringTest.j
+++ b/Tests/Foundation/CPStringTest.j
@@ -2,6 +2,18 @@ import 
 
 @implementation CPStringTest : OJTestCase
 
+
+- (void)testStringByReplacingOccurrencesOfStringWithString
+{
+    var expectedString = @"hello world. A new world!";
+    var dummyString = @"hello woold. A new woold!";
+    var actualString = [dummyString stringByReplacingOccurrencesOfString:@"woold" withString:@"world"];
+    [self assertTrue:(expectedString === actualString) 
+             message:"stringByAppendingFormat: expected:" + expectedString + " actual:" + actualString];
+    
+    
+    
+}
 - (void)testStringByAppendingFormat
 {
     var format = @"%d X %d = %d";

From 3dd3a8733b7463383f7665b5f9b372c0277f87ef Mon Sep 17 00:00:00 2001
From: Ross Boucher 
Date: Wed, 17 Sep 2008 17:03:51 -0700
Subject: [PATCH 14/20] Add CPViewAutoresizingMasks to the documentation.

---
 AppKit/CPView.j | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/AppKit/CPView.j b/AppKit/CPView.j
index 05aedecc4..e09f3f557 100644
--- a/AppKit/CPView.j
+++ b/AppKit/CPView.j
@@ -37,13 +37,47 @@ import "CPGraphicsContext.j"
 #include "CoreGraphics/CGGeometry.h"
 #include "Platform/DOM/CPDOMDisplayServer.h"
 
-
+/*
+    @global
+    @group CPViewAutoresizingMasks
+    The default resizingMask, the view will not resize or reposition itself.
+*/
 CPViewNotSizable    = 0;
+/*
+    @global
+    @group CPViewAutoresizingMasks
+    Allow for flexible space on the left hand side of the view.
+*/
 CPViewMinXMargin    = 1;
+/*
+    @global
+    @group CPViewAutoresizingMasks
+    The view should grow and shrink horizontally with its parent view.
+*/
 CPViewWidthSizable  = 2;
+/*
+    @global
+    @group CPViewAutoresizingMasks
+    Allow for flexible space to the right hand side of the view.
+*/
 CPViewMaxXMargin    = 4;
+/*
+    @global
+    @group CPViewAutoresizingMasks
+    Allow for flexible space above the view.
+*/
 CPViewMinYMargin    = 8;
+/*
+    @global
+    @group CPViewAutoresizingMasks
+    The view should grow and shrink vertically with its parent view.
+*/
 CPViewHeightSizable = 16;
+/*
+    @global
+    @group CPViewAutoresizingMasks
+    Allow for flexible space below the view.
+*/
 CPViewMaxYMargin    = 32;
 
 CPViewBoundsDidChangeNotification   = @"CPViewBoundsDidChangeNotification";

From 59e16f9e61a832befb856aee1058a10375fac450 Mon Sep 17 00:00:00 2001
From: Tom Robinson 
Date: Mon, 22 Sep 2008 00:11:12 -0700
Subject: [PATCH 15/20] Prevent Rhino's XML parsing from downloading plist DTDs
 all the time

---
 Objective-J/plist.js      |  2 +-
 Tools/Utilities/bridge.js | 26 +++++++++++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/Objective-J/plist.js b/Objective-J/plist.js
index d03ede527..59f0f8515 100644
--- a/Objective-J/plist.js
+++ b/Objective-J/plist.js
@@ -340,7 +340,7 @@ function CPPropertyListCreateFromXMLData(XMLNodeOrData)
     if (XMLNode.string)
     {
 #if RHINO
-        XMLNode = DOCUMENT_ELEMENT(Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
+        XMLNode = DOCUMENT_ELEMENT(_documentBuilder.parse(
             new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(XMLNode.string))));
 #else
         if (window.ActiveXObject)
diff --git a/Tools/Utilities/bridge.js b/Tools/Utilities/bridge.js
index bf55fb76f..96cc8e29c 100644
--- a/Tools/Utilities/bridge.js
+++ b/Tools/Utilities/bridge.js
@@ -283,9 +283,25 @@ if (typeof Packages != "undefined") {
 		}
 	};
 
-    var xhr_builder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
-    xhr_builder.setErrorHandler(function(exception, methodName) {
-    	//print("xml error!");
+    var _documentBuilderFactory = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
+    // setValidating to false doesn't seem to prevent it from downloading the DTD, but lets do it anyway
+    _documentBuilderFactory.setValidating(false);
+    
+    _documentBuilder = _documentBuilderFactory.newDocumentBuilder();
+    // prevent the Java XML parser from downloading the plist DTD from Apple every time we parse a plist
+    _documentBuilder.setEntityResolver(new Packages.org.xml.sax.EntityResolver({
+        resolveEntity: function(publicId, systemId) {
+            //Packages.java.lang.System.out.println("publicId=" + publicId + " systemId=" + systemId);
+            
+            // TODO: return a local copy of the DTD?
+            if (String(systemId) == "http://www.apple.com/DTDs/PropertyList-1.0.dtd")
+                return new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(""));
+                
+            return null;
+        } 
+    }));
+    // throw an exception on error
+    _documentBuilder.setErrorHandler(function(exception, methodName) {
     	throw exception;
     });
 
@@ -372,7 +388,7 @@ if (typeof Packages != "undefined") {
     }
     
     parseXMLString = function(string) {
-        return (Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
+        return (_documentBuilder.parse(
             new Packages.org.xml.sax.InputSource(
                 new Packages.java.io.StringReader(string))).getDocumentElement());
     }
@@ -444,7 +460,7 @@ XMLHttpRequest.prototype.send = function(body) {
 	
 	if (this.responseText.length > 0) {
 		try {
-			this.responseXML = xhr_builder.parse(new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(this.responseText)));
+			this.responseXML = _documentBuilder.parse(new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(this.responseText)));
 		} catch (e) {
 			this.responseXML = null;
 		}

From dff3b249d97a0e8c1caa2447ec2d943a580fe2cf Mon Sep 17 00:00:00 2001
From: Tom Robinson 
Date: Mon, 22 Sep 2008 16:20:00 -0700
Subject: [PATCH 16/20] Fixed readFile for Rhino (return JavaScript string
 instead of Java string)

[#66 state:resolved responsible:tlrobinson]
---
 Tools/Utilities/bridge.js | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/Tools/Utilities/bridge.js b/Tools/Utilities/bridge.js
index 96cc8e29c..9c3540c51 100644
--- a/Tools/Utilities/bridge.js
+++ b/Tools/Utilities/bridge.js
@@ -107,11 +107,11 @@ if (typeof readFile == "undefined") {
         	var f = new Packages.java.io.File(path);
 	
 	        if (!f.canRead()) {
-	            //alert("can't read: " + f.path)
+	            alert("can't read: " + f.path)
 	            return "";
 	        }
 	
-	        //alert("reading: " + f.getAbsolutePath());
+	        alert("reading: " + f.getAbsolutePath());
 	
         	var fis = new Packages.java.io.FileInputStream(f);
         	
@@ -119,12 +119,11 @@ if (typeof readFile == "undefined") {
         	fis.read(b);
         	
         	fis.close();
-	
-            //return String(new Packages.java.lang.String(b));
+
             if (characterCoding)
-                return new Packages.java.lang.String(b, characterCoding);
+                return String(new Packages.java.lang.String(b, characterCoding));
             else
-                return new Packages.java.lang.String(b);
+                return String(new Packages.java.lang.String(b));
         }
     }
     else {
@@ -451,9 +450,9 @@ XMLHttpRequest.prototype.send = function(body) {
 	
 	try {
 		this.responseText = readFile(this.url);
-		alert("xhr: " + this.url);
+		alert("xhr response:  " + this.url + " (length="+this.responseText.length+")");
 	} catch (e) {
-	    alert("read exception: " + this.url);
+	    alert("xhr exception: " + this.url);
     	this.responseText = "";
 		this.responseXML = null;
 	}    
@@ -467,7 +466,7 @@ XMLHttpRequest.prototype.send = function(body) {
 	    this.status = 200;
 	}
 	else {
-	    alert("empty file: " + this.url);
+	    alert("xhr empty:     " + this.url);
 	    this.status = 404;
 	}
 	

From 2aa5b0a1adbc11f8b929505f7a3f003516eb3c51 Mon Sep 17 00:00:00 2001
From: Francisco Ryan Tolmasky I 
Date: Mon, 22 Sep 2008 19:20:19 -0700
Subject: [PATCH 17/20] Fixed issue with custom draw rect detection.

Reviewed by me.
---
 AppKit/CPSplitView.j | 24 +++++++++---------------
 AppKit/CPView.j      | 16 ++++++++++------
 2 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j
index fc9ac630a..41d8faead 100644
--- a/AppKit/CPSplitView.j
+++ b/AppKit/CPSplitView.j
@@ -54,16 +54,15 @@ var CPSplitViewHorizontalImage = nil,
 /*
     @ignore
 */
-//+ (void)initialize
-//{
-//    if (self != [CPSplitView class])
-//        return;
-//
-//    var bundle = [CPBundle bundleForClass:self];
-//
-//    CPSplitViewHorizontalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewHorizontal.png"] size:CPSizeMake(5.0, 10.0)];
-//    CPSplitViewVerticalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewVertical.png"] size:CPSizeMake(10.0, 5.0)];
-//}
++ (void)initialize
+{
+    if (self != [CPSplitView class])
+        return;
+
+    var bundle = [CPBundle bundleForClass:self];
+    CPSplitViewHorizontalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewHorizontal.png"] size:CPSizeMake(5.0, 10.0)];
+    CPSplitViewVerticalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewVertical.png"] size:CPSizeMake(10.0, 5.0)];
+}
 
 - (id)initWithFrame:(CGRect)aFrame
 {
@@ -505,8 +504,3 @@ var CPSplitViewDelegateKey          = "CPSplitViewDelegateKey",
 }
 
 @end
-
-// FIXME: once +initialize is fixed for superclasses, remove this and uncomment +initialize
-var bundle = [CPBundle bundleForClass:CPSplitView];
-CPSplitViewHorizontalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewHorizontal.png"] size:CPSizeMake(5.0, 10.0)];
-CPSplitViewVerticalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewVertical.png"] size:CPSizeMake(10.0, 5.0)];
diff --git a/AppKit/CPView.j b/AppKit/CPView.j
index db843c9d9..558cc0082 100644
--- a/AppKit/CPView.j
+++ b/AppKit/CPView.j
@@ -173,11 +173,6 @@ var DOMElementPrototype         = nil,
 */
 + (void)initialize
 {
-#if PLATFORM(DOM)
-    if ([self instanceMethodForSelector:@selector(drawRect:)] != [CPView instanceMethodForSelector:@selector(drawRect:)])
-        CustomDrawRectViews[[self hash]] = YES;
-#endif
-
     if (self != [CPView class])
         return;
 
@@ -1380,7 +1375,16 @@ setBoundsOrigin:
 - (void)setNeedsDisplayInRect:(CPRect)aRect
 {
 #if PLATFORM(DOM)
-    if (!CustomDrawRectViews[[[self class] hash]])
+    var hash = [[self class] hash],
+        hasCustomDrawRect = CustomDrawRectViews[hash];
+    
+    if (!hasCustomDrawRect && typeof hasCustomDrawRect === "undefined")
+    {
+        hasCustomDrawRect = [self methodForSelector:@selector(drawRect:)] != [CPView instanceMethodForSelector:@selector(drawRect:)];
+        CustomDrawRectViews[hash] = hasCustomDrawRect;
+    }
+
+    if (!hasCustomDrawRect)
         return;
 #endif
         

From f4cedf5acc860766c83e3db98dfd55bb855a77de Mon Sep 17 00:00:00 2001
From: Francisco Ryan Tolmasky I 
Date: Tue, 23 Sep 2008 00:01:12 -0700
Subject: [PATCH 18/20] A number of fixes relating to how CPSplitView divides
 itself by default, as well as adding CPView-viewWillDraw.

Reviewed by Tom.
---
 AppKit/CPSplitView.j | 121 ++++++++++++++++++++++++++++++-------------
 AppKit/CPView.j      |   6 +++
 2 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j
index 41d8faead..b044cbe9a 100644
--- a/AppKit/CPSplitView.j
+++ b/AppKit/CPSplitView.j
@@ -49,6 +49,8 @@ var CPSplitViewHorizontalImage = nil,
     CPArray     _DOMDividerElements;
     CPString    _dividerImagePath;
     int         _drawingDivider;
+    
+    BOOL        _needsResizeSubviews;
 }
 
 /*
@@ -88,20 +90,45 @@ var CPSplitViewHorizontalImage = nil,
     return _isVertical;
 }
 
-- (void)setVertical:(BOOL)flag
+- (void)setVertical:(BOOL)shouldBeVertical
 {
-    [self _setVertical:flag];
+    if (![self _setVertical:shouldBeVertical])
+        return;
     
-    [self adjustSubviews];
+    // Just re-adjust evenly.
+    var frame = [self frame],
+        dividerThickness = [self dividerThickness];
+    
+    [self _postNotificationWillResize];
+    
+    var eachSize = ROUND((frame.size[_sizeComponent] - dividerThickness * (_subviews.length - 1)) / _subviews.length),
+        index = 0,
+        count = _subviews.length;
+
+    if ([self isVertical])
+        for (; index < count; ++index)
+            [_subviews[index] setFrame:CGRectMake(ROUND((eachSize + dividerThickness) * index), 0, eachSize, frame.size.height)];
+    else
+        for (; index < count; ++index)
+            [_subviews[index] setFrame:CGRectMake(0, ROUND((eachSize + dividerThickness) * index), frame.size.width, eachSize)];
+    
+    [self setNeedsDisplay:YES];
+    
+    [self _postNotificationDidResize];
+
 }
 
-- (void)_setVertical:(BOOL)flag
+- (BOOL)_setVertical:(BOOL)shouldBeVertical
 {
-    _isVertical = flag;
+    var changed = (_isVertical != shouldBeVertical);
     
-    _originComponent    = [self isVertical] ? "x" : "y";
-    _sizeComponent      = [self isVertical] ? "width" : "height";
-    _dividerImagePath   = [self isVertical] ? [CPSplitViewVerticalImage filename] : [CPSplitViewHorizontalImage filename];
+    _isVertical = shouldBeVertical;
+    
+    _originComponent = [self isVertical] ? "x" : "y";
+    _sizeComponent = [self isVertical] ? "width" : "height";
+    _dividerImagePath = [self isVertical] ? [CPSplitViewVerticalImage filename] : [CPSplitViewHorizontalImage filename];
+    
+    return changed;
 }
 
 - (BOOL)isPaneSplitter
@@ -123,32 +150,10 @@ var CPSplitViewHorizontalImage = nil,
     [self setNeedsDisplay:YES];
 }
 
-- (void)didAddSubview:(CPView)subview
+- (void)didAddSubview:(CPView)aSubview
 {
-    [self adjustSubviews];
-}
-
-- (void)adjustSubviews
-{
-    var frame = [self frame],
-        dividerThickness = [self dividerThickness];
-    
-    [self _postNotificationWillResize];
-    
-    var eachSize = ROUND((frame.size[_sizeComponent] - dividerThickness * (_subviews.length - 1)) / _subviews.length),
-        index = 0,
-        count = _subviews.length;
-
-    if ([self isVertical])
-        for (; index < count; ++index)
-            [_subviews[index] setFrame:CGRectMake(ROUND((eachSize + dividerThickness) * index), 0, eachSize, frame.size.height)];
-    else
-        for (; index < count; ++index)
-            [_subviews[index] setFrame:CGRectMake(0, ROUND((eachSize + dividerThickness) * index), frame.size.width, eachSize)];
-    
-    [self setNeedsDisplay:YES];
-    
-    [self _postNotificationDidResize];
+    _needsResizeSubviews = YES;
+//    [self adjustSubviews];
 }
 
 - (BOOL)isSubviewCollapsed:(CPView)subview
@@ -218,6 +223,39 @@ var CPSplitViewHorizontalImage = nil,
 #endif
 }
 
+- (void)viewWillDraw
+{
+    [self _adjustSubviewsWithCalculatedSize];
+}
+
+- (void)_adjustSubviewsWithCalculatedSize
+{
+    if (!_needsResizeSubviews)
+        return;
+    
+    _needsResizeSubviews = NO;
+        
+    var subviews = [self subviews],
+        count = subviews.length,
+        oldSize = CGSizeMakeZero();
+    
+    if ([self isVertical])
+    {
+        oldSize.width += [self dividerThickness] * (count - 1);
+        oldSize.height = CGRectGetHeight([self frame]);
+    }
+    else
+    {
+        oldSize.width = CGRectGetWidth([self frame]);
+        oldSize.height += [self dividerThickness] * (count - 1);
+    }
+        
+    while (count--)
+        oldSize[_sizeComponent] += [subviews[count] frame].size[_sizeComponent];
+    
+    [self resizeSubviewsWithOldSize:oldSize];
+}
+
 - (BOOL)cursorAtPoint:(CPPoint)aPoint hitDividerAtIndex:(int)anIndex
 {
     var frame = [_subviews[anIndex] frame],
@@ -353,6 +391,8 @@ var CPSplitViewHorizontalImage = nil,
 
 - (void)setPosition:(float)position ofDividerAtIndex:(int)dividerIndex
 {
+    [self _adjustSubviewsWithCalculatedSize];
+        
     // not sure where this should override other positions?
     if ([_delegate respondsToSelector:@selector(splitView:constrainSplitPosition:ofSubviewAt:)])
         position = [_delegate splitView:self constrainSplitPosition:position ofSubviewAt:dividerIndex];
@@ -386,13 +426,22 @@ var CPSplitViewHorizontalImage = nil,
     
     frameB.size[_sizeComponent] = frameB.origin[_originComponent] + frameB.size[_sizeComponent] - realPosition - [self dividerThickness];
     frameB.origin[_originComponent] = realPosition + [self dividerThickness];
-    [_subviews[dividerIndex+1] setFrame:frameB];
+    [_subviews[dividerIndex + 1] setFrame:frameB];
+    
+    [self setNeedsDisplay:YES];
+}
+
+- (void)setFrameSize:(CGSize)aSize
+{
+    [self _adjustSubviewsWithCalculatedSize];
+        
+    [super setFrameSize:aSize];
     
     [self setNeedsDisplay:YES];
 }
 
 - (void)resizeSubviewsWithOldSize:(CPSize)oldSize
-{
+{   
     if ([_delegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)])
     {
         [_delegate splitView:self resizeSubviewsWithOldSize:oldSize];
@@ -421,8 +470,6 @@ var CPSplitViewHorizontalImage = nil,
         
         [view setFrame:newFrame];
     }
-    
-    [self setNeedsDisplay:YES];
 
     [self _postNotificationDidResize];
 }
diff --git a/AppKit/CPView.j b/AppKit/CPView.j
index 558cc0082..8451ea6d9 100644
--- a/AppKit/CPView.j
+++ b/AppKit/CPView.j
@@ -1435,6 +1435,8 @@ setBoundsOrigin:
 */
 - (void)displayRect:(CPRect)aRect
 {
+    [self viewWillDraw];
+    
     [self displayRectIgnoringOpacity:aRect inContext:nil];
     
     _dirtyRect = NULL;
@@ -1450,6 +1452,10 @@ setBoundsOrigin:
     [self unlockFocus];
 }
 
+- (void)viewWillDraw
+{
+}
+
 /*
     Locks focus on the receiver, so drawing commands apply to it.
 */

From 9d5e772d0a56b8e0c4ef131efc0f708cc49f5b1d Mon Sep 17 00:00:00 2001
From: Francisco Ryan Tolmasky I 
Date: Tue, 23 Sep 2008 03:24:29 -0700
Subject: [PATCH 19/20] Name change.

Reviewed by me.
---
 AppKit/Cib/CPCib.j                                | 2 +-
 AppKit/Cib/{CPCustomView.j => _CPCibCustomView.j} | 0
 Tools/nib2cib/NSCustomView.j                      | 2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename AppKit/Cib/{CPCustomView.j => _CPCibCustomView.j} (100%)

diff --git a/AppKit/Cib/CPCib.j b/AppKit/Cib/CPCib.j
index ee27f538d..05ab20eb4 100644
--- a/AppKit/Cib/CPCib.j
+++ b/AppKit/Cib/CPCib.j
@@ -24,8 +24,8 @@ import 
 import 
 import 
 
-import "CPCustomView.j"
 import "_CPCibCustomObject.j"
+import "_CPCibCustomView.j"
 import "_CPCibKeyedUnarchiver.j"
 import "_CPCibObjectData.j"
 import "_CPCibWindowTemplate.j"
diff --git a/AppKit/Cib/CPCustomView.j b/AppKit/Cib/_CPCibCustomView.j
similarity index 100%
rename from AppKit/Cib/CPCustomView.j
rename to AppKit/Cib/_CPCibCustomView.j
diff --git a/Tools/nib2cib/NSCustomView.j b/Tools/nib2cib/NSCustomView.j
index 6a1362497..b6bc5c598 100644
--- a/Tools/nib2cib/NSCustomView.j
+++ b/Tools/nib2cib/NSCustomView.j
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-import 
+import 
 
 import "NSView.j"
 

From dbedbfddfce94d88dfc6b27144d47eca7f81e7fb Mon Sep 17 00:00:00 2001
From: Ross Boucher 
Date: Wed, 24 Sep 2008 14:09:42 -0700
Subject: [PATCH 20/20] Fixed a few accessors and spacing issues.

---
 Foundation/CPString.j | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/Foundation/CPString.j b/Foundation/CPString.j
index ef02d1060..d98b64a42 100644
--- a/Foundation/CPString.j
+++ b/Foundation/CPString.j
@@ -185,11 +185,9 @@ var CPStringHashes      = new objj_dictionary();
 - (CPString)stringByAppendingFormat:(CPString)format, ...
 {
     if (!format)
-           [CPException raise:CPInvalidArgumentException
-                       reason:"initWithFormat: the format can't be 'nil'"];
-    
+        [CPException raise:CPInvalidArgumentException reason:"initWithFormat: the format can't be 'nil'"];
 
-    return self + sprintf.apply(this, Array.prototype.slice.call(arguments, 2));   
+    return self + sprintf.apply(this, Array.prototype.slice.call(arguments, 2));
 }
 
 /*
@@ -280,6 +278,7 @@ var CPStringHashes      = new objj_dictionary();
 }
 
 // Finding characters and substrings
+
 /*
     Finds the range of characters in the receiver where the specified string exists. If the string
     does not exist in the receiver, the range length will be 0.
@@ -333,22 +332,22 @@ var CPStringHashes      = new objj_dictionary();
 */
 - (CPRange)rangeOfString:(CPString)aString options:(int)aMask range:(CPrange)aRange
 {
-    var string = (aRange == nil)?self:[self substringWithRange:aRange],
+    var string = (aRange == nil) ? self : [self substringWithRange:aRange],
         location = CPNotFound;
-    
+
     if (aMask & CPCaseInsensitiveSearch)
     {
         string = string.toLowerCase();
         aString = aString.toLowerCase();
     }
-    
-    if (aMask & CPBackwardsSearch) 
+
+    if (aMask & CPBackwardsSearch)
         location = string.lastIndexOf(aString, aMask & CPAnchoredSearch ? length - aString.length : 0);
-    else if (aMask & CPAnchoredSearch) 
+    else if (aMask & CPAnchoredSearch)
         location = string.substr(0, aString.length).indexOf(aString) != CPNotFound ? 0 : CPNotFound;
-    else 
+    else
         location = string.indexOf(aString);
-    
+
     return CPMakeRange(location, location == CPNotFound ? 0 : aString.length);
 }
 
@@ -365,11 +364,9 @@ var CPStringHashes      = new objj_dictionary();
 {
     return self.replace(new RegExp(target, "g"), replacement);
 }
+
 /*
-- (CPString)stringByReplacingOccurrencesOfString:(CPString)target 
-                                      withString:(CPString)replacement 
-                                         options:(int)options 
-                                           range:(CPRange)searchRange
+- (CPString)stringByReplacingOccurrencesOfString:(CPString)target withString:(CPString)replacement options:(int)options range:(CPRange)searchRange
 {
     //TODO :Vijay implement the method
 
@@ -383,6 +380,7 @@ var CPStringHashes      = new objj_dictionary();
 
 
 // Identifying and comparing strings
+
 /*
     Compares the receiver to the specified string.
     @param aString the string with which to compare
@@ -506,7 +504,7 @@ var CPStringHashes      = new objj_dictionary();
 */
 - (double)doubleValue
 {
-    return eval(self);
+    return parseFloat(self, 10);
 }
 /*
     Returns YES on encountering one of "Y", "y", "T", "t", or 
@@ -525,7 +523,7 @@ var CPStringHashes      = new objj_dictionary();
 */
 - (float)floatValue
 {
-    return eval(self);
+    return parseFloat(self, 10);
 }
 
 /*
@@ -533,7 +531,7 @@ var CPStringHashes      = new objj_dictionary();
 */
 - (int)intValue
 {
-    return parseInt(self);
+    return parseInt(self, 10);
 }
 
 /*
@@ -574,7 +572,7 @@ var CPStringHashes      = new objj_dictionary();
 - (CPString)stringByDeletingLastPathComponent
 {
     // FIXME: this is wrong: a/a/ returns a/a/.
-    return substr(0, lastIndexOf('/') + 1);  
+    return substr(0, lastIndexOf('/') + 1);
 }
 
 - (CPString)stringByStandardizingPath