Skip to content

Commit

Permalink
Merge branch 'master' into Aristo2
Browse files Browse the repository at this point in the history
Conflicts:
	Tests/Manual/CPPopover/Resources/MainMenu.cib
  • Loading branch information
primalmotion committed Jan 7, 2013
2 parents 7e9b12b + 45ad537 commit 7fa01fa
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 15 deletions.
25 changes: 22 additions & 3 deletions AppKit/CPCompatibility.j
Expand Up @@ -310,11 +310,18 @@ function CPBrowserStyleProperty(aProperty)
break;
default:
var prefixes = ["Webkit", "Moz", "O", "ms"],
capProperty = [aProperty capitalizedString];
strippedProperty = aProperty.split('-').join(' '),
capProperty = [strippedProperty capitalizedString].split(' ').join('');

for (var i = 0; i < prefixes.length; i++)
{
if (prefixes[i] + capProperty in testElement.style)
// First check if the property is already valid without being formatted, otherwise try the capitalized property
if (prefixes[i] + aProperty in testElement.style)
{
r = prefixes[i] + aProperty;
break;
}
else if (prefixes[i] + capProperty in testElement.style)
{
r = prefixes[i] + capProperty;
break;
Expand Down Expand Up @@ -352,9 +359,21 @@ function CPBrowserCSSProperty(aProperty)
{
if (browserProperty.substring(0, prefix.length) == prefix)
{
return prefixes[prefix] + browserProperty.substring(prefix.length).toLowerCase();
var browserPropertyWithoutPrefix = browserProperty.substring(prefix.length),
parts = browserPropertyWithoutPrefix.match(/[A-Z][a-z]+/g);

// If there were any capitalized words in the browserProperty, insert a "-" between each one
if (parts && parts.length > 0)
browserPropertyWithoutPrefix = parts.join("-");

return prefixes[prefix] + browserPropertyWithoutPrefix.toLowerCase();
}
}

var parts = browserProperty.match(/[A-Z][a-z]+/g);

if (parts && parts.length > 0)
browserProperty = parts.join("-");

return browserProperty.toLowerCase();
}
24 changes: 16 additions & 8 deletions AppKit/CPWindow/CPWindow.j
Expand Up @@ -1865,9 +1865,16 @@ CPTexturedBackgroundWindowMask
*/
- (BOOL)canBecomeKeyWindow
{
// In Cocoa only resizable or titled windows return YES here by default. But the main browser window in Cappuccino
// doesn't have these masks even that it's both titled and resizable, so we return YES when isFullPlatformWindow too.
return (_styleMask & CPTitledWindowMask) || (_styleMask & CPResizableWindowMask) || [self isFullPlatformWindow];
/*
In Cocoa only titled windows return YES here by default. But the main browser
window in Cappuccino doesn't have a title bar even that it's both titled and
resizable, so we return YES when isFullPlatformWindow too.
Note that Cocoa will return NO for a non-titled, resizable window. The Cocoa documention
says it will return YES if there is a "resize bar", but in practice
that is not the same as the resizable mask.
*/
return (_styleMask & CPTitledWindowMask) || [self isFullPlatformWindow];
}

/*!
Expand Down Expand Up @@ -2231,11 +2238,12 @@ CPTexturedBackgroundWindowMask
*/
- (BOOL)canBecomeMainWindow
{
// FIXME: Also check if we can resize and titlebar.
if ([self isVisible])
return YES;

return NO;
// Note that the Cocoa documentation says that this method returns YES if
// the window is visible and has a title bar or a "resize mechanism". It turns
// out a "resize mechanism" is not the same as having the resize mask set.
// In practice a window must have a title bar to become main, but we make
// an exception for a full platform window.
return ([self isVisible] && ((_styleMask & CPTitledWindowMask) || _isFullPlatformWindow));
}

/*!
Expand Down
8 changes: 8 additions & 0 deletions AppKit/_CPAttachedWindow.j
Expand Up @@ -389,6 +389,14 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
return YES;
}

/*!
Normally untitled windows cannot become main, but popovers can.
*/
- (BOOL)canBecomeMainWindow
{
return [self isVisible];
}

/*!
Called when the window is losing focus.
*/
Expand Down
9 changes: 8 additions & 1 deletion Foundation/CPRunLoop.j
Expand Up @@ -375,7 +375,14 @@ var CPRunLoopLastNativeRunLoop = 0;

//initiate a new window.setTimeout if there are any timers
if (_nextTimerFireDatesForModes[aMode] !== nil)
_nativeTimersForModes[aMode] = window.setNativeTimeout(function() { _effectiveDate = nextFireDate; _nativeTimersForModes[aMode] = nil; ++CPRunLoopLastNativeRunLoop; [self limitDateForMode:aMode]; _effectiveDate = nil; }, MAX(0, [nextFireDate timeIntervalSinceNow] * 1000));
_nativeTimersForModes[aMode] = window.setNativeTimeout(function()
{
_effectiveDate = nextFireDate;
_nativeTimersForModes[aMode] = nil;
++CPRunLoopLastNativeRunLoop;
[self limitDateForMode:aMode];
_effectiveDate = nil;
}, MAX(0, [nextFireDate timeIntervalSinceNow] * 1000));
}

// Run loop performers
Expand Down
18 changes: 16 additions & 2 deletions Foundation/CPTimer.j
Expand Up @@ -245,13 +245,27 @@ var _CPTimerBridgeTimer = function(codeOrFunction, aDelay, shouldRepeat, functio
theFunction = nil;

if (typeof codeOrFunction === "string")
theFunction = function() { new Function(codeOrFunction)(); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
{
theFunction = function()
{
new Function(codeOrFunction)();

if (!shouldRepeat)
CPTimersForTimeoutIDs[timeoutID] = nil;
}
}
else
{
if (!functionArgs)
functionArgs = [];

theFunction = function() { codeOrFunction.apply(window, functionArgs); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
theFunction = function()
{
codeOrFunction.apply(window, functionArgs);

if (!shouldRepeat)
CPTimersForTimeoutIDs[timeoutID] = nil;
}
}

// A call such as setTimeout(f) is technically invalid but browsers seem to treat it as setTimeout(f, 0), so so will we.
Expand Down
2 changes: 1 addition & 1 deletion Tests/Manual/CPPopover/Resources/MainMenu.cib

Large diffs are not rendered by default.

0 comments on commit 7fa01fa

Please sign in to comment.