Changeset 12679 in webkit
- Timestamp:
- Feb 8, 2006 8:05:15 PM (18 years ago)
- Location:
- trunk/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/ChangeLog
r12644 r12679 1 2006-02-08 David Kilzer <ddkilzer@kilzer.net> 2 3 Reviewed by Darin. 4 5 - Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=3527 6 Allow Safari to open postscript files in browser windows as well 7 8 * WebView/WebPDFRepresentation.m: 9 (+[WebPDFRepresentation postScriptMIMETypes]): Added. 10 (+[WebPDFRepresentation supportedMIMETypes]): Include PostScript MIME types. 11 (-[WebPDFRepresentation convertPostScriptDataSourceToPDF:]): Added. 12 (-[WebPDFRepresentation finishedLoadingWithDataSource:]): 13 Handle PostScript conversion using new convertPostScriptDataSourceToPDF method. 14 1 15 2006-02-07 Alexey Proskuryakov <ap@nypop.com> 2 16 -
trunk/WebKit/WebView/WebPDFRepresentation.m
r11962 r12679 1 1 /* 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #import <WebKit/WebFrame.h> 32 32 #import <WebKit/WebFrameView.h> 33 #import <WebKit/WebNSObjectExtras.h> 33 34 #import <WebKit/WebPDFRepresentation.h> 34 35 #import <WebKit/WebPDFView.h> … … 39 40 @implementation WebPDFRepresentation 40 41 42 + (NSArray *)postScriptMIMETypes 43 { 44 return [NSArray arrayWithObjects: 45 @"application/postscript", 46 nil]; 47 } 48 41 49 + (NSArray *)supportedMIMETypes 42 50 { 43 return [NSArray arrayWithObjects: 51 return [[[self class] postScriptMIMETypes] arrayByAddingObjectsFromArray: 52 [NSArray arrayWithObjects: 44 53 @"text/pdf", 45 54 @"application/pdf", 46 nil] ;55 nil]]; 47 56 } 48 57 … … 71 80 } 72 81 82 - (NSData *)convertPostScriptDataSourceToPDF:(NSData *)data 83 { 84 // Convert PostScript to PDF using Quartz 2D API 85 // http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_ps_convert/chapter_16_section_1.html 86 87 CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 }; 88 CGPSConverterRef converter = CGPSConverterCreate(0, &callbacks, 0); 89 ASSERT(converter); 90 91 CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)data); 92 ASSERT(provider); 93 94 CFMutableDataRef result = CFDataCreateMutable(kCFAllocatorDefault, 0); 95 ASSERT(result); 96 97 CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(result); 98 ASSERT(consumer); 99 100 // Error handled by detecting zero-length 'result' in caller 101 CGPSConverterConvert(converter, provider, consumer, 0); 102 103 CFRelease(converter); 104 CFRelease(provider); 105 CFRelease(consumer); 106 107 return WebCFAutorelease(result); 108 } 109 73 110 - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource 74 111 { 112 NSData *data = [dataSource data]; 113 114 NSArray *postScriptMIMETypes = [[self class] postScriptMIMETypes]; 115 NSString *mimeType = [[dataSource response] MIMEType]; 116 if ([postScriptMIMETypes containsObject:mimeType]) { 117 data = [self convertPostScriptDataSourceToPDF:data]; 118 if ([data length] == 0) 119 return; 120 } 121 75 122 WebPDFView *view = (WebPDFView *)[[[dataSource webFrame] frameView] documentView]; 76 PDFDocument *doc = [[[[self class] PDFDocumentClass] alloc] initWithData: [dataSource data]];123 PDFDocument *doc = [[[[self class] PDFDocumentClass] alloc] initWithData:data]; 77 124 [[view PDFSubview] setDocument:doc]; 78 125 [doc release];
Note: See TracChangeset
for help on using the changeset viewer.