Skip to content

Commit

Permalink
#417: remove more code from LookAndFeel; tune up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Sep 1, 2017
1 parent 8524974 commit 0792006
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion widget/cocoa/nsLookAndFeel.mm
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static nscolor GetColorFromNSColor(NSColor* aColor)
aResult = 4;
break;
case eIntID_ScrollArrowStyle:
#if(0)
#ifdef __LP64__
if (nsCocoaFeatures::OnLionOrLater()) {
// OS X Lion's scrollbars have no arrows
aResult = eScrollArrow_None;
Expand All @@ -374,18 +374,24 @@ static nscolor GetColorFromNSColor(NSColor* aColor)
aResult = eScrollThumbStyle_Proportional;
break;
case eIntID_UseOverlayScrollbars:
aResult = 0;
#ifdef __LP64__
if (!mUseOverlayScrollbarsCached) {
mUseOverlayScrollbars = SystemWantsOverlayScrollbars() ? 1 : 0;
mUseOverlayScrollbarsCached = true;
}
aResult = mUseOverlayScrollbars;
#endif
break;
case eIntID_AllowOverlayScrollbarsOverlap:
aResult = 0;
#ifdef __LP64__
if (!mAllowOverlayScrollbarsOverlapCached) {
mAllowOverlayScrollbarsOverlap = AllowOverlayScrollbarsOverlap() ? 1 : 0;
mAllowOverlayScrollbarsOverlapCached = true;
}
aResult = mAllowOverlayScrollbarsOverlap;
#endif
break;
case eIntID_ScrollbarDisplayOnMouseMove:
aResult = 0;
Expand Down Expand Up @@ -474,10 +480,12 @@ static nscolor GetColorFromNSColor(NSColor* aColor)
break;
case eIntID_SwipeAnimationEnabled:
aResult = 0;
#ifdef __LP64__
if ([NSEvent respondsToSelector:@selector(
isSwipeTrackingFromScrollEventsEnabled)]) {
aResult = [NSEvent isSwipeTrackingFromScrollEventsEnabled] ? 1 : 0;
}
#endif
break;
case eIntID_ColorPickerAvailable:
aResult = 1;
Expand Down
8 changes: 4 additions & 4 deletions widget/nsXPLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ nsXPLookAndFeel::GetColorImpl(ColorID aID, bool aUseStandinsForNativeColors,
nsresult
nsXPLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
{
if (!sInitialized)
if (MOZ_UNLIKELY(!sInitialized))
Init();

// Set the default values for these prefs. but allow different platforms
Expand All @@ -845,7 +845,7 @@ nsXPLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
}

for (unsigned int i = 0; i < ArrayLength(sIntPrefs); ++i) {
if (sIntPrefs[i].isSet && (sIntPrefs[i].id == aID)) {
if (MOZ_UNLIKELY(sIntPrefs[i].isSet && (sIntPrefs[i].id == aID))) {
aResult = sIntPrefs[i].intVar;
return NS_OK;
}
Expand All @@ -857,11 +857,11 @@ nsXPLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
nsresult
nsXPLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
{
if (!sInitialized)
if (MOZ_UNLIKELY(!sInitialized))
Init();

for (unsigned int i = 0; i < ArrayLength(sFloatPrefs); ++i) {
if (sFloatPrefs[i].isSet && sFloatPrefs[i].id == aID) {
if (MOZ_UNLIKELY(sFloatPrefs[i].isSet && sFloatPrefs[i].id == aID)) {
aResult = sFloatPrefs[i].floatVar;
return NS_OK;
}
Expand Down

0 comments on commit 0792006

Please sign in to comment.