From 981c2e8fef1ef229b9b6e352c723017705a89fd3 Mon Sep 17 00:00:00 2001 From: Cameron Kaiser Date: Sat, 2 Sep 2017 13:44:20 -0700 Subject: [PATCH] #437, #417: tune up LookAndFeel; some more 10.7+ removals --- widget/cocoa/nsLookAndFeel.mm | 219 ++++++++++++++++++---------------- widget/nsXPLookAndFeel.cpp | 165 ++++++++++++++----------- widget/nsXPLookAndFeel.h | 2 + 3 files changed, 211 insertions(+), 175 deletions(-) diff --git a/widget/cocoa/nsLookAndFeel.mm b/widget/cocoa/nsLookAndFeel.mm index dd7de4c905..58e34da5cc 100644 --- a/widget/cocoa/nsLookAndFeel.mm +++ b/widget/cocoa/nsLookAndFeel.mm @@ -62,77 +62,77 @@ static nscolor GetColorFromNSColor(NSColor* aColor) switch (aID) { case eColorID_WindowBackground: aColor = NS_RGB(0xff,0xff,0xff); - break; + return res; case eColorID_WindowForeground: aColor = NS_RGB(0x00,0x00,0x00); - break; + return res; case eColorID_WidgetBackground: aColor = NS_RGB(0xdd,0xdd,0xdd); - break; + return res; case eColorID_WidgetForeground: aColor = NS_RGB(0x00,0x00,0x00); - break; + return res; case eColorID_WidgetSelectBackground: aColor = NS_RGB(0x80,0x80,0x80); - break; + return res; case eColorID_WidgetSelectForeground: aColor = NS_RGB(0x00,0x00,0x80); - break; + return res; case eColorID_Widget3DHighlight: aColor = NS_RGB(0xa0,0xa0,0xa0); - break; + return res; case eColorID_Widget3DShadow: aColor = NS_RGB(0x40,0x40,0x40); - break; + return res; case eColorID_TextBackground: aColor = NS_RGB(0xff,0xff,0xff); - break; + return res; case eColorID_TextForeground: aColor = NS_RGB(0x00,0x00,0x00); - break; + return res; case eColorID_TextSelectBackground: aColor = GetColorFromNSColor([NSColor selectedTextBackgroundColor]); - break; + return res; case eColorID_highlight: // CSS2 color aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]); - break; + return res; case eColorID__moz_menuhover: aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]); - break; + return res; case eColorID_TextSelectForeground: GetColor(eColorID_TextSelectBackground, aColor); if (aColor == 0x000000) aColor = NS_RGB(0xff,0xff,0xff); else aColor = NS_DONT_CHANGE_COLOR; - break; + return res; case eColorID_highlighttext: // CSS2 color case eColorID__moz_menuhovertext: aColor = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]); - break; + return res; case eColorID_IMESelectedRawTextBackground: case eColorID_IMESelectedConvertedTextBackground: case eColorID_IMERawInputBackground: case eColorID_IMEConvertedTextBackground: aColor = NS_TRANSPARENT; - break; + return res; case eColorID_IMESelectedRawTextForeground: case eColorID_IMESelectedConvertedTextForeground: case eColorID_IMERawInputForeground: case eColorID_IMEConvertedTextForeground: aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; + return res; case eColorID_IMERawInputUnderline: case eColorID_IMEConvertedTextUnderline: aColor = NS_40PERCENT_FOREGROUND_COLOR; - break; + return res; case eColorID_IMESelectedRawTextUnderline: case eColorID_IMESelectedConvertedTextUnderline: aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; + return res; case eColorID_SpellCheckerUnderline: aColor = NS_RGB(0xff, 0, 0); - break; + return res; // // css2 system colors http://www.w3.org/TR/REC-CSS2/ui.html#system-colors @@ -147,158 +147,161 @@ static nscolor GetColorFromNSColor(NSColor* aColor) // case eColorID__moz_mac_buttonactivetext: case eColorID__moz_mac_defaultbuttontext: +#ifdef __LP64__ if (nsCocoaFeatures::OnYosemiteOrLater()) { aColor = NS_RGB(0xFF,0xFF,0xFF); - break; + return res; } // Otherwise fall through and return the regular button text: - +#endif case eColorID_buttontext: case eColorID__moz_buttonhovertext: aColor = GetColorFromNSColor([NSColor controlTextColor]); - break; + return res; case eColorID_captiontext: case eColorID_menutext: case eColorID_infotext: case eColorID__moz_menubartext: aColor = GetColorFromNSColor([NSColor textColor]); - break; + return res; case eColorID_windowtext: aColor = GetColorFromNSColor([NSColor windowFrameTextColor]); - break; + return res; case eColorID_activecaption: aColor = GetColorFromNSColor([NSColor gridColor]); - break; + return res; case eColorID_activeborder: aColor = NS_RGB(0x00,0x00,0x00); - break; + return res; case eColorID_appworkspace: aColor = NS_RGB(0xFF,0xFF,0xFF); - break; + return res; case eColorID_background: aColor = NS_RGB(0x63,0x63,0xCE); - break; + return res; case eColorID_buttonface: case eColorID__moz_buttonhoverface: aColor = NS_RGB(0xF0,0xF0,0xF0); - break; + return res; case eColorID_buttonhighlight: aColor = NS_RGB(0xFF,0xFF,0xFF); - break; + return res; case eColorID_buttonshadow: aColor = NS_RGB(0xDC,0xDC,0xDC); - break; + return res; case eColorID_graytext: aColor = GetColorFromNSColor([NSColor disabledControlTextColor]); - break; + return res; case eColorID_inactiveborder: aColor = GetColorFromNSColor([NSColor controlBackgroundColor]); - break; + return res; case eColorID_inactivecaption: aColor = GetColorFromNSColor([NSColor controlBackgroundColor]); - break; + return res; case eColorID_inactivecaptiontext: aColor = NS_RGB(0x45,0x45,0x45); - break; + return res; case eColorID_scrollbar: aColor = GetColorFromNSColor([NSColor scrollBarColor]); - break; + return res; case eColorID_threeddarkshadow: aColor = NS_RGB(0xDC,0xDC,0xDC); - break; + return res; case eColorID_threedshadow: aColor = NS_RGB(0xE0,0xE0,0xE0); - break; + return res; case eColorID_threedface: aColor = NS_RGB(0xF0,0xF0,0xF0); - break; + return res; case eColorID_threedhighlight: aColor = GetColorFromNSColor([NSColor highlightColor]); - break; + return res; case eColorID_threedlightshadow: aColor = NS_RGB(0xDA,0xDA,0xDA); - break; + return res; case eColorID_menu: aColor = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]); - break; + return res; case eColorID_infobackground: aColor = NS_RGB(0xFF,0xFF,0xC7); - break; + return res; case eColorID_windowframe: aColor = GetColorFromNSColor([NSColor gridColor]); - break; + return res; case eColorID_window: case eColorID__moz_field: case eColorID__moz_combobox: aColor = NS_RGB(0xff,0xff,0xff); - break; + return res; case eColorID__moz_fieldtext: case eColorID__moz_comboboxtext: aColor = GetColorFromNSColor([NSColor controlTextColor]); - break; + return res; case eColorID__moz_dialog: aColor = GetColorFromNSColor([NSColor controlHighlightColor]); - break; + return res; case eColorID__moz_dialogtext: case eColorID__moz_cellhighlighttext: case eColorID__moz_html_cellhighlighttext: aColor = GetColorFromNSColor([NSColor controlTextColor]); - break; + return res; case eColorID__moz_dragtargetzone: aColor = GetColorFromNSColor([NSColor selectedControlColor]); - break; + return res; case eColorID__moz_mac_chrome_active: case eColorID__moz_mac_chrome_inactive: { int grey = NativeGreyColorAsInt(headerEndGrey, (aID == eColorID__moz_mac_chrome_active)); aColor = NS_RGB(grey, grey, grey); } - break; + return res; case eColorID__moz_mac_focusring: aColor = GetColorFromNSColor([NSColor keyboardFocusIndicatorColor]); - break; + return res; case eColorID__moz_mac_menushadow: aColor = NS_RGB(0xA3,0xA3,0xA3); - break; + return res; case eColorID__moz_mac_menutextdisable: aColor = NS_RGB(0x98,0x98,0x98); - break; + return res; case eColorID__moz_mac_menutextselect: aColor = GetColorFromNSColor([NSColor selectedMenuItemTextColor]); - break; + return res; case eColorID__moz_mac_disabledtoolbartext: aColor = GetColorFromNSColor([NSColor disabledControlTextColor]); - break; + return res; case eColorID__moz_mac_menuselect: aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]); - break; + return res; case eColorID__moz_buttondefault: aColor = NS_RGB(0xDC,0xDC,0xDC); - break; + return res; case eColorID__moz_cellhighlight: case eColorID__moz_html_cellhighlight: case eColorID__moz_mac_secondaryhighlight: // For inactive list selection aColor = GetColorFromNSColor([NSColor secondarySelectedControlColor]); - break; + return res; case eColorID__moz_eventreerow: // Background color of even list rows. aColor = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] objectAtIndex:0]); - break; + return res; case eColorID__moz_oddtreerow: // Background color of odd list rows. aColor = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] objectAtIndex:1]); - break; + return res; case eColorID__moz_nativehyperlinktext: // There appears to be no available system defined color. HARDCODING to the appropriate color. aColor = NS_RGB(0x14,0x4F,0xAE); - break; + return res; default: NS_WARNING("Someone asked nsILookAndFeel for a color I don't know about"); aColor = NS_RGB(0xff,0xff,0xff); res = NS_ERROR_FAILURE; - break; + return res; } + // unreachable? + res = NS_ERROR_FAILURE; return res; NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; @@ -317,35 +320,35 @@ static nscolor GetColorFromNSColor(NSColor* aColor) switch (aID) { case eIntID_CaretBlinkTime: aResult = 567; - break; + return res; case eIntID_CaretWidth: aResult = 1; - break; + return res; case eIntID_ShowCaretDuringSelection: aResult = 0; - break; + return res; case eIntID_SelectTextfieldsOnKeyFocus: // Select textfield content when focused by kbd // used by EventStateManager::sTextfieldSelectModel aResult = 1; - break; + return res; case eIntID_SubmenuDelay: aResult = 200; - break; + return res; case eIntID_TooltipDelay: aResult = 500; - break; + return res; case eIntID_MenusCanOverlapOSBar: // xul popups are not allowed to overlap the menubar. aResult = 0; - break; + return res; case eIntID_SkipNavigatingDisabledMenuItem: aResult = 1; - break; + return res; case eIntID_DragThresholdX: case eIntID_DragThresholdY: aResult = 4; - break; + return res; case eIntID_ScrollArrowStyle: #ifdef __LP64__ if (nsCocoaFeatures::OnLionOrLater()) { @@ -369,10 +372,10 @@ static nscolor GetColorFromNSColor(NSColor* aColor) } [pool drain]; } - break; + return res; case eIntID_ScrollSliderStyle: aResult = eScrollThumbStyle_Proportional; - break; + return res; case eIntID_UseOverlayScrollbars: aResult = 0; #ifdef __LP64__ @@ -382,7 +385,7 @@ static nscolor GetColorFromNSColor(NSColor* aColor) } aResult = mUseOverlayScrollbars; #endif - break; + return res; case eIntID_AllowOverlayScrollbarsOverlap: aResult = 0; #ifdef __LP64__ @@ -392,31 +395,31 @@ static nscolor GetColorFromNSColor(NSColor* aColor) } aResult = mAllowOverlayScrollbarsOverlap; #endif - break; + return res; case eIntID_ScrollbarDisplayOnMouseMove: aResult = 0; - break; + return res; case eIntID_ScrollbarFadeBeginDelay: aResult = 450; - break; + return res; case eIntID_ScrollbarFadeDuration: aResult = 200; - break; + return res; case eIntID_TreeOpenDelay: aResult = 1000; - break; + return res; case eIntID_TreeCloseDelay: aResult = 1000; - break; + return res; case eIntID_TreeLazyScrollDelay: aResult = 150; - break; + return res; case eIntID_TreeScrollDelay: aResult = 100; - break; + return res; case eIntID_TreeScrollLinesMax: aResult = 3; - break; + return res; case eIntID_DWMCompositor: case eIntID_WindowsClassic: case eIntID_WindowsDefaultTheme: @@ -425,21 +428,22 @@ static nscolor GetColorFromNSColor(NSColor* aColor) case eIntID_OperatingSystemVersionIdentifier: aResult = 0; res = NS_ERROR_NOT_IMPLEMENTED; - break; + return res; case eIntID_MacGraphiteTheme: aResult = [NSColor currentControlTint] == NSGraphiteControlTint; - break; + return res; case eIntID_MacLionTheme: aResult = nsCocoaFeatures::OnLionOrLater(); - break; + return res; case eIntID_MacYosemiteTheme: aResult = nsCocoaFeatures::OnYosemiteOrLater(); - break; + return res; case eIntID_AlertNotificationOrigin: aResult = NS_ALERT_TOP; - break; + return res; case eIntID_TabFocusModel: { +fprintf(stderr, "TabFocusModel\n"); // we should probably cache this CFPropertyListRef fullKeyboardAccessProperty; fullKeyboardAccessProperty = ::CFPreferencesCopyValue(CFSTR("AppleKeyboardUIMode"), @@ -457,27 +461,27 @@ static nscolor GetColorFromNSColor(NSColor* aColor) ::CFRelease(fullKeyboardAccessProperty); } } - break; + return res; case eIntID_ScrollToClick: { aResult = [[NSUserDefaults standardUserDefaults] boolForKey:@"AppleScrollerPagingBehavior"]; } - break; + return res; case eIntID_ChosenMenuItemsShouldBlink: aResult = 1; - break; + return res; case eIntID_IMERawInputUnderlineStyle: case eIntID_IMEConvertedTextUnderlineStyle: case eIntID_IMESelectedRawTextUnderlineStyle: case eIntID_IMESelectedConvertedTextUnderline: aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; - break; + return res; case eIntID_SpellCheckerUnderlineStyle: aResult = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED; - break; + return res; case eIntID_ScrollbarButtonAutoRepeatBehavior: aResult = 0; - break; + return res; case eIntID_SwipeAnimationEnabled: aResult = 0; #ifdef __LP64__ @@ -486,16 +490,16 @@ static nscolor GetColorFromNSColor(NSColor* aColor) aResult = [NSEvent isSwipeTrackingFromScrollEventsEnabled] ? 1 : 0; } #endif - break; + return res; case eIntID_ColorPickerAvailable: aResult = 1; - break; + return res; case eIntID_ContextMenuOffsetVertical: aResult = -6; - break; + return res; case eIntID_ContextMenuOffsetHorizontal: aResult = 1; - break; + return res; default: aResult = 0; res = NS_ERROR_FAILURE; @@ -516,10 +520,10 @@ static nscolor GetColorFromNSColor(NSColor* aColor) switch (aID) { case eFloatID_IMEUnderlineRelativeSize: aResult = 2.0f; - break; + return res; case eFloatID_SpellCheckerUnderlineRelativeSize: aResult = 2.0f; - break; + return res; default: aResult = -1.0; res = NS_ERROR_FAILURE; @@ -589,6 +593,8 @@ static nscolor GetColorFromNSColor(NSColor* aColor) nsTArray lookAndFeelIntCache = nsXPLookAndFeel::GetIntCacheImpl(); +// Useless before 10.7. +#ifdef __LP64__ LookAndFeelInt useOverlayScrollbars; useOverlayScrollbars.id = eIntID_UseOverlayScrollbars; useOverlayScrollbars.value = GetInt(eIntID_UseOverlayScrollbars); @@ -598,6 +604,7 @@ static nscolor GetColorFromNSColor(NSColor* aColor) allowOverlayScrollbarsOverlap.id = eIntID_AllowOverlayScrollbarsOverlap; allowOverlayScrollbarsOverlap.value = GetInt(eIntID_AllowOverlayScrollbarsOverlap); lookAndFeelIntCache.AppendElement(allowOverlayScrollbarsOverlap); +#endif return lookAndFeelIntCache; } @@ -605,23 +612,28 @@ static nscolor GetColorFromNSColor(NSColor* aColor) void nsLookAndFeel::SetIntCacheImpl(const nsTArray& aLookAndFeelIntCache) { +// Useless before 10.7. +#ifdef __LP64__ for (auto entry : aLookAndFeelIntCache) { switch(entry.id) { case eIntID_UseOverlayScrollbars: mUseOverlayScrollbars = entry.value; mUseOverlayScrollbarsCached = true; - break; + return res; case eIntID_AllowOverlayScrollbarsOverlap: mAllowOverlayScrollbarsOverlap = entry.value; mAllowOverlayScrollbarsOverlapCached = true; - break; + return res; } } +#endif } void nsLookAndFeel::RefreshImpl() { +// Useless before 10.7. +#ifdef __LP64__ // We should only clear the cache if we're in the main browser process. // Otherwise, we should wait for the parent to inform us of new values // to cache via LookAndFeel::SetIntCache. @@ -629,4 +641,5 @@ static nscolor GetColorFromNSColor(NSColor* aColor) mUseOverlayScrollbarsCached = false; mAllowOverlayScrollbarsOverlapCached = false; } +#endif } diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index 51d2485e11..94135f2da3 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -250,6 +250,8 @@ bool nsXPLookAndFeel::sUseStandinsForNativeColors = false; nsLookAndFeel* nsXPLookAndFeel::sInstance = nullptr; bool nsXPLookAndFeel::sShutdown = false; +bool nsXPLookAndFeel::sAnyIntPrefsSet = false; +bool nsXPLookAndFeel::sAnyFloatPrefsSet = false; // static nsLookAndFeel* @@ -296,6 +298,7 @@ nsXPLookAndFeel::IntPrefChanged(nsLookAndFeelIntPref *data) } data->intVar = intpref; data->isSet = true; + sAnyIntPrefsSet = true; #ifdef DEBUG_akkana printf("====== Changed int pref %s to %d\n", data->name, data->intVar); #endif @@ -316,6 +319,7 @@ nsXPLookAndFeel::FloatPrefChanged(nsLookAndFeelFloatPref *data) } data->floatVar = (float)intpref / 100.0f; data->isSet = true; + sAnyFloatPrefsSet = true; #ifdef DEBUG_akkana printf("====== Changed float pref %s to %f\n", data->name, data->floatVar); #endif @@ -359,6 +363,7 @@ nsXPLookAndFeel::InitFromPref(nsLookAndFeelIntPref* aPref) int32_t intpref; nsresult rv = Preferences::GetInt(aPref->name, &intpref); if (NS_SUCCEEDED(rv)) { + sAnyIntPrefsSet = true; aPref->isSet = true; aPref->intVar = intpref; } @@ -370,6 +375,7 @@ nsXPLookAndFeel::InitFromPref(nsLookAndFeelFloatPref* aPref) int32_t intpref; nsresult rv = Preferences::GetInt(aPref->name, &intpref); if (NS_SUCCEEDED(rv)) { + sAnyFloatPrefsSet = true; aPref->isSet = true; aPref->floatVar = (float)intpref / 100.0f; } @@ -404,6 +410,11 @@ nsXPLookAndFeel::OnPrefChanged(const char* aPref, void* aClosure) nsDependentCString prefName(aPref); unsigned int i; + + // reset the set caches just in case we can optimize checks away + sAnyFloatPrefsSet = false; + sAnyIntPrefsSet = false; + for (i = 0; i < ArrayLength(sIntPrefs); ++i) { if (prefName.Equals(sIntPrefs[i].name)) { IntPrefChanged(&sIntPrefs[i]); @@ -446,6 +457,11 @@ nsXPLookAndFeel::Init() Preferences::RegisterCallback(OnPrefChanged, "accessibility.tabfocus"); unsigned int i; + + // reset the set caches just in case we can optimize checks away + sAnyFloatPrefsSet = false; + sAnyIntPrefsSet = false; + for (i = 0; i < ArrayLength(sIntPrefs); ++i) { InitFromPref(&sIntPrefs[i]); } @@ -465,6 +481,8 @@ nsXPLookAndFeel::Init() "ui.use_standins_for_native_colors", sUseStandinsForNativeColors); +// Unpossible in TenFourFox and irrelevant before 10.7. +#ifdef __LP64__ if (XRE_IsContentProcess()) { mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton(); @@ -473,6 +491,7 @@ nsXPLookAndFeel::Init() cc->SendGetLookAndFeelCache(&lookAndFeelIntCache); LookAndFeel::SetIntCache(lookAndFeelIntCache); } +#endif } nsXPLookAndFeel::~nsXPLookAndFeel() @@ -548,9 +567,9 @@ nsXPLookAndFeel::ColorIsNotCSSAccessible(ColorID aID) case eColorID_IMESelectedConvertedTextUnderline: case eColorID_SpellCheckerUnderline: result = true; - break; + return result; default: - break; + return result; } return result; @@ -565,95 +584,95 @@ nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID) // except Mac-specific colors which are taken from Mac OS 10.7. switch (aID) { // CSS 2 colors: - case eColorID_activeborder: result = NS_RGB(0xB4, 0xB4, 0xB4); break; - case eColorID_activecaption: result = NS_RGB(0x99, 0xB4, 0xD1); break; - case eColorID_appworkspace: result = NS_RGB(0xAB, 0xAB, 0xAB); break; - case eColorID_background: result = NS_RGB(0x00, 0x00, 0x00); break; - case eColorID_buttonface: result = NS_RGB(0xF0, 0xF0, 0xF0); break; - case eColorID_buttonhighlight: result = NS_RGB(0xFF, 0xFF, 0xFF); break; - case eColorID_buttonshadow: result = NS_RGB(0xA0, 0xA0, 0xA0); break; - case eColorID_buttontext: result = NS_RGB(0x00, 0x00, 0x00); break; - case eColorID_captiontext: result = NS_RGB(0x00, 0x00, 0x00); break; - case eColorID_graytext: result = NS_RGB(0x6D, 0x6D, 0x6D); break; - case eColorID_highlight: result = NS_RGB(0x33, 0x99, 0xFF); break; - case eColorID_highlighttext: result = NS_RGB(0xFF, 0xFF, 0xFF); break; - case eColorID_inactiveborder: result = NS_RGB(0xF4, 0xF7, 0xFC); break; - case eColorID_inactivecaption: result = NS_RGB(0xBF, 0xCD, 0xDB); break; + case eColorID_activeborder: result = NS_RGB(0xB4, 0xB4, 0xB4); return result; + case eColorID_activecaption: result = NS_RGB(0x99, 0xB4, 0xD1); return result; + case eColorID_appworkspace: result = NS_RGB(0xAB, 0xAB, 0xAB); return result; + case eColorID_background: result = NS_RGB(0x00, 0x00, 0x00); return result; + case eColorID_buttonface: result = NS_RGB(0xF0, 0xF0, 0xF0); return result; + case eColorID_buttonhighlight: result = NS_RGB(0xFF, 0xFF, 0xFF); return result; + case eColorID_buttonshadow: result = NS_RGB(0xA0, 0xA0, 0xA0); return result; + case eColorID_buttontext: result = NS_RGB(0x00, 0x00, 0x00); return result; + case eColorID_captiontext: result = NS_RGB(0x00, 0x00, 0x00); return result; + case eColorID_graytext: result = NS_RGB(0x6D, 0x6D, 0x6D); return result; + case eColorID_highlight: result = NS_RGB(0x33, 0x99, 0xFF); return result; + case eColorID_highlighttext: result = NS_RGB(0xFF, 0xFF, 0xFF); return result; + case eColorID_inactiveborder: result = NS_RGB(0xF4, 0xF7, 0xFC); return result; + case eColorID_inactivecaption: result = NS_RGB(0xBF, 0xCD, 0xDB); return result; case eColorID_inactivecaptiontext: - result = NS_RGB(0x43, 0x4E, 0x54); break; - case eColorID_infobackground: result = NS_RGB(0xFF, 0xFF, 0xE1); break; - case eColorID_infotext: result = NS_RGB(0x00, 0x00, 0x00); break; - case eColorID_menu: result = NS_RGB(0xF0, 0xF0, 0xF0); break; - case eColorID_menutext: result = NS_RGB(0x00, 0x00, 0x00); break; - case eColorID_scrollbar: result = NS_RGB(0xC8, 0xC8, 0xC8); break; - case eColorID_threeddarkshadow: result = NS_RGB(0x69, 0x69, 0x69); break; - case eColorID_threedface: result = NS_RGB(0xF0, 0xF0, 0xF0); break; - case eColorID_threedhighlight: result = NS_RGB(0xFF, 0xFF, 0xFF); break; - case eColorID_threedlightshadow: result = NS_RGB(0xE3, 0xE3, 0xE3); break; - case eColorID_threedshadow: result = NS_RGB(0xA0, 0xA0, 0xA0); break; - case eColorID_window: result = NS_RGB(0xFF, 0xFF, 0xFF); break; - case eColorID_windowframe: result = NS_RGB(0x64, 0x64, 0x64); break; - case eColorID_windowtext: result = NS_RGB(0x00, 0x00, 0x00); break; + result = NS_RGB(0x43, 0x4E, 0x54); return result; + case eColorID_infobackground: result = NS_RGB(0xFF, 0xFF, 0xE1); return result; + case eColorID_infotext: result = NS_RGB(0x00, 0x00, 0x00); return result; + case eColorID_menu: result = NS_RGB(0xF0, 0xF0, 0xF0); return result; + case eColorID_menutext: result = NS_RGB(0x00, 0x00, 0x00); return result; + case eColorID_scrollbar: result = NS_RGB(0xC8, 0xC8, 0xC8); return result; + case eColorID_threeddarkshadow: result = NS_RGB(0x69, 0x69, 0x69); return result; + case eColorID_threedface: result = NS_RGB(0xF0, 0xF0, 0xF0); return result; + case eColorID_threedhighlight: result = NS_RGB(0xFF, 0xFF, 0xFF); return result; + case eColorID_threedlightshadow: result = NS_RGB(0xE3, 0xE3, 0xE3); return result; + case eColorID_threedshadow: result = NS_RGB(0xA0, 0xA0, 0xA0); return result; + case eColorID_window: result = NS_RGB(0xFF, 0xFF, 0xFF); return result; + case eColorID_windowframe: result = NS_RGB(0x64, 0x64, 0x64); return result; + case eColorID_windowtext: result = NS_RGB(0x00, 0x00, 0x00); return result; case eColorID__moz_buttondefault: - result = NS_RGB(0x69, 0x69, 0x69); break; - case eColorID__moz_field: result = NS_RGB(0xFF, 0xFF, 0xFF); break; - case eColorID__moz_fieldtext: result = NS_RGB(0x00, 0x00, 0x00); break; - case eColorID__moz_dialog: result = NS_RGB(0xF0, 0xF0, 0xF0); break; - case eColorID__moz_dialogtext: result = NS_RGB(0x00, 0x00, 0x00); break; + result = NS_RGB(0x69, 0x69, 0x69); return result; + case eColorID__moz_field: result = NS_RGB(0xFF, 0xFF, 0xFF); return result; + case eColorID__moz_fieldtext: result = NS_RGB(0x00, 0x00, 0x00); return result; + case eColorID__moz_dialog: result = NS_RGB(0xF0, 0xF0, 0xF0); return result; + case eColorID__moz_dialogtext: result = NS_RGB(0x00, 0x00, 0x00); return result; case eColorID__moz_dragtargetzone: - result = NS_RGB(0xFF, 0xFF, 0xFF); break; + result = NS_RGB(0xFF, 0xFF, 0xFF); return result; case eColorID__moz_cellhighlight: - result = NS_RGB(0xF0, 0xF0, 0xF0); break; + result = NS_RGB(0xF0, 0xF0, 0xF0); return result; case eColorID__moz_cellhighlighttext: - result = NS_RGB(0x00, 0x00, 0x00); break; + result = NS_RGB(0x00, 0x00, 0x00); return result; case eColorID__moz_html_cellhighlight: - result = NS_RGB(0x33, 0x99, 0xFF); break; + result = NS_RGB(0x33, 0x99, 0xFF); return result; case eColorID__moz_html_cellhighlighttext: - result = NS_RGB(0xFF, 0xFF, 0xFF); break; + result = NS_RGB(0xFF, 0xFF, 0xFF); return result; case eColorID__moz_buttonhoverface: - result = NS_RGB(0xF0, 0xF0, 0xF0); break; + result = NS_RGB(0xF0, 0xF0, 0xF0); return result; case eColorID__moz_buttonhovertext: - result = NS_RGB(0x00, 0x00, 0x00); break; + result = NS_RGB(0x00, 0x00, 0x00); return result; case eColorID__moz_menuhover: - result = NS_RGB(0x33, 0x99, 0xFF); break; + result = NS_RGB(0x33, 0x99, 0xFF); return result; case eColorID__moz_menuhovertext: - result = NS_RGB(0x00, 0x00, 0x00); break; + result = NS_RGB(0x00, 0x00, 0x00); return result; case eColorID__moz_menubartext: - result = NS_RGB(0x00, 0x00, 0x00); break; + result = NS_RGB(0x00, 0x00, 0x00); return result; case eColorID__moz_menubarhovertext: - result = NS_RGB(0x00, 0x00, 0x00); break; + result = NS_RGB(0x00, 0x00, 0x00); return result; case eColorID__moz_oddtreerow: - result = NS_RGB(0xFF, 0xFF, 0xFF); break; + result = NS_RGB(0xFF, 0xFF, 0xFF); return result; case eColorID__moz_mac_chrome_active: - result = NS_RGB(0xB2, 0xB2, 0xB2); break; + result = NS_RGB(0xB2, 0xB2, 0xB2); return result; case eColorID__moz_mac_chrome_inactive: - result = NS_RGB(0xE1, 0xE1, 0xE1); break; + result = NS_RGB(0xE1, 0xE1, 0xE1); return result; case eColorID__moz_mac_focusring: - result = NS_RGB(0x60, 0x9D, 0xD7); break; + result = NS_RGB(0x60, 0x9D, 0xD7); return result; case eColorID__moz_mac_menuselect: - result = NS_RGB(0x38, 0x75, 0xD7); break; + result = NS_RGB(0x38, 0x75, 0xD7); return result; case eColorID__moz_mac_menushadow: - result = NS_RGB(0xA3, 0xA3, 0xA3); break; + result = NS_RGB(0xA3, 0xA3, 0xA3); return result; case eColorID__moz_mac_menutextdisable: - result = NS_RGB(0x88, 0x88, 0x88); break; + result = NS_RGB(0x88, 0x88, 0x88); return result; case eColorID__moz_mac_menutextselect: - result = NS_RGB(0xFF, 0xFF, 0xFF); break; + result = NS_RGB(0xFF, 0xFF, 0xFF); return result; case eColorID__moz_mac_disabledtoolbartext: - result = NS_RGB(0x3F, 0x3F, 0x3F); break; + result = NS_RGB(0x3F, 0x3F, 0x3F); return result; case eColorID__moz_mac_secondaryhighlight: - result = NS_RGB(0xD4, 0xD4, 0xD4); break; + result = NS_RGB(0xD4, 0xD4, 0xD4); return result; case eColorID__moz_win_mediatext: - result = NS_RGB(0xFF, 0xFF, 0xFF); break; + result = NS_RGB(0xFF, 0xFF, 0xFF); return result; case eColorID__moz_win_communicationstext: - result = NS_RGB(0xFF, 0xFF, 0xFF); break; + result = NS_RGB(0xFF, 0xFF, 0xFF); return result; case eColorID__moz_nativehyperlinktext: - result = NS_RGB(0x00, 0x66, 0xCC); break; + result = NS_RGB(0x00, 0x66, 0xCC); return result; case eColorID__moz_comboboxtext: - result = NS_RGB(0x00, 0x00, 0x00); break; + result = NS_RGB(0x00, 0x00, 0x00); return result; case eColorID__moz_combobox: - result = NS_RGB(0xFF, 0xFF, 0xFF); break; + result = NS_RGB(0xFF, 0xFF, 0xFF); return result; default: - break; + return result; } return result; @@ -689,35 +708,35 @@ nsXPLookAndFeel::GetColorImpl(ColorID aID, bool aUseStandinsForNativeColors, case eColorID_captiontext: // text in active window caption aResult = NS_RGB(0xff, 0x00, 0x00); - break; + return result; case eColorID_highlight: // background of selected item case eColorID_highlighttext: // text of selected item aResult = NS_RGB(0xff, 0xff, 0x00); - break; + return result; case eColorID_inactivecaption: // inactive window caption case eColorID_inactivecaptiontext: // text in inactive window caption aResult = NS_RGB(0x66, 0x66, 0x00); - break; + return result; case eColorID_infobackground: // tooltip background color case eColorID_infotext: // tooltip text color aResult = NS_RGB(0x00, 0xff, 0x00); - break; + return result; case eColorID_menu: // menu background case eColorID_menutext: // menu text aResult = NS_RGB(0x00, 0xff, 0xff); - break; + return result; case eColorID_threedface: case eColorID_buttonface: @@ -725,12 +744,12 @@ nsXPLookAndFeel::GetColorImpl(ColorID aID, bool aUseStandinsForNativeColors, case eColorID_buttontext: // text on push buttons aResult = NS_RGB(0x00, 0x66, 0x66); - break; + return result; case eColorID_window: case eColorID_windowtext: aResult = NS_RGB(0x00, 0x00, 0xff); - break; + return result; // from the CSS3 working draft (not yet finalized) // http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color @@ -738,12 +757,12 @@ nsXPLookAndFeel::GetColorImpl(ColorID aID, bool aUseStandinsForNativeColors, case eColorID__moz_field: case eColorID__moz_fieldtext: aResult = NS_RGB(0xff, 0x00, 0xff); - break; + return result; case eColorID__moz_dialog: case eColorID__moz_dialogtext: aResult = NS_RGB(0x66, 0x00, 0x66); - break; + return result; default: rv = NS_ERROR_NOT_AVAILABLE; @@ -841,7 +860,7 @@ nsXPLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult) * The metrics above are hardcoded platform defaults. All the other * metrics are stored in sIntPrefs and can be changed at runtime. */ - break; + if (MOZ_LIKELY(!sAnyIntPrefsSet)) return NS_ERROR_NOT_AVAILABLE; // else fall through } for (unsigned int i = 0; i < ArrayLength(sIntPrefs); ++i) { @@ -859,6 +878,8 @@ nsXPLookAndFeel::GetFloatImpl(FloatID aID, float &aResult) { if (MOZ_UNLIKELY(!sInitialized)) Init(); + + if (MOZ_LIKELY(!sAnyFloatPrefsSet)) return NS_ERROR_NOT_AVAILABLE; // else fall through for (unsigned int i = 0; i < ArrayLength(sFloatPrefs); ++i) { if (MOZ_UNLIKELY(sFloatPrefs[i].isSet && sFloatPrefs[i].id == aID)) { diff --git a/widget/nsXPLookAndFeel.h b/widget/nsXPLookAndFeel.h index 0b8a308fb3..a949974282 100644 --- a/widget/nsXPLookAndFeel.h +++ b/widget/nsXPLookAndFeel.h @@ -114,6 +114,8 @@ class nsXPLookAndFeel: public mozilla::LookAndFeel static nsLookAndFeel* sInstance; static bool sShutdown; + static bool sAnyIntPrefsSet; + static bool sAnyFloatPrefsSet; }; #endif