зеркало из 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:
Родитель
48dd1fc8b2
Коммит
a2182db8b4
|
@ -182,5 +182,6 @@ LDFLAGS += \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
CXXFLAGS += \
|
CXXFLAGS += \
|
||||||
-DUSE_COCOA \
|
-DUSE_COCOA \
|
||||||
$(NULL)
|
-fobjc-exceptions \
|
||||||
|
$(NULL)
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "nsStringStream.h"
|
#include "nsStringStream.h"
|
||||||
#include "nsDragService.h"
|
#include "nsDragService.h"
|
||||||
#include "nsEscape.h"
|
#include "nsEscape.h"
|
||||||
|
#include "nsPrintfCString.h"
|
||||||
|
|
||||||
// Screenshots use the (undocumented) png pasteboard type.
|
// Screenshots use the (undocumented) png pasteboard type.
|
||||||
#define IMAGE_PASTEBOARD_TYPES NSTIFFPboardType, @"Apple PNG pasteboard type", nil
|
#define IMAGE_PASTEBOARD_TYPES NSTIFFPboardType, @"Apple PNG pasteboard type", nil
|
||||||
|
@ -210,17 +211,6 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable, PRInt32 aWhi
|
||||||
if (!type)
|
if (!type)
|
||||||
continue;
|
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
|
// Figure out what type we're converting to
|
||||||
CFStringRef outputType = NULL;
|
CFStringRef outputType = NULL;
|
||||||
if (flavorStr.EqualsLiteral(kJPEGImageMime))
|
if (flavorStr.EqualsLiteral(kJPEGImageMime))
|
||||||
|
@ -232,6 +222,16 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable, PRInt32 aWhi
|
||||||
else
|
else
|
||||||
continue;
|
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.
|
// Use ImageIO to interpret the data on the clipboard and transcode.
|
||||||
// Note that ImageIO, like all CF APIs, allows NULLs to propagate freely
|
// Note that ImageIO, like all CF APIs, allows NULLs to propagate freely
|
||||||
// and safely in most cases (like ObjC). A notable exception is CFRelease.
|
// 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;
|
drawFrame.size.height = offscreenHeight - NATIVE_PUSH_BUTTON_HEIGHT_DIFF;
|
||||||
|
|
||||||
// draw into offscreen image
|
// draw into offscreen image
|
||||||
NS_DURING
|
@try {
|
||||||
[image lockFocus];
|
[image lockFocus];
|
||||||
NS_HANDLER
|
} @catch (NSException* e) {
|
||||||
NS_ASSERTION(0, "Could not lock focus on offscreen buffer");
|
NS_WARNING(nsPrintfCString(256, "Exception raised while drawing to offscreen buffer: \"%s - %s\"",
|
||||||
|
[[e name] UTF8String], [[e reason] UTF8String]).get());
|
||||||
[image release];
|
[image release];
|
||||||
return;
|
return;
|
||||||
NS_ENDHANDLER
|
}
|
||||||
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationLow];
|
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationLow];
|
||||||
HIThemeDrawButton(&drawFrame, &bdi, (CGContext*)[[NSGraphicsContext currentContext] graphicsPort], kHIThemeOrientationInverted, NULL);
|
HIThemeDrawButton(&drawFrame, &bdi, (CGContext*)[[NSGraphicsContext currentContext] graphicsPort], kHIThemeOrientationInverted, NULL);
|
||||||
[image unlockFocus];
|
[image unlockFocus];
|
||||||
|
@ -520,13 +521,14 @@ nsNativeThemeCocoa::DrawScrollbar(CGContextRef aCGContext, const HIRect& aBoxRec
|
||||||
::HIThemeDrawTrack(&tdi, NULL, aCGContext, HITHEME_ORIENTATION);
|
::HIThemeDrawTrack(&tdi, NULL, aCGContext, HITHEME_ORIENTATION);
|
||||||
else {
|
else {
|
||||||
NSImage *buffer = [[NSImage alloc] initWithSize:NSMakeSize(aBoxRect.size.width, aBoxRect.size.height)];
|
NSImage *buffer = [[NSImage alloc] initWithSize:NSMakeSize(aBoxRect.size.width, aBoxRect.size.height)];
|
||||||
NS_DURING
|
@try {
|
||||||
[buffer lockFocus];
|
[buffer lockFocus];
|
||||||
NS_HANDLER
|
} @catch (NSException* e) {
|
||||||
NS_ASSERTION(0, "Could not lock focus on offscreen buffer");
|
NS_WARNING(nsPrintfCString(256, "Exception raised while drawing to offscreen buffer: \"%s - %s\"",
|
||||||
|
[[e name] UTF8String], [[e reason] UTF8String]).get());
|
||||||
[buffer release];
|
[buffer release];
|
||||||
return;
|
return;
|
||||||
NS_ENDHANDLER
|
}
|
||||||
::HIThemeDrawTrack(&tdi, NULL, (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort],
|
::HIThemeDrawTrack(&tdi, NULL, (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort],
|
||||||
kHIThemeOrientationInverted);
|
kHIThemeOrientationInverted);
|
||||||
[buffer unlockFocus];
|
[buffer unlockFocus];
|
||||||
|
|
Загрузка…
Ссылка в новой задаче