mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1279017 - Remove code specific to 10.6-10.8 in widget/cocoa. r=mstange.
This commit is contained in:
parent
e4f93ee534
commit
a5320d1288
@ -104,65 +104,6 @@ class APZCTreeManager;
|
||||
|
||||
@end
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_6) || \
|
||||
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
|
||||
@interface NSEvent (SnowLeopardEventFeatures)
|
||||
+ (NSUInteger)pressedMouseButtons;
|
||||
+ (NSUInteger)modifierFlags;
|
||||
@end
|
||||
#endif
|
||||
|
||||
// The following section, required to support fluid swipe tracking on OS X 10.7
|
||||
// and up, contains defines/declarations that are only available on 10.7 and up.
|
||||
// [NSEvent trackSwipeEventWithOptions:...] also requires that the compiler
|
||||
// support "blocks"
|
||||
// (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html)
|
||||
// -- which it does on 10.6 and up (using the 10.6 SDK or higher).
|
||||
//
|
||||
// MAC_OS_X_VERSION_MAX_ALLOWED "controls which OS functionality, if used,
|
||||
// will result in a compiler error because that functionality is not
|
||||
// available" (quoting from AvailabilityMacros.h). The compiler initializes
|
||||
// it to the version of the SDK being used. Its value does *not* prevent the
|
||||
// binary from running on higher OS versions. MAC_OS_X_VERSION_10_7 and
|
||||
// friends are defined (in AvailabilityMacros.h) as decimal numbers (not
|
||||
// hexadecimal numbers).
|
||||
#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
enum {
|
||||
NSFullScreenWindowMask = 1 << 14
|
||||
};
|
||||
|
||||
@interface NSWindow (LionWindowFeatures)
|
||||
- (NSRect)convertRectToScreen:(NSRect)aRect;
|
||||
@end
|
||||
|
||||
#ifdef __LP64__
|
||||
enum {
|
||||
NSEventSwipeTrackingLockDirection = 0x1 << 0,
|
||||
NSEventSwipeTrackingClampGestureAmount = 0x1 << 1
|
||||
};
|
||||
typedef NSUInteger NSEventSwipeTrackingOptions;
|
||||
|
||||
enum {
|
||||
NSEventGestureAxisNone = 0,
|
||||
NSEventGestureAxisHorizontal,
|
||||
NSEventGestureAxisVertical
|
||||
};
|
||||
typedef NSInteger NSEventGestureAxis;
|
||||
|
||||
@interface NSEvent (FluidSwipeTracking)
|
||||
+ (BOOL)isSwipeTrackingFromScrollEventsEnabled;
|
||||
- (BOOL)hasPreciseScrollingDeltas;
|
||||
- (CGFloat)scrollingDeltaX;
|
||||
- (CGFloat)scrollingDeltaY;
|
||||
- (NSEventPhase)phase;
|
||||
- (void)trackSwipeEventWithOptions:(NSEventSwipeTrackingOptions)options
|
||||
dampenAmountThresholdMin:(CGFloat)minDampenThreshold
|
||||
max:(CGFloat)maxDampenThreshold
|
||||
usingHandler:(void (^)(CGFloat gestureAmount, NSEventPhase phase, BOOL isComplete, BOOL *stop))trackingHandler;
|
||||
@end
|
||||
#endif // #ifdef __LP64__
|
||||
#endif // #if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
|
||||
@interface ChildView : NSView<
|
||||
#ifdef ACCESSIBILITY
|
||||
mozAccessible,
|
||||
@ -311,9 +252,6 @@ typedef NSInteger NSEventGestureAxis;
|
||||
- (void)scrollWheel:(NSEvent *)anEvent;
|
||||
- (void)handleAsyncScrollEvent:(CGEventRef)cgEvent ofType:(CGEventType)type;
|
||||
|
||||
// Helper function for Lion smart magnify events
|
||||
+ (BOOL)isLionSmartMagnifyEvent:(NSEvent*)anEvent;
|
||||
|
||||
- (void)setUsingOMTCompositor:(BOOL)aUseOMTC;
|
||||
|
||||
- (NSEvent*)lastKeyDownEvent;
|
||||
|
@ -487,13 +487,11 @@ nsresult nsChildView::Create(nsIWidget* aParent,
|
||||
nsToolkit::SwizzleMethods([NSView class], @selector(mouseDownCanMoveWindow),
|
||||
@selector(nsChildView_NSView_mouseDownCanMoveWindow));
|
||||
#ifdef __LP64__
|
||||
if (nsCocoaFeatures::OnLionOrLater()) {
|
||||
nsToolkit::SwizzleMethods([NSEvent class], @selector(addLocalMonitorForEventsMatchingMask:handler:),
|
||||
@selector(nsChildView_NSEvent_addLocalMonitorForEventsMatchingMask:handler:),
|
||||
true);
|
||||
nsToolkit::SwizzleMethods([NSEvent class], @selector(removeMonitor:),
|
||||
@selector(nsChildView_NSEvent_removeMonitor:), true);
|
||||
}
|
||||
nsToolkit::SwizzleMethods([NSEvent class], @selector(addLocalMonitorForEventsMatchingMask:handler:),
|
||||
@selector(nsChildView_NSEvent_addLocalMonitorForEventsMatchingMask:handler:),
|
||||
true);
|
||||
nsToolkit::SwizzleMethods([NSEvent class], @selector(removeMonitor:),
|
||||
@selector(nsChildView_NSEvent_removeMonitor:), true);
|
||||
#endif
|
||||
gChildViewMethodsSwizzled = true;
|
||||
}
|
||||
@ -4338,15 +4336,6 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
if (!anEvent || !mGeckoChild)
|
||||
return;
|
||||
|
||||
/*
|
||||
* In OS X 10.7.* (Lion), smart zoom events come through magnifyWithEvent,
|
||||
* instead of smartMagnifyWithEvent. See bug 863841.
|
||||
*/
|
||||
if ([ChildView isLionSmartMagnifyEvent: anEvent]) {
|
||||
[self smartMagnifyWithEvent: anEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
||||
|
||||
float deltaZ = [anEvent deltaZ];
|
||||
@ -4511,28 +4500,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
+ (BOOL)isLionSmartMagnifyEvent:(NSEvent*)anEvent
|
||||
{
|
||||
/*
|
||||
* On Lion, smart zoom events have type NSEventTypeGesture, subtype 0x16,
|
||||
* whereas pinch zoom events have type NSEventTypeMagnify. So, use that to
|
||||
* discriminate between the two. Smart zoom gestures do not call
|
||||
* beginGestureWithEvent or endGestureWithEvent, so mGestureState is not
|
||||
* changed. Documentation couldn't be found for the meaning of the subtype
|
||||
* 0x16, but it will probably never change. See bug 863841.
|
||||
*/
|
||||
return nsCocoaFeatures::OnLionOrLater() &&
|
||||
!nsCocoaFeatures::OnMountainLionOrLater() &&
|
||||
[anEvent type] == NSEventTypeGesture &&
|
||||
[anEvent subtype] == 0x16;
|
||||
}
|
||||
|
||||
- (bool)shouldConsiderStartingSwipeFromEvent:(NSEvent*)anEvent
|
||||
{
|
||||
if (!nsCocoaFeatures::OnLionOrLater()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This method checks whether the AppleEnableSwipeNavigateWithScrolls global
|
||||
// preference is set. If it isn't, fluid swipe tracking is disabled, and a
|
||||
// horizontal two-finger gesture is always a scroll (even in Safari). This
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#define MAC_OS_X_VERSION_MASK 0x0000FFFF
|
||||
#define MAC_OS_X_VERSION_10_0_HEX 0x00001000
|
||||
#define MAC_OS_X_VERSION_10_6_HEX 0x00001060
|
||||
#define MAC_OS_X_VERSION_10_7_HEX 0x00001070
|
||||
#define MAC_OS_X_VERSION_10_8_HEX 0x00001080
|
||||
#define MAC_OS_X_VERSION_10_9_HEX 0x00001090
|
||||
@ -83,12 +82,12 @@ int32_t nsCocoaFeatures::GetVersion(int32_t aMajor, int32_t aMinor, int32_t aBug
|
||||
int32_t osxVersion;
|
||||
if (aMajor < 10) {
|
||||
aMajor = 10;
|
||||
NS_ERROR("Couldn't determine OS X version, assuming 10.6");
|
||||
osxVersion = MAC_OS_X_VERSION_10_6_HEX;
|
||||
} else if (aMinor < 6) {
|
||||
aMinor = 6;
|
||||
NS_ERROR("OS X version too old, assuming 10.6");
|
||||
osxVersion = MAC_OS_X_VERSION_10_6_HEX;
|
||||
NS_ERROR("Couldn't determine OS X version, assuming 10.7");
|
||||
osxVersion = MAC_OS_X_VERSION_10_7_HEX;
|
||||
} else if (aMinor < 7) {
|
||||
aMinor = 7;
|
||||
NS_ERROR("OS X version too old, assuming 10.7");
|
||||
osxVersion = MAC_OS_X_VERSION_10_7_HEX;
|
||||
} else {
|
||||
MOZ_ASSERT(aMajor == 10); // For now, even though we're ready...
|
||||
MOZ_ASSERT(aMinor < 16);
|
||||
|
@ -25,24 +25,11 @@
|
||||
- (CGFloat)backingScaleFactor;
|
||||
@end
|
||||
|
||||
// When building with a pre-10.7 SDK, NSEventPhase is not defined.
|
||||
#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
enum {
|
||||
NSEventPhaseNone = 0,
|
||||
NSEventPhaseBegan = 0x1 << 0,
|
||||
NSEventPhaseStationary = 0x1 << 1,
|
||||
NSEventPhaseChanged = 0x1 << 2,
|
||||
NSEventPhaseEnded = 0x1 << 3,
|
||||
NSEventPhaseCancelled = 0x1 << 4,
|
||||
};
|
||||
typedef NSUInteger NSEventPhase;
|
||||
#endif // #if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_8) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
|
||||
enum {
|
||||
NSEventPhaseMayBegin = 0x1 << 5
|
||||
};
|
||||
#endif // #if !defined(MAC_OS_X_VERSION_10_8) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
|
||||
#endif
|
||||
|
||||
class nsIWidget;
|
||||
|
||||
@ -99,11 +86,6 @@ private:
|
||||
// versions of OS X from (at least) 10.2.8 through 10.5.
|
||||
- (void)_modalSession:(NSModalSession)aSession sendEvent:(NSEvent *)theEvent;
|
||||
|
||||
// Present (and documented) on OS X 10.6 and above. Not present before 10.6.
|
||||
// This declaration needed to avoid compiler warnings when compiling on 10.5
|
||||
// and below (or using the 10.5 SDK and below).
|
||||
- (void)setHelpMenu:(NSMenu *)helpMenu;
|
||||
|
||||
@end
|
||||
|
||||
struct KeyBindingsCommand
|
||||
|
@ -20,36 +20,6 @@ class nsChildView;
|
||||
class nsMenuBarX;
|
||||
@class ChildView;
|
||||
|
||||
// If we are using an SDK older than 10.7, define bits we need that are missing
|
||||
// from it.
|
||||
#if !defined(MAC_OS_X_VERSION_10_7) || \
|
||||
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
|
||||
enum {
|
||||
NSWindowAnimationBehaviorDefault = 0,
|
||||
NSWindowAnimationBehaviorNone = 2,
|
||||
NSWindowAnimationBehaviorDocumentWindow = 3,
|
||||
NSWindowAnimationBehaviorUtilityWindow = 4,
|
||||
NSWindowAnimationBehaviorAlertPanel = 5,
|
||||
NSWindowCollectionBehaviorFullScreenPrimary = 128, // 1 << 7
|
||||
};
|
||||
|
||||
typedef NSInteger NSWindowAnimationBehavior;
|
||||
|
||||
@interface NSWindow (LionWindowFeatures)
|
||||
- (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior;
|
||||
- (void)toggleFullScreen:(id)sender;
|
||||
@end
|
||||
|
||||
typedef struct NSEdgeInsets {
|
||||
CGFloat top;
|
||||
CGFloat left;
|
||||
CGFloat bottom;
|
||||
CGFloat right;
|
||||
} NSEdgeInsets;
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct _nsCocoaWindowList {
|
||||
_nsCocoaWindowList() : prev(nullptr), window(nullptr) {}
|
||||
struct _nsCocoaWindowList *prev;
|
||||
@ -182,11 +152,7 @@ typedef struct _nsCocoaWindowList {
|
||||
|
||||
@end
|
||||
|
||||
#if defined( MAC_OS_X_VERSION_10_6 ) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 )
|
||||
@interface WindowDelegate : NSObject <NSWindowDelegate>
|
||||
#else
|
||||
@interface WindowDelegate : NSObject
|
||||
#endif
|
||||
{
|
||||
nsCocoaWindow* mGeckoWindow; // [WEAK] (we are owned by the window)
|
||||
// Used to avoid duplication when we send NS_ACTIVATE and
|
||||
@ -446,9 +412,8 @@ protected:
|
||||
|
||||
// Only true on 10.7+ if SetShowsFullScreenButton(true) is called.
|
||||
bool mSupportsNativeFullScreen;
|
||||
// Whether we are currently using Lion native fullscreen. It could be
|
||||
// false either because we are not on Lion, or we are in the DOM
|
||||
// fullscreen where we do not use the native fullscreen.
|
||||
// Whether we are currently using native fullscreen. It could be false because
|
||||
// we are in the DOM fullscreen where we do not use the native fullscreen.
|
||||
bool mInNativeFullScreenMode;
|
||||
|
||||
bool mIsAnimationSuppressed;
|
||||
|
@ -3263,7 +3263,7 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior";
|
||||
// We work around this problem by only returning AXChildren that are
|
||||
// mozAccessible object or are one of the titlebar's buttons (which
|
||||
// instantiate subclasses of NSButtonCell).
|
||||
if (nsCocoaFeatures::OnLionOrLater() && [retval isKindOfClass:[NSArray class]] &&
|
||||
if ([retval isKindOfClass:[NSArray class]] &&
|
||||
[attribute isEqualToString:@"AXChildren"]) {
|
||||
NSMutableArray *holder = [NSMutableArray arrayWithCapacity:10];
|
||||
[holder addObjectsFromArray:(NSArray *)retval];
|
||||
@ -3284,22 +3284,6 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior";
|
||||
return retval;
|
||||
}
|
||||
|
||||
// If we were built on OS X 10.6 or with the 10.6 SDK and are running on Lion,
|
||||
// the OS (specifically -[NSWindow sendEvent:]) won't send NSEventTypeGesture
|
||||
// events to -[ChildView magnifyWithEvent:] as it should. The following code
|
||||
// gets around this. See bug 863841.
|
||||
#if !defined( MAC_OS_X_VERSION_10_7 ) || \
|
||||
( MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 )
|
||||
- (void)sendEvent:(NSEvent *)anEvent
|
||||
{
|
||||
if ([ChildView isLionSmartMagnifyEvent: anEvent]) {
|
||||
[[self mainChildView] magnifyWithEvent:anEvent];
|
||||
return;
|
||||
}
|
||||
[super sendEvent:anEvent];
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
// This class allows us to exercise control over the window's title bar. This
|
||||
@ -3361,7 +3345,7 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior";
|
||||
// setBottomCornerRounded: is a private API call, so we check to make sure
|
||||
// we respond to it just in case.
|
||||
if ([self respondsToSelector:@selector(setBottomCornerRounded:)])
|
||||
[self setBottomCornerRounded:nsCocoaFeatures::OnLionOrLater()];
|
||||
[self setBottomCornerRounded:YES];
|
||||
|
||||
[self setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
|
||||
[self setContentBorderThickness:0.0f forEdge:NSMaxYEdge];
|
||||
@ -3657,14 +3641,11 @@ DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
|
||||
{
|
||||
nsNativeThemeCocoa::DrawNativeTitlebar(aContext, aTitlebarRect, aUnifiedToolbarHeight, aIsMain, NO);
|
||||
|
||||
if (nsCocoaFeatures::OnLionOrLater()) {
|
||||
// On Lion the call to CUIDraw doesn't draw the top pixel strip at some
|
||||
// window widths. We don't want to have a flickering transparent line, so
|
||||
// we overdraw it.
|
||||
CGContextSetRGBFillColor(aContext, 0.95, 0.95, 0.95, 1);
|
||||
CGContextFillRect(aContext, CGRectMake(0, CGRectGetMaxY(aTitlebarRect) - 1,
|
||||
// The call to CUIDraw doesn't draw the top pixel strip at some window widths.
|
||||
// We don't want to have a flickering transparent line, so we overdraw it.
|
||||
CGContextSetRGBFillColor(aContext, 0.95, 0.95, 0.95, 1);
|
||||
CGContextFillRect(aContext, CGRectMake(0, CGRectGetMaxY(aTitlebarRect) - 1,
|
||||
aTitlebarRect.size.width, 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Pattern draw callback for standard titlebar gradients and solid titlebar colors
|
||||
|
@ -346,21 +346,7 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
||||
aResult = 4;
|
||||
break;
|
||||
case eIntID_ScrollArrowStyle:
|
||||
if (nsCocoaFeatures::OnLionOrLater()) {
|
||||
// OS X Lion's scrollbars have no arrows
|
||||
aResult = eScrollArrow_None;
|
||||
} else {
|
||||
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
||||
if ([buttonPlacement isEqualToString:@"Single"]) {
|
||||
aResult = eScrollArrowStyle_Single;
|
||||
} else if ([buttonPlacement isEqualToString:@"DoubleMin"]) {
|
||||
aResult = eScrollArrowStyle_BothAtTop;
|
||||
} else if ([buttonPlacement isEqualToString:@"DoubleBoth"]) {
|
||||
aResult = eScrollArrowStyle_BothAtEachEnd;
|
||||
} else {
|
||||
aResult = eScrollArrowStyle_BothAtBottom; // The default is BothAtBottom.
|
||||
}
|
||||
}
|
||||
aResult = eScrollArrow_None;
|
||||
break;
|
||||
case eIntID_ScrollSliderStyle:
|
||||
aResult = eScrollThumbStyle_Proportional;
|
||||
@ -525,7 +511,7 @@ bool nsLookAndFeel::SystemWantsOverlayScrollbars()
|
||||
|
||||
bool nsLookAndFeel::AllowOverlayScrollbarsOverlap()
|
||||
{
|
||||
return (UseOverlayScrollbars() && nsCocoaFeatures::OnMountainLionOrLater());
|
||||
return UseOverlayScrollbars();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -23,11 +23,7 @@ class nsIWidget;
|
||||
|
||||
// MenuDelegate is used to receive Cocoa notifications for setting
|
||||
// up carbon events. Protocol is defined as of 10.6 SDK.
|
||||
#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6)
|
||||
@interface MenuDelegate : NSObject < NSMenuDelegate >
|
||||
#else
|
||||
@interface MenuDelegate : NSObject
|
||||
#endif
|
||||
{
|
||||
nsMenuX* mGeckoMenu; // weak ref
|
||||
}
|
||||
|
@ -470,8 +470,6 @@ WindowButtonsSize(nsIFrame* aFrame)
|
||||
NSWindow* window = NativeWindowForFrame(aFrame);
|
||||
if (!window) {
|
||||
// Return fallback values.
|
||||
if (!nsCocoaFeatures::OnLionOrLater())
|
||||
return NSMakeSize(57, 16);
|
||||
return NSMakeSize(54, 16);
|
||||
}
|
||||
|
||||
@ -1115,8 +1113,7 @@ nsNativeThemeCocoa::DrawSearchField(CGContextRef cgContext, const HIRect& inBoxR
|
||||
}
|
||||
|
||||
static const NSSize kCheckmarkSize = NSMakeSize(11, 11);
|
||||
static const NSSize kMenuarrowSize = nsCocoaFeatures::OnLionOrLater() ?
|
||||
NSMakeSize(9, 10) : NSMakeSize(8, 10);
|
||||
static const NSSize kMenuarrowSize = NSMakeSize(9, 10);
|
||||
static const NSSize kMenuScrollArrowSize = NSMakeSize(10, 8);
|
||||
static NSString* kCheckmarkImage = @"MenuOnState";
|
||||
static NSString* kMenuarrowRightImage = @"MenuSubmenu";
|
||||
@ -1144,19 +1141,8 @@ nsNativeThemeCocoa::DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect,
|
||||
aRect.origin.y + ceil(paddingY / 2),
|
||||
aIconSize.width, aIconSize.height);
|
||||
|
||||
BOOL isDisabled = IsDisabled(aFrame, inState);
|
||||
BOOL isActive = CheckBooleanAttr(aFrame, nsGkAtoms::menuactive);
|
||||
|
||||
// On 10.6 and at least on 10.7.0, Apple doesn’t seem to have implemented all
|
||||
// keys and values used on 10.7.5 and later. We can however draw menu icons
|
||||
// on earlier OS versions by using different keys/values.
|
||||
BOOL otherKeysAndValues = !nsCocoaFeatures::IsAtLeastVersion(10,7,5);
|
||||
|
||||
// 2 states combined with 2 different backgroundTypeKeys on earlier versions.
|
||||
NSString* state = isDisabled ? @"disabled" :
|
||||
(isActive && !otherKeysAndValues) ? @"pressed" : @"normal";
|
||||
NSString* backgroundTypeKey = !otherKeysAndValues ? @"kCUIBackgroundTypeMenu" :
|
||||
!isDisabled && isActive ? @"backgroundTypeDark" : @"backgroundTypeLight";
|
||||
NSString* state = IsDisabled(aFrame, inState) ? @"disabled" :
|
||||
(CheckBooleanAttr(aFrame, nsGkAtoms::menuactive) ? @"pressed" : @"normal");
|
||||
|
||||
NSString* imageName = aImageName;
|
||||
if (!nsCocoaFeatures::OnElCapitanOrLater()) {
|
||||
@ -1164,19 +1150,14 @@ nsNativeThemeCocoa::DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect,
|
||||
imageName = [@"image." stringByAppendingString:aImageName];
|
||||
}
|
||||
|
||||
NSMutableArray* keys = [NSMutableArray arrayWithObjects:@"backgroundTypeKey",
|
||||
@"imageNameKey", @"state", @"widget", @"is.flipped", nil];
|
||||
NSMutableArray* values = [NSMutableArray arrayWithObjects: backgroundTypeKey,
|
||||
imageName, state, @"image", [NSNumber numberWithBool:YES], nil];
|
||||
|
||||
if (otherKeysAndValues) { // Earlier versions used one more key-value pair.
|
||||
[keys insertObject:@"imageIsGrayscaleKey" atIndex:1];
|
||||
[values insertObject:[NSNumber numberWithBool:YES] atIndex:1];
|
||||
}
|
||||
|
||||
RenderWithCoreUI(drawRect, cgContext,
|
||||
[NSDictionary dictionaryWithObjects:values
|
||||
forKeys:keys]);
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"kCUIBackgroundTypeMenu", @"backgroundTypeKey",
|
||||
aImageName, @"imageNameKey",
|
||||
state, @"state",
|
||||
@"image", @"widget",
|
||||
[NSNumber numberWithBool:YES], @"is.flipped",
|
||||
nil]);
|
||||
|
||||
#if DRAW_IN_FRAME_DEBUG
|
||||
CGContextSetRGBFillColor(cgContext, 0.0, 0.0, 0.5, 0.25);
|
||||
@ -2072,13 +2053,6 @@ nsNativeThemeCocoa::DrawSegment(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||
nil]);
|
||||
}
|
||||
|
||||
static inline UInt8
|
||||
ConvertToPressState(EventStates aButtonState, UInt8 aPressState)
|
||||
{
|
||||
// If the button is pressed, return the press state passed in. Otherwise, return 0.
|
||||
return aButtonState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER) ? aPressState : 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsNativeThemeCocoa::GetScrollbarPressStates(nsIFrame* aFrame,
|
||||
EventStates aButtonStates[])
|
||||
@ -2160,30 +2134,6 @@ nsNativeThemeCocoa::GetScrollbarDrawInfo(HIThemeTrackDrawInfo& aTdi, nsIFrame *a
|
||||
|
||||
aTdi.trackInfo.scrollbar.pressState = 0;
|
||||
|
||||
// Only go get these scrollbar button states if we need it. For example,
|
||||
// there's no reason to look up scrollbar button states when we're only
|
||||
// creating a TrackDrawInfo to determine the size of the thumb. There's
|
||||
// also no reason to do this on Lion or later, whose scrollbars have no
|
||||
// arrow buttons.
|
||||
if (aShouldGetButtonStates && !nsCocoaFeatures::OnLionOrLater()) {
|
||||
EventStates buttonStates[4];
|
||||
GetScrollbarPressStates(aFrame, buttonStates);
|
||||
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
||||
// It seems that unless all four buttons are showing, kThemeTopOutsideArrowPressed is the correct constant for
|
||||
// the up scrollbar button.
|
||||
if ([buttonPlacement isEqualToString:@"DoubleBoth"]) {
|
||||
aTdi.trackInfo.scrollbar.pressState = ConvertToPressState(buttonStates[0], kThemeTopOutsideArrowPressed) |
|
||||
ConvertToPressState(buttonStates[1], kThemeTopInsideArrowPressed) |
|
||||
ConvertToPressState(buttonStates[2], kThemeBottomInsideArrowPressed) |
|
||||
ConvertToPressState(buttonStates[3], kThemeBottomOutsideArrowPressed);
|
||||
} else {
|
||||
aTdi.trackInfo.scrollbar.pressState = ConvertToPressState(buttonStates[0], kThemeTopOutsideArrowPressed) |
|
||||
ConvertToPressState(buttonStates[1], kThemeBottomOutsideArrowPressed) |
|
||||
ConvertToPressState(buttonStates[2], kThemeTopOutsideArrowPressed) |
|
||||
ConvertToPressState(buttonStates[3], kThemeBottomOutsideArrowPressed);
|
||||
}
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
@ -2391,7 +2341,7 @@ DrawVibrancyBackground(CGContextRef cgContext, CGRect inBoxRect,
|
||||
static bool
|
||||
ScrollbarTrackAndThumbDrawSeparately()
|
||||
{
|
||||
return nsLookAndFeel::UseOverlayScrollbars() || nsCocoaFeatures::OnLionOrLater();
|
||||
return nsLookAndFeel::UseOverlayScrollbars();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2882,7 +2832,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
|
||||
BOOL isRolledOver = IsParentScrollbarRolledOver(aFrame);
|
||||
nsIFrame* scrollbarFrame = GetParentScrollbarFrame(aFrame);
|
||||
bool isSmall = (scrollbarFrame && scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL);
|
||||
if (isOverlay && (!nsCocoaFeatures::OnMountainLionOrLater() || !isRolledOver)) {
|
||||
if (isOverlay && !isRolledOver) {
|
||||
if (isHorizontal) {
|
||||
macRect.origin.y += 4;
|
||||
macRect.size.height -= 4;
|
||||
@ -2933,21 +2883,6 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
|
||||
BOOL isHorizontal = (aWidgetType == NS_THEME_SCROLLBARTRACK_HORIZONTAL);
|
||||
nsIFrame* scrollbarFrame = GetParentScrollbarFrame(aFrame);
|
||||
bool isSmall = (scrollbarFrame && scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL);
|
||||
if (isOverlay && !nsCocoaFeatures::OnMountainLionOrLater()) {
|
||||
// On OSX 10.7, scrollbars don't grow when hovered.
|
||||
// The adjustments below were obtained by trial and error.
|
||||
if (isHorizontal) {
|
||||
macRect.origin.y += 2.0;
|
||||
} else {
|
||||
if (aFrame->StyleVisibility()->mDirection !=
|
||||
NS_STYLE_DIRECTION_RTL) {
|
||||
macRect.origin.x += 3.0;
|
||||
} else {
|
||||
macRect.origin.x -= 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const BOOL isOnTopOfDarkBackground = IsDarkBackground(aFrame);
|
||||
RenderWithCoreUILegacy(macRect, cgContext,
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@ -3165,27 +3100,6 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext,
|
||||
case NS_THEME_SCROLLBARTRACK_VERTICAL:
|
||||
{
|
||||
bool isHorizontal = (aWidgetType == NS_THEME_SCROLLBARTRACK_HORIZONTAL);
|
||||
|
||||
// On Lion and later, scrollbars have no arrows.
|
||||
if (!nsCocoaFeatures::OnLionOrLater()) {
|
||||
// There's only an endcap to worry about when both arrows are on the bottom
|
||||
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
||||
if (!buttonPlacement || [buttonPlacement isEqualToString:@"DoubleMax"]) {
|
||||
nsIFrame *scrollbarFrame = GetParentScrollbarFrame(aFrame);
|
||||
if (!scrollbarFrame) return NS_ERROR_FAILURE;
|
||||
bool isSmall = (scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL);
|
||||
|
||||
// There isn't a metric for this, so just hardcode a best guess at the value.
|
||||
// This value is even less exact due to the fact that the endcap is partially concave.
|
||||
int32_t endcapSize = isSmall ? 5 : 6;
|
||||
|
||||
if (isHorizontal)
|
||||
aResult->SizeTo(0, 0, 0, endcapSize);
|
||||
else
|
||||
aResult->SizeTo(endcapSize, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsLookAndFeel::UseOverlayScrollbars()) {
|
||||
if (isHorizontal) {
|
||||
aResult->SizeTo(2, 1, 1, 1);
|
||||
|
@ -15,14 +15,6 @@ enum ColorName {
|
||||
toolbarBottomBorderGrey,
|
||||
};
|
||||
|
||||
static const int sSnowLeopardThemeColors[][2] = {
|
||||
/* { active window, inactive window } */
|
||||
// toolbar:
|
||||
{ 0xD0, 0xF1 }, // top separator line
|
||||
{ 0xA7, 0xD8 }, // fill color
|
||||
{ 0x51, 0x99 }, // bottom separator line
|
||||
};
|
||||
|
||||
static const int sLionThemeColors[][2] = {
|
||||
/* { active window, inactive window } */
|
||||
// toolbar:
|
||||
@ -44,11 +36,7 @@ static int NativeGreyColorAsInt(ColorName name, BOOL isMain)
|
||||
{
|
||||
if (nsCocoaFeatures::OnYosemiteOrLater())
|
||||
return sYosemiteThemeColors[name][isMain ? 0 : 1];
|
||||
|
||||
if (nsCocoaFeatures::OnLionOrLater())
|
||||
return sLionThemeColors[name][isMain ? 0 : 1];
|
||||
|
||||
return sSnowLeopardThemeColors[name][isMain ? 0 : 1];
|
||||
return sLionThemeColors[name][isMain ? 0 : 1];
|
||||
}
|
||||
|
||||
__attribute__((unused))
|
||||
|
Loading…
Reference in New Issue
Block a user