[webkit-changes] cvs commit: WebKit/WebView.subproj WebDataSource.m
WebFrameView.m WebHTMLRepresentation.h
WebHTMLRepresentation.m WebHTMLView.m WebHTMLViewPrivate.h
WebImageRepresentation.h WebImageRepresentation.m
WebImageView.h WebImageView.m WebPDFRepresentation.h
WebPDFRepresentation.m WebPDFView.h WebPDFView.m
WebTextRepresentation.h WebTextRepresentation.m WebTextView.h
WebTextView.m WebView.m
Eric
eseidel at opensource.apple.com
Tue Sep 20 01:33:11 PDT 2005
eseidel 05/09/20 01:33:11
Modified: . ChangeLog
WebView.subproj WebDataSource.m WebFrameView.m
WebHTMLRepresentation.h WebHTMLRepresentation.m
WebHTMLView.m WebHTMLViewPrivate.h
WebImageRepresentation.h WebImageRepresentation.m
WebImageView.h WebImageView.m
WebPDFRepresentation.h WebPDFRepresentation.m
WebPDFView.h WebPDFView.m WebTextRepresentation.h
WebTextRepresentation.m WebTextView.h WebTextView.m
WebView.m
Log:
Bug #: 5037
Submitted by: eseidel
Reviewed by: mjs
Moved MIME type support from a hard coded list
(in two places) to single lists in the corresponding
*Representation classes. Also moved the list of types
supported by WebCore (WebHTMLRepresentation) into WebCore.
http://bugzilla.opendarwin.org/show_bug.cgi?id=5037
* WebView.subproj/WebDataSource.m:
(addTypesFromClass): new inline function
(+[WebDataSource _repTypesAllowImageTypeOmission:]):
* WebView.subproj/WebFrameView.m:
(addTypesFromClass): new inline function
(+[WebFrameView _viewTypesAllowImageTypeOmission:]):
* WebView.subproj/WebHTMLRepresentation.h:
* WebView.subproj/WebHTMLRepresentation.m:
(+[WebHTMLRepresentation supportedMIMETypes]):
* WebView.subproj/WebHTMLView.m:
(+[WebHTMLView supportedMIMETypes]):
* WebView.subproj/WebHTMLViewPrivate.h:
* WebView.subproj/WebImageRepresentation.h:
* WebView.subproj/WebImageRepresentation.m:
(+[WebImageRepresentation supportedMIMETypes]):
* WebView.subproj/WebImageView.h:
* WebView.subproj/WebImageView.m:
(+[WebImageView supportedMIMETypes]):
* WebView.subproj/WebPDFRepresentation.h:
* WebView.subproj/WebPDFRepresentation.m:
(+[WebPDFRepresentation supportedMIMETypes]):
* WebView.subproj/WebPDFView.h:
* WebView.subproj/WebPDFView.m:
(+[WebPDFView supportedMIMETypes]):
* WebView.subproj/WebTextRepresentation.h:
* WebView.subproj/WebTextRepresentation.m:
(+[WebTextRepresentation supportedMIMETypes]):
* WebView.subproj/WebTextView.h:
* WebView.subproj/WebTextView.m:
(+[WebTextView supportedMIMETypes]):
* WebView.subproj/WebView.m:
(+[WebView _viewClass:andRepresentationClass:forMIMEType:]):
(+[WebView MIMETypesShownAsHTML]): updated to match style
(+[WebView setMIMETypesShownAsHTML:]): ditto
Revision Changes Path
1.3326 +45 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3325
retrieving revision 1.3326
diff -u -r1.3325 -r1.3326
--- ChangeLog 17 Sep 2005 00:09:10 -0000 1.3325
+++ ChangeLog 20 Sep 2005 08:32:58 -0000 1.3326
@@ -1,3 +1,48 @@
+2005-09-20 Eric Seidel <eseidel at apple.com>
+
+ Reviewed by mjs.
+
+ Moved MIME type support from a hard coded list
+ (in two places) to single lists in the corresponding
+ *Representation classes. Also moved the list of types
+ supported by WebCore (WebHTMLRepresentation) into WebCore.
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=5037
+
+ * WebView.subproj/WebDataSource.m:
+ (addTypesFromClass): new inline function
+ (+[WebDataSource _repTypesAllowImageTypeOmission:]):
+ * WebView.subproj/WebFrameView.m:
+ (addTypesFromClass): new inline function
+ (+[WebFrameView _viewTypesAllowImageTypeOmission:]):
+ * WebView.subproj/WebHTMLRepresentation.h:
+ * WebView.subproj/WebHTMLRepresentation.m:
+ (+[WebHTMLRepresentation supportedMIMETypes]):
+ * WebView.subproj/WebHTMLView.m:
+ (+[WebHTMLView supportedMIMETypes]):
+ * WebView.subproj/WebHTMLViewPrivate.h:
+ * WebView.subproj/WebImageRepresentation.h:
+ * WebView.subproj/WebImageRepresentation.m:
+ (+[WebImageRepresentation supportedMIMETypes]):
+ * WebView.subproj/WebImageView.h:
+ * WebView.subproj/WebImageView.m:
+ (+[WebImageView supportedMIMETypes]):
+ * WebView.subproj/WebPDFRepresentation.h:
+ * WebView.subproj/WebPDFRepresentation.m:
+ (+[WebPDFRepresentation supportedMIMETypes]):
+ * WebView.subproj/WebPDFView.h:
+ * WebView.subproj/WebPDFView.m:
+ (+[WebPDFView supportedMIMETypes]):
+ * WebView.subproj/WebTextRepresentation.h:
+ * WebView.subproj/WebTextRepresentation.m:
+ (+[WebTextRepresentation supportedMIMETypes]):
+ * WebView.subproj/WebTextView.h:
+ * WebView.subproj/WebTextView.m:
+ (+[WebTextView supportedMIMETypes]):
+ * WebView.subproj/WebView.m:
+ (+[WebView _viewClass:andRepresentationClass:forMIMEType:]):
+ (+[WebView MIMETypesShownAsHTML]): updated to match style
+ (+[WebView setMIMETypesShownAsHTML:]): ditto
+
2005-09-16 John Sullivan <sullivan at apple.com>
* WebView.subproj/WebImageView.m:
1.212 +20 -27 WebKit/WebView.subproj/WebDataSource.m
Index: WebDataSource.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebDataSource.m,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -r1.211 -r1.212
--- WebDataSource.m 15 Sep 2005 01:26:12 -0000 1.211
+++ WebDataSource.m 20 Sep 2005 08:33:04 -0000 1.212
@@ -651,43 +651,36 @@
_private->mainDocumentError = nil;
}
+static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class, NSArray *supportTypes)
+{
+ NSEnumerator *enumerator = [supportTypes objectEnumerator];
+ ASSERT(enumerator != nil);
+ NSString *mime = nil;
+ while ((mime = [enumerator nextObject]) != nil) {
+ // Don't clobber previously-registered classes.
+ if ([allTypes objectForKey:mime] == nil)
+ [allTypes setObject:class forKey:mime];
+ }
+}
+
+ (NSMutableDictionary *)_repTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission
{
static NSMutableDictionary *repTypes = nil;
- static BOOL addedImageTypes;
+ static BOOL addedImageTypes = NO;
if (!repTypes) {
- repTypes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
- [WebHTMLRepresentation class], @"text/html",
- [WebHTMLRepresentation class], @"text/xml",
- [WebHTMLRepresentation class], @"text/xsl",
- [WebHTMLRepresentation class], @"application/xml",
- [WebHTMLRepresentation class], @"application/xhtml+xml",
- [WebHTMLRepresentation class], @"application/rss+xml",
- [WebHTMLRepresentation class], @"application/atom+xml",
- [WebHTMLRepresentation class], @"application/x-webarchive",
- [WebHTMLRepresentation class], @"multipart/x-mixed-replace",
- [WebTextRepresentation class], @"text/",
- [WebTextRepresentation class], @"application/x-javascript",
- nil];
+ repTypes = [[NSMutableDictionary alloc] init];
+ addTypesFromClass(repTypes, [WebHTMLRepresentation class], [WebHTMLRepresentation supportedMIMETypes]);
+ addTypesFromClass(repTypes, [WebTextRepresentation class], [WebTextRepresentation supportedMIMETypes]);
// Since this is a "secret default" we don't both registering it.
- BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
- if (!omitPDFSupport) {
- [repTypes setObject:[WebPDFRepresentation class] forKey:@"text/pdf"];
- [repTypes setObject:[WebPDFRepresentation class] forKey:@"application/pdf"];
- }
+ BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
+ if (!omitPDFSupport)
+ addTypesFromClass(repTypes, [WebPDFRepresentation class], [WebPDFRepresentation supportedMIMETypes]);
}
if (!addedImageTypes && !allowImageTypeOmission) {
- NSEnumerator *enumerator = [[WebImageView supportedImageMIMETypes] objectEnumerator];
- NSString *mime;
- while ((mime = [enumerator nextObject]) != nil) {
- // Don't clobber previously-registered rep classes.
- if ([repTypes objectForKey:mime] == nil) {
- [repTypes setObject:[WebImageRepresentation class] forKey:mime];
- }
- }
+ addTypesFromClass(repTypes, [WebImageRepresentation class], [WebImageRepresentation supportedMIMETypes]);
addedImageTypes = YES;
}
1.188 +22 -31 WebKit/WebView.subproj/WebFrameView.m
Index: WebFrameView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebFrameView.m,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -r1.187 -r1.188
--- WebFrameView.m 8 Sep 2005 21:35:08 -0000 1.187
+++ WebFrameView.m 20 Sep 2005 08:33:04 -0000 1.188
@@ -238,45 +238,36 @@
return (height < overlap) ? height / 2 : height - overlap;
}
-static NSMutableDictionary *viewTypes;
+static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class, NSArray *supportTypes)
+{
+ NSEnumerator *enumerator = [supportTypes objectEnumerator];
+ ASSERT(enumerator != nil);
+ NSString *mime = nil;
+ while ((mime = [enumerator nextObject]) != nil) {
+ // Don't clobber previously-registered classes.
+ if ([allTypes objectForKey:mime] == nil)
+ [allTypes setObject:class forKey:mime];
+ }
+}
+ (NSMutableDictionary *)_viewTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission
{
- static BOOL addedImageTypes;
-
+ static NSMutableDictionary *viewTypes = nil;
+ static BOOL addedImageTypes = NO;
+
if (!viewTypes) {
- viewTypes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
- [WebHTMLView class], @"text/html",
- [WebHTMLView class], @"text/xml",
- [WebHTMLView class], @"text/xsl",
- [WebHTMLView class], @"application/xml",
- [WebHTMLView class], @"application/xhtml+xml",
- [WebHTMLView class], @"application/rss+xml",
- [WebHTMLView class], @"application/atom+xml",
- [WebHTMLView class], @"application/x-webarchive",
- [WebHTMLView class], @"multipart/x-mixed-replace",
- [WebTextView class], @"text/",
- [WebTextView class], @"application/x-javascript",
- nil];
+ viewTypes = [[NSMutableDictionary alloc] init];
+ addTypesFromClass(viewTypes, [WebHTMLView class], [WebHTMLView supportedMIMETypes]);
+ addTypesFromClass(viewTypes, [WebTextView class], [WebTextView supportedMIMETypes]);
// Since this is a "secret default" we don't both registering it.
- BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
- if (!omitPDFSupport) {
- [viewTypes setObject:[WebPDFView class] forKey:@"text/pdf"];
- [viewTypes setObject:[WebPDFView class] forKey:@"application/pdf"];
- }
+ BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
+ if (!omitPDFSupport)
+ addTypesFromClass(viewTypes, [WebPDFView class], [WebPDFView supportedMIMETypes]);
}
-
+
if (!addedImageTypes && !allowImageTypeOmission) {
- NSEnumerator *enumerator = [[WebImageView supportedImageMIMETypes] objectEnumerator];
- ASSERT(enumerator != nil);
- NSString *mime;
- while ((mime = [enumerator nextObject]) != nil) {
- // Don't clobber previously-registered view classes.
- if ([viewTypes objectForKey:mime] == nil) {
- [viewTypes setObject:[WebImageView class] forKey:mime];
- }
- }
+ addTypesFromClass(viewTypes, [WebImageView class], [WebImageView supportedMIMETypes]);
addedImageTypes = YES;
}
1.31 +2 -0 WebKit/WebView.subproj/WebHTMLRepresentation.h
Index: WebHTMLRepresentation.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebHTMLRepresentation.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- WebHTMLRepresentation.h 29 Jul 2005 21:16:56 -0000 1.30
+++ WebHTMLRepresentation.h 20 Sep 2005 08:33:04 -0000 1.31
@@ -48,6 +48,8 @@
WebHTMLRepresentationPrivate *_private;
}
++ (NSArray *)supportedMIMETypes;
+
- (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset;
- (DOMElement *)elementWithName:(NSString *)name inForm:(DOMElement *)form;
1.58 +5 -0 WebKit/WebView.subproj/WebHTMLRepresentation.m
Index: WebHTMLRepresentation.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebHTMLRepresentation.m,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- WebHTMLRepresentation.m 29 Jul 2005 21:16:56 -0000 1.57
+++ WebHTMLRepresentation.m 20 Sep 2005 08:33:04 -0000 1.58
@@ -64,6 +64,11 @@
@implementation WebHTMLRepresentation
++ (NSArray *)supportedMIMETypes
+{
+ return [WebCoreBridge supportedMIMETypes];
+}
+
- init
{
self = [super init];
1.468 +5 -0 WebKit/WebView.subproj/WebHTMLView.m
Index: WebHTMLView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebHTMLView.m,v
retrieving revision 1.467
retrieving revision 1.468
diff -u -r1.467 -r1.468
--- WebHTMLView.m 5 Sep 2005 22:26:05 -0000 1.467
+++ WebHTMLView.m 20 Sep 2005 08:33:04 -0000 1.468
@@ -644,6 +644,11 @@
[WebImageRenderer stopAnimationsInView:self];
}
++ (NSArray *)supportedMIMETypes
+{
+ return [WebHTMLRepresentation supportedMIMETypes];
+}
+
+ (void)_postFlagsChangedEvent:(NSEvent *)flagsChangedEvent
{
NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved
1.95 +1 -0 WebKit/WebView.subproj/WebHTMLViewPrivate.h
Index: WebHTMLViewPrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebHTMLViewPrivate.h,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- WebHTMLViewPrivate.h 18 Jul 2005 18:02:21 -0000 1.94
+++ WebHTMLViewPrivate.h 20 Sep 2005 08:33:05 -0000 1.95
@@ -39,6 +39,7 @@
@interface WebHTMLView (WebPrivate)
- (void)_reset;
++ (NSArray *)supportedMIMETypes;
// Modifier (flagsChanged) tracking SPI
+ (void)_postFlagsChangedEvent:(NSEvent *)flagsChangedEvent;
1.13 +1 -0 WebKit/WebView.subproj/WebImageRepresentation.h
Index: WebImageRepresentation.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebImageRepresentation.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WebImageRepresentation.h 5 Jun 2005 17:54:47 -0000 1.12
+++ WebImageRepresentation.h 20 Sep 2005 08:33:05 -0000 1.13
@@ -40,6 +40,7 @@
WebImageRenderer *image;
BOOL doneLoading;
}
++ (NSArray *)supportedMIMETypes;
- (WebImageRenderer *)image;
- (NSString *)filename;
- (WebArchive *)archive;
1.26 +11 -0 WebKit/WebView.subproj/WebImageRepresentation.m
Index: WebImageRepresentation.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebImageRepresentation.m,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- WebImageRepresentation.m 5 Jun 2005 17:54:47 -0000 1.25
+++ WebImageRepresentation.m 20 Sep 2005 08:33:05 -0000 1.26
@@ -41,6 +41,17 @@
@implementation WebImageRepresentation
++ (NSArray *)supportedMIMETypes
+{
+ static NSMutableArray *imageMIMETypes = nil;
+ if (imageMIMETypes == nil) {
+ imageMIMETypes = [[[WebImageRendererFactory sharedFactory] supportedMIMETypes] mutableCopy];
+ [imageMIMETypes removeObject:@"application/pdf"];
+ [imageMIMETypes removeObject:@"application/postscript"];
+ }
+ return imageMIMETypes;
+}
+
- (void)dealloc
{
[image release];
1.18 +1 -1 WebKit/WebView.subproj/WebImageView.h
Index: WebImageView.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebImageView.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- WebImageView.h 5 Jun 2005 17:54:47 -0000 1.17
+++ WebImageView.h 20 Sep 2005 08:33:05 -0000 1.18
@@ -38,5 +38,5 @@
NSEvent *mouseDownEvent;
unsigned int dragSourceActionMask;
}
-+ (NSArray *)supportedImageMIMETypes;
++ (NSArray *)supportedMIMETypes;
@end
1.75 +2 -8 WebKit/WebView.subproj/WebImageView.m
Index: WebImageView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebImageView.m,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- WebImageView.m 17 Sep 2005 00:09:13 -0000 1.74
+++ WebImageView.m 20 Sep 2005 08:33:05 -0000 1.75
@@ -51,15 +51,9 @@
[NSApp registerServicesMenuSendTypes:[NSArray arrayWithObject:NSTIFFPboardType] returnTypes:nil];
}
-+ (NSArray *)supportedImageMIMETypes
++ (NSArray *)supportedMIMETypes
{
- static NSMutableArray *imageMIMETypes = nil;
- if (imageMIMETypes == nil) {
- imageMIMETypes = [[[WebImageRendererFactory sharedFactory] supportedMIMETypes] mutableCopy];
- [imageMIMETypes removeObject:@"application/pdf"];
- [imageMIMETypes removeObject:@"application/postscript"];
- }
- return imageMIMETypes;
+ return [WebImageRepresentation supportedMIMETypes];
}
- (id)initWithFrame:(NSRect)frame
1.5 +1 -0 WebKit/WebView.subproj/WebPDFRepresentation.h
Index: WebPDFRepresentation.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFRepresentation.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WebPDFRepresentation.h 16 Aug 2005 19:03:35 -0000 1.4
+++ WebPDFRepresentation.h 20 Sep 2005 08:33:06 -0000 1.5
@@ -31,4 +31,5 @@
@protocol WebDocumentRepresentation;
@interface WebPDFRepresentation : NSObject <WebDocumentRepresentation>
++ (NSArray *)supportedMIMETypes;
@end
1.7 +8 -0 WebKit/WebView.subproj/WebPDFRepresentation.m
Index: WebPDFRepresentation.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFRepresentation.m,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WebPDFRepresentation.m 16 Aug 2005 19:03:35 -0000 1.6
+++ WebPDFRepresentation.m 20 Sep 2005 08:33:06 -0000 1.7
@@ -38,6 +38,14 @@
@implementation WebPDFRepresentation
++ (NSArray *)supportedMIMETypes
+{
+ return [NSArray arrayWithObjects:
+ @"text/pdf",
+ @"application/pdf",
+ nil];
+}
+
+ (Class)PDFDocumentClass
{
static Class PDFDocumentClass = nil;
1.14 +1 -0 WebKit/WebView.subproj/WebPDFView.h
Index: WebPDFView.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFView.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- WebPDFView.h 16 Aug 2005 19:03:35 -0000 1.13
+++ WebPDFView.h 20 Sep 2005 08:33:06 -0000 1.14
@@ -45,6 +45,7 @@
PDFView *PDFSubviewProxy;
}
++ (NSArray *)supportedMIMETypes;
+ (NSBundle *)PDFKitBundle;
- (PDFView *)PDFSubview;
1.26 +6 -0 WebKit/WebView.subproj/WebPDFView.m
Index: WebPDFView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFView.m,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- WebPDFView.m 16 Aug 2005 19:03:35 -0000 1.25
+++ WebPDFView.m 20 Sep 2005 08:33:06 -0000 1.26
@@ -42,6 +42,7 @@
#import <WebKit/WebView.h>
#import <WebKit/WebViewPrivate.h>
#import <WebKit/WebPreferencesPrivate.h>
+#import <WebKit/WebPDFRepresentation.h>
#import <WebKitSystemInterface.h>
#import <PDFKit/PDFKit.h>
@@ -94,6 +95,11 @@
return PDFViewClass;
}
++ (NSArray *)supportedMIMETypes
+{
+ return [WebPDFRepresentation supportedMIMETypes];
+}
+
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
1.7 +1 -0 WebKit/WebView.subproj/WebTextRepresentation.h
Index: WebTextRepresentation.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebTextRepresentation.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WebTextRepresentation.h 5 Jun 2005 17:54:48 -0000 1.6
+++ WebTextRepresentation.h 20 Sep 2005 08:33:06 -0000 1.7
@@ -35,4 +35,5 @@
NSString *RTFSource;
BOOL hasRTFSource;
}
++ (NSArray *)supportedMIMETypes;
@end
1.19 +8 -0 WebKit/WebView.subproj/WebTextRepresentation.m
Index: WebTextRepresentation.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebTextRepresentation.m,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WebTextRepresentation.m 5 Jun 2005 17:54:48 -0000 1.18
+++ WebTextRepresentation.m 20 Sep 2005 08:33:06 -0000 1.19
@@ -38,6 +38,14 @@
@implementation WebTextRepresentation
++ (NSArray *)supportedMIMETypes
+{
+ return [NSArray arrayWithObjects:
+ @"text/",
+ @"application/x-javascript",
+ nil];
+}
+
- (void)dealloc
{
[RTFSource release];
1.20 +1 -0 WebKit/WebView.subproj/WebTextView.h
Index: WebTextView.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebTextView.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WebTextView.h 18 Jul 2005 18:02:21 -0000 1.19
+++ WebTextView.h 20 Sep 2005 08:33:06 -0000 1.20
@@ -36,6 +36,7 @@
float _textSizeMultiplier;
}
++ (NSArray *)supportedMIMETypes;
+ (NSArray *)unsupportedTextMIMETypes;
- (void)setFixedWidthFont;
1.61 +6 -0 WebKit/WebView.subproj/WebTextView.m
Index: WebTextView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebTextView.m,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- WebTextView.m 27 Jul 2005 21:36:44 -0000 1.60
+++ WebTextView.m 20 Sep 2005 08:33:06 -0000 1.61
@@ -42,6 +42,7 @@
#import <WebKit/WebPreferences.h>
#import <WebKit/WebTextRendererFactory.h>
#import <WebKit/WebViewPrivate.h>
+#import <WebKit/WebTextRepresentation.h>
#import <Foundation/NSURLResponse.h>
@@ -58,6 +59,11 @@
@implementation WebTextView
++ (NSArray *)supportedMIMETypes
+{
+ return [WebTextRepresentation supportedMIMETypes];
+}
+
+ (NSArray *)unsupportedTextMIMETypes
{
return [NSArray arrayWithObjects:
1.306 +16 -33 WebKit/WebView.subproj/WebView.m
Index: WebView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
retrieving revision 1.305
retrieving revision 1.306
diff -u -r1.305 -r1.306
--- WebView.m 11 Sep 2005 17:04:17 -0000 1.305
+++ WebView.m 20 Sep 2005 08:33:06 -0000 1.306
@@ -369,30 +369,19 @@
+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
{
MIMEType = [MIMEType lowercaseString];
- Class viewClass;
- Class repClass;
+ Class viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];
+ Class repClass = [[WebDataSource _repTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];
- // Simple optimization that avoids loading the plug-in DB and image types for the HTML case.
- if ([self canShowMIMETypeAsHTML:MIMEType]) {
- viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];
- repClass = [[WebDataSource _repTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];
- if (viewClass && repClass) {
- if (vClass) {
- *vClass = viewClass;
- }
- if (rClass) {
- *rClass = repClass;
- }
- return YES;
- }
+ if (!viewClass || !repClass) {
+ // Our optimization to avoid loading the plug-in DB and image types for the HTML case failed.
+ // Load the plug-in DB allowing plug-ins to install types.
+ [WebPluginDatabase installedPlugins];
+
+ // Load the image types and get the view class and rep class. This should be the fullest picture of all handled types.
+ viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:NO] _webkit_objectForMIMEType:MIMEType];
+ repClass = [[WebDataSource _repTypesAllowImageTypeOmission:NO] _webkit_objectForMIMEType:MIMEType];
}
- // Load the plug-in DB allowing plug-ins to install types.
- [WebPluginDatabase installedPlugins];
-
- // Load the image types and get the view class and rep class. This should be the fullest picture of all handled types.
- viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:NO] _webkit_objectForMIMEType:MIMEType];
- repClass = [[WebDataSource _repTypesAllowImageTypeOmission:NO] _webkit_objectForMIMEType:MIMEType];
if (viewClass && repClass) {
// Special-case WebTextView for text types that shouldn't be shown.
if (viewClass == [WebTextView class] &&
@@ -400,12 +389,10 @@
[[WebTextView unsupportedTextMIMETypes] containsObject:MIMEType]) {
return NO;
}
- if (vClass) {
+ if (vClass)
*vClass = viewClass;
- }
- if (rClass) {
+ if (rClass)
*rClass = repClass;
- }
return YES;
}
@@ -1488,9 +1475,8 @@
NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease];
while ((key = [enumerator nextObject])) {
- if ([viewTypes objectForKey:key] == [WebHTMLView class]) {
+ if ([viewTypes objectForKey:key] == [WebHTMLView class])
[array addObject:key];
- }
}
return array;
@@ -1498,15 +1484,12 @@
+ (void)setMIMETypesShownAsHTML:(NSArray *)MIMETypes
{
- NSEnumerator *enumerator;
- id key;
-
NSMutableDictionary *viewTypes = [WebFrameView _viewTypesAllowImageTypeOmission:YES];
- enumerator = [viewTypes keyEnumerator];
+ NSEnumerator *enumerator = [viewTypes keyEnumerator];
+ id key;
while ((key = [enumerator nextObject])) {
- if ([viewTypes objectForKey:key] == [WebHTMLView class]) {
+ if ([viewTypes objectForKey:key] == [WebHTMLView class])
[WebView _unregisterViewClassAndRepresentationClassForMIMEType:key];
- }
}
int i, count = [MIMETypes count];
More information about the webkit-changes
mailing list