Skip to content

Commit

Permalink
Merge branch '280north/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Boucher committed Jan 21, 2009
2 parents 6291804 + 03ec852 commit 62284c9
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 28 deletions.
6 changes: 5 additions & 1 deletion AppKit/CPDocument.j
Expand Up @@ -386,10 +386,14 @@ var CPDocumentUntitledCount = 0;
*/
- (void)connection:(CPURLConnection)aConnection didReceiveResponse:(CPURLResponse)aResponse
{
// If we got this far and it wasn't an HTTP request, then everything is fine.
if (![aResponse isKindOfClass:[CPHTTPURLResponse class]])
return;

var statusCode = [aResponse statusCode];

// Nothing to do if everything is hunky dory.
if (statusCode == 200)
if (statusCode === 200)
return;

var session = aConnection.session;
Expand Down
13 changes: 8 additions & 5 deletions AppKit/CPTextField.j
Expand Up @@ -666,11 +666,14 @@ var _CPTextFieldSquareBezelColor = nil,
#if PLATFORM(DOM)
var displayString = "";

if (aValue && [aValue respondsToSelector:@selector(string)])
displayString = [aValue string];
else if (aValue)
displayString += aValue;

if (aValue !== nil && aValue !== undefined)
{
if ([aValue respondsToSelector:@selector(string)])
displayString = [aValue string];
else
displayString += aValue;
}

if ([[self window] firstResponder] == self)
[[self class] _inputElement].value = displayString;

Expand Down
2 changes: 2 additions & 0 deletions AppKit/CPToolbar.j
Expand Up @@ -448,6 +448,8 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)

CPPopUpButton _additionalItemsButton;
CPColor _labelColor;

float _minWidth;
}

+ (void)initialize
Expand Down
2 changes: 1 addition & 1 deletion AppKit/CoreGraphics/CGContext.j
Expand Up @@ -338,7 +338,7 @@ function CGContextFillRect(aContext, aRect)

function CGContextFillRects(aContext, rects, count)
{
if (arguments["count"] == NULL)
if (arguments[2] === undefined)
var count = rects.length;

CGContextBeginPath(aContext);
Expand Down
21 changes: 11 additions & 10 deletions Foundation/CPBundle.j
Expand Up @@ -123,17 +123,18 @@
{
objj_decompile([data string], self);

var files = [self objectForInfoDictionaryKey:@"CPBundleReplacedFiles"];
importCallback = function()
{
// FIXME: Should we share a common context across all these loads?
if (files.length > 0)
objj_import([self bundlePath] + '/' + files.pop(), YES, importCallback);
else if ([_delegate respondsToSelector:@selector(bundleDidFinishLoading:)])
[_delegate bundleDidFinishLoading:self];
}
var context = new objj_context();

if ([_delegate respondsToSelector:@selector(bundleDidFinishLoading:)])
context.didCompleteCallback = function() { [_delegate bundleDidFinishLoading:self]; };

var files = [self objectForInfoDictionaryKey:@"CPBundleReplacedFiles"],
count = files.length;

while (count--)
context.pushFragment(fragment_create_file([self bundlePath] + '/' + files[count], new objj_bundle(""), YES, NULL));

objj_import([self bundlePath] + '/' + files.pop(), YES, importCallback);
context.evaluate();
}
}

Expand Down
29 changes: 25 additions & 4 deletions Foundation/CPURLConnection.j
Expand Up @@ -80,6 +80,7 @@ var CPURLConnectionDelegate = nil;
CPURLRequest _request;
id _delegate;
BOOL _isCanceled;
BOOL _isLocalFileConnection;

XMLHTTPRequest _XMLHTTPRequest;
}
Expand Down Expand Up @@ -150,6 +151,12 @@ var CPURLConnectionDelegate = nil;
_delegate = aDelegate;
_isCanceled = NO;

var path = [_request URL];

_isLocalFileConnection = path.indexOf("file:") === 0 ||
((path.indexOf("http:") !== 0 || path.indexOf("https:") !== 0) &&
window.location && window.location.protocol === "file:");

_XMLHTTPRequest = objj_request_xmlhttp();

if (shouldStartImmediately)
Expand Down Expand Up @@ -217,20 +224,34 @@ var CPURLConnectionDelegate = nil;
}
}

- (BOOL)isLocalFileConnection
{
return _isLocalFileConnection;
}

/* @ignore */
- (void)_readyStateDidChange
{
if (_XMLHTTPRequest.readyState == XMLHTTPRequestComplete)
{
var statusCode = _XMLHTTPRequest.status,
url = [_request URL];
URL = [_request URL];

if ([_delegate respondsToSelector:@selector(connection:didReceiveResponse:)])
[_delegate connection:self didReceiveResponse:[[CPHTTPURLResponse alloc] _initWithStatusCode:statusCode]];

if (_isLocalFileConnection)
[_delegate connection:self didReceiveResponse:[[CPURLResponse alloc] initWithURL:URL]];
else
{
var response = [[CPHTTPURLResponse alloc] initWithURL:URL];

[response _setStatusCode:statusCode];

[_delegate connection:self didReceiveResponse:response];
}

if (!_isCanceled)
{
if (statusCode == 200 || (url.indexOf("file:") === 0 && statusCode === 0) || ((url.indexOf("http:") !== 0 || url.indexOf("https:") !== 0) && window.location && window.location.protocol === "file:" && statusCode === 0))
if (statusCode == 200 || (statusCode === 0 && _isLocalFileConnection))
{
[_delegate connection:self didReceiveData:_XMLHTTPRequest.responseText];
[_delegate connectionDidFinishLoading:self];
Expand Down
25 changes: 18 additions & 7 deletions Foundation/CPURLResponse.j
Expand Up @@ -34,6 +34,22 @@
*/
@implementation CPURLResponse : CPObject
{
CPURL _URL;
}

- (id)initWithURL:(CPURL)aURL
{
self = [super init];

if (self)
_URL = aURL;

return self;
}

- (CPURL)URL
{
return _URL;
}
/*
Creating a Response
Expand All @@ -56,14 +72,9 @@ Getting the Response Properties
}

/* @ignore */
- (id)_initWithStatusCode:(int)aStatusCode
- (id)_setStatusCode:(int)aStatusCode
{
self = [super init];

if (self)
_statusCode = aStatusCode;

return self;
_statusCode = aStatusCode;
}

/*!
Expand Down

0 comments on commit 62284c9

Please sign in to comment.