Skip to content

Commit

Permalink
Fixed an issue where local documents could not be opened by Cappuccin…
Browse files Browse the repository at this point in the history
…o's document-apps.

Reviewed by me.
  • Loading branch information
Francisco Ryan Tolmasky I committed Jan 17, 2009
1 parent 6d27e5d commit e926aad
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion AppKit/CPDocument.j
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ var CPDocumentUntitledCount = 0;
var statusCode = [aResponse statusCode];

// Nothing to do if everything is hunky dory.
if (statusCode == 200)
if (statusCode === 200 || (statusCode === 0 && [aConnection isLocalFileConnection]))
return;

var session = aConnection.session;
Expand Down
13 changes: 8 additions & 5 deletions AppKit/CPTextField.j
Original file line number Diff line number Diff line change
Expand Up @@ -633,11 +633,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: 1 addition & 1 deletion AppKit/CoreGraphics/CGContext.j
Original file line number Diff line number Diff line change
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
14 changes: 13 additions & 1 deletion Foundation/CPURLConnection.j
Original file line number Diff line number Diff line change
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,6 +224,11 @@ var CPURLConnectionDelegate = nil;
}
}

- (BOOL)isLocalFileConnection
{
return _isLocalFileConnection;
}

/* @ignore */
- (void)_readyStateDidChange
{
Expand All @@ -230,7 +242,7 @@ var CPURLConnectionDelegate = nil;

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

0 comments on commit e926aad

Please sign in to comment.