summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorolaru@adobe.com <olaru@adobe.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 08:09:35 +0000
committerolaru@adobe.com <olaru@adobe.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 08:09:35 +0000
commita0e54b7cc76a061cda211d9d4632b5f5d75daa9e (patch)
tree8d8f1e9a001b78aa2385a1cc64d622e4a9a39d70 /content
parent6364322b2afafecb363a1c7be571b6e192fddfcf (diff)
downloadchromium_src-a0e54b7cc76a061cda211d9d4632b5f5d75daa9e.zip
chromium_src-a0e54b7cc76a061cda211d9d4632b5f5d75daa9e.tar.gz
chromium_src-a0e54b7cc76a061cda211d9d4632b5f5d75daa9e.tar.bz2
Fix Chromium crashing on early OS X 10.7 systems, when accessing NSWindowDidChangeBackingPropertiesNotification.
This issue was originally fixed for OS X 10.6 versions, but still crashes on 10.7. According to comments in NSWindow.h and AppKit release notes, the NSWindowDidChangeBackingPropertiesNotification is available starting with OS X 10.7.3. Because of this, the same crash occurs on 10.7-10.7.2. R=thakis@chromium.org BUG=260595 Review URL: https://chromiumcodereview.appspot.com/21088004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214629 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm27
1 files changed, 26 insertions, 1 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 099e688..0744888 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -4,6 +4,7 @@
#include "content/browser/renderer_host/render_widget_host_view_mac.h"
+#import <objc/runtime.h>
#include <QuartzCore/QuartzCore.h>
#include "base/bind.h"
@@ -137,6 +138,29 @@ static inline int ToWebKitModifiers(NSUInteger flags) {
return modifiers;
}
+// This method will return YES for OS X versions 10.7.3 and later, and NO
+// otherwise.
+// Used to prevent a crash when building with the 10.7 SDK and accessing the
+// notification below. See: http://crbug.com/260595.
+static BOOL SupportsBackingPropertiesChangedNotification() {
+ // windowDidChangeBackingProperties: method has been added to the
+ // NSWindowDelegate protocol in 10.7.3, at the same time as the
+ // NSWindowDidChangeBackingPropertiesNotification notification was added.
+ // If the protocol contains this method description, the notification should
+ // be supported as well.
+ Protocol* windowDelegateProtocol = NSProtocolFromString(@"NSWindowDelegate");
+ struct objc_method_description methodDescription =
+ protocol_getMethodDescription(
+ windowDelegateProtocol,
+ @selector(windowDidChangeBackingProperties:),
+ NO,
+ YES);
+
+ // If the protocol does not contain the method, the returned method
+ // description is {NULL, NULL}
+ return methodDescription.name != NULL || methodDescription.types != NULL;
+}
+
static float ScaleFactor(NSView* view) {
return ui::GetScaleFactorScale(ui::GetScaleFactorForNativeView(view));
}
@@ -2452,7 +2476,8 @@ void RenderWidgetHostViewMac::FrameSwapped() {
// Backing property notifications crash on 10.6 when building with the 10.7
// SDK, see http://crbug.com/260595.
- BOOL supportsBackingPropertiesNotification = base::mac::IsOSLionOrLater();
+ static BOOL supportsBackingPropertiesNotification =
+ SupportsBackingPropertiesChangedNotification();
if (oldWindow) {
if (supportsBackingPropertiesNotification) {