- fixed <rdar://problem/
4792761> Safari should use fancier embedded PDFKit stuff when it's available
* WebKit.xcodeproj/project.pbxproj:
version wars
* WebView/WebFrameView.m:
(-[WebFrameView _makeDocumentViewForDataSource:]):
initialize document view with frame view's rect instead of empty rect. This avoids some problems when
constructing view hierarchies from nibs
* WebView/WebPreferencesPrivate.h:
declare new _usePDFPreviewView and _setUsePDFPreviewView:, used for debugging
* WebView/WebPreferenceKeysPrivate.h:
declare new preference key string
* WebView/WebPreferences.m:
(+[WebPreferences initialize]):
initialize new preference to true (we will by default use the new view if it's available)
(-[WebPreferences _usePDFPreviewView]):
new accessor for new pref
(-[WebPreferences _setUsePDFPreviewView:]):
ditto
* WebView/WebPDFView.h:
new previewView ivar
* WebView/WebPDFView.m:
(+[WebPDFView PDFPreviewViewClass]):
new method, returns class to use for fancier embedded PDFKit stuff, or nil if fancy stuff isn't available
(-[WebPDFView initWithFrame:]):
now tries to use fancier embedded PDFKit stuff if it's available and the pref is set to use it; falls back
to old behavior otherwise
(-[WebPDFView dealloc]):
release new previewView ivar (retained in initWithFrame:)
(-[WebPDFView viewWillMoveToWindow:]):
stop observing PDFKit notification when we're removed from window
(-[WebPDFView viewDidMoveToWindow]):
start observing PDFKit notification when we're added to window
(-[WebPDFView _receivedPDFKitLaunchNotification:]):
respond to this new PDFKit notification by opening the document via NSWorkspace
* English.lproj/StringsNotToBeLocalized.txt:
updated for lots of recent changes
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17139
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-10-19 John Sullivan <sullivan@apple.com>
+
+ Reviewed by Kevin Decker
+
+ - fixed <rdar://problem/4792761> Safari should use fancier embedded PDFKit stuff when it's available
+
+ * WebKit.xcodeproj/project.pbxproj:
+ version wars
+
+ * WebView/WebFrameView.m:
+ (-[WebFrameView _makeDocumentViewForDataSource:]):
+ initialize document view with frame view's rect instead of empty rect. This avoids some problems when
+ constructing view hierarchies from nibs
+
+ * WebView/WebPreferencesPrivate.h:
+ declare new _usePDFPreviewView and _setUsePDFPreviewView:, used for debugging
+ * WebView/WebPreferenceKeysPrivate.h:
+ declare new preference key string
+ * WebView/WebPreferences.m:
+ (+[WebPreferences initialize]):
+ initialize new preference to true (we will by default use the new view if it's available)
+ (-[WebPreferences _usePDFPreviewView]):
+ new accessor for new pref
+ (-[WebPreferences _setUsePDFPreviewView:]):
+ ditto
+
+ * WebView/WebPDFView.h:
+ new previewView ivar
+
+ * WebView/WebPDFView.m:
+ (+[WebPDFView PDFPreviewViewClass]):
+ new method, returns class to use for fancier embedded PDFKit stuff, or nil if fancy stuff isn't available
+ (-[WebPDFView initWithFrame:]):
+ now tries to use fancier embedded PDFKit stuff if it's available and the pref is set to use it; falls back
+ to old behavior otherwise
+ (-[WebPDFView dealloc]):
+ release new previewView ivar (retained in initWithFrame:)
+ (-[WebPDFView viewWillMoveToWindow:]):
+ stop observing PDFKit notification when we're removed from window
+ (-[WebPDFView viewDidMoveToWindow]):
+ start observing PDFKit notification when we're added to window
+ (-[WebPDFView _receivedPDFKitLaunchNotification:]):
+ respond to this new PDFKit notification by opening the document via NSWorkspace
+
+ * English.lproj/StringsNotToBeLocalized.txt:
+ updated for lots of recent changes
+
2006-10-19 Sam Weinig <sam.weinig@gmail.com>
Reviewed by ap.
" "
-" %s -> %6ld : %.0f : %.0f\n"
-" %s : %6ld : %.0f : %.0f\n"
" "
" #%*[^\n\r]%*[\n\r]"
" %32[^# \t\n\r]%*[^# \t\n\r] "
"%"
"%.1lf"
"%.2lu/%.2lu/%.10lu-%.10lu.cache"
+"%.2u/%.2u/%.10u-%.10u.cache"
"%2d) "
"%@ %.0fpx %.0fpx %.0fpx"
"%@ %.0fpx %.0fpx"
"%@/.tmp%d"
"%@/Library/Preferences/%@"
"%@:%u"
-"%@://%@"
"%d"
"%dpx"
-"%lld"
","
"-"
"-1px"
"/Frameworks/PDFKit.framework"
"/Library/Internet Plug-Ins"
"/Volumes"
-"/favicon.ico"
"/image.pict"
"/image.tiff"
"/tmp/"
"BP_CreatePluginMIMETypesPreferences"
"Cache-Control"
"Content-Length"
-"Content-Type"
"Courier"
"DOCBASE"
"DYLD_FRAMEWORK_PATH"
"FrameName"
-"GET"
"GroupName"
"Helvetica"
"ISO-8859-1"
"LTR"
"LangAnalysis"
"Library/Internet Plug-Ins"
-"List count: %d items\n"
-"List total size: %d bytes\n"
"Look Up in Dictionary menu title."
"MenuCommands"
"Mozilla/5.0 (Macintosh; U; "
"NSErrorFailingURLKey"
"NSErrorFailingURLStringKey"
"NSEvent"
-"NSFileModificationDate"
-"NSFileOwnerAccountName"
-"NSFilePosixPermissions"
"NSView"
"NeXT smart paste pasteboard type"
"PDFDocument"
+"PDFPreviewLaunchPreview"
+"PDFPreviewView"
"PDFView"
"POST"
"PPC"
"Papyrus"
"Quartz.framework"
"RTL"
-"Referer"
"SAMILang"
"SAMIStyle"
"Search in Google menu title."
"Times"
"UTF-8"
"UseBackForwardList"
-"User-Agent"
"Volumes"
"WEBKIT_UNSET_DYLD_FRAMEWORK_PATH"
"WebActionButtonKey"
"WebActionOriginalURLKey"
"WebAuthenticationPanel"
"WebBackForwardList:\n"
-"WebDataRequest"
"WebElementDOMNode"
"WebElementFrame"
"WebElementImage"
"WebElementLinkURL"
"WebElementTargetFrame"
"WebElementTitle"
-"WebFrameStateCommittedPage"
-"WebFrameStateComplete"
-"WebFrameStateProvisional"
"WebHistoryAllItemsRemovedNotification"
"WebHistoryDates"
"WebHistoryFileVersion"
"WebIconDatabaseEnabled"
"WebIconDatabaseVersion"
"WebIconNotificationUserInfoURLKey"
-"WebIconURLToSiteURLs"
-"WebIconsOnDisk"
"WebJavaScriptTextInputPanel"
-"WebKitAllowAnimatedImageLoopingPreferenceKey"
-"WebKitAllowAnimatedImagesPreferenceKey"
-"WebKitBackForwardCacheExpirationIntervalKey"
-"WebKitCursiveFont"
-"WebKitDefaultFixedFontSize"
-"WebKitDefaultFontSize"
-"WebKitDefaultTextEncodingName"
"WebKitDeveloperExtras"
-"WebKitDisplayImagesKey"
"WebKitDisplayThrottleRunLoopMode"
-"WebKitEnableInspectElementContextMenuItem"
"WebKitErrorDomain"
"WebKitErrorMIMETypeKey"
"WebKitErrorPlugInNameKey"
"WebKitErrorPlugInPageURLStringKey"
-"WebKitFantasyFont"
-"WebKitFixedFont"
"WebKitHistoryAgeInDaysLimit"
"WebKitHistoryItemLimit"
-"WebKitJavaEnabled"
-"WebKitJavaScriptCanOpenWindowsAutomatically"
-"WebKitJavaScriptEnabled"
-"WebKitLogLevel"
-"WebKitMinimumFontSize"
-"WebKitMinimumLogicalFontSize"
-"WebKitObjectCacheSizePreferenceKey"
"WebKitOmitPDFSupport"
-"WebKitPDFDisplayMode"
-"WebKitPDFScaleFactor"
-"WebKitPageCacheSizePreferenceKey"
-"WebKitPluginsEnabled"
-"WebKitPrivateBrowsingEnabled"
-"WebKitRespectStandardStyleKeyEquivalents"
-"WebKitSansSerifFont"
-"WebKitSerifFont"
-"WebKitShouldPrintBackgroundsPreferenceKey"
-"WebKitShowsURLsInToolTips"
-"WebKitStandardFont"
-"WebKitTabToLinksPreferenceKey"
-"WebKitTextAreasAreResizable"
-"WebKitThrottleWindowDisplay"
-"WebKitUserStyleSheetEnabledPreferenceKey"
-"WebKitUserStyleSheetLocationPreferenceKey"
+"WebKitScriptDebuggerEnabled"
"WebLoginWindowDidSwitchFromUserNotification"
"WebLoginWindowDidSwitchToUserNotification"
"WebMainResource"
"\n "
"\n"
"\n--------------------------------------------\n"
-"\nDict data: %ld items\n"
-"\nHeap data: %ld items\n"
-"\nList root path: %s\n"
"\r"
"\r\n"
"\t"
"a"
"about:"
"about:blank"
-"applewebdata"
"application/atom+xml"
"application/octet-stream"
"application/pdf"
"doctype"
"en"
"estimatedProgress"
-"file:"
"ftp:"
"htm"
"html"
"mainFrameIcon"
"mainFrameTitle"
"mainFrameURL"
-"max-age=0"
"missing_image"
-"multipart/x-mixed-replace"
"must-revalidate"
"nullplugin"
"pluginspage"
"text/x-vcalendar"
"text/x-vcard"
"text/x-vcf"
-"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
"tiff"
"txt"
"u"
-"url_icon"
-"utf-16"
"visitCount"
-"webarchive"
"webplugin"
"x"
"x-apple-web-kit/"
DefaultDelegates/WebDefaultContextMenuDelegate.m:"Look Up in Dictionary"
DefaultDelegates/WebDefaultContextMenuDelegate.m:"Search in Google"
DefaultDelegates/WebDefaultContextMenuDelegate.m:"Search in Spotlight"
+DefaultDelegates/WebScriptDebugServer.m
History/WebHistoryItem.m:" in \"%@\""
History/WebHistoryItem.m:"children"
History/WebHistoryItem.m:"title"
Misc/WebKitLogging.m
+Misc/WebKitVersionChecks.m
Misc/WebNSURLExtras.m:"IDNScriptWhiteList"
Misc/WebNSURLExtras.m:"IDNScriptWhiteList.txt"
Misc/WebNSURLExtras.m:"file"
+Misc/WebNSURLRequestExtras.m
Plugins/WebBaseNetscapePluginView.m:"height"
Plugins/WebBaseNetscapePluginView.m:"width"
Plugins/WebBasePluginPackage.m:"Java Applet Plugin Enabler"
Plugins/WebBasePluginPackage.m:"name: %@\npath: %@\nmimeTypes:\n%@\npluginDescription:%@"
Plugins/WebNetscapePluginPackage.m:"RealPlayer Plugin"
Plugins/WebNetscapePluginPackage.m:"main"
-Plugins/WebPluginDocumentView.m:"type"
WebCoreSupport/WebFrameBridge.m:"height"
WebCoreSupport/WebFrameBridge.m:"width"
WebInspector/WebInspector.m
WebInspector/WebInspectorPanel.m:"control"
WebInspector/WebInspectorPanel.m:"resize"
-WebView/WebFrame.m:"Accept"
-WebView/WebFrame.m:"Refresh"
WebView/WebHTMLView.m:"%0.fpx"
WebView/WebHTMLView.m:"'%@'"
WebView/WebHTMLView.m:"Version:"
WebView/WebHTMLView.m:"transparent"
WebView/WebHTMLView.m:"underline"
WebView/WebHTMLView.m:"white"
+WebView/WebPreferenceKeysPrivate.h
WebView/WebPreferences.m:"Identifier"
WebView/WebPreferences.m:"Values"
WebView/WebPreferences.m:"WebPreferences%d"
WebView/WebRenderNode.m
+WebView/WebScriptDebugDelegate.m
WebView/WebView.m:"Preferences"
WebView/WebView.m:"Search With Google"
WebView/WebView.m:"Show DOM Tree"
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
+ compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
+ projectRoot = "";
+ shouldCheckCompatibility = 1;
targets = (
9398100A0824BF01008DF038 /* WebKit */,
);
if (dataSourceRepresentation && [dataSourceRepresentation class] == viewClass)
documentView = (NSView <WebDocumentView> *)[dataSourceRepresentation retain];
else
- documentView = [[viewClass alloc] init];
+ documentView = [[viewClass alloc] initWithFrame:[self bounds]];
} else
documentView = nil;
@interface WebPDFView : NSView <WebDocumentView, WebDocumentSearching, WebDocumentSelection, WebDocumentElement, _WebDocumentViewState, _WebDocumentTextSizing>
{
+ NSView *previewView;
PDFView *PDFSubview;
NSString *path;
id trackedFirstResponder;
#import <WebCore/WebFrameLoader.h>
#import <WebKitSystemInterface.h>
+#define PDFKitLaunchNotification @"PDFPreviewLaunchPreview"
+
// QuartzPrivate.h doesn't include the PDFKit private headers, so we can't get at PDFViewPriv.h. (3957971)
// Even if that was fixed, we'd have to tweak compile options to include QuartzPrivate.h. (3957839)
return PDFViewClass;
}
++ (Class)PDFPreviewViewClass
+{
+ static Class PDFPreviewViewClass = nil;
+ static BOOL checkedForPDFPreviewViewClass = NO;
+
+ if (!checkedForPDFPreviewViewClass) {
+ checkedForPDFPreviewViewClass = YES;
+ PDFPreviewViewClass = [[WebPDFView PDFKitBundle] classNamed:@"PDFPreviewView"];
+ }
+
+ // This class might not be available; callers need to deal with a nil return here.
+ return PDFPreviewViewClass;
+}
+
+ (NSArray *)supportedMIMETypes
{
return [WebPDFRepresentation supportedMIMETypes];
{
self = [super initWithFrame:frame];
if (self) {
- [self setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
- PDFSubview = [[[[self class] PDFViewClass] alloc] initWithFrame:frame];
- [PDFSubview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
- [self addSubview:PDFSubview];
+ [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+
+ Class previewViewClass = nil;
+ if ([[WebPreferences standardPreferences] _usePDFPreviewView])
+ previewViewClass = [[self class] PDFPreviewViewClass];
+
+ // We might not have found a previewViewClass even if we looked for one.
+ // But if we found the class we should be able to create an instance.
+ if (previewViewClass) {
+ previewView = [[previewViewClass alloc] initWithFrame:frame];
+ ASSERT(previewView);
+ }
+
+ NSView *topLevelPDFKitView = nil;
+ if (previewView) {
+ PDFSubview = [previewView performSelector:@selector(pdfView)];
+ topLevelPDFKitView = previewView;
+ } else {
+ PDFSubview = [[[[self class] PDFViewClass] alloc] initWithFrame:frame];
+ topLevelPDFKitView = PDFSubview;
+ }
+
+ ASSERT(PDFSubview);
+
+ [topLevelPDFKitView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+ [self addSubview:topLevelPDFKitView];
+
[PDFSubview setDelegate:self];
written = NO;
// Messaging this proxy is the same as messaging PDFSubview, with the side effect that the
- (void)dealloc
{
ASSERT(!trackedFirstResponder);
+ [previewView release];
[PDFSubview release];
[path release];
[PDFSubviewProxy release];
[self _applyPDFDefaults];
}
-
- (void)_trackFirstResponder
{
ASSERT([self window]);
if (!oldWindow)
return;
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSWindowDidUpdateNotification
- object:oldWindow];
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ [notificationCenter removeObserver:self
+ name:NSWindowDidUpdateNotification
+ object:oldWindow];
+ if (previewView)
+ [notificationCenter removeObserver:self
+ name:PDFKitLaunchNotification
+ object:previewView];
[trackedFirstResponder release];
trackedFirstResponder = nil;
return;
[self _trackFirstResponder];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(_trackFirstResponder)
- name:NSWindowDidUpdateNotification
- object:newWindow];
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ [notificationCenter addObserver:self
+ selector:@selector(_trackFirstResponder)
+ name:NSWindowDidUpdateNotification
+ object:newWindow];
+
+ if (previewView)
+ [notificationCenter addObserver:self
+ selector:@selector(_receivedPDFKitLaunchNotification:)
+ name:PDFKitLaunchNotification
+ object:previewView];
}
- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
}
}
+- (void)_receivedPDFKitLaunchNotification:(NSNotification *)notification
+{
+ ASSERT([notification object] == previewView);
+ [self openWithFinder:self];
+}
+
// FIXME 4182876: We can eliminate this function in favor if -isEqual: if [PDFSelection isEqual:] is overridden
// to compare contents.
static BOOL PDFSelectionsAreEqual(PDFSelection *selectionA, PDFSelection *selectionB)
#define WebKitShowsURLsInToolTipsPreferenceKey @"WebKitShowsURLsInToolTips"
#define WebKitPDFDisplayModePreferenceKey @"WebKitPDFDisplayMode"
#define WebKitPDFScaleFactorPreferenceKey @"WebKitPDFScaleFactor"
+#define WebKitUsePDFPreviewViewPreferenceKey @"WebKitUsePDFPreviewView"
#define WebKitEditableLinkBehaviorPreferenceKey @"WebKitEditableLinkBehavior"
[NSNumber numberWithBool:NO], WebKitShowsURLsInToolTipsPreferenceKey,
@"1", WebKitPDFDisplayModePreferenceKey,
@"0", WebKitPDFScaleFactorPreferenceKey,
+ @"1", WebKitUsePDFPreviewViewPreferenceKey,
[NSNumber numberWithInt:WebKitEditableLinkDefaultBehavior],
WebKitEditableLinkBehaviorPreferenceKey,
nil];
[self _setIntegerValue:mode forKey:WebKitPDFDisplayModePreferenceKey];
}
+- (BOOL)_usePDFPreviewView
+{
+ return [self _boolValueForKey:WebKitUsePDFPreviewViewPreferenceKey];
+}
+
+- (void)_setUsePDFPreviewView:(BOOL)newValue
+{
+ [self _setBoolValue:newValue forKey:WebKitUsePDFPreviewViewPreferenceKey];
+}
+
- (WebKitEditableLinkBehavior)editableLinkBehavior
{
WebKitEditableLinkBehavior value = [self _integerValueForKey:WebKitEditableLinkBehaviorPreferenceKey];
- (WebKitEditableLinkBehavior)editableLinkBehavior;
- (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior;
+// For debugging purposes, can be removed when no longer needed
+- (BOOL)_usePDFPreviewView;
+- (void)_setUsePDFPreviewView:(BOOL)newValue;
+
// Other private methods
- (size_t)_pageCacheSize;
- (size_t)_objectCacheSize;