diff --git a/widget/cocoa/nsCocoaUtils.mm b/widget/cocoa/nsCocoaUtils.mm index fb529213a96e..a4dddec03861 100644 --- a/widget/cocoa/nsCocoaUtils.mm +++ b/widget/cocoa/nsCocoaUtils.mm @@ -563,69 +563,13 @@ nsCocoaUtils::ConvertToCarbonModifier(NSUInteger aCocoaModifier) static bool sHiDPIEnabled = false; static bool sHiDPIPrefInitialized = false; -@interface ScreenParamChangeWatcher : NSObject -- (id)init; -@end - -@implementation ScreenParamChangeWatcher -- (id)init -{ - [super init]; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(applicationDidChangeScreenParameters:) - name:NSApplicationDidChangeScreenParametersNotification - object:NSApp]; - return self; -} - -- (void)applicationDidChangeScreenParameters:(NSNotification *)notification -{ - // reset flags so that the next call to HiDPIEnabled() will re-evaluate - sHiDPIEnabled = false; - sHiDPIPrefInitialized = false; -} -@end - -class HiDPIPrefObserver MOZ_FINAL : public nsIObserver { - public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER -}; - -NS_IMPL_ISUPPORTS1(HiDPIPrefObserver, nsIObserver) - -NS_IMETHODIMP -HiDPIPrefObserver::Observe(nsISupports* aSubject, const char* aTopic, - const PRUnichar* aData) -{ - // reset flags so that the next call to HiDPIEnabled() will re-evaluate - sHiDPIEnabled = false; - sHiDPIPrefInitialized = false; - return NS_OK; -} - // static bool nsCocoaUtils::HiDPIEnabled() { - static ScreenParamChangeWatcher* sChangeWatcher = nil; - if (!sHiDPIPrefInitialized) { sHiDPIPrefInitialized = true; - if (!sChangeWatcher) { - // Create an object to watch for changes in screen configuration. - // Note that we'll leak this object at shutdown; - // this is all a temporary hack until we have multi-screen HiDPI working - // properly and can dispense with this code. - sChangeWatcher = [[ScreenParamChangeWatcher alloc] init]; - - // And create an observer for changes to the preference. - nsCOMPtr obs(new HiDPIPrefObserver()); - Preferences::AddStrongObserver(obs, "gfx.hidpi.enabled"); - } - int prefSetting = Preferences::GetInt("gfx.hidpi.enabled", 1); if (prefSetting <= 0) { return false;