@@ -17,6 +17,72 @@ diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp
17
17
if (appDataFile && *appDataFile) {
18
18
rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appini));
19
19
if (NS_FAILED(rv)) {
20
+ diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm
21
+ --- a/widget/cocoa/nsChildView.mm
22
+ +++ b/widget/cocoa/nsChildView.mm
23
+ @@ -428,13 +428,6 @@ nsChildView::Create(nsIWidget* aParent,
24
+ if (!gChildViewMethodsSwizzled) {
25
+ nsToolkit::SwizzleMethods([NSView class], @selector(mouseDownCanMoveWindow),
26
+ @selector(nsChildView_NSView_mouseDownCanMoveWindow));
27
+ - #ifdef __LP64__
28
+ - nsToolkit::SwizzleMethods([NSEvent class], @selector(addLocalMonitorForEventsMatchingMask:handler:),
29
+ - @selector(nsChildView_NSEvent_addLocalMonitorForEventsMatchingMask:handler:),
30
+ - true);
31
+ - nsToolkit::SwizzleMethods([NSEvent class], @selector(removeMonitor:),
32
+ - @selector(nsChildView_NSEvent_removeMonitor:), true);
33
+ - #endif
34
+ gChildViewMethodsSwizzled = true;
35
+ }
36
+
37
+ @@ -6533,48 +6526,3 @@ static const CGEventField kCGWindowNumbe
38
+ }
39
+
40
+ @end
41
+ -
42
+ - #ifdef __LP64__
43
+ - // When using blocks, at least on OS X 10.7, the OS sometimes calls
44
+ - // +[NSEvent removeMonitor:] more than once on a single event monitor, which
45
+ - // causes crashes. See bug 678607. We hook these methods to work around
46
+ - // the problem.
47
+ - @interface NSEvent (MethodSwizzling)
48
+ - + (id)nsChildView_NSEvent_addLocalMonitorForEventsMatchingMask:(unsigned long long)mask handler:(id)block;
49
+ - + (void)nsChildView_NSEvent_removeMonitor:(id)eventMonitor;
50
+ - @end
51
+ -
52
+ - // This is a local copy of the AppKit frameworks sEventObservers hashtable.
53
+ - // It only stores "local monitors". We use it to ensure that +[NSEvent
54
+ - // removeMonitor:] is never called more than once on the same local monitor.
55
+ - static NSHashTable *sLocalEventObservers = nil;
56
+ -
57
+ - @implementation NSEvent (MethodSwizzling)
58
+ -
59
+ - + (id)nsChildView_NSEvent_addLocalMonitorForEventsMatchingMask:(unsigned long long)mask handler:(id)block
60
+ - {
61
+ - if (!sLocalEventObservers) {
62
+ - sLocalEventObservers = [[NSHashTable hashTableWithOptions:
63
+ - NSHashTableStrongMemory | NSHashTableObjectPointerPersonality] retain];
64
+ - }
65
+ - id retval =
66
+ - [self nsChildView_NSEvent_addLocalMonitorForEventsMatchingMask:mask handler:block];
67
+ - if (sLocalEventObservers && retval && ![sLocalEventObservers containsObject:retval]) {
68
+ - [sLocalEventObservers addObject:retval];
69
+ - }
70
+ - return retval;
71
+ - }
72
+ -
73
+ - + (void)nsChildView_NSEvent_removeMonitor:(id)eventMonitor
74
+ - {
75
+ - if (sLocalEventObservers && [eventMonitor isKindOfClass: ::NSClassFromString(@"_NSLocalEventObserver")]) {
76
+ - if (![sLocalEventObservers containsObject:eventMonitor]) {
77
+ - return;
78
+ - }
79
+ - [sLocalEventObservers removeObject:eventMonitor];
80
+ - }
81
+ - [self nsChildView_NSEvent_removeMonitor:eventMonitor];
82
+ - }
83
+ -
84
+ - @end
85
+ - #endif // #ifdef __LP64__
20
86
diff --git a/widget/cocoa/nsCocoaFeatures.h b/widget/cocoa/nsCocoaFeatures.h
21
87
--- a/widget/cocoa/nsCocoaFeatures.h
22
88
+++ b/widget/cocoa/nsCocoaFeatures.h
0 commit comments