зеркало из https://github.com/mozilla/pjs.git
Bug 397381 - Enable @try/@catch/@finally for Cocoa widgets r=josh sr+a1.9=roc
This commit is contained in:
Родитель
4965649b0a
Коммит
cc3a07e888
|
@ -182,5 +182,6 @@ LDFLAGS += \
|
|||
$(NULL)
|
||||
|
||||
CXXFLAGS += \
|
||||
-DUSE_COCOA \
|
||||
$(NULL)
|
||||
-DUSE_COCOA \
|
||||
-fobjc-exceptions \
|
||||
$(NULL)
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsStringStream.h"
|
||||
#include "nsDragService.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
// Screenshots use the (undocumented) png pasteboard type.
|
||||
#define IMAGE_PASTEBOARD_TYPES NSTIFFPboardType, @"Apple PNG pasteboard type", nil
|
||||
|
@ -210,17 +211,6 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable, PRInt32 aWhi
|
|||
if (!type)
|
||||
continue;
|
||||
|
||||
// Read data off the clipboard, make sure to catch any exceptions (timeouts)
|
||||
// XXX should convert to @try/@catch someday?
|
||||
NSData *pasteboardData = nil;
|
||||
NS_DURING
|
||||
pasteboardData = [cocoaPasteboard dataForType:type];
|
||||
NS_HANDLER
|
||||
NS_ASSERTION(0, "Exception raised while getting data from the pasteboard.");
|
||||
NS_ENDHANDLER
|
||||
if (!pasteboardData)
|
||||
continue;
|
||||
|
||||
// Figure out what type we're converting to
|
||||
CFStringRef outputType = NULL;
|
||||
if (flavorStr.EqualsLiteral(kJPEGImageMime))
|
||||
|
@ -232,6 +222,16 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable, PRInt32 aWhi
|
|||
else
|
||||
continue;
|
||||
|
||||
// Read data off the clipboard
|
||||
NSData *pasteboardData = nil;
|
||||
@try {
|
||||
pasteboardData = [cocoaPasteboard dataForType:type];
|
||||
} @catch (NSException* e) {
|
||||
NS_WARNING(nsPrintfCString(256, "Exception raised while getting data from the pasteboard: \"%s - %s\"",
|
||||
[[e name] UTF8String], [[e reason] UTF8String]).get());
|
||||
continue;
|
||||
}
|
||||
|
||||
// Use ImageIO to interpret the data on the clipboard and transcode.
|
||||
// Note that ImageIO, like all CF APIs, allows NULLs to propagate freely
|
||||
// and safely in most cases (like ObjC). A notable exception is CFRelease.
|
||||
|
|
|
@ -189,13 +189,14 @@ nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
|
|||
drawFrame.size.height = offscreenHeight - NATIVE_PUSH_BUTTON_HEIGHT_DIFF;
|
||||
|
||||
// draw into offscreen image
|
||||
NS_DURING
|
||||
@try {
|
||||
[image lockFocus];
|
||||
NS_HANDLER
|
||||
NS_ASSERTION(0, "Could not lock focus on offscreen buffer");
|
||||
} @catch (NSException* e) {
|
||||
NS_WARNING(nsPrintfCString(256, "Exception raised while drawing to offscreen buffer: \"%s - %s\"",
|
||||
[[e name] UTF8String], [[e reason] UTF8String]).get());
|
||||
[image release];
|
||||
return;
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationLow];
|
||||
HIThemeDrawButton(&drawFrame, &bdi, (CGContext*)[[NSGraphicsContext currentContext] graphicsPort], kHIThemeOrientationInverted, NULL);
|
||||
[image unlockFocus];
|
||||
|
@ -520,13 +521,14 @@ nsNativeThemeCocoa::DrawScrollbar(CGContextRef aCGContext, const HIRect& aBoxRec
|
|||
::HIThemeDrawTrack(&tdi, NULL, aCGContext, HITHEME_ORIENTATION);
|
||||
else {
|
||||
NSImage *buffer = [[NSImage alloc] initWithSize:NSMakeSize(aBoxRect.size.width, aBoxRect.size.height)];
|
||||
NS_DURING
|
||||
@try {
|
||||
[buffer lockFocus];
|
||||
NS_HANDLER
|
||||
NS_ASSERTION(0, "Could not lock focus on offscreen buffer");
|
||||
} @catch (NSException* e) {
|
||||
NS_WARNING(nsPrintfCString(256, "Exception raised while drawing to offscreen buffer: \"%s - %s\"",
|
||||
[[e name] UTF8String], [[e reason] UTF8String]).get());
|
||||
[buffer release];
|
||||
return;
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
::HIThemeDrawTrack(&tdi, NULL, (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort],
|
||||
kHIThemeOrientationInverted);
|
||||
[buffer unlockFocus];
|
||||
|
|
Загрузка…
Ссылка в новой задаче