summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/WebView
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/WebView')
-rw-r--r--WebKit/mac/WebView/WebArchive.h97
-rw-r--r--WebKit/mac/WebView/WebArchive.mm374
-rw-r--r--WebKit/mac/WebView/WebArchiveInternal.h41
-rw-r--r--WebKit/mac/WebView/WebClipView.h42
-rw-r--r--WebKit/mac/WebView/WebClipView.m118
-rw-r--r--WebKit/mac/WebView/WebDataSource.h180
-rw-r--r--WebKit/mac/WebView/WebDataSource.mm504
-rw-r--r--WebKit/mac/WebView/WebDataSourceInternal.h60
-rw-r--r--WebKit/mac/WebView/WebDataSourcePrivate.h40
-rw-r--r--WebKit/mac/WebView/WebDocument.h209
-rw-r--r--WebKit/mac/WebView/WebDocumentInternal.h81
-rw-r--r--WebKit/mac/WebView/WebDocumentLoaderMac.h68
-rw-r--r--WebKit/mac/WebView/WebDocumentLoaderMac.mm156
-rw-r--r--WebKit/mac/WebView/WebDocumentPrivate.h82
-rw-r--r--WebKit/mac/WebView/WebDynamicScrollBarsView.h48
-rw-r--r--WebKit/mac/WebView/WebDynamicScrollBarsView.m306
-rw-r--r--WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h56
-rw-r--r--WebKit/mac/WebView/WebEditingDelegate.h57
-rw-r--r--WebKit/mac/WebView/WebEditingDelegatePrivate.h38
-rw-r--r--WebKit/mac/WebView/WebFormDelegate.h74
-rw-r--r--WebKit/mac/WebView/WebFormDelegate.m79
-rw-r--r--WebKit/mac/WebView/WebFormDelegatePrivate.h33
-rw-r--r--WebKit/mac/WebView/WebFrame.h210
-rw-r--r--WebKit/mac/WebView/WebFrame.mm1357
-rw-r--r--WebKit/mac/WebView/WebFrameInternal.h193
-rw-r--r--WebKit/mac/WebView/WebFrameLoadDelegate.h197
-rw-r--r--WebKit/mac/WebView/WebFramePrivate.h87
-rw-r--r--WebKit/mac/WebView/WebFrameView.h103
-rw-r--r--WebKit/mac/WebView/WebFrameView.mm984
-rw-r--r--WebKit/mac/WebView/WebFrameViewInternal.h47
-rw-r--r--WebKit/mac/WebView/WebFrameViewPrivate.h65
-rw-r--r--WebKit/mac/WebView/WebHTMLRepresentation.h66
-rw-r--r--WebKit/mac/WebView/WebHTMLRepresentation.mm350
-rw-r--r--WebKit/mac/WebView/WebHTMLRepresentationInternal.h33
-rw-r--r--WebKit/mac/WebView/WebHTMLRepresentationPrivate.h36
-rw-r--r--WebKit/mac/WebView/WebHTMLView.h63
-rw-r--r--WebKit/mac/WebView/WebHTMLView.mm5780
-rw-r--r--WebKit/mac/WebView/WebHTMLViewInternal.h61
-rw-r--r--WebKit/mac/WebView/WebHTMLViewPrivate.h130
-rw-r--r--WebKit/mac/WebView/WebPDFRepresentation.h35
-rw-r--r--WebKit/mac/WebView/WebPDFRepresentation.m145
-rw-r--r--WebKit/mac/WebView/WebPDFView.h55
-rw-r--r--WebKit/mac/WebView/WebPDFView.mm1485
-rw-r--r--WebKit/mac/WebView/WebPolicyDelegate.h198
-rw-r--r--WebKit/mac/WebView/WebPolicyDelegate.mm121
-rw-r--r--WebKit/mac/WebView/WebPolicyDelegatePrivate.h52
-rw-r--r--WebKit/mac/WebView/WebPreferenceKeysPrivate.h92
-rw-r--r--WebKit/mac/WebView/WebPreferences.h442
-rw-r--r--WebKit/mac/WebView/WebPreferences.mm1070
-rw-r--r--WebKit/mac/WebView/WebPreferencesPrivate.h124
-rw-r--r--WebKit/mac/WebView/WebRenderNode.h51
-rw-r--r--WebKit/mac/WebView/WebRenderNode.mm152
-rw-r--r--WebKit/mac/WebView/WebResource.h87
-rw-r--r--WebKit/mac/WebView/WebResource.mm346
-rw-r--r--WebKit/mac/WebView/WebResourceInternal.h42
-rw-r--r--WebKit/mac/WebView/WebResourceLoadDelegate.h166
-rw-r--r--WebKit/mac/WebView/WebResourceLoadDelegatePrivate.h47
-rw-r--r--WebKit/mac/WebView/WebResourcePrivate.h49
-rw-r--r--WebKit/mac/WebView/WebScriptDebugDelegate.h137
-rw-r--r--WebKit/mac/WebView/WebScriptDebugDelegate.mm231
-rw-r--r--WebKit/mac/WebView/WebScriptDebugger.h67
-rw-r--r--WebKit/mac/WebView/WebScriptDebugger.mm193
-rw-r--r--WebKit/mac/WebView/WebTextIterator.h66
-rw-r--r--WebKit/mac/WebView/WebTextIterator.mm108
-rw-r--r--WebKit/mac/WebView/WebUIDelegate.h575
-rw-r--r--WebKit/mac/WebView/WebUIDelegatePrivate.h109
-rw-r--r--WebKit/mac/WebView/WebView.h835
-rw-r--r--WebKit/mac/WebView/WebView.mm5222
-rw-r--r--WebKit/mac/WebView/WebViewInternal.h219
-rw-r--r--WebKit/mac/WebView/WebViewPrivate.h457
70 files changed, 0 insertions, 25483 deletions
diff --git a/WebKit/mac/WebView/WebArchive.h b/WebKit/mac/WebView/WebArchive.h
deleted file mode 100644
index cf54da5..0000000
--- a/WebKit/mac/WebView/WebArchive.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2004, 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-@class WebArchivePrivate;
-@class WebResource;
-
-/*!
- @const WebArchivePboardType
- @abstract The pasteboard type constant used when adding or accessing a WebArchive on the pasteboard.
-*/
-extern NSString *WebArchivePboardType;
-
-/*!
- @class WebArchive
- @discussion WebArchive represents a main resource as well as all the subresources and subframes associated with the main resource.
- The main resource can be an entire web page, a portion of a web page, or some other kind of data such as an image.
- This class can be used for saving standalone web pages, representing portions of a web page on the pasteboard, or any other
- application where one class is needed to represent rich web content.
-*/
-@interface WebArchive : NSObject <NSCoding, NSCopying>
-{
- @private
- WebArchivePrivate *_private;
-}
-
-/*!
- @method initWithMainResource:subresources:subframeArchives:
- @abstract The initializer for WebArchive.
- @param mainResource The main resource of the archive.
- @param subresources The subresources of the archive (can be nil).
- @param subframeArchives The archives representing the subframes of the archive (can be nil).
- @result An initialized WebArchive.
-*/
-- (id)initWithMainResource:(WebResource *)mainResource subresources:(NSArray *)subresources subframeArchives:(NSArray *)subframeArchives;
-
-/*!
- @method initWithData:
- @abstract The initializer for creating a WebArchive from data.
- @param data The data representing the archive. This can be obtained using WebArchive's data method.
- @result An initialized WebArchive.
-*/
-- (id)initWithData:(NSData *)data;
-
-/*!
- @method mainResource
- @result The main resource of the archive.
-*/
-- (WebResource *)mainResource;
-
-/*!
- @method subresources
- @result The subresource of the archive (can be nil).
-*/
-- (NSArray *)subresources;
-
-/*!
- @method subframeArchives
- @result The archives representing the subframes of the archive (can be nil).
-*/
-- (NSArray *)subframeArchives;
-
-/*!
- @method data
- @result The data representation of the archive.
- @discussion The data returned by this method can be used to save a web archive to a file or to place a web archive on the pasteboard
- using WebArchivePboardType. To create a WebArchive using the returned data, call initWithData:.
-*/
-- (NSData *)data;
-
-@end
diff --git a/WebKit/mac/WebView/WebArchive.mm b/WebKit/mac/WebView/WebArchive.mm
deleted file mode 100644
index c989a9a..0000000
--- a/WebKit/mac/WebView/WebArchive.mm
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebArchive.h"
-#import "WebArchiveInternal.h"
-
-#import "WebKitLogging.h"
-#import "WebResourceInternal.h"
-#import "WebResourcePrivate.h"
-#import "WebTypesInternal.h"
-
-#import <WebCore/ArchiveResource.h>
-#import <WebCore/LegacyWebArchive.h>
-#import <WebCore/WebCoreObjCExtras.h>
-
-using namespace WebCore;
-
-NSString *WebArchivePboardType = @"Apple Web Archive pasteboard type";
-
-static NSString * const WebMainResourceKey = @"WebMainResource";
-static NSString * const WebSubresourcesKey = @"WebSubresources";
-static NSString * const WebSubframeArchivesKey = @"WebSubframeArchives";
-
-@interface WebArchivePrivate : NSObject
-{
-@public
- WebResource *cachedMainResource;
- NSArray *cachedSubresources;
- NSArray *cachedSubframeArchives;
-@private
- LegacyWebArchive* coreArchive;
-}
-
-- (id)initWithCoreArchive:(PassRefPtr<LegacyWebArchive>)coreArchive;
-- (LegacyWebArchive*)coreArchive;
-- (void)setCoreArchive:(PassRefPtr<LegacyWebArchive>)newCoreArchive;
-@end
-
-@implementation WebArchivePrivate
-
-#ifndef BUILDING_ON_TIGER
-+ (void)initialize
-{
- WebCoreObjCFinalizeOnMainThread(self);
-}
-#endif
-
-- (id)init
-{
- self = [super init];
- if (self)
- coreArchive = LegacyWebArchive::create().releaseRef();
- return self;
-}
-
-- (id)initWithCoreArchive:(PassRefPtr<LegacyWebArchive>)_coreArchive
-{
- self = [super init];
- if (!self || !_coreArchive) {
- [self release];
- return nil;
- }
-
- coreArchive = _coreArchive.releaseRef();
-
- return self;
-}
-
-- (LegacyWebArchive*)coreArchive
-{
- return coreArchive;
-}
-
-- (void)setCoreArchive:(PassRefPtr<LegacyWebArchive>)newCoreArchive
-{
- ASSERT(coreArchive);
- ASSERT(newCoreArchive);
- coreArchive->deref();
- coreArchive = newCoreArchive.releaseRef();
-}
-
-- (void)dealloc
-{
- if (WebCoreObjCScheduleDeallocateOnMainThread([WebArchivePrivate class], self))
- return;
-
- ASSERT(coreArchive);
- coreArchive->deref();
- coreArchive = 0;
-
- [cachedMainResource release];
- [cachedSubresources release];
- [cachedSubframeArchives release];
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- ASSERT(coreArchive);
- coreArchive->deref();
- coreArchive = 0;
-
- [super finalize];
-}
-
-@end
-
-@implementation WebArchive
-
-- (id)init
-{
- self = [super init];
- if (!self)
- return nil;
- _private = [[WebArchivePrivate alloc] init];
- return self;
-}
-
-static BOOL isArrayOfClass(id object, Class elementClass)
-{
- if (![object isKindOfClass:[NSArray class]])
- return NO;
- NSArray *array = (NSArray *)object;
- NSUInteger count = [array count];
- for (NSUInteger i = 0; i < count; ++i)
- if (![[array objectAtIndex:i] isKindOfClass:elementClass])
- return NO;
- return YES;
-}
-
-- (id)initWithMainResource:(WebResource *)mainResource subresources:(NSArray *)subresources subframeArchives:(NSArray *)subframeArchives
-{
- self = [super init];
- if (!self)
- return nil;
-
- _private = [[WebArchivePrivate alloc] init];
-
- _private->cachedMainResource = [mainResource retain];
- if (!_private->cachedMainResource) {
- [self release];
- return nil;
- }
-
- if (!subresources || isArrayOfClass(subresources, [WebResource class]))
- _private->cachedSubresources = [subresources retain];
- else {
- [self release];
- return nil;
- }
-
- if (!subframeArchives || isArrayOfClass(subframeArchives, [WebArchive class]))
- _private->cachedSubframeArchives = [subframeArchives retain];
- else {
- [self release];
- return nil;
- }
-
- RefPtr<ArchiveResource> coreMainResource = mainResource ? [mainResource _coreResource] : 0;
-
- Vector<PassRefPtr<ArchiveResource> > coreResources;
- NSEnumerator *enumerator = [subresources objectEnumerator];
- WebResource *subresource;
- while ((subresource = [enumerator nextObject]) != nil)
- coreResources.append([subresource _coreResource]);
-
- Vector<PassRefPtr<LegacyWebArchive> > coreArchives;
- enumerator = [subframeArchives objectEnumerator];
- WebArchive *subframeArchive;
- while ((subframeArchive = [enumerator nextObject]) != nil)
- coreArchives.append([subframeArchive->_private coreArchive]);
-
- [_private setCoreArchive:LegacyWebArchive::create(coreMainResource.release(), coreResources, coreArchives)];
- if (![_private coreArchive]) {
- [self release];
- return nil;
- }
-
- return self;
-}
-
-- (id)initWithData:(NSData *)data
-{
- self = [super init];
- if (!self)
- return nil;
-
-#if !LOG_DISABLED
- CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
-#endif
-
- _private = [[WebArchivePrivate alloc] init];
- [_private setCoreArchive:LegacyWebArchive::create(SharedBuffer::wrapNSData(data).get())];
-
-#if !LOG_DISABLED
- CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
- CFAbsoluteTime duration = end - start;
-#endif
- LOG(Timing, "Parsing web archive with [NSPropertyListSerialization propertyListFromData::::] took %f seconds", duration);
-
- return self;
-}
-
-- (id)initWithCoder:(NSCoder *)decoder
-{
- WebResource *mainResource = nil;
- NSArray *subresources = nil;
- NSArray *subframeArchives = nil;
-
- @try {
- id object = [decoder decodeObjectForKey:WebMainResourceKey];
- if ([object isKindOfClass:[WebResource class]])
- mainResource = [object retain];
- object = [decoder decodeObjectForKey:WebSubresourcesKey];
- if (isArrayOfClass(object, [WebResource class]))
- subresources = [object retain];
- object = [decoder decodeObjectForKey:WebSubframeArchivesKey];
- if (isArrayOfClass(object, [WebArchive class]))
- subframeArchives = [object retain];
- } @catch(id) {
- [self release];
- return nil;
- }
-
- return [self initWithMainResource:mainResource subresources:subresources subframeArchives:subframeArchives];
-}
-
-- (void)encodeWithCoder:(NSCoder *)encoder
-{
- [encoder encodeObject:[self mainResource] forKey:WebMainResourceKey];
- [encoder encodeObject:[self subresources] forKey:WebSubresourcesKey];
- [encoder encodeObject:[self subframeArchives] forKey:WebSubframeArchivesKey];
-}
-
-- (void)dealloc
-{
- [_private release];
- [super dealloc];
-}
-
-- (id)copyWithZone:(NSZone *)zone
-{
- return [self retain];
-}
-
-- (WebResource *)mainResource
-{
- // Currently from WebKit API perspective, WebArchives are entirely immutable once created
- // If they ever become mutable, we'll need to rethink this.
- if (!_private->cachedMainResource) {
- LegacyWebArchive* coreArchive = [_private coreArchive];
- if (coreArchive)
- _private->cachedMainResource = [[WebResource alloc] _initWithCoreResource:coreArchive->mainResource()];
- }
-
- return [[_private->cachedMainResource retain] autorelease];
-}
-
-- (NSArray *)subresources
-{
- // Currently from WebKit API perspective, WebArchives are entirely immutable once created
- // If they ever become mutable, we'll need to rethink this.
- if (!_private->cachedSubresources) {
- LegacyWebArchive* coreArchive = [_private coreArchive];
- if (!coreArchive)
- _private->cachedSubresources = [[NSArray alloc] init];
- else {
- const Vector<RefPtr<ArchiveResource> >& subresources(coreArchive->subresources());
- NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:subresources.size()];
- _private->cachedSubresources = mutableArray;
- for (unsigned i = 0; i < subresources.size(); ++i) {
- WebResource *resource = [[WebResource alloc] _initWithCoreResource:subresources[i].get()];
- if (resource) {
- [mutableArray addObject:resource];
- [resource release];
- }
- }
- }
- }
-
- return [[_private->cachedSubresources retain] autorelease];
-}
-
-- (NSArray *)subframeArchives
-{
- // Currently from WebKit API perspective, WebArchives are entirely immutable once created
- // If they ever become mutable, we'll need to rethink this.
- if (!_private->cachedSubframeArchives) {
- LegacyWebArchive* coreArchive = [_private coreArchive];
- if (!coreArchive)
- _private->cachedSubframeArchives = [[NSArray alloc] init];
- else {
- const Vector<RefPtr<Archive> >& subframeArchives(coreArchive->subframeArchives());
- NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:subframeArchives.size()];
- _private->cachedSubframeArchives = mutableArray;
- for (unsigned i = 0; i < subframeArchives.size(); ++i) {
- WebArchive *archive = [[WebArchive alloc] _initWithCoreLegacyWebArchive:(LegacyWebArchive *)subframeArchives[i].get()];
- [mutableArray addObject:archive];
- [archive release];
- }
- }
- }
-
- return [[_private->cachedSubframeArchives retain] autorelease];
-}
-
-- (NSData *)data
-{
-#if !LOG_DISABLED
- CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
-#endif
-
- RetainPtr<CFDataRef> data = [_private coreArchive]->rawDataRepresentation();
-
-#if !LOG_DISABLED
- CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
- CFAbsoluteTime duration = end - start;
-#endif
- LOG(Timing, "Serializing web archive to raw CFPropertyList data took %f seconds", duration);
-
- return [[(NSData *)data.get() retain] autorelease];
-}
-
-@end
-
-@implementation WebArchive (WebInternal)
-
-- (id)_initWithCoreLegacyWebArchive:(PassRefPtr<WebCore::LegacyWebArchive>)coreLegacyWebArchive
-{
- self = [super init];
- if (!self)
- return nil;
-
- _private = [[WebArchivePrivate alloc] initWithCoreArchive:coreLegacyWebArchive];
- if (!_private) {
- [self release];
- return nil;
- }
-
- return self;
-}
-
-- (WebCore::LegacyWebArchive *)_coreLegacyWebArchive
-{
- return [_private coreArchive];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebArchiveInternal.h b/WebKit/mac/WebView/WebArchiveInternal.h
deleted file mode 100644
index 071d4ab..0000000
--- a/WebKit/mac/WebView/WebArchiveInternal.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebArchive.h"
-#import <JavaScriptCore/Forward.h>
-
-namespace WebCore {
- class LegacyWebArchive;
-}
-
-@interface WebArchive (WebInternal)
-
-- (id)_initWithCoreLegacyWebArchive:(WTF::PassRefPtr<WebCore::LegacyWebArchive>)coreLegacyWebArchive;
-- (WebCore::LegacyWebArchive *)_coreLegacyWebArchive;
-
-@end
diff --git a/WebKit/mac/WebView/WebClipView.h b/WebKit/mac/WebView/WebClipView.h
deleted file mode 100644
index 76cc50c..0000000
--- a/WebKit/mac/WebView/WebClipView.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <AppKit/AppKit.h>
-
-@interface WebClipView : NSClipView
-{
- BOOL _haveAdditionalClip;
- NSRect _additionalClip;
-}
-
-- (void)setAdditionalClip:(NSRect)additionalClip;
-- (void)resetAdditionalClip;
-- (BOOL)hasAdditionalClip;
-- (NSRect)additionalClip;
-
-@end
diff --git a/WebKit/mac/WebView/WebClipView.m b/WebKit/mac/WebView/WebClipView.m
deleted file mode 100644
index b551145..0000000
--- a/WebKit/mac/WebView/WebClipView.m
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebClipView.h"
-
-#import <WebKit/WebHTMLView.h>
-#import <WebKit/WebNSViewExtras.h>
-#import <WebKit/WebViewPrivate.h>
-#import <wtf/Assertions.h>
-
-// WebClipView's entire reason for existing is to set the clip used by focus ring redrawing.
-// There's no easy way to prevent the focus ring from drawing outside the passed-in clip rectangle
-// because it expects to have to draw outside the bounds of the view it's being drawn for.
-// But it looks for the enclosing clip view, which gives us a hook we can use to control it.
-// The "additional clip" is a clip for focus ring redrawing.
-
-// FIXME: Change terminology from "additional clip" to "focus ring clip".
-
-@interface NSView (WebViewMethod)
-- (WebView *)_webView;
-@end
-
-@implementation WebClipView
-
-- (id)initWithFrame:(NSRect)frame
-{
- self = [super initWithFrame:frame];
- if (!self)
- return nil;
-
- // In WebHTMLView, we set a clip. This is not typical to do in an
- // NSView, and while correct for any one invocation of drawRect:,
- // it causes some bad problems if that clip is cached between calls.
- // The cached graphics state, which clip views keep around, does
- // cache the clip in this undesirable way. Consequently, we want to
- // release the GState for all clip views for all views contained in
- // a WebHTMLView. Here we do it for subframes, which use WebClipView.
- // See these bugs for more information:
- // <rdar://problem/3409315>: REGRESSSION (7B58-7B60)?: Safari draws blank frames on macosx.apple.com perf page
- [self releaseGState];
-
- return self;
-}
-
-- (void)resetAdditionalClip
-{
- ASSERT(_haveAdditionalClip);
- _haveAdditionalClip = NO;
-}
-
-- (void)setAdditionalClip:(NSRect)additionalClip
-{
- ASSERT(!_haveAdditionalClip);
- _haveAdditionalClip = YES;
- _additionalClip = additionalClip;
-}
-
-- (BOOL)hasAdditionalClip
-{
- return _haveAdditionalClip;
-}
-
-- (NSRect)additionalClip
-{
- ASSERT(_haveAdditionalClip);
- return _additionalClip;
-}
-
-- (NSRect)_focusRingVisibleRect
-{
- NSRect rect = [self visibleRect];
- if (_haveAdditionalClip) {
- rect = NSIntersectionRect(rect, _additionalClip);
- }
- return rect;
-}
-
-- (void)scrollWheel:(NSEvent *)event
-{
- NSView *docView = [self documentView];
- if ([docView respondsToSelector:@selector(_webView)]) {
-#if ENABLE(DASHBOARD_SUPPORT)
- WebView *wv = [docView _webView];
- if ([wv _dashboardBehavior:WebDashboardBehaviorAllowWheelScrolling]) {
- [super scrollWheel:event];
- }
-#endif
- return;
- }
- [super scrollWheel:event];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebDataSource.h b/WebKit/mac/WebView/WebDataSource.h
deleted file mode 100644
index 1ffd339..0000000
--- a/WebKit/mac/WebView/WebDataSource.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-#import <WebKit/WebDocument.h>
-
-@class NSMutableURLRequest;
-@class NSURLConnection;
-@class NSURLRequest;
-@class NSURLResponse;
-@class WebArchive;
-@class WebDataSourcePrivate;
-@class WebFrame;
-@class WebResource;
-
-/*!
- @class WebDataSource
- @discussion A WebDataSource represents the data associated with a web page.
- A datasource has a WebDocumentRepresentation which holds an appropriate
- representation of the data. WebDataSources manage a hierarchy of WebFrames.
- WebDataSources are typically related to a view by their containing WebFrame.
-*/
-@interface WebDataSource : NSObject
-{
-@private
- WebDataSourcePrivate *_private;
-}
-
-/*!
- @method initWithRequest:
- @abstract The designated initializer for WebDataSource.
- @param request The request to use in creating a datasource.
- @result Returns an initialized WebDataSource.
-*/
-- (id)initWithRequest:(NSURLRequest *)request;
-
-/*!
- @method data
- @discussion The data will be incomplete until the datasource has completely loaded.
- @result Returns the raw data associated with the datasource. Returns nil
- if the datasource hasn't loaded any data.
-*/
-- (NSData *)data;
-
-/*!
- @method representation
- @discussion A representation holds a type specific representation
- of the datasource's data. The representation class is determined by mapping
- a MIME type to a class. The representation is created once the MIME type
- of the datasource content has been determined.
- @result Returns the representation associated with this datasource.
- Returns nil if the datasource hasn't created it's representation.
-*/
-- (id <WebDocumentRepresentation>)representation;
-
-/*!
- @method webFrame
- @result Return the frame that represents this data source.
-*/
-- (WebFrame *)webFrame;
-
-/*!
- @method initialRequest
- @result Returns a reference to the original request that created the
- datasource. This request will be unmodified by WebKit.
-*/
-- (NSURLRequest *)initialRequest;
-
-/*!
- @method request
- @result Returns the request that was used to create this datasource.
-*/
-- (NSMutableURLRequest *)request;
-
-/*!
- @method response
- @result returns the WebResourceResponse for the data source.
-*/
-- (NSURLResponse *)response;
-
-/*!
- @method textEncodingName
- @result Returns either the override encoding, as set on the WebView for this
- dataSource or the encoding from the response.
-*/
-- (NSString *)textEncodingName;
-
-/*!
- @method isLoading
- @discussion Returns YES if there are any pending loads.
-*/
-- (BOOL)isLoading;
-
-/*!
- @method pageTitle
- @result Returns nil or the page title.
-*/
-- (NSString *)pageTitle;
-
-/*!
- @method unreachableURL
- @discussion This will be non-nil only for dataSources created by calls to the
- WebFrame method loadAlternateHTMLString:baseURL:forUnreachableURL:.
- @result returns the unreachableURL for which this dataSource is showing alternate content, or nil
-*/
-- (NSURL *)unreachableURL;
-
-/*!
- @method webArchive
- @result A WebArchive representing the data source, its subresources and child frames.
- @description This method constructs a WebArchive using the original downloaded data.
- In the case of HTML, if the current state of the document is preferred, webArchive should be
- called on the DOM document instead.
-*/
-- (WebArchive *)webArchive;
-
-/*!
- @method mainResource
- @result A WebResource representing the data source.
- @description This method constructs a WebResource using the original downloaded data.
- This method can be used to construct a WebArchive in case the archive returned by
- WebDataSource's webArchive isn't sufficient.
-*/
-- (WebResource *)mainResource;
-
-/*!
- @method subresources
- @abstract Returns all the subresources associated with the data source.
- @description The returned array only contains subresources that have fully downloaded.
-*/
-- (NSArray *)subresources;
-
-/*!
- method subresourceForURL:
- @abstract Returns a subresource for a given URL.
- @param URL The URL of the subresource.
- @description Returns non-nil if the data source has fully downloaded a subresource with the given URL.
-*/
-- (WebResource *)subresourceForURL:(NSURL *)URL;
-
-/*!
- @method addSubresource:
- @abstract Adds a subresource to the data source.
- @param subresource The subresource to be added.
- @description addSubresource: adds a subresource to the data source's list of subresources.
- Later, if something causes the data source to load the URL of the subresource, the data source
- will load the data from the subresource instead of from the network. For example, if one wants to add
- an image that is already downloaded to a web page, addSubresource: can be called so that the data source
- uses the downloaded image rather than accessing the network. NOTE: If the data source already has a
- subresource with the same URL, addSubresource: will replace it.
-*/
-- (void)addSubresource:(WebResource *)subresource;
-
-@end
diff --git a/WebKit/mac/WebView/WebDataSource.mm b/WebKit/mac/WebView/WebDataSource.mm
deleted file mode 100644
index aeff7d7..0000000
--- a/WebKit/mac/WebView/WebDataSource.mm
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebDataSource.h"
-
-#import "WebArchive.h"
-#import "WebArchiveInternal.h"
-#import "WebDataSourceInternal.h"
-#import "WebDocument.h"
-#import "WebDocumentLoaderMac.h"
-#import "WebFrameInternal.h"
-#import "WebFrameLoadDelegate.h"
-#import "WebFrameLoaderClient.h"
-#import "WebHTMLRepresentation.h"
-#import "WebKitErrorsPrivate.h"
-#import "WebKitLogging.h"
-#import "WebKitStatisticsPrivate.h"
-#import "WebKitNSStringExtras.h"
-#import "WebNSURLExtras.h"
-#import "WebNSURLRequestExtras.h"
-#import "WebPDFRepresentation.h"
-#import "WebResourceInternal.h"
-#import "WebResourceLoadDelegate.h"
-#import "WebResourcePrivate.h"
-#import "WebViewInternal.h"
-#import <WebCore/ApplicationCacheStorage.h>
-#import <WebCore/FrameLoader.h>
-#import <WebCore/KURL.h>
-#import <WebCore/LegacyWebArchive.h>
-#import <WebCore/MIMETypeRegistry.h>
-#import <WebCore/ResourceRequest.h>
-#import <WebCore/SharedBuffer.h>
-#import <WebCore/WebCoreObjCExtras.h>
-#import <WebCore/WebCoreURLResponse.h>
-#import <WebKit/DOMHTML.h>
-#import <WebKit/DOMPrivate.h>
-#import <wtf/Assertions.h>
-
-using namespace WebCore;
-
-@interface WebDataSourcePrivate : NSObject {
-@public
- WebDocumentLoaderMac* loader;
-
- id <WebDocumentRepresentation> representation;
-
- BOOL representationFinishedLoading;
-}
-@end
-
-@implementation WebDataSourcePrivate
-
-#ifndef BUILDING_ON_TIGER
-+ (void)initialize
-{
- WebCoreObjCFinalizeOnMainThread(self);
-}
-#endif
-
-- (void)dealloc
-{
- if (WebCoreObjCScheduleDeallocateOnMainThread([WebDataSourcePrivate class], self))
- return;
-
- ASSERT(!loader->isLoading());
- loader->detachDataSource();
- loader->deref();
-
- [representation release];
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- ASSERT_MAIN_THREAD();
-
- ASSERT(!loader->isLoading());
- loader->detachDataSource();
- loader->deref();
-
- [super finalize];
-}
-
-@end
-
-@interface WebDataSource (WebFileInternal)
-@end
-
-@implementation WebDataSource (WebFileInternal)
-
-- (void)_setRepresentation:(id<WebDocumentRepresentation>)representation
-{
- [_private->representation release];
- _private->representation = [representation retain];
- _private->representationFinishedLoading = NO;
-}
-
-static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCClass, 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:objCClass forKey:mime];
- }
-}
-
-+ (Class)_representationClassForMIMEType:(NSString *)MIMEType
-{
- Class repClass;
- return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType] ? repClass : nil;
-}
-@end
-
-@implementation WebDataSource (WebPrivate)
-
-- (NSError *)_mainDocumentError
-{
- return _private->loader->mainDocumentError();
-}
-
-- (void)_addSubframeArchives:(NSArray *)subframeArchives
-{
- // FIXME: This SPI is poor, poor design. Can we come up with another solution for those who need it?
- DocumentLoader* loader = [self _documentLoader];
- ASSERT(loader);
-
- NSEnumerator *enumerator = [subframeArchives objectEnumerator];
- WebArchive *archive;
- while ((archive = [enumerator nextObject]) != nil)
- loader->addAllArchiveResources([archive _coreLegacyWebArchive]);
-}
-
-- (NSFileWrapper *)_fileWrapperForURL:(NSURL *)URL
-{
- if ([URL isFileURL]) {
- NSString *path = [[URL path] stringByResolvingSymlinksInPath];
- return [[[NSFileWrapper alloc] initWithPath:path] autorelease];
- }
-
- WebResource *resource = [self subresourceForURL:URL];
- if (resource)
- return [resource _fileWrapperRepresentation];
-
- NSCachedURLResponse *cachedResponse = [[self _webView] _cachedResponseForURL:URL];
- if (cachedResponse) {
- NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:[cachedResponse data]] autorelease];
- [wrapper setPreferredFilename:[[cachedResponse response] suggestedFilename]];
- return wrapper;
- }
-
- return nil;
-}
-
-- (NSString *)_responseMIMEType
-{
- return [[self response] _webcore_MIMEType];
-}
-
-- (BOOL)_transferApplicationCache:(NSString*)destinationBundleIdentifier
-{
- DocumentLoader* loader = [self _documentLoader];
-
- if (!loader)
- return NO;
-
- ApplicationCache* cache = loader->applicationCache();
- if (!cache)
- return YES;
-
- NSString *cacheDir = [NSString _webkit_localCacheDirectoryWithBundleIdentifier:destinationBundleIdentifier];
-
- return ApplicationCacheStorage::storeCopyOfCache(cacheDir, cache);
-}
-
-@end
-
-@implementation WebDataSource (WebInternal)
-
-- (void)_finishedLoading
-{
- _private->representationFinishedLoading = YES;
- [[self representation] finishedLoadingWithDataSource:self];
-}
-
-- (void)_receivedData:(NSData *)data
-{
- // protect self temporarily, as the bridge receivedData call could remove our last ref
- RetainPtr<WebDataSource*> protect(self);
-
- [[self representation] receivedData:data withDataSource:self];
- [[[[self webFrame] frameView] documentView] dataSourceUpdated:self];
-}
-
-- (void)_setMainDocumentError:(NSError *)error
-{
- if (!_private->representationFinishedLoading) {
- _private->representationFinishedLoading = YES;
- [[self representation] receivedError:error withDataSource:self];
- }
-}
-
-- (void)_revertToProvisionalState
-{
- [self _setRepresentation:nil];
-}
-
-+ (NSMutableDictionary *)_repTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission
-{
- static NSMutableDictionary *repTypes = nil;
- static BOOL addedImageTypes = NO;
-
- if (!repTypes) {
- repTypes = [[NSMutableDictionary alloc] init];
- addTypesFromClass(repTypes, [WebHTMLRepresentation class], [WebHTMLRepresentation supportedNonImageMIMETypes]);
-
- // Since this is a "secret default" we don't both registering it.
- BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
- if (!omitPDFSupport)
- addTypesFromClass(repTypes, [WebPDFRepresentation class], [WebPDFRepresentation supportedMIMETypes]);
- }
-
- if (!addedImageTypes && !allowImageTypeOmission) {
- addTypesFromClass(repTypes, [WebHTMLRepresentation class], [WebHTMLRepresentation supportedImageMIMETypes]);
- addedImageTypes = YES;
- }
-
- return repTypes;
-}
-
-- (void)_replaceSelectionWithArchive:(WebArchive *)archive selectReplacement:(BOOL)selectReplacement
-{
- DOMDocumentFragment *fragment = [self _documentFragmentWithArchive:archive];
- if (fragment)
- [[self webFrame] _replaceSelectionWithFragment:fragment selectReplacement:selectReplacement smartReplace:NO matchStyle:NO];
-}
-
-// FIXME: There are few reasons why this method and many of its related methods can't be pushed entirely into WebCore in the future.
-- (DOMDocumentFragment *)_documentFragmentWithArchive:(WebArchive *)archive
-{
- ASSERT(archive);
- WebResource *mainResource = [archive mainResource];
- if (mainResource) {
- NSString *MIMEType = [mainResource MIMEType];
- if ([WebView canShowMIMETypeAsHTML:MIMEType]) {
- NSString *markupString = [[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding];
- // FIXME: seems poor form to do this as a side effect of getting a document fragment
- if (DocumentLoader* loader = [self _documentLoader])
- loader->addAllArchiveResources([archive _coreLegacyWebArchive]);
-
- DOMDocumentFragment *fragment = [[self webFrame] _documentFragmentWithMarkupString:markupString baseURLString:[[mainResource URL] _web_originalDataAsString]];
- [markupString release];
- return fragment;
- } else if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType)) {
- return [self _documentFragmentWithImageResource:mainResource];
-
- }
- }
- return nil;
-}
-
-- (DOMDocumentFragment *)_documentFragmentWithImageResource:(WebResource *)resource
-{
- DOMElement *imageElement = [self _imageElementWithImageResource:resource];
- if (!imageElement)
- return 0;
- DOMDocumentFragment *fragment = [[[self webFrame] DOMDocument] createDocumentFragment];
- [fragment appendChild:imageElement];
- return fragment;
-}
-
-- (DOMElement *)_imageElementWithImageResource:(WebResource *)resource
-{
- if (!resource)
- return 0;
-
- [self addSubresource:resource];
-
- DOMElement *imageElement = [[[self webFrame] DOMDocument] createElement:@"img"];
-
- // FIXME: calling _web_originalDataAsString on a file URL returns an absolute path. Workaround this.
- NSURL *URL = [resource URL];
- [imageElement setAttribute:@"src" value:[URL isFileURL] ? [URL absoluteString] : [URL _web_originalDataAsString]];
-
- return imageElement;
-}
-
-// May return nil if not initialized with a URL.
-- (NSURL *)_URL
-{
- const KURL& url = _private->loader->url();
- if (url.isEmpty())
- return nil;
- return url;
-}
-
-- (WebView *)_webView
-{
- return [[self webFrame] webView];
-}
-
-- (BOOL)_isDocumentHTML
-{
- NSString *MIMEType = [self _responseMIMEType];
- return [WebView canShowMIMETypeAsHTML:MIMEType];
-}
-
--(void)_makeRepresentation
-{
- Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType]];
-
- // Check if the data source was already bound?
- if (![[self representation] isKindOfClass:repClass]) {
- id newRep = repClass != nil ? [[repClass alloc] init] : nil;
- [self _setRepresentation:(id <WebDocumentRepresentation>)newRep];
- [newRep release];
- }
-
- [_private->representation setDataSource:self];
-}
-
-- (DocumentLoader*)_documentLoader
-{
- return _private->loader;
-}
-
-- (id)_initWithDocumentLoader:(PassRefPtr<WebDocumentLoaderMac>)loader
-{
- self = [super init];
- if (!self)
- return nil;
-
- _private = [[WebDataSourcePrivate alloc] init];
-
- _private->loader = loader.releaseRef();
-
- LOG(Loading, "creating datasource for %@", static_cast<NSURL *>(_private->loader->request().url()));
-
- ++WebDataSourceCount;
-
- return self;
-}
-
-@end
-
-@implementation WebDataSource
-
-- (id)initWithRequest:(NSURLRequest *)request
-{
- return [self _initWithDocumentLoader:WebDocumentLoaderMac::create(request, SubstituteData())];
-}
-
-- (void)dealloc
-{
- --WebDataSourceCount;
-
- [_private release];
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- --WebDataSourceCount;
-
- [super finalize];
-}
-
-- (NSData *)data
-{
- RefPtr<SharedBuffer> mainResourceData = _private->loader->mainResourceData();
- if (!mainResourceData)
- return nil;
- return [mainResourceData->createNSData() autorelease];
-}
-
-- (id <WebDocumentRepresentation>)representation
-{
- return _private->representation;
-}
-
-- (WebFrame *)webFrame
-{
- FrameLoader* frameLoader = _private->loader->frameLoader();
- if (!frameLoader)
- return nil;
- return static_cast<WebFrameLoaderClient*>(frameLoader->client())->webFrame();
-}
-
-- (NSURLRequest *)initialRequest
-{
- return _private->loader->originalRequest().nsURLRequest();
-}
-
-- (NSMutableURLRequest *)request
-{
- FrameLoader* frameLoader = _private->loader->frameLoader();
- if (!frameLoader || !frameLoader->frameHasLoaded())
- return nil;
-
- // FIXME: this cast is dubious
- return (NSMutableURLRequest *)_private->loader->request().nsURLRequest();
-}
-
-- (NSURLResponse *)response
-{
- return _private->loader->response().nsURLResponse();
-}
-
-- (NSString *)textEncodingName
-{
- NSString *textEncodingName = _private->loader->overrideEncoding();
- if (!textEncodingName)
- textEncodingName = [[self response] textEncodingName];
- return textEncodingName;
-}
-
-- (BOOL)isLoading
-{
- return _private->loader->isLoadingInAPISense();
-}
-
-// Returns nil or the page title.
-- (NSString *)pageTitle
-{
- return [[self representation] title];
-}
-
-- (NSURL *)unreachableURL
-{
- const KURL& unreachableURL = _private->loader->unreachableURL();
- if (unreachableURL.isEmpty())
- return nil;
- return unreachableURL;
-}
-
-- (WebArchive *)webArchive
-{
- // it makes no sense to grab a WebArchive from an uncommitted document.
- if (!_private->loader->isCommitted())
- return nil;
-
- return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core([self webFrame]))] autorelease];
-}
-
-- (WebResource *)mainResource
-{
- RefPtr<ArchiveResource> coreResource = _private->loader->mainResource();
- return [[[WebResource alloc] _initWithCoreResource:coreResource.release()] autorelease];
-}
-
-- (NSArray *)subresources
-{
- Vector<PassRefPtr<ArchiveResource> > coreSubresources;
- _private->loader->getSubresources(coreSubresources);
-
- NSMutableArray *subresources = [[NSMutableArray alloc] initWithCapacity:coreSubresources.size()];
- for (unsigned i = 0; i < coreSubresources.size(); ++i)
- [subresources addObject:[[[WebResource alloc] _initWithCoreResource:coreSubresources[i]] autorelease]];
-
- return [subresources autorelease];
-}
-
-- (WebResource *)subresourceForURL:(NSURL *)URL
-{
- RefPtr<ArchiveResource> subresource = _private->loader->subresource(URL);
-
- return subresource ? [[[WebResource alloc] _initWithCoreResource:subresource.get()] autorelease] : nil;
-}
-
-- (void)addSubresource:(WebResource *)subresource
-{
- _private->loader->addArchiveResource([subresource _coreResource]);
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebDataSourceInternal.h b/WebKit/mac/WebView/WebDataSourceInternal.h
deleted file mode 100644
index 29497d5..0000000
--- a/WebKit/mac/WebView/WebDataSourceInternal.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebDataSourcePrivate.h"
-#import <wtf/Forward.h>
-
-namespace WebCore {
- class DocumentLoader;
-}
-
-class WebDocumentLoaderMac;
-
-@class DOMDocumentFragment;
-@class DOMElement;
-@class WebArchive;
-@class WebResource;
-@class WebView;
-
-@interface WebDataSource (WebInternal)
-- (void)_makeRepresentation;
-- (BOOL)_isDocumentHTML;
-- (WebView *)_webView;
-- (NSURL *)_URL;
-- (DOMElement *)_imageElementWithImageResource:(WebResource *)resource;
-- (DOMDocumentFragment *)_documentFragmentWithImageResource:(WebResource *)resource;
-- (DOMDocumentFragment *)_documentFragmentWithArchive:(WebArchive *)archive;
-+ (NSMutableDictionary *)_repTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission;
-- (void)_replaceSelectionWithArchive:(WebArchive *)archive selectReplacement:(BOOL)selectReplacement;
-- (id)_initWithDocumentLoader:(PassRefPtr<WebDocumentLoaderMac>)loader;
-- (void)_finishedLoading;
-- (void)_receivedData:(NSData *)data;
-- (void)_revertToProvisionalState;
-- (void)_setMainDocumentError:(NSError *)error;
-- (WebCore::DocumentLoader*)_documentLoader;
-@end
diff --git a/WebKit/mac/WebView/WebDataSourcePrivate.h b/WebKit/mac/WebView/WebDataSourcePrivate.h
deleted file mode 100644
index ae8d4cf..0000000
--- a/WebKit/mac/WebView/WebDataSourcePrivate.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebDataSource.h>
-
-@interface WebDataSource (WebPrivate)
-
-- (NSFileWrapper *)_fileWrapperForURL:(NSURL *)URL;
-- (void)_addSubframeArchives:(NSArray *) archives;
-- (NSError *)_mainDocumentError;
-- (NSString *)_responseMIMEType;
-
-- (BOOL)_transferApplicationCache:(NSString*)destinationBundleIdentifier;
-
-@end
diff --git a/WebKit/mac/WebView/WebDocument.h b/WebKit/mac/WebView/WebDocument.h
deleted file mode 100644
index b18215a..0000000
--- a/WebKit/mac/WebView/WebDocument.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-@class NSError;
-@class WebDataSource;
-
-/*!
- @protocol WebDocumentView
- @discussion Protocol implemented by the document view of WebFrameView
-*/
-@protocol WebDocumentView <NSObject>
-
-/*!
- @method setDataSource:
- @abstract Called when the corresponding data source has been created.
- @param dataSource The corresponding data source.
-*/
-- (void)setDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method dataSourceUpdated:
- @abstract Called when the corresponding data source has received data.
- @param dataSource The corresponding data source.
-*/
-- (void)dataSourceUpdated:(WebDataSource *)dataSource;
-
-/*!
- @method setNeedsLayout:
- @discussion Called when WebKit has determined that the document view needs to layout.
- This method should simply set a flag and call layout from drawRect if the flag is YES.
- @param flag YES to cause a layout, no to not cause a layout.
-*/
-- (void)setNeedsLayout:(BOOL)flag;
-
-/*!
- @method layout
- @discussion Called when the document view must immediately layout. For simple views,
- setting the frame is a sufficient implementation of this method.
-*/
-- (void)layout;
-
-/*!
- @method viewWillMoveToHostWindow:
- @param hostWindow The host window for the document view.
- @abstract Called before the host window is set on the parent web view.
-*/
-- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow;
-
-/*!
- @method viewDidMoveToHostWindow
- @abstract Called after the host window is set on the parent web view.
-*/
-- (void)viewDidMoveToHostWindow;
-
-@end
-
-
-/*!
- @protocol WebDocumentSearching
- @discussion Optional protocol for searching document view of WebFrameView.
-*/
-@protocol WebDocumentSearching <NSObject>
-/*!
- @method searchFor:direction:caseSensitive:wrap:
- @abstract Searches a document view for a string and highlights the string if it is found.
- @param string The string to search for.
- @param forward YES to search forward, NO to seach backwards.
- @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
- @param wrapFlag YES to wrap around, NO to avoid wrapping.
- @result YES if found, NO if not found.
-*/
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag;
-@end
-
-
-/*!
- @protocol WebDocumentText
- @discussion Optional protocol for supporting text operations.
-*/
-@protocol WebDocumentText <NSObject>
-
-/*!
- @method supportsTextEncoding
- @result YES if the document view support text encoding, NO if it doesn't.
-*/
-- (BOOL)supportsTextEncoding;
-
-/*!
- @method string
- @result String that represents the entire document.
-*/
-- (NSString *)string;
-
-/*!
- @method attributedString
- @result Attributed string that represents the entire document.
-*/
-- (NSAttributedString *)attributedString;
-
-/*!
- @method selectedString
- @result String that represents the current selection.
-*/
-- (NSString *)selectedString;
-
-/*!
- @method selectedAttributedString
- @result Attributed string that represents the current selection.
-*/
-- (NSAttributedString *)selectedAttributedString;
-
-
-/*!
- @method selectAll
- @abstract Selects all the text in the document.
-*/
-- (void)selectAll;
-
-/*!
- @method deselectText
- @abstract Causes a text selection to lose its selection.
-*/
-- (void)deselectAll;
-
-@end
-
-
-/*!
- @protocol WebDocumentRepresentation
- @discussion Protocol implemented by the document representation of a data source.
-*/
-@protocol WebDocumentRepresentation <NSObject>
-/*!
- @method setDataSource:
- @abstract Called soon after the document representation is created.
- @param dataSource The data source that is set.
-*/
-- (void)setDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method receivedData:withDataSource:
- @abstract Called when the data source has received data.
- @param data The data that the data source has received.
- @param dataSource The data source that has received data.
-*/
-- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method receivedError:withDataSource:
- @abstract Called when the data source has received an error.
- @param error The error that the data source has received.
- @param dataSource The data source that has received the error.
-*/
-- (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method finishedLoadingWithDataSource:
- @abstract Called when the data source has finished loading.
- @param dataSource The datasource that has finished loading.
-*/
-- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method canProvideDocumentSource
- @result Returns true if the representation can provide document source.
-*/
-- (BOOL)canProvideDocumentSource;
-
-/*!
- @method documentSource
- @result Returns the textual source representation of the document. For HTML documents
- this is the original HTML source.
-*/
-- (NSString *)documentSource;
-
-/*!
- @method title
- @result Return the title for the document.
-*/
-- (NSString *)title;
-
-@end
diff --git a/WebKit/mac/WebView/WebDocumentInternal.h b/WebKit/mac/WebView/WebDocumentInternal.h
deleted file mode 100644
index 191264b..0000000
--- a/WebKit/mac/WebView/WebDocumentInternal.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebDocumentPrivate.h>
-#import <WebKit/WebHTMLView.h>
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSUInteger unsigned int
-#else
-#define WebNSUInteger NSUInteger
-#endif
-
-/*!
-@protocol _WebDocumentZooming
-@discussion Optional protocol for a view that wants to handle its own zoom.
-*/
-@protocol _WebDocumentZooming <NSObject>
-
-// Methods to perform the actual commands
-- (IBAction)_zoomOut:(id)sender;
-- (IBAction)_zoomIn:(id)sender;
-- (IBAction)_resetZoom:(id)sender;
-
-// Whether or not the commands can be executed.
-- (BOOL)_canZoomOut;
-- (BOOL)_canZoomIn;
-- (BOOL)_canResetZoom;
-
-@end
-
-@protocol WebDocumentElement <NSObject>
-- (NSDictionary *)elementAtPoint:(NSPoint)point;
-- (NSDictionary *)elementAtPoint:(NSPoint)point allowShadowContent:(BOOL)allow;
-@end
-
-@protocol WebMultipleTextMatches <NSObject>
-- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue;
-- (BOOL)markedTextMatchesAreHighlighted;
-- (WebNSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(WebNSUInteger)limit;
-- (void)unmarkAllTextMatches;
-- (NSArray *)rectsForTextMatches;
-@end
-
-
-/* Used to save and restore state in the view, typically when going back/forward */
-@protocol _WebDocumentViewState <NSObject>
-- (NSPoint)scrollPoint;
-- (void)setScrollPoint:(NSPoint)p;
-- (id)viewState;
-- (void)setViewState:(id)statePList;
-@end
-
-@interface WebHTMLView (WebDocumentInternalProtocols) <WebDocumentElement, WebMultipleTextMatches>
-@end
-
-#undef WebNSUInteger
diff --git a/WebKit/mac/WebView/WebDocumentLoaderMac.h b/WebKit/mac/WebView/WebDocumentLoaderMac.h
deleted file mode 100644
index 83e2bb3..0000000
--- a/WebKit/mac/WebView/WebDocumentLoaderMac.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebCore/DocumentLoader.h>
-#import <wtf/RetainPtr.h>
-#import <wtf/HashSet.h>
-
-@class WebDataSource;
-@class WebView;
-
-namespace WebCore {
- class ResourceRequest;
-}
-
-class WebDocumentLoaderMac : public WebCore::DocumentLoader {
-public:
- static PassRefPtr<WebDocumentLoaderMac> create(const WebCore::ResourceRequest& request, const WebCore::SubstituteData& data)
- {
- return adoptRef(new WebDocumentLoaderMac(request, data));
- }
-
- void setDataSource(WebDataSource *, WebView*);
- void detachDataSource();
- WebDataSource *dataSource() const;
-
- void increaseLoadCount(unsigned long identifier);
- void decreaseLoadCount(unsigned long identifier);
-
-private:
- WebDocumentLoaderMac(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
-
- virtual void attachToFrame();
- virtual void detachFromFrame();
-
- void retainDataSource();
- void releaseDataSource();
-
- WebDataSource *m_dataSource;
- bool m_isDataSourceRetained;
- RetainPtr<id> m_resourceLoadDelegate;
- RetainPtr<id> m_downloadDelegate;
- HashSet<unsigned long> m_loadingResources;
-};
diff --git a/WebKit/mac/WebView/WebDocumentLoaderMac.mm b/WebKit/mac/WebView/WebDocumentLoaderMac.mm
deleted file mode 100644
index d5812a4..0000000
--- a/WebKit/mac/WebView/WebDocumentLoaderMac.mm
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebDocumentLoaderMac.h"
-
-#import "WebKitVersionChecks.h"
-#import "WebView.h"
-
-using namespace WebCore;
-
-WebDocumentLoaderMac::WebDocumentLoaderMac(const ResourceRequest& request, const SubstituteData& substituteData)
- : DocumentLoader(request, substituteData)
- , m_dataSource(nil)
- , m_isDataSourceRetained(false)
-{
-}
-
-static inline bool needsDataLoadWorkaround(WebView *webView)
-{
-#ifdef BUILDING_ON_TIGER
- // Tiger has to be a little less efficient.
- id frameLoadDelegate = [webView frameLoadDelegate];
- if (!frameLoadDelegate)
- return false;
-
- NSString *bundleIdentifier = [[NSBundle bundleForClass:[frameLoadDelegate class]] bundleIdentifier];
-
- if ([bundleIdentifier isEqualToString:@"com.apple.AppKit"])
- return true;
- if ([bundleIdentifier isEqualToString:@"com.adobe.Installers.Setup"])
- return true;
- return false;
-#else
- static bool needsWorkaround = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITHOUT_ADOBE_INSTALLER_QUIRK)
- && [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.adobe.Installers.Setup"];
- return needsWorkaround;
-#endif
-}
-
-void WebDocumentLoaderMac::setDataSource(WebDataSource *dataSource, WebView *webView)
-{
- ASSERT(!m_dataSource);
- ASSERT(!m_isDataSourceRetained);
-
- m_dataSource = dataSource;
- retainDataSource();
-
- m_resourceLoadDelegate = [webView resourceLoadDelegate];
- m_downloadDelegate = [webView downloadDelegate];
-
- // Some clients run the run loop in a way that prevents the data load timer
- // from firing. We work around that issue here. See <rdar://problem/5266289>
- // and <rdar://problem/5049509>.
- if (needsDataLoadWorkaround(webView))
- m_deferMainResourceDataLoad = false;
-}
-
-WebDataSource *WebDocumentLoaderMac::dataSource() const
-{
- return m_dataSource;
-}
-
-void WebDocumentLoaderMac::attachToFrame()
-{
- DocumentLoader::attachToFrame();
-
- retainDataSource();
-}
-
-void WebDocumentLoaderMac::detachFromFrame()
-{
- DocumentLoader::detachFromFrame();
-
- if (m_loadingResources.isEmpty())
- releaseDataSource();
-
- // FIXME: What prevents the data source from getting deallocated while the
- // frame is not attached?
-}
-
-void WebDocumentLoaderMac::increaseLoadCount(unsigned long identifier)
-{
- ASSERT(m_dataSource);
-
- if (m_loadingResources.contains(identifier))
- return;
- m_loadingResources.add(identifier);
-
- retainDataSource();
-}
-
-void WebDocumentLoaderMac::decreaseLoadCount(unsigned long identifier)
-{
- HashSet<unsigned long>::iterator it = m_loadingResources.find(identifier);
-
- // It is valid for a load to be cancelled before it's started.
- if (it == m_loadingResources.end())
- return;
-
- m_loadingResources.remove(it);
-
- if (m_loadingResources.isEmpty()) {
- m_resourceLoadDelegate = 0;
- m_downloadDelegate = 0;
- if (!frame())
- releaseDataSource();
- }
-}
-
-void WebDocumentLoaderMac::retainDataSource()
-{
- if (m_isDataSourceRetained || !m_dataSource)
- return;
- m_isDataSourceRetained = true;
- CFRetain(m_dataSource);
-}
-
-void WebDocumentLoaderMac::releaseDataSource()
-{
- if (!m_isDataSourceRetained)
- return;
- ASSERT(m_dataSource);
- m_isDataSourceRetained = false;
- CFRelease(m_dataSource);
-}
-
-void WebDocumentLoaderMac::detachDataSource()
-{
- ASSERT(!m_isDataSourceRetained);
- m_dataSource = nil;
-}
diff --git a/WebKit/mac/WebView/WebDocumentPrivate.h b/WebKit/mac/WebView/WebDocumentPrivate.h
deleted file mode 100644
index f09d3bd..0000000
--- a/WebKit/mac/WebView/WebDocumentPrivate.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebDocument.h>
-#import <WebKit/WebHTMLView.h>
-
-@class DOMDocument;
-
-@protocol WebDocumentImage <NSObject>
-- (NSImage *)image;
-@end
-
-// This method is deprecated as it now lives on WebFrame.
-@protocol WebDocumentDOM <NSObject>
-- (DOMDocument *)DOMDocument;
-- (BOOL)canSaveAsWebArchive;
-@end
-
-@protocol WebDocumentSelection <WebDocumentText>
-- (NSArray *)pasteboardTypesForSelection;
-- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
-
-// Array of rects that tightly enclose the selected text, in coordinates of selectinView.
-- (NSArray *)selectionTextRects;
-
-// Rect tightly enclosing the entire selected area, in coordinates of selectionView.
-- (NSRect)selectionRect;
-
-// NSImage of the portion of the selection that's in view. This does not draw backgrounds.
-// The text is all black according to the parameter.
-- (NSImage *)selectionImageForcingBlackText:(BOOL)forceBlackText;
-
-// Rect tightly enclosing the entire selected area, in coordinates of selectionView.
-// NOTE: This method is equivalent to selectionRect and shouldn't be used; use selectionRect instead.
-- (NSRect)selectionImageRect;
-
-// View that draws the selection and can be made first responder. Often this is self but it could be
-// a nested view, as for example in the case of WebPDFView.
-- (NSView *)selectionView;
-@end
-
-@protocol WebDocumentIncrementalSearching
-/*!
-@method searchFor:direction:caseSensitive:wrap:startInSelection:
- @abstract Searches a document view for a string and highlights the string if it is found.
- @param string The string to search for.
- @param forward YES to search forward, NO to seach backwards.
- @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
- @param wrapFlag YES to wrap around, NO to avoid wrapping.
- @param startInSelection YES to begin search in the selected text (useful for incremental searching), NO to begin search after the selected text.
- @result YES if found, NO if not found.
- */
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection;
-@end
-
-@interface WebHTMLView (WebDocumentPrivateProtocols) <WebDocumentSelection, WebDocumentIncrementalSearching>
-@end
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.h b/WebKit/mac/WebView/WebDynamicScrollBarsView.h
deleted file mode 100644
index a0f8006..0000000
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// This is a Private header (containing SPI), despite the fact that its name
-// does not contain the word Private.
-
-// FIXME: Does Safari really need to use this any more? AppKit added autohidesScrollers
-// in Panther, and that was the original reason we needed this view in Safari.
-
-// FIXME: <rdar://problem/5898985> Mail currently expects this header to define WebCoreScrollbarAlwaysOn.
-extern const int WebCoreScrollbarAlwaysOn;
-
-@interface WebDynamicScrollBarsView : NSScrollView {
- int hScroll; // FIXME: Should be WebCore::ScrollbarMode if this was an ObjC++ header.
- int vScroll; // Ditto.
- BOOL hScrollModeLocked;
- BOOL vScrollModeLocked;
- BOOL suppressLayout;
- BOOL suppressScrollers;
- BOOL inUpdateScrollers;
-}
-- (void)setAllowsHorizontalScrolling:(BOOL)flag; // This method is used by Safari, so it cannot be removed.
-@end
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.m b/WebKit/mac/WebView/WebDynamicScrollBarsView.m
deleted file mode 100644
index 1eb2d80..0000000
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.m
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebDynamicScrollBarsViewInternal.h"
-
-#import "WebDocument.h"
-#import "WebFrameView.h"
-#import <WebKitSystemInterface.h>
-
-using namespace WebCore;
-
-// FIXME: <rdar://problem/5898985> Mail expects a constant of this name to exist.
-const int WebCoreScrollbarAlwaysOn = ScrollbarAlwaysOn;
-
-@implementation WebDynamicScrollBarsView
-
-- (void)setAllowsHorizontalScrolling:(BOOL)flag
-{
- if (hScrollModeLocked)
- return;
- if (flag && hScroll == ScrollbarAlwaysOff)
- hScroll = ScrollbarAuto;
- else if (!flag && hScroll != ScrollbarAlwaysOff)
- hScroll = ScrollbarAlwaysOff;
- [self updateScrollers];
-}
-
-@end
-
-@implementation WebDynamicScrollBarsView (WebInternal)
-
-- (void)setSuppressLayout:(BOOL)flag;
-{
- suppressLayout = flag;
-}
-
-- (void)setScrollBarsSuppressed:(BOOL)suppressed repaintOnUnsuppress:(BOOL)repaint
-{
- suppressScrollers = suppressed;
-
- // This code was originally changes for a Leopard performance imporvement. We decided to
- // ifdef it to fix correctness issues on Tiger documented in <rdar://problem/5441823>.
-#ifndef BUILDING_ON_TIGER
- if (suppressed) {
- [[self verticalScroller] setNeedsDisplay:NO];
- [[self horizontalScroller] setNeedsDisplay:NO];
- }
-
- if (!suppressed && repaint)
- [super reflectScrolledClipView:[self contentView]];
-#else
- if (suppressed || repaint) {
- [[self verticalScroller] setNeedsDisplay: !suppressed];
- [[self horizontalScroller] setNeedsDisplay: !suppressed];
- }
-#endif
-}
-
-- (void)updateScrollers
-{
- // We need to do the work below twice in the case where a scroll bar disappears,
- // making the second layout have a wider width than the first. Doing it more than
- // twice would indicate some kind of infinite loop, so we do it at most twice.
- // It's quite efficient to do this work twice in the normal case, so we don't bother
- // trying to figure out of the second pass is needed or not.
- if (inUpdateScrollers)
- return;
-
- inUpdateScrollers = true;
-
- int pass;
- BOOL hasVerticalScroller = [self hasVerticalScroller];
- BOOL hasHorizontalScroller = [self hasHorizontalScroller];
- BOOL oldHasVertical = hasVerticalScroller;
- BOOL oldHasHorizontal = hasHorizontalScroller;
-
- for (pass = 0; pass < 2; pass++) {
- BOOL scrollsVertically;
- BOOL scrollsHorizontally;
-
- if (!suppressLayout && !suppressScrollers && (hScroll == ScrollbarAuto || vScroll == ScrollbarAuto)) {
- // Do a layout if pending, before checking if scrollbars are needed.
- // This fixes 2969367, although may introduce a slowdown in live resize performance.
- NSView *documentView = [self documentView];
- if (!documentView) {
- scrollsHorizontally = NO;
- scrollsVertically = NO;
- } else {
- if ((hasVerticalScroller != oldHasVertical ||
- hasHorizontalScroller != oldHasHorizontal || [documentView inLiveResize]) && [documentView conformsToProtocol:@protocol(WebDocumentView)]) {
- [(id <WebDocumentView>)documentView setNeedsLayout: YES];
- [(id <WebDocumentView>)documentView layout];
- }
-
- NSSize documentSize = [documentView frame].size;
- NSSize frameSize = [self frame].size;
-
- scrollsVertically = (vScroll == ScrollbarAlwaysOn) ||
- (vScroll == ScrollbarAuto && documentSize.height > frameSize.height);
- if (scrollsVertically)
- scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) ||
- (hScroll == ScrollbarAuto && documentSize.width + [NSScroller scrollerWidth] > frameSize.width);
- else {
- scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) ||
- (hScroll == ScrollbarAuto && documentSize.width > frameSize.width);
- if (scrollsHorizontally)
- scrollsVertically = (vScroll == ScrollbarAlwaysOn) ||
- (vScroll == ScrollbarAuto && documentSize.height + [NSScroller scrollerWidth] > frameSize.height);
- }
- }
- } else {
- scrollsHorizontally = (hScroll == ScrollbarAuto) ? hasHorizontalScroller : (hScroll == ScrollbarAlwaysOn);
- scrollsVertically = (vScroll == ScrollbarAuto) ? hasVerticalScroller : (vScroll == ScrollbarAlwaysOn);
- }
-
- if (hasVerticalScroller != scrollsVertically) {
- [self setHasVerticalScroller:scrollsVertically];
- hasVerticalScroller = scrollsVertically;
- }
-
- if (hasHorizontalScroller != scrollsHorizontally) {
- [self setHasHorizontalScroller:scrollsHorizontally];
- hasHorizontalScroller = scrollsHorizontally;
- }
- }
-
- if (suppressScrollers) {
- [[self verticalScroller] setNeedsDisplay: NO];
- [[self horizontalScroller] setNeedsDisplay: NO];
- }
-
- inUpdateScrollers = false;
-}
-
-// Make the horizontal and vertical scroll bars come and go as needed.
-- (void)reflectScrolledClipView:(NSClipView *)clipView
-{
- if (clipView == [self contentView]) {
- // FIXME: This hack here prevents infinite recursion that takes place when we
- // gyrate between having a vertical scroller and not having one. A reproducible
- // case is clicking on the "the Policy Routing text" link at
- // http://www.linuxpowered.com/archive/howto/Net-HOWTO-8.html.
- // The underlying cause is some problem in the NSText machinery, but I was not
- // able to pin it down.
- if (!inUpdateScrollers && [[NSGraphicsContext currentContext] isDrawingToScreen])
- [self updateScrollers];
- }
-
- // This code was originally changed for a Leopard performance imporvement. We decided to
- // ifdef it to fix correctness issues on Tiger documented in <rdar://problem/5441823>.
-#ifndef BUILDING_ON_TIGER
- // Update the scrollers if they're not being suppressed.
- if (!suppressScrollers)
- [super reflectScrolledClipView:clipView];
-#else
- [super reflectScrolledClipView:clipView];
-
- // Validate the scrollers if they're being suppressed.
- if (suppressScrollers) {
- [[self verticalScroller] setNeedsDisplay: NO];
- [[self horizontalScroller] setNeedsDisplay: NO];
- }
-#endif
-}
-
-- (BOOL)allowsHorizontalScrolling
-{
- return hScroll != ScrollbarAlwaysOff;
-}
-
-- (BOOL)allowsVerticalScrolling
-{
- return vScroll != ScrollbarAlwaysOff;
-}
-
-- (void)scrollingModes:(WebCore::ScrollbarMode*)hMode vertical:(WebCore::ScrollbarMode*)vMode
-{
- *hMode = static_cast<ScrollbarMode>(hScroll);
- *vMode = static_cast<ScrollbarMode>(vScroll);
-}
-
-- (ScrollbarMode)horizontalScrollingMode
-{
- return static_cast<ScrollbarMode>(hScroll);
-}
-
-- (ScrollbarMode)verticalScrollingMode
-{
- return static_cast<ScrollbarMode>(vScroll);
-}
-
-- (void)setHorizontalScrollingMode:(ScrollbarMode)horizontalMode andLock:(BOOL)lock
-{
- [self setScrollingModes:horizontalMode vertical:[self verticalScrollingMode] andLock:lock];
-}
-
-- (void)setVerticalScrollingMode:(ScrollbarMode)verticalMode andLock:(BOOL)lock
-{
- [self setScrollingModes:[self horizontalScrollingMode] vertical:verticalMode andLock:lock];
-}
-
-- (void)setScrollingModes:(ScrollbarMode)horizontalMode vertical:(ScrollbarMode)verticalMode andLock:(BOOL)lock
-{
- BOOL update = NO;
- if (verticalMode != vScroll && !vScrollModeLocked) {
- vScroll = verticalMode;
- update = YES;
- }
-
- if (horizontalMode != hScroll && !hScrollModeLocked) {
- hScroll = horizontalMode;
- update = YES;
- }
-
- if (lock)
- [self setScrollingModesLocked:YES];
-
- if (update)
- [self updateScrollers];
-}
-
-- (void)setHorizontalScrollingModeLocked:(BOOL)locked
-{
- hScrollModeLocked = locked;
-}
-
-- (void)setVerticalScrollingModeLocked:(BOOL)locked
-{
- vScrollModeLocked = locked;
-}
-
-- (void)setScrollingModesLocked:(BOOL)locked
-{
- hScrollModeLocked = vScrollModeLocked = locked;
-}
-
-- (BOOL)horizontalScrollingModeLocked
-{
- return hScrollModeLocked;
-}
-
-- (BOOL)verticalScrollingModeLocked
-{
- return vScrollModeLocked;
-}
-
-- (BOOL)autoforwardsScrollWheelEvents
-{
- return YES;
-}
-
-- (void)scrollWheel:(NSEvent *)event
-{
- float deltaX;
- float deltaY;
- BOOL isContinuous;
- WKGetWheelEventDeltas(event, &deltaX, &deltaY, &isContinuous);
-
- if (fabsf(deltaY) > fabsf(deltaX)) {
- if (![self allowsVerticalScrolling]) {
- [[self nextResponder] scrollWheel:event];
- return;
- }
- } else if (![self allowsHorizontalScrolling]) {
- [[self nextResponder] scrollWheel:event];
- return;
- }
-
- [super scrollWheel:event];
-}
-
-- (BOOL)accessibilityIsIgnored
-{
- id docView = [self documentView];
- if ([docView isKindOfClass:[WebFrameView class]] && ![(WebFrameView *)docView allowsScrolling])
- return YES;
-
- return [super accessibilityIsIgnored];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h b/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h
deleted file mode 100644
index 312cf9d..0000000
--- a/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebDynamicScrollBarsView.h"
-#import <WebCore/WebCoreFrameView.h>
-
-@interface WebDynamicScrollBarsView (WebInternal) <WebCoreFrameScrollView>
-
-- (BOOL)allowsHorizontalScrolling;
-- (BOOL)allowsVerticalScrolling;
-
-- (void)setScrollingModes:(WebCore::ScrollbarMode)hMode vertical:(WebCore::ScrollbarMode)vMode andLock:(BOOL)lock;
-- (void)scrollingModes:(WebCore::ScrollbarMode*)hMode vertical:(WebCore::ScrollbarMode*)vMode;
-
-- (WebCore::ScrollbarMode)horizontalScrollingMode;
-- (WebCore::ScrollbarMode)verticalScrollingMode;
-
-- (void)setHorizontalScrollingMode:(WebCore::ScrollbarMode)mode andLock:(BOOL)lock;
-- (void)setVerticalScrollingMode:(WebCore::ScrollbarMode)mode andLock:(BOOL)lock;
-
-- (void)setHorizontalScrollingModeLocked:(BOOL)locked;
-- (void)setVerticalScrollingModeLocked:(BOOL)locked;
-- (void)setScrollingModesLocked:(BOOL)mode;
-
-- (BOOL)horizontalScrollingModeLocked;
-- (BOOL)verticalScrollingModeLocked;
-
-- (void)updateScrollers;
-- (void)setSuppressLayout:(BOOL)flag;
-
-@end
diff --git a/WebKit/mac/WebView/WebEditingDelegate.h b/WebKit/mac/WebView/WebEditingDelegate.h
deleted file mode 100644
index 5de9ef0..0000000
--- a/WebKit/mac/WebView/WebEditingDelegate.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2004, 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-@class DOMCSSStyleDeclaration;
-@class DOMRange;
-@class WebView;
-
-typedef enum {
- WebViewInsertActionTyped,
- WebViewInsertActionPasted,
- WebViewInsertActionDropped,
-} WebViewInsertAction;
-
-@interface NSObject (WebViewEditingDelegate)
-- (BOOL)webView:(WebView *)webView shouldBeginEditingInDOMRange:(DOMRange *)range;
-- (BOOL)webView:(WebView *)webView shouldEndEditingInDOMRange:(DOMRange *)range;
-- (BOOL)webView:(WebView *)webView shouldInsertNode:(DOMNode *)node replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action;
-- (BOOL)webView:(WebView *)webView shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action;
-- (BOOL)webView:(WebView *)webView shouldDeleteDOMRange:(DOMRange *)range;
-- (BOOL)webView:(WebView *)webView shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
-- (BOOL)webView:(WebView *)webView shouldApplyStyle:(DOMCSSStyleDeclaration *)style toElementsInDOMRange:(DOMRange *)range;
-- (BOOL)webView:(WebView *)webView shouldChangeTypingStyle:(DOMCSSStyleDeclaration *)currentStyle toStyle:(DOMCSSStyleDeclaration *)proposedStyle;
-- (BOOL)webView:(WebView *)webView doCommandBySelector:(SEL)selector;
-- (void)webViewDidBeginEditing:(NSNotification *)notification;
-- (void)webViewDidChange:(NSNotification *)notification;
-- (void)webViewDidEndEditing:(NSNotification *)notification;
-- (void)webViewDidChangeTypingStyle:(NSNotification *)notification;
-- (void)webViewDidChangeSelection:(NSNotification *)notification;
-- (NSUndoManager *)undoManagerForWebView:(WebView *)webView;
-@end
diff --git a/WebKit/mac/WebView/WebEditingDelegatePrivate.h b/WebKit/mac/WebView/WebEditingDelegatePrivate.h
deleted file mode 100644
index 1116de3..0000000
--- a/WebKit/mac/WebView/WebEditingDelegatePrivate.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebEditingDelegate.h>
-
-@class DOMHTMLElement;
-
-@interface NSObject (WebViewEditingDelegatePrivate)
-- (BOOL)webView:(WebView *)webView shouldShowDeleteInterfaceForElement:(DOMHTMLElement *)element;
-- (void)webView:(WebView *)webView didWriteSelectionToPasteboard:(NSPasteboard *)pasteboard;
-- (void)webView:(WebView *)webView didSetSelectionTypesForPasteboard:(NSPasteboard *)pasteboard;
-- (BOOL)webView:(WebView *)webView shouldMoveRangeAfterDelete:(DOMRange *)range replacingRange:(DOMRange *)rangeToBeReplaced;
-@end
diff --git a/WebKit/mac/WebView/WebFormDelegate.h b/WebKit/mac/WebView/WebFormDelegate.h
deleted file mode 100644
index 1f4bee0..0000000
--- a/WebKit/mac/WebView/WebFormDelegate.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2003, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <AppKit/AppKit.h>
-
-@class DOMElement;
-@class DOMHTMLInputElement;
-@class DOMHTMLTextAreaElement;
-@class WebFrame;
-
-/*!
- @protocol WebFormSubmissionListener
-*/
-@protocol WebFormSubmissionListener <NSObject>
-- (void)continue;
-@end
-
-/*!
- @protocol WebFormDelegate
-*/
-@protocol WebFormDelegate <NSObject>
-
-// Various methods send by controls that edit text to their delegates, which are all
-// analogous to similar methods in AppKit/NSControl.h.
-// These methods are forwarded from widgets used in forms to the WebFormDelegate.
-
-- (void)textFieldDidBeginEditing:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame;
-- (void)textFieldDidEndEditing:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame;
-- (void)textDidChangeInTextField:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame;
-- (void)textDidChangeInTextArea:(DOMHTMLTextAreaElement *)element inFrame:(WebFrame *)frame;
-
-- (BOOL)textField:(DOMHTMLInputElement *)element doCommandBySelector:(SEL)commandSelector inFrame:(WebFrame *)frame;
-- (BOOL)textField:(DOMHTMLInputElement *)element shouldHandleEvent:(NSEvent *)event inFrame:(WebFrame *)frame;
-
-// Sent when a form is just about to be submitted (before the load is started)
-// listener must be sent continue when the delegate is done.
-- (void)frame:(WebFrame *)frame sourceFrame:(WebFrame *)sourceFrame willSubmitForm:(DOMElement *)form
- withValues:(NSDictionary *)values submissionListener:(id <WebFormSubmissionListener>)listener;
-
-@end
-
-/*!
- @class WebFormDelegate
- @discussion The WebFormDelegate class responds to all WebFormDelegate protocol
- methods by doing nothing. It's provided for the convenience of clients who only want
- to implement some of the above methods and ignore others.
-*/
-@interface WebFormDelegate : NSObject <WebFormDelegate>
-@end
diff --git a/WebKit/mac/WebView/WebFormDelegate.m b/WebKit/mac/WebView/WebFormDelegate.m
deleted file mode 100644
index df25f20..0000000
--- a/WebKit/mac/WebView/WebFormDelegate.m
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebFormDelegatePrivate.h"
-
-// FIXME: This could become an informal protocol; we switched all the API
-// delegates to be informal.
-
-@implementation WebFormDelegate
-
-static WebFormDelegate *sharedDelegate = nil;
-
-// Return a object with NOP implementations of the protocol's methods
-// Note this feature relies on our default delegate being stateless
-+ (WebFormDelegate *)_sharedWebFormDelegate
-{
- if (!sharedDelegate)
- sharedDelegate = [[WebFormDelegate alloc] init];
- return sharedDelegate;
-}
-
-- (void)textFieldDidBeginEditing:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame
-{
-}
-
-- (void)textFieldDidEndEditing:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame
-{
-}
-
-- (void)textDidChangeInTextField:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame
-{
-}
-
-- (void)textDidChangeInTextArea:(DOMHTMLTextAreaElement *)element inFrame:(WebFrame *)frame
-{
-}
-
-- (BOOL)textField:(DOMHTMLInputElement *)element doCommandBySelector:(SEL)commandSelector inFrame:(WebFrame *)frame
-{
- return NO;
-}
-
-- (BOOL)textField:(DOMHTMLInputElement *)element shouldHandleEvent:(NSEvent *)event inFrame:(WebFrame *)frame
-{
- return NO;
-}
-
-- (void)frame:(WebFrame *)frame sourceFrame:(WebFrame *)sourceFrame willSubmitForm:(DOMElement *)form
- withValues:(NSDictionary *)values submissionListener:(id <WebFormSubmissionListener>)listener
-{
- [listener continue];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebFormDelegatePrivate.h b/WebKit/mac/WebView/WebFormDelegatePrivate.h
deleted file mode 100644
index d566e89..0000000
--- a/WebKit/mac/WebView/WebFormDelegatePrivate.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebFormDelegate.h"
-
-@interface WebFormDelegate (WebPrivate)
-+ (WebFormDelegate *)_sharedWebFormDelegate;
-@end
diff --git a/WebKit/mac/WebView/WebFrame.h b/WebKit/mac/WebView/WebFrame.h
deleted file mode 100644
index e435087..0000000
--- a/WebKit/mac/WebView/WebFrame.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-#import <JavaScriptCore/JSBase.h>
-
-@class DOMDocument;
-@class DOMHTMLElement;
-@class NSURLRequest;
-@class WebArchive;
-@class WebDataSource;
-@class WebFramePrivate;
-@class WebFrameView;
-@class WebScriptObject;
-@class WebView;
-
-/*!
- @class WebFrame
- @discussion Every web page is represented by at least one WebFrame. A WebFrame
- has a WebFrameView and a WebDataSource.
-*/
-@interface WebFrame : NSObject
-{
-@private
- WebFramePrivate *_private;
-}
-
-/*!
- @method initWithName:webFrameView:webView:
- @abstract The designated initializer of WebFrame.
- @discussion WebFrames are normally created for you by the WebView. You should
- not need to invoke this method directly.
- @param name The name of the frame.
- @param view The WebFrameView for the frame.
- @param webView The WebView that manages the frame.
- @result Returns an initialized WebFrame.
-*/
-- (id)initWithName:(NSString *)name webFrameView:(WebFrameView *)view webView:(WebView *)webView;
-
-/*!
- @method name
- @result The frame name.
-*/
-- (NSString *)name;
-
-/*!
- @method webView
- @result Returns the WebView for the document that includes this frame.
-*/
-- (WebView *)webView;
-
-/*!
- @method frameView
- @result The WebFrameView for this frame.
-*/
-- (WebFrameView *)frameView;
-
-/*!
- @method DOMDocument
- @abstract Returns the DOM document of the frame.
- @description Returns nil if the frame does not contain a DOM document such as a standalone image.
-*/
-- (DOMDocument *)DOMDocument;
-
-/*!
- @method frameElement
- @abstract Returns the frame element of the frame.
- @description The class of the result is either DOMHTMLFrameElement, DOMHTMLIFrameElement or DOMHTMLObjectElement.
- Returns nil if the frame is the main frame since there is no frame element for the frame in this case.
-*/
-- (DOMHTMLElement *)frameElement;
-
-/*!
- @method loadRequest:
- @param request The web request to load.
-*/
-- (void)loadRequest:(NSURLRequest *)request;
-
-/*!
- @method loadData:MIMEType:textEncodingName:baseURL:
- @param data The data to use for the main page of the document.
- @param MIMEType The MIME type of the data.
- @param encodingName The encoding of the data.
- @param URL The base URL to apply to relative URLs within the document.
-*/
-- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)URL;
-
-/*!
- @method loadHTMLString:baseURL:
- @param string The string to use for the main page of the document.
- @param URL The base URL to apply to relative URLs within the document.
-*/
-- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)URL;
-
-/*!
- @method loadAlternateHTMLString:baseURL:forUnreachableURL:
- @abstract Loads a page to display as a substitute for a URL that could not be reached.
- @discussion This allows clients to display page-loading errors in the webview itself.
- This is typically called while processing the WebFrameLoadDelegate method
- -webView:didFailProvisionalLoadWithError:forFrame: or one of the the WebPolicyDelegate methods
- -webView:decidePolicyForMIMEType:request:frame:decisionListener: or
- -webView:unableToImplementPolicyWithError:frame:. If it is called from within one of those
- three delegate methods then the back/forward list will be maintained appropriately.
- @param string The string to use for the main page of the document.
- @param baseURL The baseURL to apply to relative URLs within the document.
- @param unreachableURL The URL for which this page will serve as alternate content.
-*/
-- (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL;
-
-/*!
- @method loadArchive:
- @abstract Causes WebFrame to load a WebArchive.
- @param archive The archive to be loaded.
-*/
-- (void)loadArchive:(WebArchive *)archive;
-
-/*!
- @method dataSource
- @discussion Returns the committed data source. Will return nil if the
- provisional data source hasn't yet been loaded.
- @result The datasource for this frame.
-*/
-- (WebDataSource *)dataSource;
-
-/*!
- @method provisionalDataSource
- @discussion Will return the provisional data source. The provisional data source will
- be nil if no data source has been set on the frame, or the data source
- has successfully transitioned to the committed data source.
- @result The provisional datasource of this frame.
-*/
-- (WebDataSource *)provisionalDataSource;
-
-/*!
- @method stopLoading
- @discussion Stop any pending loads on the frame's data source,
- and its children.
-*/
-- (void)stopLoading;
-
-/*!
- @method reload
-*/
-- (void)reload;
-
-/*!
- @method findFrameNamed:
- @discussion This method returns a frame with the given name. findFrameNamed returns self
- for _self and _current, the parent frame for _parent and the main frame for _top.
- findFrameNamed returns self for _parent and _top if the receiver is the mainFrame.
- findFrameNamed first searches from the current frame to all descending frames then the
- rest of the frames in the WebView. If still not found, findFrameNamed searches the
- frames of the other WebViews.
- @param name The name of the frame to find.
- @result The frame matching the provided name. nil if the frame is not found.
-*/
-- (WebFrame *)findFrameNamed:(NSString *)name;
-
-/*!
- @method parentFrame
- @result The frame containing this frame, or nil if this is a top level frame.
-*/
-- (WebFrame *)parentFrame;
-
-/*!
- @method childFrames
- @discussion The frames in the array are associated with a frame set or iframe.
- @result Returns an array of WebFrame.
-*/
-- (NSArray *)childFrames;
-
-/*!
- @method windowObject
- @result The WebScriptObject representing the frame's JavaScript window object.
-*/
-- (WebScriptObject *)windowObject;
-
-/*!
- @method globalContext
- @result The frame's global JavaScript execution context. Use this method to
- bridge between the WebKit and JavaScriptCore APIs.
-*/
-- (JSGlobalContextRef)globalContext;
-
-@end
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
deleted file mode 100644
index 13a6ad4..0000000
--- a/WebKit/mac/WebView/WebFrame.mm
+++ /dev/null
@@ -1,1357 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebFrameInternal.h"
-
-#import "DOMCSSStyleDeclarationInternal.h"
-#import "DOMDocumentFragmentInternal.h"
-#import "DOMDocumentInternal.h"
-#import "DOMElementInternal.h"
-#import "DOMHTMLElementInternal.h"
-#import "DOMNodeInternal.h"
-#import "DOMRangeInternal.h"
-#import "WebArchiveInternal.h"
-#import "WebChromeClient.h"
-#import "WebDataSourceInternal.h"
-#import "WebDocumentLoaderMac.h"
-#import "WebFrameLoaderClient.h"
-#import "WebFrameViewInternal.h"
-#import "WebHTMLView.h"
-#import "WebHTMLViewInternal.h"
-#import "WebIconFetcherInternal.h"
-#import "WebKitStatisticsPrivate.h"
-#import "WebNSURLExtras.h"
-#import "WebScriptDebugger.h"
-#import "WebViewInternal.h"
-#import <JavaScriptCore/APICast.h>
-#import <WebCore/AccessibilityObject.h>
-#import <WebCore/AXObjectCache.h>
-#import <WebCore/ColorMac.h>
-#import <WebCore/DOMImplementation.h>
-#import <WebCore/DocLoader.h>
-#import <WebCore/DocumentFragment.h>
-#import <WebCore/EventHandler.h>
-#import <WebCore/Frame.h>
-#import <WebCore/FrameLoader.h>
-#import <WebCore/FrameTree.h>
-#import <WebCore/GraphicsContext.h>
-#import <WebCore/HTMLFrameOwnerElement.h>
-#import <WebCore/HistoryItem.h>
-#import <WebCore/HitTestResult.h>
-#import <WebCore/LegacyWebArchive.h>
-#import <WebCore/Page.h>
-#import <WebCore/PluginData.h>
-#import <WebCore/RenderPart.h>
-#import <WebCore/RenderView.h>
-#import <WebCore/RenderLayer.h>
-#import <WebCore/ReplaceSelectionCommand.h>
-#import <WebCore/SmartReplace.h>
-#import <WebCore/SystemTime.h>
-#import <WebCore/TextIterator.h>
-#import <WebCore/TypingCommand.h>
-#import <WebCore/htmlediting.h>
-#import <WebCore/ScriptController.h>
-#import <WebCore/markup.h>
-#import <WebCore/visible_units.h>
-#import <runtime/JSLock.h>
-
-using namespace std;
-using namespace WebCore;
-using namespace HTMLNames;
-
-using JSC::JSGlobalObject;
-using JSC::JSLock;
-using JSC::JSValue;
-
-/*
-Here is the current behavior matrix for four types of navigations:
-
-Standard Nav:
-
- Restore form state: YES
- Restore scroll and focus state: YES
- Cache policy: NSURLRequestUseProtocolCachePolicy
- Add to back/forward list: YES
-
-Back/Forward:
-
- Restore form state: YES
- Restore scroll and focus state: YES
- Cache policy: NSURLRequestReturnCacheDataElseLoad
- Add to back/forward list: NO
-
-Reload (meaning only the reload button):
-
- Restore form state: NO
- Restore scroll and focus state: YES
- Cache policy: NSURLRequestReloadIgnoringCacheData
- Add to back/forward list: NO
-
-Repeat load of the same URL (by any other means of navigation other than the reload button, including hitting return in the location field):
-
- Restore form state: NO
- Restore scroll and focus state: NO, reset to initial conditions
- Cache policy: NSURLRequestReloadIgnoringCacheData
- Add to back/forward list: NO
-*/
-
-NSString *WebPageCacheEntryDateKey = @"WebPageCacheEntryDateKey";
-NSString *WebPageCacheDataSourceKey = @"WebPageCacheDataSourceKey";
-NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
-
-// FIXME: Remove when this key becomes publicly defined
-NSString *NSAccessibilityEnhancedUserInterfaceAttribute = @"AXEnhancedUserInterface";
-
-@implementation WebFramePrivate
-
-- (void)dealloc
-{
- [webFrameView release];
-
- delete scriptDebugger;
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- delete scriptDebugger;
-
- [super finalize];
-}
-
-- (void)setWebFrameView:(WebFrameView *)v
-{
- [v retain];
- [webFrameView release];
- webFrameView = v;
-}
-
-@end
-
-CSSStyleDeclaration* core(DOMCSSStyleDeclaration *declaration)
-{
- return [declaration _CSSStyleDeclaration];
-}
-
-DOMCSSStyleDeclaration *kit(WebCore::CSSStyleDeclaration* declaration)
-{
- return [DOMCSSStyleDeclaration _wrapCSSStyleDeclaration:declaration];
-}
-
-Element* core(DOMElement *element)
-{
- return [element _element];
-}
-
-DOMElement *kit(Element* element)
-{
- return [DOMElement _wrapElement:element];
-}
-
-Node* core(DOMNode *node)
-{
- return [node _node];
-}
-
-DOMNode *kit(Node* node)
-{
- return [DOMNode _wrapNode:node];
-}
-
-DOMNode *kit(PassRefPtr<Node> node)
-{
- return [DOMNode _wrapNode:node.get()];
-}
-
-Document* core(DOMDocument *document)
-{
- return [document _document];
-}
-
-DOMDocument *kit(Document* document)
-{
- return [DOMDocument _wrapDocument:document];
-}
-
-DocumentFragment* core(DOMDocumentFragment *fragment)
-{
- return [fragment _documentFragment];
-}
-
-DOMDocumentFragment *kit(DocumentFragment* fragment)
-{
- return [DOMDocumentFragment _wrapDocumentFragment:fragment];
-}
-
-HTMLElement* core(DOMHTMLElement *element)
-{
- return [element _HTMLElement];
-}
-
-DOMHTMLElement *kit(HTMLElement *element)
-{
- return [DOMHTMLElement _wrapHTMLElement:element];
-}
-
-Range* core(DOMRange *range)
-{
- return [range _range];
-}
-
-DOMRange *kit(Range* range)
-{
- return [DOMRange _wrapRange:range];
-}
-
-EditableLinkBehavior core(WebKitEditableLinkBehavior editableLinkBehavior)
-{
- switch (editableLinkBehavior) {
- case WebKitEditableLinkDefaultBehavior:
- return EditableLinkDefaultBehavior;
- case WebKitEditableLinkAlwaysLive:
- return EditableLinkAlwaysLive;
- case WebKitEditableLinkOnlyLiveWithShiftKey:
- return EditableLinkOnlyLiveWithShiftKey;
- case WebKitEditableLinkLiveWhenNotFocused:
- return EditableLinkLiveWhenNotFocused;
- case WebKitEditableLinkNeverLive:
- return EditableLinkNeverLive;
- }
- ASSERT_NOT_REACHED();
- return EditableLinkDefaultBehavior;
-}
-
-@implementation WebFrame (WebInternal)
-
-Frame* core(WebFrame *frame)
-{
- return frame ? frame->_private->coreFrame : 0;
-}
-
-WebFrame *kit(Frame* frame)
-{
- return frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : nil;
-}
-
-Page* core(WebView *webView)
-{
- return [webView page];
-}
-
-WebView *kit(Page* page)
-{
- return page ? static_cast<WebChromeClient*>(page->chrome()->client())->webView() : nil;
-}
-
-WebView *getWebView(WebFrame *webFrame)
-{
- Frame* coreFrame = core(webFrame);
- if (!coreFrame)
- return nil;
- return kit(coreFrame->page());
-}
-
-+ (PassRefPtr<Frame>)_createFrameWithPage:(Page*)page frameName:(const String&)name frameView:(WebFrameView *)frameView ownerElement:(HTMLFrameOwnerElement*)ownerElement
-{
- WebView *webView = kit(page);
-
- WebFrame *frame = [[self alloc] _initWithWebFrameView:frameView webView:webView];
- RefPtr<Frame> coreFrame = Frame::create(page, ownerElement, new WebFrameLoaderClient(frame));
- [frame release];
- frame->_private->coreFrame = coreFrame.get();
-
- coreFrame->tree()->setName(name);
- if (ownerElement) {
- ASSERT(ownerElement->document()->frame());
- ownerElement->document()->frame()->tree()->appendChild(coreFrame.get());
- }
-
- coreFrame->init();
-
- [webView _setZoomMultiplier:[webView _realZoomMultiplier] isTextOnly:[webView _realZoomMultiplierIsTextOnly]];
-
- return coreFrame.release();
-}
-
-+ (void)_createMainFrameWithPage:(Page*)page frameName:(const String&)name frameView:(WebFrameView *)frameView
-{
- [self _createFrameWithPage:page frameName:name frameView:frameView ownerElement:0];
-}
-
-+ (PassRefPtr<WebCore::Frame>)_createSubframeWithOwnerElement:(HTMLFrameOwnerElement*)ownerElement frameName:(const String&)name frameView:(WebFrameView *)frameView
-{
- return [self _createFrameWithPage:ownerElement->document()->frame()->page() frameName:name frameView:frameView ownerElement:ownerElement];
-}
-
-- (void)_attachScriptDebugger
-{
- ScriptController* scriptController = _private->coreFrame->script();
-
- // Calling ScriptController::globalObject() would create a window shell, and dispatch corresponding callbacks, which may be premature
- // if the script debugger is attached before a document is created.
- if (!scriptController->haveWindowShell())
- return;
-
- JSGlobalObject* globalObject = scriptController->globalObject();
- if (!globalObject)
- return;
-
- if (_private->scriptDebugger) {
- ASSERT(_private->scriptDebugger == globalObject->debugger());
- return;
- }
-
- _private->scriptDebugger = new WebScriptDebugger(globalObject);
-}
-
-- (void)_detachScriptDebugger
-{
- if (!_private->scriptDebugger)
- return;
-
- delete _private->scriptDebugger;
- _private->scriptDebugger = 0;
-}
-
-- (id)_initWithWebFrameView:(WebFrameView *)fv webView:(WebView *)v
-{
- self = [super init];
- if (!self)
- return nil;
-
- _private = [[WebFramePrivate alloc] init];
-
- if (fv) {
- [_private setWebFrameView:fv];
- [fv _setWebFrame:self];
- }
-
- _private->shouldCreateRenderers = YES;
-
- ++WebFrameCount;
-
- return self;
-}
-
-- (void)_clearCoreFrame
-{
- _private->coreFrame = 0;
-}
-
-- (void)_updateBackgroundAndUpdatesWhileOffscreen
-{
- WebView *webView = getWebView(self);
- BOOL drawsBackground = [webView drawsBackground];
- NSColor *backgroundColor = [webView backgroundColor];
-
- Frame* coreFrame = _private->coreFrame;
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
- WebFrame *webFrame = kit(frame);
- // Never call setDrawsBackground:YES here on the scroll view or the background color will
- // flash between pages loads. setDrawsBackground:YES will be called in _frameLoadCompleted.
- if (!drawsBackground)
- [[[webFrame frameView] _scrollView] setDrawsBackground:NO];
- [[[webFrame frameView] _scrollView] setBackgroundColor:backgroundColor];
- id documentView = [[webFrame frameView] documentView];
- if ([documentView respondsToSelector:@selector(setDrawsBackground:)])
- [documentView setDrawsBackground:drawsBackground];
- if ([documentView respondsToSelector:@selector(setBackgroundColor:)])
- [documentView setBackgroundColor:backgroundColor];
- if (frame && frame->view()) {
- frame->view()->setTransparent(!drawsBackground);
- Color color = colorFromNSColor([backgroundColor colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
- frame->view()->setBaseBackgroundColor(color);
- frame->view()->setShouldUpdateWhileOffscreen([webView shouldUpdateWhileOffscreen]);
- }
- }
-}
-
-- (void)_setInternalLoadDelegate:(id)internalLoadDelegate
-{
- _private->internalLoadDelegate = internalLoadDelegate;
-}
-
-- (id)_internalLoadDelegate
-{
- return _private->internalLoadDelegate;
-}
-
-#ifndef BUILDING_ON_TIGER
-- (void)_unmarkAllBadGrammar
-{
- Frame* coreFrame = _private->coreFrame;
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
- if (Document* document = frame->document())
- document->removeMarkers(DocumentMarker::Grammar);
- }
-}
-#endif
-
-- (void)_unmarkAllMisspellings
-{
- Frame* coreFrame = _private->coreFrame;
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
- if (Document* document = frame->document())
- document->removeMarkers(DocumentMarker::Spelling);
- }
-}
-
-- (BOOL)_hasSelection
-{
- id documentView = [_private->webFrameView documentView];
-
- // optimization for common case to avoid creating potentially large selection string
- if ([documentView isKindOfClass:[WebHTMLView class]])
- if (Frame* coreFrame = _private->coreFrame)
- return coreFrame->selection()->isRange();
-
- if ([documentView conformsToProtocol:@protocol(WebDocumentText)])
- return [[documentView selectedString] length] > 0;
-
- return NO;
-}
-
-- (void)_clearSelection
-{
- id documentView = [_private->webFrameView documentView];
- if ([documentView conformsToProtocol:@protocol(WebDocumentText)])
- [documentView deselectAll];
-}
-
-#if !ASSERT_DISABLED
-- (BOOL)_atMostOneFrameHasSelection
-{
- // FIXME: 4186050 is one known case that makes this debug check fail.
- BOOL found = NO;
- Frame* coreFrame = _private->coreFrame;
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame))
- if ([kit(frame) _hasSelection]) {
- if (found)
- return NO;
- found = YES;
- }
- return YES;
-}
-#endif
-
-- (WebFrame *)_findFrameWithSelection
-{
- Frame* coreFrame = _private->coreFrame;
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
- WebFrame *webFrame = kit(frame);
- if ([webFrame _hasSelection])
- return webFrame;
- }
- return nil;
-}
-
-- (void)_clearSelectionInOtherFrames
-{
- // We rely on WebDocumentSelection protocol implementors to call this method when they become first
- // responder. It would be nicer to just notice first responder changes here instead, but there's no
- // notification sent when the first responder changes in general (Radar 2573089).
- WebFrame *frameWithSelection = [[getWebView(self) mainFrame] _findFrameWithSelection];
- if (frameWithSelection != self)
- [frameWithSelection _clearSelection];
-
- // While we're in the general area of selection and frames, check that there is only one now.
- ASSERT([[getWebView(self) mainFrame] _atMostOneFrameHasSelection]);
-}
-
-static inline WebDataSource *dataSource(DocumentLoader* loader)
-{
- return loader ? static_cast<WebDocumentLoaderMac*>(loader)->dataSource() : nil;
-}
-
-- (WebDataSource *)_dataSource
-{
- return dataSource(_private->coreFrame->loader()->documentLoader());
-}
-
-- (void)_addData:(NSData *)data
-{
- Document* document = _private->coreFrame->document();
-
- // Document may be nil if the part is about to redirect
- // as a result of JS executing during load, i.e. one frame
- // changing another's location before the frame's document
- // has been created.
- if (!document)
- return;
-
- document->setShouldCreateRenderers(_private->shouldCreateRenderers);
- _private->coreFrame->loader()->addData((const char *)[data bytes], [data length]);
-}
-
-- (NSString *)_stringWithDocumentTypeStringAndMarkupString:(NSString *)markupString
-{
- return _private->coreFrame->documentTypeString() + markupString;
-}
-
-- (NSArray *)_nodesFromList:(Vector<Node*> *)nodesVector
-{
- size_t size = nodesVector->size();
- NSMutableArray *nodes = [NSMutableArray arrayWithCapacity:size];
- for (size_t i = 0; i < size; ++i)
- [nodes addObject:[DOMNode _wrapNode:(*nodesVector)[i]]];
- return nodes;
-}
-
-- (NSString *)_markupStringFromRange:(DOMRange *)range nodes:(NSArray **)nodes
-{
- // FIXME: This is always "for interchange". Is that right? See the previous method.
- Vector<Node*> nodeList;
- NSString *markupString = createMarkup([range _range], nodes ? &nodeList : 0, AnnotateForInterchange);
- if (nodes)
- *nodes = [self _nodesFromList:&nodeList];
-
- return [self _stringWithDocumentTypeStringAndMarkupString:markupString];
-}
-
-- (NSString *)_selectedString
-{
- String text = _private->coreFrame->selectedText();
- text.replace('\\', _private->coreFrame->backslashAsCurrencySymbol());
- return text;
-}
-
-- (NSString *)_stringForRange:(DOMRange *)range
-{
- // This will give a system malloc'd buffer that can be turned directly into an NSString
- unsigned length;
- UChar* buf = plainTextToMallocAllocatedBuffer([range _range], length);
-
- if (!buf)
- return [NSString string];
-
- UChar backslashAsCurrencySymbol = _private->coreFrame->backslashAsCurrencySymbol();
- if (backslashAsCurrencySymbol != '\\')
- for (unsigned n = 0; n < length; n++)
- if (buf[n] == '\\')
- buf[n] = backslashAsCurrencySymbol;
-
- // Transfer buffer ownership to NSString
- return [[[NSString alloc] initWithCharactersNoCopy:buf length:length freeWhenDone:YES] autorelease];
-}
-
-- (void)_drawRect:(NSRect)rect contentsOnly:(BOOL)contentsOnly
-{
- PlatformGraphicsContext* platformContext = static_cast<PlatformGraphicsContext*>([[NSGraphicsContext currentContext] graphicsPort]);
- ASSERT([[NSGraphicsContext currentContext] isFlipped]);
- GraphicsContext context(platformContext);
-
- if (contentsOnly)
- _private->coreFrame->view()->paintContents(&context, enclosingIntRect(rect));
- else
- _private->coreFrame->view()->paint(&context, enclosingIntRect(rect));
-}
-
-// Used by pagination code called from AppKit when a standalone web page is printed.
-- (NSArray*)_computePageRectsWithPrintWidthScaleFactor:(float)printWidthScaleFactor printHeight:(float)printHeight
-{
- NSMutableArray* pages = [NSMutableArray arrayWithCapacity:5];
- if (printWidthScaleFactor <= 0) {
- LOG_ERROR("printWidthScaleFactor has bad value %.2f", printWidthScaleFactor);
- return pages;
- }
-
- if (printHeight <= 0) {
- LOG_ERROR("printHeight has bad value %.2f", printHeight);
- return pages;
- }
-
- if (!_private->coreFrame || !_private->coreFrame->document() || !_private->coreFrame->view()) return pages;
- RenderView* root = static_cast<RenderView *>(_private->coreFrame->document()->renderer());
- if (!root) return pages;
-
- FrameView* view = _private->coreFrame->view();
- if (!view)
- return pages;
-
- NSView* documentView = view->documentView();
- if (!documentView)
- return pages;
-
- float currPageHeight = printHeight;
- float docHeight = root->layer()->height();
- float docWidth = root->layer()->width();
- float printWidth = docWidth/printWidthScaleFactor;
-
- // We need to give the part the opportunity to adjust the page height at each step.
- for (float i = 0; i < docHeight; i += currPageHeight) {
- float proposedBottom = min(docHeight, i + printHeight);
- _private->coreFrame->adjustPageHeight(&proposedBottom, i, proposedBottom, i);
- currPageHeight = max(1.0f, proposedBottom - i);
- for (float j = 0; j < docWidth; j += printWidth) {
- NSValue* val = [NSValue valueWithRect: NSMakeRect(j, i, printWidth, currPageHeight)];
- [pages addObject: val];
- }
- }
-
- return pages;
-}
-
-- (BOOL)_getVisibleRect:(NSRect*)rect;
-{
- ASSERT_ARG(rect, rect);
- if (RenderPart* ownerRenderer = _private->coreFrame->ownerRenderer()) {
- if (ownerRenderer->needsLayout())
- return NO;
- *rect = ownerRenderer->absoluteClippedOverflowRect();
- return YES;
- }
-
- return NO;
-}
-
-- (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string
-{
- return [self _stringByEvaluatingJavaScriptFromString:string forceUserGesture:true];
-}
-
-- (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string forceUserGesture:(BOOL)forceUserGesture
-{
- ASSERT(_private->coreFrame->document());
-
- JSValue* result = _private->coreFrame->loader()->executeScript(string, forceUserGesture);
-
- if (!_private->coreFrame) // In case the script removed our frame from the page.
- return @"";
-
- // This bizarre set of rules matches behavior from WebKit for Safari 2.0.
- // If you don't like it, use -[WebScriptObject evaluateWebScript:] or
- // JSEvaluateScript instead, since they have less surprising semantics.
- if (!result || !result->isBoolean() && !result->isString() && !result->isNumber())
- return @"";
-
- JSLock lock(false);
- return String(result->toString(_private->coreFrame->script()->globalObject()->globalExec()));
-}
-
-- (NSRect)_caretRectAtNode:(DOMNode *)node offset:(int)offset affinity:(NSSelectionAffinity)affinity
-{
- VisiblePosition visiblePosition([node _node], offset, static_cast<EAffinity>(affinity));
- return visiblePosition.caretRect();
-}
-
-- (NSRect)_firstRectForDOMRange:(DOMRange *)range
-{
- return _private->coreFrame->firstRectForRange([range _range]);
-}
-
-- (void)_scrollDOMRangeToVisible:(DOMRange *)range
-{
- NSRect rangeRect = [self _firstRectForDOMRange:range];
- Node *startNode = [[range startContainer] _node];
-
- if (startNode && startNode->renderer()) {
- RenderLayer *layer = startNode->renderer()->enclosingLayer();
- if (layer)
- layer->scrollRectToVisible(enclosingIntRect(rangeRect), false, RenderLayer::gAlignToEdgeIfNeeded, RenderLayer::gAlignToEdgeIfNeeded);
- }
-}
-
-- (BOOL)_needsLayout
-{
- return _private->coreFrame->view() ? _private->coreFrame->view()->needsLayout() : false;
-}
-
-- (id)_accessibilityTree
-{
- if (!AXObjectCache::accessibilityEnabled()) {
- AXObjectCache::enableAccessibility();
- if ([[NSApp accessibilityAttributeValue:NSAccessibilityEnhancedUserInterfaceAttribute] boolValue])
- AXObjectCache::enableEnhancedUserInterfaceAccessibility();
- }
-
- if (!_private->coreFrame || !_private->coreFrame->document())
- return nil;
- RenderView* root = static_cast<RenderView *>(_private->coreFrame->document()->renderer());
- if (!root)
- return nil;
- return _private->coreFrame->document()->axObjectCache()->get(root)->wrapper();
-}
-
-- (DOMRange *)_rangeByAlteringCurrentSelection:(SelectionController::EAlteration)alteration direction:(SelectionController::EDirection)direction granularity:(TextGranularity)granularity
-{
- if (_private->coreFrame->selection()->isNone())
- return nil;
-
- SelectionController selection;
- selection.setSelection(_private->coreFrame->selection()->selection());
- selection.modify(alteration, direction, granularity);
- return [DOMRange _wrapRange:selection.toRange().get()];
-}
-
-- (TextGranularity)_selectionGranularity
-{
- return _private->coreFrame->selectionGranularity();
-}
-
-- (NSRange)_convertToNSRange:(Range *)range
-{
- if (!range || !range->startContainer())
- return NSMakeRange(NSNotFound, 0);
-
- Element* selectionRoot = _private->coreFrame->selection()->rootEditableElement();
- Element* scope = selectionRoot ? selectionRoot : _private->coreFrame->document()->documentElement();
-
- // Mouse events may cause TSM to attempt to create an NSRange for a portion of the view
- // that is not inside the current editable region. These checks ensure we don't produce
- // potentially invalid data when responding to such requests.
- if (range->startContainer() != scope && !range->startContainer()->isDescendantOf(scope))
- return NSMakeRange(NSNotFound, 0);
- if (range->endContainer() != scope && !range->endContainer()->isDescendantOf(scope))
- return NSMakeRange(NSNotFound, 0);
-
- RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
- ASSERT(testRange->startContainer() == scope);
- int startPosition = TextIterator::rangeLength(testRange.get());
-
- ExceptionCode ec;
- testRange->setEnd(range->endContainer(), range->endOffset(), ec);
- ASSERT(testRange->startContainer() == scope);
- int endPosition = TextIterator::rangeLength(testRange.get());
-
- return NSMakeRange(startPosition, endPosition - startPosition);
-}
-
-- (PassRefPtr<Range>)_convertToDOMRange:(NSRange)nsrange
-{
- if (nsrange.location > INT_MAX)
- return 0;
- if (nsrange.length > INT_MAX || nsrange.location + nsrange.length > INT_MAX)
- nsrange.length = INT_MAX - nsrange.location;
-
- // our critical assumption is that we are only called by input methods that
- // concentrate on a given area containing the selection
- // We have to do this because of text fields and textareas. The DOM for those is not
- // directly in the document DOM, so serialization is problematic. Our solution is
- // to use the root editable element of the selection start as the positional base.
- // That fits with AppKit's idea of an input context.
- Element* selectionRoot = _private->coreFrame->selection()->rootEditableElement();
- Element* scope = selectionRoot ? selectionRoot : _private->coreFrame->document()->documentElement();
- return TextIterator::rangeFromLocationAndLength(scope, nsrange.location, nsrange.length);
-}
-
-- (DOMRange *)_convertNSRangeToDOMRange:(NSRange)nsrange
-{
- return [DOMRange _wrapRange:[self _convertToDOMRange:nsrange].get()];
-}
-
-- (NSRange)_convertDOMRangeToNSRange:(DOMRange *)range
-{
- return [self _convertToNSRange:[range _range]];
-}
-
-- (DOMRange *)_markDOMRange
-{
- return [DOMRange _wrapRange:_private->coreFrame->mark().toRange().get()];
-}
-
-// Given proposedRange, returns an extended range that includes adjacent whitespace that should
-// be deleted along with the proposed range in order to preserve proper spacing and punctuation of
-// the text surrounding the deletion.
-- (DOMRange *)_smartDeleteRangeForProposedRange:(DOMRange *)proposedRange
-{
- Node *startContainer = [[proposedRange startContainer] _node];
- Node *endContainer = [[proposedRange endContainer] _node];
- if (startContainer == nil || endContainer == nil)
- return nil;
-
- ASSERT(startContainer->document() == endContainer->document());
-
- _private->coreFrame->document()->updateLayoutIgnorePendingStylesheets();
-
- Position start(startContainer, [proposedRange startOffset]);
- Position end(endContainer, [proposedRange endOffset]);
- Position newStart = start.upstream().leadingWhitespacePosition(DOWNSTREAM, true);
- if (newStart.isNull())
- newStart = start;
- Position newEnd = end.downstream().trailingWhitespacePosition(DOWNSTREAM, true);
- if (newEnd.isNull())
- newEnd = end;
-
- newStart = rangeCompliantEquivalent(newStart);
- newEnd = rangeCompliantEquivalent(newEnd);
-
- RefPtr<Range> range = _private->coreFrame->document()->createRange();
- int exception = 0;
- range->setStart(newStart.node(), newStart.offset(), exception);
- range->setEnd(newStart.node(), newStart.offset(), exception);
- return [DOMRange _wrapRange:range.get()];
-}
-
-// Determines whether whitespace needs to be added around aString to preserve proper spacing and
-// punctuation when it’s inserted into the receiver’s text over charRange. Returns by reference
-// in beforeString and afterString any whitespace that should be added, unless either or both are
-// nil. Both are returned as nil if aString is nil or if smart insertion and deletion are disabled.
-- (void)_smartInsertForString:(NSString *)pasteString replacingRange:(DOMRange *)rangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString
-{
- // give back nil pointers in case of early returns
- if (beforeString)
- *beforeString = nil;
- if (afterString)
- *afterString = nil;
-
- // inspect destination
- Node *startContainer = [[rangeToReplace startContainer] _node];
- Node *endContainer = [[rangeToReplace endContainer] _node];
-
- Position startPos(startContainer, [rangeToReplace startOffset]);
- Position endPos(endContainer, [rangeToReplace endOffset]);
-
- VisiblePosition startVisiblePos = VisiblePosition(startPos, VP_DEFAULT_AFFINITY);
- VisiblePosition endVisiblePos = VisiblePosition(endPos, VP_DEFAULT_AFFINITY);
-
- // this check also ensures startContainer, startPos, endContainer, and endPos are non-null
- if (startVisiblePos.isNull() || endVisiblePos.isNull())
- return;
-
- bool addLeadingSpace = startPos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isStartOfParagraph(startVisiblePos);
- if (addLeadingSpace)
- if (UChar previousChar = startVisiblePos.previous().characterAfter())
- addLeadingSpace = !isCharacterSmartReplaceExempt(previousChar, true);
-
- bool addTrailingSpace = endPos.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isEndOfParagraph(endVisiblePos);
- if (addTrailingSpace)
- if (UChar thisChar = endVisiblePos.characterAfter())
- addTrailingSpace = !isCharacterSmartReplaceExempt(thisChar, false);
-
- // inspect source
- bool hasWhitespaceAtStart = false;
- bool hasWhitespaceAtEnd = false;
- unsigned pasteLength = [pasteString length];
- if (pasteLength > 0) {
- NSCharacterSet *whiteSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
-
- if ([whiteSet characterIsMember:[pasteString characterAtIndex:0]]) {
- hasWhitespaceAtStart = YES;
- }
- if ([whiteSet characterIsMember:[pasteString characterAtIndex:(pasteLength - 1)]]) {
- hasWhitespaceAtEnd = YES;
- }
- }
-
- // issue the verdict
- if (beforeString && addLeadingSpace && !hasWhitespaceAtStart)
- *beforeString = @" ";
- if (afterString && addTrailingSpace && !hasWhitespaceAtEnd)
- *afterString = @" ";
-}
-
-- (DOMDocumentFragment *)_documentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString
-{
- if (!_private->coreFrame || !_private->coreFrame->document())
- return 0;
-
- return [DOMDocumentFragment _wrapDocumentFragment:createFragmentFromMarkup(_private->coreFrame->document(), markupString, baseURLString).get()];
-}
-
-- (DOMDocumentFragment *)_documentFragmentWithNodesAsParagraphs:(NSArray *)nodes
-{
- if (!_private->coreFrame || !_private->coreFrame->document())
- return 0;
-
- NSEnumerator *nodeEnum = [nodes objectEnumerator];
- Vector<Node*> nodesVector;
- DOMNode *node;
- while ((node = [nodeEnum nextObject]))
- nodesVector.append([node _node]);
-
- return [DOMDocumentFragment _wrapDocumentFragment:createFragmentFromNodes(_private->coreFrame->document(), nodesVector).get()];
-}
-
-- (void)_replaceSelectionWithFragment:(DOMDocumentFragment *)fragment selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle
-{
- if (_private->coreFrame->selection()->isNone() || !fragment)
- return;
-
- applyCommand(ReplaceSelectionCommand::create(_private->coreFrame->document(), [fragment _documentFragment], selectReplacement, smartReplace, matchStyle));
- _private->coreFrame->revealSelection(RenderLayer::gAlignToEdgeIfNeeded);
-}
-
-- (void)_replaceSelectionWithNode:(DOMNode *)node selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle
-{
- DOMDocumentFragment *fragment = [DOMDocumentFragment _wrapDocumentFragment:_private->coreFrame->document()->createDocumentFragment().get()];
- [fragment appendChild:node];
- [self _replaceSelectionWithFragment:fragment selectReplacement:selectReplacement smartReplace:smartReplace matchStyle:matchStyle];
-}
-
-- (void)_replaceSelectionWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace
-{
- DOMDocumentFragment *fragment = [self _documentFragmentWithMarkupString:markupString baseURLString:baseURLString];
- [self _replaceSelectionWithFragment:fragment selectReplacement:selectReplacement smartReplace:smartReplace matchStyle:NO];
-}
-
-- (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace
-{
- [self _replaceSelectionWithFragment:kit(createFragmentFromText(_private->coreFrame->selection()->toRange().get(), text).get())
- selectReplacement:selectReplacement smartReplace:smartReplace matchStyle:YES];
-}
-
-- (void)_insertParagraphSeparatorInQuotedContent
-{
- if (_private->coreFrame->selection()->isNone())
- return;
-
- TypingCommand::insertParagraphSeparatorInQuotedContent(_private->coreFrame->document());
- _private->coreFrame->revealSelection(RenderLayer::gAlignToEdgeIfNeeded);
-}
-
-- (VisiblePosition)_visiblePositionForPoint:(NSPoint)point
-{
- IntPoint outerPoint(point);
- HitTestResult result = _private->coreFrame->eventHandler()->hitTestResultAtPoint(outerPoint, true);
- Node* node = result.innerNode();
- if (!node)
- return VisiblePosition();
- RenderObject* renderer = node->renderer();
- if (!renderer)
- return VisiblePosition();
- VisiblePosition visiblePos = renderer->positionForCoordinates(result.localPoint().x(), result.localPoint().y());
- if (visiblePos.isNull())
- visiblePos = VisiblePosition(Position(node, 0));
- return visiblePos;
-}
-
-- (DOMRange *)_characterRangeAtPoint:(NSPoint)point
-{
- VisiblePosition position = [self _visiblePositionForPoint:point];
- if (position.isNull())
- return nil;
-
- VisiblePosition previous = position.previous();
- if (previous.isNotNull()) {
- DOMRange *previousCharacterRange = [DOMRange _wrapRange:makeRange(previous, position).get()];
- NSRect rect = [self _firstRectForDOMRange:previousCharacterRange];
- if (NSPointInRect(point, rect))
- return previousCharacterRange;
- }
-
- VisiblePosition next = position.next();
- if (next.isNotNull()) {
- DOMRange *nextCharacterRange = [DOMRange _wrapRange:makeRange(position, next).get()];
- NSRect rect = [self _firstRectForDOMRange:nextCharacterRange];
- if (NSPointInRect(point, rect))
- return nextCharacterRange;
- }
-
- return nil;
-}
-
-- (DOMCSSStyleDeclaration *)_typingStyle
-{
- if (!_private->coreFrame || !_private->coreFrame->typingStyle())
- return nil;
- return [DOMCSSStyleDeclaration _wrapCSSStyleDeclaration:_private->coreFrame->typingStyle()->copy().get()];
-}
-
-- (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
-{
- if (!_private->coreFrame)
- return;
- _private->coreFrame->computeAndSetTypingStyle([style _CSSStyleDeclaration], undoAction);
-}
-
-- (void)_dragSourceMovedTo:(NSPoint)windowLoc
-{
- if (!_private->coreFrame)
- return;
- FrameView* view = _private->coreFrame->view();
- if (!view)
- return;
- // FIXME: These are fake modifier keys here, but they should be real ones instead.
- PlatformMouseEvent event(IntPoint(windowLoc), globalPoint(windowLoc, [view->platformWidget() window]),
- LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime());
- _private->coreFrame->eventHandler()->dragSourceMovedTo(event);
-}
-
-- (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation
-{
- if (!_private->coreFrame)
- return;
- FrameView* view = _private->coreFrame->view();
- if (!view)
- return;
- // FIXME: These are fake modifier keys here, but they should be real ones instead.
- PlatformMouseEvent event(IntPoint(windowLoc), globalPoint(windowLoc, [view->platformWidget() window]),
- LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime());
- _private->coreFrame->eventHandler()->dragSourceEndedAt(event, (DragOperation)operation);
-}
-
-- (BOOL)_canProvideDocumentSource
-{
- String mimeType = _private->coreFrame->loader()->responseMIMEType();
-
- if (WebCore::DOMImplementation::isTextMIMEType(mimeType) ||
- Image::supportsType(mimeType) ||
- (_private->coreFrame->page() && _private->coreFrame->page()->pluginData()->supportsMimeType(mimeType)))
- return NO;
-
- return YES;
-}
-
-- (BOOL)_canSaveAsWebArchive
-{
- // Currently, all documents that we can view source for
- // (HTML and XML documents) can also be saved as web archives
- return [self _canProvideDocumentSource];
-}
-
-- (void)_receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName
-{
- // Set the encoding. This only needs to be done once, but it's harmless to do it again later.
- String encoding = _private->coreFrame->loader()->documentLoader()->overrideEncoding();
- bool userChosen = !encoding.isNull();
- if (encoding.isNull())
- encoding = textEncodingName;
- _private->coreFrame->loader()->setEncoding(encoding, userChosen);
- [self _addData:data];
-}
-
-@end
-
-@implementation WebFrame (WebPrivate)
-
-// FIXME: This exists only as a convenience for Safari, consider moving there.
-- (BOOL)_isDescendantOfFrame:(WebFrame *)ancestor
-{
- Frame* coreFrame = _private->coreFrame;
- return coreFrame && coreFrame->tree()->isDescendantOf(core(ancestor));
-}
-
-- (void)_setShouldCreateRenderers:(BOOL)shouldCreateRenderers
-{
- _private->shouldCreateRenderers = shouldCreateRenderers;
-}
-
-- (NSColor *)_bodyBackgroundColor
-{
- Document* document = _private->coreFrame->document();
- if (!document)
- return nil;
- HTMLElement* body = document->body();
- if (!body)
- return nil;
- RenderObject* bodyRenderer = body->renderer();
- if (!bodyRenderer)
- return nil;
- Color color = bodyRenderer->style()->backgroundColor();
- if (!color.isValid())
- return nil;
- return nsColor(color);
-}
-
-- (BOOL)_isFrameSet
-{
- return _private->coreFrame->isFrameSet();
-}
-
-- (BOOL)_firstLayoutDone
-{
- return _private->coreFrame->loader()->firstLayoutDone();
-}
-
-- (WebFrameLoadType)_loadType
-{
- return (WebFrameLoadType)_private->coreFrame->loader()->loadType();
-}
-
-- (NSRange)_selectedNSRange
-{
- return [self _convertToNSRange:_private->coreFrame->selection()->toRange().get()];
-}
-
-- (void)_selectNSRange:(NSRange)range
-{
- RefPtr<Range> domRange = [self _convertToDOMRange:range];
- if (domRange)
- _private->coreFrame->selection()->setSelection(Selection(domRange.get(), SEL_DEFAULT_AFFINITY));
-}
-
-- (BOOL)_isDisplayingStandaloneImage
-{
- Document* document = _private->coreFrame->document();
- return document && document->isImageDocument();
-}
-
-- (unsigned)_pendingFrameUnloadEventCount
-{
- return _private->coreFrame->eventHandler()->pendingFrameUnloadEventCount();
-}
-
-- (WebIconFetcher *)fetchApplicationIcon:(id)target
- selector:(SEL)selector
-{
- return [WebIconFetcher _fetchApplicationIconForFrame:self
- target:target
- selector:selector];
-}
-
-- (void)_setIsDisconnected:(bool)isDisconnected
-{
- _private->coreFrame->setIsDisconnected(isDisconnected);
-}
-
-- (void)_setExcludeFromTextSearch:(bool)exclude
-{
- _private->coreFrame->setExcludeFromTextSearch(exclude);
-}
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-- (void)_recursive_resumeNullEventsForAllNetscapePlugins
-{
- Frame* coreFrame = core(self);
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
- NSView <WebDocumentView> *documentView = [[kit(frame) frameView] documentView];
- if ([documentView isKindOfClass:[WebHTMLView class]])
- [(WebHTMLView *)documentView _resumeNullEventsForAllNetscapePlugins];
- }
-}
-
-- (void)_recursive_pauseNullEventsForAllNetscapePlugins
-{
- Frame* coreFrame = core(self);
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
- NSView <WebDocumentView> *documentView = [[kit(frame) frameView] documentView];
- if ([documentView isKindOfClass:[WebHTMLView class]])
- [(WebHTMLView *)documentView _pauseNullEventsForAllNetscapePlugins];
- }
-}
-#endif
-
-@end
-
-@implementation WebFrame
-
-- (id)init
-{
- return nil;
-}
-
-// Should be deprecated.
-- (id)initWithName:(NSString *)name webFrameView:(WebFrameView *)view webView:(WebView *)webView
-{
- return nil;
-}
-
-- (void)dealloc
-{
- [_private release];
- --WebFrameCount;
- [super dealloc];
-}
-
-- (void)finalize
-{
- --WebFrameCount;
- [super finalize];
-}
-
-- (NSString *)name
-{
- Frame* coreFrame = _private->coreFrame;
- if (!coreFrame)
- return nil;
- return coreFrame->tree()->name();
-}
-
-- (WebFrameView *)frameView
-{
- return _private->webFrameView;
-}
-
-- (WebView *)webView
-{
- return getWebView(self);
-}
-
-- (DOMDocument *)DOMDocument
-{
- Frame* coreFrame = _private->coreFrame;
- if (!coreFrame)
- return nil;
-
- // FIXME: <rdar://problem/5145841> When loading a custom view/representation
- // into a web frame, the old document can still be around. This makes sure that
- // we'll return nil in those cases.
- if (![[self _dataSource] _isDocumentHTML])
- return nil;
-
- Document* document = coreFrame->document();
-
- // According to the documentation, we should return nil if the frame doesn't have a document.
- // While full-frame images and plugins do have an underlying HTML document, we return nil here to be
- // backwards compatible.
- if (document && (document->isPluginDocument() || document->isImageDocument()))
- return nil;
-
- return kit(coreFrame->document());
-}
-
-- (DOMHTMLElement *)frameElement
-{
- Frame* coreFrame = _private->coreFrame;
- if (!coreFrame)
- return nil;
- return kit(coreFrame->ownerElement());
-}
-
-- (WebDataSource *)provisionalDataSource
-{
- Frame* coreFrame = _private->coreFrame;
- return coreFrame ? dataSource(coreFrame->loader()->provisionalDocumentLoader()) : nil;
-}
-
-- (WebDataSource *)dataSource
-{
- Frame* coreFrame = _private->coreFrame;
- return coreFrame && coreFrame->loader()->frameHasLoaded() ? [self _dataSource] : nil;
-}
-
-- (void)loadRequest:(NSURLRequest *)request
-{
- _private->coreFrame->loader()->load(request);
-}
-
-static NSURL *createUniqueWebDataURL()
-{
- CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
- NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
- CFRelease(UUIDRef);
- NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"applewebdata://%@", UUIDString]];
- CFRelease(UUIDString);
- return URL;
-}
-
-- (void)_loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL unreachableURL:(NSURL *)unreachableURL
-{
- KURL responseURL;
- if (!baseURL) {
- baseURL = blankURL();
- responseURL = createUniqueWebDataURL();
- }
-
- ResourceRequest request([baseURL absoluteURL]);
-
- // hack because Mail checks for this property to detect data / archive loads
- [NSURLProtocol setProperty:@"" forKey:@"WebDataRequest" inRequest:(NSMutableURLRequest *)request.nsURLRequest()];
-
- SubstituteData substituteData(WebCore::SharedBuffer::wrapNSData(data), MIMEType, encodingName, [unreachableURL absoluteURL], responseURL);
-
- _private->coreFrame->loader()->load(request, substituteData);
-}
-
-
-- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL
-{
- if (!MIMEType)
- MIMEType = @"text/html";
- [self _loadData:data MIMEType:MIMEType textEncodingName:encodingName baseURL:baseURL unreachableURL:nil];
-}
-
-- (void)_loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL unreachableURL:(NSURL *)unreachableURL
-{
- NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
- [self _loadData:data MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL unreachableURL:unreachableURL];
-}
-
-- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
-{
- [self _loadHTMLString:string baseURL:baseURL unreachableURL:nil];
-}
-
-- (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL
-{
- [self _loadHTMLString:string baseURL:baseURL unreachableURL:unreachableURL];
-}
-
-- (void)loadArchive:(WebArchive *)archive
-{
- if (LegacyWebArchive* coreArchive = [archive _coreLegacyWebArchive])
- _private->coreFrame->loader()->loadArchive(coreArchive);
-}
-
-- (void)stopLoading
-{
- if (!_private->coreFrame)
- return;
- _private->coreFrame->loader()->stopForUserCancel();
-}
-
-- (void)reload
-{
- _private->coreFrame->loader()->reload();
-}
-
-- (WebFrame *)findFrameNamed:(NSString *)name
-{
- Frame* coreFrame = _private->coreFrame;
- if (!coreFrame)
- return nil;
- return kit(coreFrame->tree()->find(name));
-}
-
-- (WebFrame *)parentFrame
-{
- Frame* coreFrame = _private->coreFrame;
- if (!coreFrame)
- return nil;
- return [[kit(coreFrame->tree()->parent()) retain] autorelease];
-}
-
-- (NSArray *)childFrames
-{
- Frame* coreFrame = _private->coreFrame;
- if (!coreFrame)
- return [NSArray array];
- NSMutableArray *children = [NSMutableArray arrayWithCapacity:coreFrame->tree()->childCount()];
- for (Frame* child = coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling())
- [children addObject:kit(child)];
- return children;
-}
-
-- (WebScriptObject *)windowObject
-{
- Frame* coreFrame = _private->coreFrame;
- if (!coreFrame)
- return 0;
- return coreFrame->script()->windowScriptObject();
-}
-
-- (JSGlobalContextRef)globalContext
-{
- Frame* coreFrame = _private->coreFrame;
- if (!coreFrame)
- return 0;
- return toGlobalRef(coreFrame->script()->globalObject()->globalExec());
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebFrameInternal.h b/WebKit/mac/WebView/WebFrameInternal.h
deleted file mode 100644
index 5cf7690..0000000
--- a/WebKit/mac/WebView/WebFrameInternal.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// This header contains WebFrame declarations that can be used anywhere in WebKit, but are neither SPI nor API.
-
-#import "WebFramePrivate.h"
-#import "WebPreferencesPrivate.h"
-
-#import <WebCore/EditAction.h>
-#import <WebCore/FrameLoaderTypes.h>
-#import <WebCore/SelectionController.h>
-#import <WebCore/Settings.h>
-
-@class DOMCSSStyleDeclaration;
-@class DOMDocumentFragment;
-@class DOMElement;
-@class DOMNode;
-@class DOMRange;
-@class WebFrameView;
-@class WebHistoryItem;
-
-class WebScriptDebugger;
-
-namespace WebCore {
- class CSSStyleDeclaration;
- class Document;
- class DocumentLoader;
- class Element;
- class Frame;
- class Frame;
- class HistoryItem;
- class HTMLElement;
- class HTMLFrameOwnerElement;
- class Node;
- class Page;
- class Range;
-}
-
-typedef WebCore::HistoryItem WebCoreHistoryItem;
-
-WebCore::CSSStyleDeclaration* core(DOMCSSStyleDeclaration *);
-DOMCSSStyleDeclaration *kit(WebCore::CSSStyleDeclaration*);
-
-WebCore::Frame* core(WebFrame *);
-WebFrame *kit(WebCore::Frame *);
-
-WebCore::Element* core(DOMElement *);
-DOMElement *kit(WebCore::Element*);
-
-WebCore::Node* core(DOMNode *);
-DOMNode *kit(WebCore::Node*);
-
-WebCore::Document* core(DOMDocument *);
-DOMDocument *kit(WebCore::Document*);
-
-WebCore::DocumentFragment* core(DOMDocumentFragment *);
-DOMDocumentFragment *kit(WebCore::DocumentFragment*);
-
-WebCore::HTMLElement* core(DOMHTMLElement *);
-DOMHTMLElement *kit(WebCore::HTMLElement*);
-
-WebCore::Range* core(DOMRange *);
-DOMRange *kit(WebCore::Range*);
-
-WebCore::Page* core(WebView *);
-WebView *kit(WebCore::Page*);
-
-WebCore::EditableLinkBehavior core(WebKitEditableLinkBehavior);
-
-WebView *getWebView(WebFrame *webFrame);
-
-@interface WebFramePrivate : NSObject {
-@public
- WebCore::Frame* coreFrame;
- WebFrameView *webFrameView;
- WebScriptDebugger* scriptDebugger;
- id internalLoadDelegate;
- BOOL shouldCreateRenderers;
-}
-@end
-
-@protocol WebCoreRenderTreeCopier <NSObject>
-- (NSObject *)nodeWithName:(NSString *)name position:(NSPoint)position rect:(NSRect)rect view:(NSView *)view children:(NSArray *)children;
-@end
-
-@interface WebFrame (WebInternal)
-
-+ (void)_createMainFrameWithPage:(WebCore::Page*)page frameName:(const WebCore::String&)name frameView:(WebFrameView *)frameView;
-+ (PassRefPtr<WebCore::Frame>)_createSubframeWithOwnerElement:(WebCore::HTMLFrameOwnerElement*)ownerElement frameName:(const WebCore::String&)name frameView:(WebFrameView *)frameView;
-- (id)_initWithWebFrameView:(WebFrameView *)webFrameView webView:(WebView *)webView;
-
-- (void)_clearCoreFrame;
-
-- (void)_updateBackgroundAndUpdatesWhileOffscreen;
-- (void)_setInternalLoadDelegate:(id)internalLoadDelegate;
-- (id)_internalLoadDelegate;
-#ifndef BUILDING_ON_TIGER
-- (void)_unmarkAllBadGrammar;
-#endif
-- (void)_unmarkAllMisspellings;
-
-- (BOOL)_hasSelection;
-- (void)_clearSelection;
-- (WebFrame *)_findFrameWithSelection;
-- (void)_clearSelectionInOtherFrames;
-
-- (void)_attachScriptDebugger;
-- (void)_detachScriptDebugger;
-
-// dataSource reports null for the initial empty document's data source; this is needed
-// to preserve compatibility with Mail and Safari among others. But internal to WebKit,
-// we need to be able to get the initial data source as well, so the _dataSource method
-// should be used instead.
-- (WebDataSource *)_dataSource;
-
-- (BOOL)_needsLayout;
-- (void)_drawRect:(NSRect)rect contentsOnly:(BOOL)contentsOnly;
-- (BOOL)_getVisibleRect:(NSRect*)rect;
-- (NSArray*)_computePageRectsWithPrintWidthScaleFactor:(float)printWidthScaleFactor printHeight:(float)printHeight;
-
-- (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string;
-- (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string forceUserGesture:(BOOL)forceUserGesture;
-
-- (NSString *)_selectedString;
-- (NSString *)_stringForRange:(DOMRange *)range;
-
-- (NSString *)_markupStringFromRange:(DOMRange *)range nodes:(NSArray **)nodes;
-
-- (NSRect)_caretRectAtNode:(DOMNode *)node offset:(int)offset affinity:(NSSelectionAffinity)affinity;
-- (NSRect)_firstRectForDOMRange:(DOMRange *)range;
-- (void)_scrollDOMRangeToVisible:(DOMRange *)range;
-
-- (id)_accessibilityTree;
-
-- (DOMRange *)_rangeByAlteringCurrentSelection:(WebCore::SelectionController::EAlteration)alteration direction:(WebCore::SelectionController::EDirection)direction granularity:(WebCore::TextGranularity)granularity;
-- (void)_smartInsertForString:(NSString *)pasteString replacingRange:(DOMRange *)charRangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString;
-- (NSRange)_convertToNSRange:(WebCore::Range*)range;
-- (DOMRange *)_convertNSRangeToDOMRange:(NSRange)range;
-- (NSRange)_convertDOMRangeToNSRange:(DOMRange *)range;
-
-- (DOMDocumentFragment *)_documentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString;
-- (DOMDocumentFragment *)_documentFragmentWithNodesAsParagraphs:(NSArray *)nodes;
-
-- (void)_replaceSelectionWithFragment:(DOMDocumentFragment *)fragment selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle;
-- (void)_replaceSelectionWithNode:(DOMNode *)node selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle;
-- (void)_replaceSelectionWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace;
-- (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace;
-
-- (void)_insertParagraphSeparatorInQuotedContent;
-
-- (DOMRange *)_characterRangeAtPoint:(NSPoint)point;
-
-- (DOMCSSStyleDeclaration *)_typingStyle;
-- (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction;
-
-- (void)_dragSourceMovedTo:(NSPoint)windowLoc;
-- (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation;
-
-- (BOOL)_canProvideDocumentSource;
-- (BOOL)_canSaveAsWebArchive;
-
-- (void)_receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName;
-
-@end
-
-@interface NSObject (WebInternalFrameLoadDelegate)
-- (void)webFrame:(WebFrame *)webFrame didFinishLoadWithError:(NSError *)error;
-@end
diff --git a/WebKit/mac/WebView/WebFrameLoadDelegate.h b/WebKit/mac/WebView/WebFrameLoadDelegate.h
deleted file mode 100644
index e5f1c7c..0000000
--- a/WebKit/mac/WebView/WebFrameLoadDelegate.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-#import <JavaScriptCore/WebKitAvailability.h>
-
-@class NSError;
-@class WebFrame;
-@class WebScriptObject;
-@class WebView;
-
-/*!
- @category WebFrameLoadDelegate
- @discussion A WebView's WebFrameLoadDelegate tracks the loading progress of its frames.
- When a data source of a frame starts to load, the data source is considered "provisional".
- Once at least one byte is received, the data source is considered "committed". This is done
- so the contents of the frame will not be lost if the new data source fails to successfully load.
-*/
-@interface NSObject (WebFrameLoadDelegate)
-
-/*!
- @method webView:didStartProvisionalLoadForFrame:
- @abstract Notifies the delegate that the provisional load of a frame has started
- @param webView The WebView sending the message
- @param frame The frame for which the provisional load has started
- @discussion This method is called after the provisional data source of a frame
- has started to load.
-*/
-- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didReceiveServerRedirectForProvisionalLoadForFrame:
- @abstract Notifies the delegate that a server redirect occurred during the provisional load
- @param webView The WebView sending the message
- @param frame The frame for which the redirect occurred
-*/
-- (void)webView:(WebView *)sender didReceiveServerRedirectForProvisionalLoadForFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didFailProvisionalLoadWithError:forFrame:
- @abstract Notifies the delegate that the provisional load has failed
- @param webView The WebView sending the message
- @param error The error that occurred
- @param frame The frame for which the error occurred
- @discussion This method is called after the provisional data source has failed to load.
- The frame will continue to display the contents of the committed data source if there is one.
-*/
-- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didCommitLoadForFrame:
- @abstract Notifies the delegate that the load has changed from provisional to committed
- @param webView The WebView sending the message
- @param frame The frame for which the load has committed
- @discussion This method is called after the provisional data source has become the
- committed data source.
-
- In some cases, a single load may be committed more than once. This happens
- in the case of multipart/x-mixed-replace, also known as "server push". In this case,
- a single location change leads to multiple documents that are loaded in sequence. When
- this happens, a new commit will be sent for each document.
-*/
-- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didReceiveTitle:forFrame:
- @abstract Notifies the delegate that the page title for a frame has been received
- @param webView The WebView sending the message
- @param title The new page title
- @param frame The frame for which the title has been received
- @discussion The title may update during loading; clients should be prepared for this.
-*/
-- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didReceiveIcon:forFrame:
- @abstract Notifies the delegate that a page icon image for a frame has been received
- @param webView The WebView sending the message
- @param image The icon image. Also known as a "favicon".
- @param frame The frame for which a page icon has been received
-*/
-- (void)webView:(WebView *)sender didReceiveIcon:(NSImage *)image forFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didFinishLoadForFrame:
- @abstract Notifies the delegate that the committed load of a frame has completed
- @param webView The WebView sending the message
- @param frame The frame that finished loading
- @discussion This method is called after the committed data source of a frame has successfully loaded
- and will only be called when all subresources such as images and stylesheets are done loading.
- Plug-In content and JavaScript-requested loads may occur after this method is called.
-*/
-- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didFailLoadWithError:forFrame:
- @abstract Notifies the delegate that the committed load of a frame has failed
- @param webView The WebView sending the message
- @param error The error that occurred
- @param frame The frame that failed to load
- @discussion This method is called after a data source has committed but failed to completely load.
-*/
-- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didChangeLocationWithinPageForFrame:
- @abstract Notifies the delegate that the scroll position in a frame has changed
- @param webView The WebView sending the message
- @param frame The frame that scrolled
- @discussion This method is called when anchors within a page have been clicked.
-*/
-- (void)webView:(WebView *)sender didChangeLocationWithinPageForFrame:(WebFrame *)frame;
-
-/*!
- @method webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:
- @abstract Notifies the delegate that a frame will perform a client-side redirect
- @param webView The WebView sending the message
- @param URL The URL to be redirected to
- @param seconds Seconds in which the redirect will happen
- @param date The fire date
- @param frame The frame on which the redirect will occur
- @discussion This method can be used to continue progress feedback while a client-side
- redirect is pending.
-*/
-- (void)webView:(WebView *)sender willPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date forFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didCancelClientRedirectForFrame:
- @abstract Notifies the delegate that a pending client-side redirect has been cancelled
- @param webView The WebView sending the message
- @param frame The frame for which the pending redirect was cancelled
- @discussion A client-side redirect can be cancelled if a frame changes location before the timeout.
-*/
-- (void)webView:(WebView *)sender didCancelClientRedirectForFrame:(WebFrame *)frame;
-
-/*!
- @method webView:willCloseFrame:
- @abstract Notifies the delegate that a frame will be closed
- @param webView The WebView sending the message
- @param frame The frame that will be closed
- @discussion This method is called right before WebKit is done with the frame
- and the objects that it contains.
-*/
-- (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame;
-
-/*!
- @method webView:didClearWindowObject:forFrame:
- @abstract Notifies the delegate that the JavaScript window object in a frame has
- been cleared in preparation for a new load. This is the preferred place to set custom
- properties on the window object using the WebScriptObject and JavaScriptCore APIs.
- @param webView The webView sending the message.
- @param windowObject The WebScriptObject representing the frame's JavaScript window object.
- @param frame The WebFrame to which windowObject belongs.
- @discussion If a delegate implements both webView:didClearWindowObject:forFrame:
- and webView:windowScriptObjectAvailable:, only webView:didClearWindowObject:forFrame:
- will be invoked. This enables a delegate to implement both methods for backwards
- compatibility with older versions of WebKit.
-*/
-- (void)webView:(WebView *)webView didClearWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame;
-
-/*!
- @method webView:windowScriptObjectAvailable:
- @abstract Notifies the delegate that the scripting object for a page is available. This is called
- before the page is loaded. It may be useful to allow delegates to bind native objects to the window.
- @param webView The webView sending the message.
- @param windowScriptObject The WebScriptObject for the window in the scripting environment.
- @discussion This method is deprecated. Consider using webView:didClearWindowObject:forFrame:
- instead.
-*/
-- (void)webView:(WebView *)webView windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0);
-
-@end
diff --git a/WebKit/mac/WebView/WebFramePrivate.h b/WebKit/mac/WebView/WebFramePrivate.h
deleted file mode 100644
index 428c142..0000000
--- a/WebKit/mac/WebView/WebFramePrivate.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// This header contains the WebFrame SPI.
-
-#import <WebKit/WebFrame.h>
-#import <JavaScriptCore/JSBase.h>
-
-#if !defined(ENABLE_NETSCAPE_PLUGIN_API)
-#define ENABLE_NETSCAPE_PLUGIN_API 1
-#endif
-
-@class WebIconFetcher;
-@class WebScriptObject;
-
-// Keys for accessing the values in the page cache dictionary.
-extern NSString *WebPageCacheEntryDateKey;
-extern NSString *WebPageCacheDataSourceKey;
-extern NSString *WebPageCacheDocumentViewKey;
-
-typedef enum {
- WebFrameLoadTypeStandard,
- WebFrameLoadTypeBack,
- WebFrameLoadTypeForward,
- WebFrameLoadTypeIndexedBackForward, // a multi-item hop in the backforward list
- WebFrameLoadTypeReload,
- WebFrameLoadTypeReloadAllowingStaleData,
- WebFrameLoadTypeSame, // user loads same URL again (but not reload button)
- WebFrameLoadTypeInternal, // maps to WebCore::FrameLoadTypeRedirectWithLockedHistory
- WebFrameLoadTypeReplace
-} WebFrameLoadType;
-
-@interface WebFrame (WebPrivate)
-- (BOOL)_isDescendantOfFrame:(WebFrame *)frame;
-- (void)_setShouldCreateRenderers:(BOOL)f;
-- (NSColor *)_bodyBackgroundColor;
-- (BOOL)_isFrameSet;
-- (BOOL)_firstLayoutDone;
-- (WebFrameLoadType)_loadType;
-
-// These methods take and return NSRanges based on the root editable element as the positional base.
-// This fits with AppKit's idea of an input context. These methods are slow compared to their DOMRange equivalents.
-// You should use WebView's selectedDOMRange and setSelectedDOMRange whenever possible.
-- (NSRange)_selectedNSRange;
-- (void)_selectNSRange:(NSRange)range;
-
-- (BOOL)_isDisplayingStandaloneImage;
-
-- (unsigned) _pendingFrameUnloadEventCount;
-
-- (WebIconFetcher *)fetchApplicationIcon:(id)target
- selector:(SEL)selector;
-
-- (void)_setIsDisconnected:(bool)isDisconnected;
-- (void)_setExcludeFromTextSearch:(bool)exclude;
-
-#if ENABLE_NETSCAPE_PLUGIN_API
-- (void)_recursive_resumeNullEventsForAllNetscapePlugins;
-- (void)_recursive_pauseNullEventsForAllNetscapePlugins;
-#endif
-
-@end
diff --git a/WebKit/mac/WebView/WebFrameView.h b/WebKit/mac/WebView/WebFrameView.h
deleted file mode 100644
index e170403..0000000
--- a/WebKit/mac/WebView/WebFrameView.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-@class WebDataSource;
-@class WebFrame;
-@class WebFrameViewPrivate;
-
-@protocol WebDocumentView;
-
-/*!
- @class WebFrameView
-*/
-@interface WebFrameView : NSView
-{
-@private
- WebFrameViewPrivate *_private;
-}
-
-/*!
- @method webFrame
- @abstract Returns the WebFrame associated with this WebFrameView
- @result The WebFrameView's frame.
-*/
-- (WebFrame *)webFrame;
-
-/*!
- @method documentView
- @abstract Returns the WebFrameView's document subview
- @result The subview that renders the WebFrameView's contents
-*/
-- (NSView <WebDocumentView> *)documentView;
-
-/*!
- @method setAllowsScrolling:
- @abstract Sets whether the WebFrameView allows its document to be scrolled
- @param flag YES to allow the document to be scrolled, NO to disallow scrolling
-*/
-- (void)setAllowsScrolling:(BOOL)flag;
-
-/*!
- @method allowsScrolling
- @abstract Returns whether the WebFrameView allows its document to be scrolled
- @result YES if the document is allowed to scroll, otherwise NO
-*/
-- (BOOL)allowsScrolling;
-
-/*!
- @method canPrintHeadersAndFooters
- @abstract Tells whether this frame can print headers and footers
- @result YES if the frame can, no otherwise
-*/
-- (BOOL)canPrintHeadersAndFooters;
-
-/*!
- @method printOperationWithPrintInfo
- @abstract Creates a print operation set up to print this frame
- @result A newly created print operation object
-*/
-- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo;
-
-/*!
- @method documentViewShouldHandlePrint
- @abstract Called by the host application before it initializes and runs a print operation.
- @result If NO is returned, the host application will abort its print operation and call -printDocumentView on the
- WebFrameView. The document view is then expected to run its own print operation. If YES is returned, the host
- application's print operation will continue as normal.
-*/
-- (BOOL)documentViewShouldHandlePrint;
-
-/*!
- @method printDocumentView
- @abstract Called by the host application when the WebFrameView returns YES from -documentViewShouldHandlePrint.
-*/
-- (void)printDocumentView;
-
-@end
diff --git a/WebKit/mac/WebView/WebFrameView.mm b/WebKit/mac/WebView/WebFrameView.mm
deleted file mode 100644
index e9c0aae..0000000
--- a/WebKit/mac/WebView/WebFrameView.mm
+++ /dev/null
@@ -1,984 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebFrameView.h"
-
-#import "WebClipView.h"
-#import "WebDataSourcePrivate.h"
-#import "WebDocument.h"
-#import "WebDynamicScrollBarsViewInternal.h"
-#import "WebFrame.h"
-#import "WebFrameInternal.h"
-#import "WebFrameViewInternal.h"
-#import "WebFrameViewPrivate.h"
-#import "WebHistoryItemInternal.h"
-#import "WebHTMLViewPrivate.h"
-#import "WebKeyGenerator.h"
-#import "WebKitErrorsPrivate.h"
-#import "WebKitStatisticsPrivate.h"
-#import "WebKitVersionChecks.h"
-#import "WebNSDictionaryExtras.h"
-#import "WebNSObjectExtras.h"
-#import "WebNSPasteboardExtras.h"
-#import "WebNSViewExtras.h"
-#import "WebNSWindowExtras.h"
-#import "WebPDFView.h"
-#import "WebPreferenceKeysPrivate.h"
-#import "WebSystemInterface.h"
-#import "WebViewFactory.h"
-#import "WebViewInternal.h"
-#import "WebViewPrivate.h"
-#import <Foundation/NSURLRequest.h>
-#import <WebCore/DragController.h>
-#import <WebCore/EventHandler.h>
-#import <WebCore/Frame.h>
-#import <WebCore/FrameView.h>
-#import <WebCore/HistoryItem.h>
-#import <WebCore/Page.h>
-#import <WebCore/RenderPart.h>
-#import <WebCore/ThreadCheck.h>
-#import <WebCore/WebCoreFrameView.h>
-#import <WebCore/WebCoreView.h>
-#import <WebKitSystemInterface.h>
-#import <wtf/Assertions.h>
-
-using namespace WebCore;
-
-@interface NSWindow (WindowPrivate)
-- (BOOL)_needsToResetDragMargins;
-- (void)_setNeedsToResetDragMargins:(BOOL)s;
-@end
-
-@interface NSClipView (AppKitSecretsIKnow)
-- (BOOL)_scrollTo:(const NSPoint *)newOrigin animate:(BOOL)animate; // need the boolean result from this method
-@end
-
-enum {
- SpaceKey = 0x0020
-};
-
-@interface WebFrameView (WebFrameViewFileInternal) <WebCoreFrameView>
-- (float)_verticalKeyboardScrollDistance;
-@end
-
-@interface WebFrameViewPrivate : NSObject {
-@public
- WebFrame *webFrame;
- WebDynamicScrollBarsView *frameScrollView;
-}
-@end
-
-@implementation WebFrameViewPrivate
-
-- (void)dealloc
-{
- [frameScrollView release];
- [super dealloc];
-}
-
-@end
-
-@implementation WebFrameView (WebFrameViewFileInternal)
-
-- (float)_verticalKeyboardScrollDistance
-{
- // Arrow keys scroll the same distance that clicking the scroll arrow does.
- return [[self _scrollView] verticalLineScroll];
-}
-
-- (Frame*)_web_frame
-{
- return core(_private->webFrame);
-}
-
-@end
-
-@implementation WebFrameView (WebInternal)
-
-// Note that the WebVew is not retained.
-- (WebView *)_webView
-{
- return [_private->webFrame webView];
-}
-
-- (void)_setDocumentView:(NSView <WebDocumentView> *)view
-{
- WebDynamicScrollBarsView *sv = [self _scrollView];
- core([self _webView])->dragController()->setDidInitiateDrag(false);
-
- [sv setSuppressLayout:YES];
-
- // If the old view is the first responder, transfer first responder status to the new view as
- // a convenience and so that we don't leave the window pointing to a view that's no longer in it.
- NSWindow *window = [sv window];
- NSResponder *firstResponder = [window firstResponder];
- bool makeNewViewFirstResponder = [firstResponder isKindOfClass:[NSView class]] && [(NSView *)firstResponder isDescendantOf:[sv documentView]];
-
- // Suppress the resetting of drag margins since we know we can't affect them.
- BOOL resetDragMargins = [window _needsToResetDragMargins];
- [window _setNeedsToResetDragMargins:NO];
- [sv setDocumentView:view];
- [window _setNeedsToResetDragMargins:resetDragMargins];
-
- if (makeNewViewFirstResponder)
- [window makeFirstResponder:view];
- [sv setSuppressLayout:NO];
-}
-
--(NSView <WebDocumentView> *)_makeDocumentViewForDataSource:(WebDataSource *)dataSource
-{
- NSString* MIMEType = [dataSource _responseMIMEType];
- if (!MIMEType)
- MIMEType = @"text/html";
- Class viewClass = [[self class] _viewClassForMIMEType:MIMEType];
- NSView <WebDocumentView> *documentView;
- if (viewClass) {
- // If the dataSource's representation has already been created, and it is also the
- // same class as the desired documentView, then use it as the documentView instead
- // of creating another one (Radar 4340787).
- id <WebDocumentRepresentation> dataSourceRepresentation = [dataSource representation];
- if (dataSourceRepresentation && [dataSourceRepresentation class] == viewClass)
- documentView = (NSView <WebDocumentView> *)[dataSourceRepresentation retain];
- else
- documentView = [[viewClass alloc] initWithFrame:[self bounds]];
- } else
- documentView = nil;
-
- [self _setDocumentView:documentView];
- [documentView release];
-
- return documentView;
-}
-
-- (void)_setWebFrame:(WebFrame *)webFrame
-{
- if (!webFrame) {
- NSView *docV = [self documentView];
- if ([docV respondsToSelector:@selector(close)])
- [docV performSelector:@selector(close)];
- }
-
- // Not retained because the WebView owns the WebFrame, which owns the WebFrameView.
- _private->webFrame = webFrame;
-}
-
-- (WebDynamicScrollBarsView *)_scrollView
-{
- // this can be called by [super dealloc] when cleaning up the keyview loop,
- // after _private has been nilled out.
- if (_private == nil) {
- return nil;
- }
- return _private->frameScrollView;
-}
-
-- (float)_verticalPageScrollDistance
-{
- float overlap = [self _verticalKeyboardScrollDistance];
- float height = [[self _contentView] bounds].size.height;
- return (height < overlap) ? height / 2 : height - overlap;
-}
-
-static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCClass, 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:objCClass forKey:mime];
- }
-}
-
-+ (NSMutableDictionary *)_viewTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission
-{
- static NSMutableDictionary *viewTypes = nil;
- static BOOL addedImageTypes = NO;
-
- if (!viewTypes) {
- viewTypes = [[NSMutableDictionary alloc] init];
- addTypesFromClass(viewTypes, [WebHTMLView class], [WebHTMLView supportedNonImageMIMETypes]);
-
- // Since this is a "secret default" we don't bother registering it.
- BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
- if (!omitPDFSupport)
- addTypesFromClass(viewTypes, [WebPDFView class], [WebPDFView supportedMIMETypes]);
- }
-
- if (!addedImageTypes && !allowImageTypeOmission) {
- addTypesFromClass(viewTypes, [WebHTMLView class], [WebHTMLView supportedImageMIMETypes]);
- addedImageTypes = YES;
- }
-
- return viewTypes;
-}
-
-+ (BOOL)_canShowMIMETypeAsHTML:(NSString *)MIMEType
-{
- return [[[self _viewTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType] isSubclassOfClass:[WebHTMLView class]];
-}
-
-+ (Class)_viewClassForMIMEType:(NSString *)MIMEType
-{
- Class viewClass;
- return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType] ? viewClass : nil;
-}
-
-- (void)_install
-{
- ASSERT(_private->webFrame);
- ASSERT(_private->frameScrollView);
-
- Frame* frame = core(_private->webFrame);
-
- ASSERT(frame);
- ASSERT(frame->page());
-
- // If this isn't the main frame, it must have an owner element set, or it
- // won't ever get installed in the view hierarchy.
- ASSERT(frame == frame->page()->mainFrame() || frame->ownerElement());
-
- FrameView* view = frame->view();
-
- view->setPlatformWidget(_private->frameScrollView);
-
- // FIXME: Frame tries to do this too. Is this code needed?
- if (RenderPart* owner = frame->ownerRenderer()) {
- owner->setWidget(view);
- // Now the render part owns the view, so we don't any more.
- }
-
- view->initScrollbars();
-}
-
-@end
-
-@implementation WebFrameView
-
-- initWithCoder:(NSCoder *)decoder
-{
- // Older nibs containing WebViews will also contain WebFrameViews. We need to keep track of
- // their count also to match the decrement in -dealloc.
- ++WebFrameViewCount;
- return [super initWithCoder:decoder];
-}
-
-- initWithFrame:(NSRect)frame
-{
- self = [super initWithFrame:frame];
- if (!self)
- return nil;
-
- static bool didFirstTimeInitialization;
- if (!didFirstTimeInitialization) {
- didFirstTimeInitialization = true;
- InitWebCoreSystemInterface();
-
- // Need to tell WebCore what function to call for the
- // "History Item has Changed" notification
- // Note: We also do this in WebHistoryItem's init method
- WebCore::notifyHistoryItemChanged = WKNotifyHistoryItemChanged;
-
- [WebViewFactory createSharedFactory];
- [WebKeyGenerator createSharedGenerator];
-
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-
- // CoreGraphics deferred updates are disabled if WebKitEnableCoalescedUpdatesPreferenceKey is set
- // to NO, or has no value. For compatibility with Mac OS X 10.4.6, deferred updates are OFF by
- // default.
- if (![defaults boolForKey:WebKitEnableDeferredUpdatesPreferenceKey])
- WKDisableCGDeferredUpdates();
-
- if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_MAIN_THREAD_EXCEPTIONS))
- setDefaultThreadViolationBehavior(LogOnFirstThreadViolation);
- }
-
- _private = [[WebFrameViewPrivate alloc] init];
-
- WebDynamicScrollBarsView *scrollView = [[WebDynamicScrollBarsView alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, frame.size.width, frame.size.height)];
- _private->frameScrollView = scrollView;
- [scrollView setContentView:[[[WebClipView alloc] initWithFrame:[scrollView bounds]] autorelease]];
- [scrollView setDrawsBackground:NO];
- [scrollView setHasVerticalScroller:NO];
- [scrollView setHasHorizontalScroller:NO];
- [scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
- [scrollView setLineScroll:40.0f];
- [self addSubview:scrollView];
- // don't call our overridden version here; we need to make the standard NSView link between us
- // and our subview so that previousKeyView and previousValidKeyView work as expected. This works
- // together with our becomeFirstResponder and setNextKeyView overrides.
- [super setNextKeyView:scrollView];
-
- ++WebFrameViewCount;
-
- return self;
-}
-
-- (void)dealloc
-{
- --WebFrameViewCount;
-
- [_private release];
- _private = nil;
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- --WebFrameViewCount;
-
- [super finalize];
-}
-
-- (WebFrame *)webFrame
-{
- return _private->webFrame;
-}
-
-- (void)setAllowsScrolling:(BOOL)flag
-{
- WebCore::Frame *frame = core([self webFrame]);
- if (WebCore::FrameView *view = frame? frame->view() : 0)
- view->setCanHaveScrollbars(flag);
-}
-
-- (BOOL)allowsScrolling
-{
- WebCore::Frame *frame = core([self webFrame]);
- if (WebCore::FrameView *view = frame? frame->view() : 0)
- return view->canHaveScrollbars();
- return YES;
-}
-
-- (NSView <WebDocumentView> *)documentView
-{
- return [[self _scrollView] documentView];
-}
-
-- (BOOL)acceptsFirstResponder
-{
- // We always accept first responder; this matches OS X 10.2 WebKit
- // behavior (see 3469791).
- return YES;
-}
-
-- (BOOL)becomeFirstResponder
-{
- // This works together with setNextKeyView to splice the WebFrameView into
- // the key loop similar to the way NSScrollView does this. Note that
- // WebView has similar code.
-
- // If the scrollView won't accept first-responderness now, then we just become
- // the first responder ourself like a normal view. This lets us be the first
- // responder in cases where no page has yet been loaded (see 3469791).
- if ([[self _scrollView] acceptsFirstResponder]) {
- NSWindow *window = [self window];
- if ([window keyViewSelectionDirection] == NSSelectingPrevious) {
- NSView *previousValidKeyView = [self previousValidKeyView];
- // If we couldn't find a previous valid key view, ask the webview. This handles frameset
- // cases like 3748628. Note that previousValidKeyView should never be self but can be
- // due to AppKit oddness (mentioned in 3748628).
- if (previousValidKeyView == nil || previousValidKeyView == self) {
- previousValidKeyView = [[[self webFrame] webView] previousValidKeyView];
- }
- // I don't know if the following cases ever occur anymore, but I'm leaving in the old test for
- // now to avoid causing trouble just before shipping Tiger.
- ASSERT((previousValidKeyView != self) && (previousValidKeyView != [self _scrollView]));
- if ((previousValidKeyView != self) && (previousValidKeyView != [self _scrollView])) {
- [window makeFirstResponder:previousValidKeyView];
- }
- } else {
- [window makeFirstResponder:[self _scrollView]];
- }
- }
-
- return YES;
-}
-
-- (void)setNextKeyView:(NSView *)aView
-{
- // This works together with becomeFirstResponder to splice the WebFrameView into
- // the key loop similar to the way NSScrollView does this. Note that
- // WebView has very similar code.
- if ([self _scrollView] != nil) {
- [[self _scrollView] setNextKeyView:aView];
- } else {
- [super setNextKeyView:aView];
- }
-}
-
-- (BOOL)isOpaque
-{
- return [[self _webView] drawsBackground];
-}
-
-- (void)drawRect:(NSRect)rect
-{
- if ([self documentView] == nil) {
- // Need to paint ourselves if there's no documentView to do it instead.
- if ([[self _webView] drawsBackground]) {
- [[[self _webView] backgroundColor] set];
- NSRectFill(rect);
- }
- } else {
-#ifndef NDEBUG
- if ([[self _scrollView] drawsBackground]) {
- [[NSColor cyanColor] set];
- NSRectFill(rect);
- }
-#endif
- }
-}
-
-- (NSRect)visibleRect
-{
- // This method can be called beneath -[NSView dealloc] after we have cleared _private.
- if (!_private)
- return [super visibleRect];
-
- // FIXME: <rdar://problem/6213380> This method does not work correctly with transforms, for two reasons:
- // 1) [super visibleRect] does not account for the transform, since it is not represented
- // in the NSView hierarchy.
- // 2) -_getVisibleRect: does not correct for transforms.
-
- NSRect rendererVisibleRect;
- if (![[self webFrame] _getVisibleRect:&rendererVisibleRect])
- return [super visibleRect];
-
- if (NSIsEmptyRect(rendererVisibleRect))
- return NSZeroRect;
-
- NSRect viewVisibleRect = [super visibleRect];
- if (NSIsEmptyRect(viewVisibleRect))
- return NSZeroRect;
-
- NSRect frame = [self frame];
- // rendererVisibleRect is in the parent's coordinate space, and frame is in the superview's coordinate space.
- // The return value from this method needs to be in this view's coordinate space. We get that right by subtracting
- // the origins (and correcting for flipping), but when we support transforms, we will need to do better than this.
- rendererVisibleRect.origin.x -= frame.origin.x;
- rendererVisibleRect.origin.y = NSMaxY(frame) - NSMaxY(rendererVisibleRect);
- return NSIntersectionRect(rendererVisibleRect, viewVisibleRect);
-}
-
-- (void)setFrameSize:(NSSize)size
-{
- if (!NSEqualSizes(size, [self frame].size) && [[[self webFrame] webView] drawsBackground]) {
- [[self _scrollView] setDrawsBackground:YES];
- }
- [super setFrameSize:size];
-}
-
-- (BOOL)_scrollOverflowInDirection:(ScrollDirection)direction granularity:(ScrollGranularity)granularity
-{
- // scrolling overflows is only applicable if we're dealing with an WebHTMLView
- if (![[self documentView] isKindOfClass:[WebHTMLView class]])
- return NO;
- Frame* frame = core([self webFrame]);
- if (!frame)
- return NO;
- return frame->eventHandler()->scrollOverflow(direction, granularity);
-}
-
-- (void)scrollToBeginningOfDocument:(id)sender
-{
- if (![self _scrollOverflowInDirection:ScrollUp granularity:ScrollByDocument]) {
-
- if (![self _hasScrollBars]) {
- [[self _largestChildWithScrollBars] scrollToBeginningOfDocument:sender];
- return;
- }
-
- [[self _contentView] scrollPoint:[[[self _scrollView] documentView] frame].origin];
- }
-}
-
-- (void)scrollToEndOfDocument:(id)sender
-{
- if (![self _scrollOverflowInDirection:ScrollDown granularity:ScrollByDocument]) {
-
- if (![self _hasScrollBars]) {
- [[self _largestChildWithScrollBars] scrollToEndOfDocument:sender];
- return;
- }
-
- NSRect frame = [[[self _scrollView] documentView] frame];
- [[self _contentView] scrollPoint:NSMakePoint(frame.origin.x, NSMaxY(frame))];
- }
-}
-
-- (void)_goBack
-{
- [[self _webView] goBack];
-}
-
-- (void)_goForward
-{
- [[self _webView] goForward];
-}
-
-- (BOOL)_scrollVerticallyBy:(float)delta
-{
- // This method uses the secret method _scrollTo on NSClipView.
- // It does that because it needs to know definitively whether scrolling was
- // done or not to help implement the "scroll parent if we are at the limit" feature.
- // In the presence of smooth scrolling, there's no easy way to tell if the method
- // did any scrolling or not with the public API.
- NSPoint point = [[self _contentView] bounds].origin;
- point.y += delta;
- return [[self _contentView] _scrollTo:&point animate:YES];
-}
-
-- (BOOL)_scrollHorizontallyBy:(float)delta
-{
- NSPoint point = [[self _contentView] bounds].origin;
- point.x += delta;
- return [[self _contentView] _scrollTo:&point animate:YES];
-}
-
-- (float)_horizontalKeyboardScrollDistance
-{
- // Arrow keys scroll the same distance that clicking the scroll arrow does.
- return [[self _scrollView] horizontalLineScroll];
-}
-
-- (float)_horizontalPageScrollDistance
-{
- float overlap = [self _horizontalKeyboardScrollDistance];
- float width = [[self _contentView] bounds].size.width;
- return (width < overlap) ? width / 2 : width - overlap;
-}
-
-- (BOOL)_pageVertically:(BOOL)up
-{
- if ([self _scrollOverflowInDirection:up ? ScrollUp : ScrollDown granularity:ScrollByPage])
- return YES;
-
- if (![self _hasScrollBars])
- return [[self _largestChildWithScrollBars] _pageVertically:up];
-
- float delta = [self _verticalPageScrollDistance];
- return [self _scrollVerticallyBy:up ? -delta : delta];
-}
-
-- (BOOL)_pageHorizontally:(BOOL)left
-{
- if ([self _scrollOverflowInDirection:left ? ScrollLeft : ScrollRight granularity:ScrollByPage])
- return YES;
-
- if (![self _hasScrollBars])
- return [[self _largestChildWithScrollBars] _pageHorizontally:left];
-
- float delta = [self _horizontalPageScrollDistance];
- return [self _scrollHorizontallyBy:left ? -delta : delta];
-}
-
-- (BOOL)_scrollLineVertically:(BOOL)up
-{
- if ([self _scrollOverflowInDirection:up ? ScrollUp : ScrollDown granularity:ScrollByLine])
- return YES;
-
- if (![self _hasScrollBars])
- return [[self _largestChildWithScrollBars] _scrollLineVertically:up];
-
- float delta = [self _verticalKeyboardScrollDistance];
- return [self _scrollVerticallyBy:up ? -delta : delta];
-}
-
-- (BOOL)_scrollLineHorizontally:(BOOL)left
-{
- if ([self _scrollOverflowInDirection:left ? ScrollLeft : ScrollRight granularity:ScrollByLine])
- return YES;
-
- if (![self _hasScrollBars])
- return [[self _largestChildWithScrollBars] _scrollLineHorizontally:left];
-
- float delta = [self _horizontalKeyboardScrollDistance];
- return [self _scrollHorizontallyBy:left ? -delta : delta];
-}
-
-- (void)scrollPageUp:(id)sender
-{
- if (![self _pageVertically:YES]) {
- // If we were already at the top, tell the next responder to scroll if it can.
- [[self nextResponder] tryToPerform:@selector(scrollPageUp:) with:sender];
- }
-}
-
-- (void)scrollPageDown:(id)sender
-{
- if (![self _pageVertically:NO]) {
- // If we were already at the bottom, tell the next responder to scroll if it can.
- [[self nextResponder] tryToPerform:@selector(scrollPageDown:) with:sender];
- }
-}
-
-- (void)scrollLineUp:(id)sender
-{
- [self _scrollLineVertically:YES];
-}
-
-- (void)scrollLineDown:(id)sender
-{
- [self _scrollLineVertically:NO];
-}
-
-- (BOOL)_firstResponderIsFormControl
-{
- NSResponder *firstResponder = [[self window] firstResponder];
-
- // WebHTMLView is an NSControl subclass these days, but it's not a form control
- if ([firstResponder isKindOfClass:[WebHTMLView class]]) {
- return NO;
- }
- return [firstResponder isKindOfClass:[NSControl class]];
-}
-
-- (void)keyDown:(NSEvent *)event
-{
- NSString *characters = [event characters];
- int index, count;
- BOOL callSuper = YES;
- Frame* coreFrame = [self _web_frame];
- BOOL maintainsBackForwardList = coreFrame && coreFrame->page()->backForwardList()->enabled() ? YES : NO;
-
- count = [characters length];
- for (index = 0; index < count; ++index) {
- switch ([characters characterAtIndex:index]) {
- case NSDeleteCharacter:
- if (!maintainsBackForwardList) {
- callSuper = YES;
- break;
- }
- // This odd behavior matches some existing browsers,
- // including Windows IE
- if ([event modifierFlags] & NSShiftKeyMask) {
- [self _goForward];
- } else {
- [self _goBack];
- }
- callSuper = NO;
- break;
- case SpaceKey:
- // Checking for a control will allow events to percolate
- // correctly when the focus is on a form control and we
- // are in full keyboard access mode.
- if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) || [self _firstResponderIsFormControl]) {
- callSuper = YES;
- break;
- }
- if ([event modifierFlags] & NSShiftKeyMask) {
- [self scrollPageUp:nil];
- } else {
- [self scrollPageDown:nil];
- }
- callSuper = NO;
- break;
- case NSPageUpFunctionKey:
- if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) {
- callSuper = YES;
- break;
- }
- [self scrollPageUp:nil];
- callSuper = NO;
- break;
- case NSPageDownFunctionKey:
- if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) {
- callSuper = YES;
- break;
- }
- [self scrollPageDown:nil];
- callSuper = NO;
- break;
- case NSHomeFunctionKey:
- if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) {
- callSuper = YES;
- break;
- }
- [self scrollToBeginningOfDocument:nil];
- callSuper = NO;
- break;
- case NSEndFunctionKey:
- if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) {
- callSuper = YES;
- break;
- }
- [self scrollToEndOfDocument:nil];
- callSuper = NO;
- break;
- case NSUpArrowFunctionKey:
- // We don't handle shifted or control-arrow keys here, so let super have a chance.
- if ([event modifierFlags] & (NSShiftKeyMask | NSControlKeyMask)) {
- callSuper = YES;
- break;
- }
- if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) ||
- [[[self window] firstResponder] isKindOfClass:[NSPopUpButton class]]) {
- // Let arrow keys go through to pop up buttons
- // <rdar://problem/3455910>: hitting up or down arrows when focus is on a
- // pop-up menu should pop the menu
- callSuper = YES;
- break;
- }
- if ([event modifierFlags] & NSCommandKeyMask) {
- [self scrollToBeginningOfDocument:nil];
- } else if ([event modifierFlags] & NSAlternateKeyMask) {
- [self scrollPageUp:nil];
- } else {
- [self scrollLineUp:nil];
- }
- callSuper = NO;
- break;
- case NSDownArrowFunctionKey:
- // We don't handle shifted or control-arrow keys here, so let super have a chance.
- if ([event modifierFlags] & (NSShiftKeyMask | NSControlKeyMask)) {
- callSuper = YES;
- break;
- }
- if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) ||
- [[[self window] firstResponder] isKindOfClass:[NSPopUpButton class]]) {
- // Let arrow keys go through to pop up buttons
- // <rdar://problem/3455910>: hitting up or down arrows when focus is on a
- // pop-up menu should pop the menu
- callSuper = YES;
- break;
- }
- if ([event modifierFlags] & NSCommandKeyMask) {
- [self scrollToEndOfDocument:nil];
- } else if ([event modifierFlags] & NSAlternateKeyMask) {
- [self scrollPageDown:nil];
- } else {
- [self scrollLineDown:nil];
- }
- callSuper = NO;
- break;
- case NSLeftArrowFunctionKey:
- // We don't handle shifted or control-arrow keys here, so let super have a chance.
- if ([event modifierFlags] & (NSShiftKeyMask | NSControlKeyMask)) {
- callSuper = YES;
- break;
- }
- // Check back/forward related keys.
- if ([event modifierFlags] & NSCommandKeyMask) {
- if (!maintainsBackForwardList) {
- callSuper = YES;
- break;
- }
- [self _goBack];
- } else {
- // Now check scrolling related keys.
- if ((![self allowsScrolling] && ![self _largestChildWithScrollBars])) {
- callSuper = YES;
- break;
- }
-
- if ([event modifierFlags] & NSAlternateKeyMask) {
- [self _pageHorizontally:YES];
- } else {
- [self _scrollLineHorizontally:YES];
- }
- }
- callSuper = NO;
- break;
- case NSRightArrowFunctionKey:
- // We don't handle shifted or control-arrow keys here, so let super have a chance.
- if ([event modifierFlags] & (NSShiftKeyMask | NSControlKeyMask)) {
- callSuper = YES;
- break;
- }
- // Check back/forward related keys.
- if ([event modifierFlags] & NSCommandKeyMask) {
- if (!maintainsBackForwardList) {
- callSuper = YES;
- break;
- }
- [self _goForward];
- } else {
- // Now check scrolling related keys.
- if ((![self allowsScrolling] && ![self _largestChildWithScrollBars])) {
- callSuper = YES;
- break;
- }
-
- if ([event modifierFlags] & NSAlternateKeyMask) {
- [self _pageHorizontally:NO];
- } else {
- [self _scrollLineHorizontally:NO];
- }
- }
- callSuper = NO;
- break;
- }
- }
-
- if (callSuper) {
- [super keyDown:event];
- } else {
- // if we did something useful, get the cursor out of the way
- [NSCursor setHiddenUntilMouseMoves:YES];
- }
-}
-
-- (NSView *)_webcore_effectiveFirstResponder
-{
- NSView *view = [self documentView];
- return view ? [view _webcore_effectiveFirstResponder] : [super _webcore_effectiveFirstResponder];
-}
-
-- (BOOL)canPrintHeadersAndFooters
-{
- NSView *documentView = [[self _scrollView] documentView];
- if ([documentView respondsToSelector:@selector(canPrintHeadersAndFooters)]) {
- return [(id)documentView canPrintHeadersAndFooters];
- }
- return NO;
-}
-
-- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo
-{
- NSView *documentView = [[self _scrollView] documentView];
- if (!documentView) {
- return nil;
- }
- if ([documentView respondsToSelector:@selector(printOperationWithPrintInfo:)]) {
- return [(id)documentView printOperationWithPrintInfo:printInfo];
- }
- return [NSPrintOperation printOperationWithView:documentView printInfo:printInfo];
-}
-
-- (BOOL)documentViewShouldHandlePrint
-{
- NSView *documentView = [[self _scrollView] documentView];
- if (documentView && [documentView respondsToSelector:@selector(documentViewShouldHandlePrint)])
- return [(id)documentView documentViewShouldHandlePrint];
-
- return NO;
-}
-
-- (void)printDocumentView
-{
- NSView *documentView = [[self _scrollView] documentView];
- if (documentView && [documentView respondsToSelector:@selector(printDocumentView)])
- [(id)documentView printDocumentView];
-}
-
-@end
-
-@implementation WebFrameView (WebPrivate)
-
-- (float)_area
-{
- NSRect frame = [self frame];
- return frame.size.height * frame.size.width;
-}
-
-- (BOOL)_hasScrollBars
-{
- NSScrollView *scrollView = [self _scrollView];
- return [scrollView hasHorizontalScroller] || [scrollView hasVerticalScroller];
-}
-
-- (WebFrameView *)_largestChildWithScrollBars
-{
- WebFrameView *largest = nil;
- NSArray *frameChildren = [[self webFrame] childFrames];
-
- unsigned i;
- for (i=0; i < [frameChildren count]; i++) {
- WebFrameView *childFrameView = [[frameChildren objectAtIndex:i] frameView];
- WebFrameView *scrollableFrameView = [childFrameView _hasScrollBars] ? childFrameView : [childFrameView _largestChildWithScrollBars];
- if (!scrollableFrameView)
- continue;
-
- // Some ads lurk in child frames of zero width and height, see radar 4406994. These don't count as scrollable.
- // Maybe someday we'll discover that this minimum area check should be larger, but this covers the known cases.
- float area = [scrollableFrameView _area];
- if (area < 1.0)
- continue;
-
- if (!largest || (area > [largest _area])) {
- largest = scrollableFrameView;
- }
- }
-
- return largest;
-}
-
-- (NSClipView *)_contentView
-{
- return [[self _scrollView] contentView];
-}
-
-- (Class)_customScrollViewClass
-{
- if ([_private->frameScrollView class] == [WebDynamicScrollBarsView class])
- return nil;
- return [_private->frameScrollView class];
-}
-
-- (void)_setCustomScrollViewClass:(Class)customClass
-{
- if (!customClass)
- customClass = [WebDynamicScrollBarsView class];
- ASSERT([customClass isSubclassOfClass:[WebDynamicScrollBarsView class]]);
- if (customClass == [_private->frameScrollView class])
- return;
- if (![customClass isSubclassOfClass:[WebDynamicScrollBarsView class]])
- return;
-
- WebDynamicScrollBarsView *oldScrollView = _private->frameScrollView; // already retained
- NSView <WebDocumentView> *documentView = [[self documentView] retain];
-
- WebDynamicScrollBarsView *scrollView = [[customClass alloc] initWithFrame:[oldScrollView frame]];
- [scrollView setContentView:[[[WebClipView alloc] initWithFrame:[scrollView bounds]] autorelease]];
- [scrollView setDrawsBackground:[oldScrollView drawsBackground]];
- [scrollView setHasVerticalScroller:[oldScrollView hasVerticalScroller]];
- [scrollView setHasHorizontalScroller:[oldScrollView hasHorizontalScroller]];
- [scrollView setAutoresizingMask:[oldScrollView autoresizingMask]];
- [scrollView setLineScroll:[oldScrollView lineScroll]];
- [self addSubview:scrollView];
-
- // don't call our overridden version here; we need to make the standard NSView link between us
- // and our subview so that previousKeyView and previousValidKeyView work as expected. This works
- // together with our becomeFirstResponder and setNextKeyView overrides.
- [super setNextKeyView:scrollView];
-
- _private->frameScrollView = scrollView;
-
- [self _setDocumentView:documentView];
- [self _install];
-
- [oldScrollView removeFromSuperview];
- [oldScrollView release];
- [documentView release];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebFrameViewInternal.h b/WebKit/mac/WebView/WebFrameViewInternal.h
deleted file mode 100644
index 726b62e..0000000
--- a/WebKit/mac/WebView/WebFrameViewInternal.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebFrameView.h>
-
-@class WebDynamicScrollBarsView;
-@class WebView;
-
-@interface WebFrameView (WebInternal)
-
-- (WebView *)_webView;
-- (void)_setDocumentView:(NSView <WebDocumentView> *)view;
-- (NSView <WebDocumentView> *)_makeDocumentViewForDataSource:(WebDataSource *)dataSource;
-- (void)_setWebFrame:(WebFrame *)webFrame;
-- (float)_verticalPageScrollDistance;
-+ (NSMutableDictionary *)_viewTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission;
-+ (Class)_viewClassForMIMEType:(NSString *)MIMEType;
-+ (BOOL)_canShowMIMETypeAsHTML:(NSString *)MIMEType;
-- (WebDynamicScrollBarsView *)_scrollView;
-- (void)_install;
-
-@end
diff --git a/WebKit/mac/WebView/WebFrameViewPrivate.h b/WebKit/mac/WebView/WebFrameViewPrivate.h
deleted file mode 100644
index 47c053e..0000000
--- a/WebKit/mac/WebView/WebFrameViewPrivate.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebFrameView.h>
-
-@interface WebFrameView (WebPrivate)
-
-/*!
- @method _largestChildWithScrollBars
- @abstract Of the child WebFrameViews that are displaying scroll bars, determines which has the largest area.
- @result A child WebFrameView that is displaying scroll bars, or nil if none.
-*/
-- (WebFrameView *)_largestChildWithScrollBars;
-
-/*!
- @method _hasScrollBars
- @result YES if at least one scroll bar is currently displayed
- */
-- (BOOL)_hasScrollBars;
-
-/*!
- @method _contentView
- @result The content view (NSClipView) of the WebFrameView's scroll view.
- */
-- (NSClipView *)_contentView;
-
-/*!
- @method _customScrollViewClass
- @result The custom scroll view class that is installed, nil if the default scroll view is being used.
- */
-- (Class)_customScrollViewClass;
-
-/*!
- @method _setCustomScrollViewClass:
- @result Switches the WebFrameView's scroll view class, this class needs to be a subclass of WebDynamicScrollBarsView.
- Passing nil will switch back to the default WebDynamicScrollBarsView class.
- */
-- (void)_setCustomScrollViewClass:(Class)scrollViewClass;
-
-@end
diff --git a/WebKit/mac/WebView/WebHTMLRepresentation.h b/WebKit/mac/WebView/WebHTMLRepresentation.h
deleted file mode 100644
index 2098c47..0000000
--- a/WebKit/mac/WebView/WebHTMLRepresentation.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-#import <WebKit/WebDocumentPrivate.h>
-
-@class WebHTMLRepresentationPrivate;
-@class NSView;
-
-@class DOMNode;
-@class DOMElement;
-
-@protocol WebDocumentMarkup;
-@protocol WebDocumentRepresentation;
-@protocol WebDocumentSourceRepresentation;
-
-/*!
- @class WebHTMLRepresentation
-*/
-@interface WebHTMLRepresentation : NSObject <WebDocumentRepresentation, WebDocumentDOM>
-{
- WebHTMLRepresentationPrivate *_private;
-}
-
-+ (NSArray *)supportedMIMETypes;
-+ (NSArray *)supportedNonImageMIMETypes;
-+ (NSArray *)supportedImageMIMETypes;
-
-- (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset;
-
-- (DOMElement *)elementWithName:(NSString *)name inForm:(DOMElement *)form;
-- (BOOL)elementDoesAutoComplete:(DOMElement *)element;
-- (BOOL)elementIsPassword:(DOMElement *)element;
-- (DOMElement *)formForElement:(DOMElement *)element;
-- (DOMElement *)currentForm;
-- (NSArray *)controlsInForm:(DOMElement *)form;
-- (NSString *)searchForLabels:(NSArray *)labels beforeElement:(DOMElement *)element;
-- (NSString *)matchLabels:(NSArray *)labels againstElement:(DOMElement *)element;
-
-@end
diff --git a/WebKit/mac/WebView/WebHTMLRepresentation.mm b/WebKit/mac/WebView/WebHTMLRepresentation.mm
deleted file mode 100644
index 4b4d11e..0000000
--- a/WebKit/mac/WebView/WebHTMLRepresentation.mm
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebHTMLRepresentation.h"
-
-#import "DOMNodeInternal.h"
-#import "DOMRangeInternal.h"
-#import "WebArchive.h"
-#import "WebBasePluginPackage.h"
-#import "WebDataSourceInternal.h"
-#import "WebDocumentPrivate.h"
-#import "WebFrameInternal.h"
-#import "WebKitNSStringExtras.h"
-#import "WebKitStatisticsPrivate.h"
-#import "WebNSAttributedStringExtras.h"
-#import "WebNSObjectExtras.h"
-#import "WebResourcePrivate.h"
-#import "WebView.h"
-#import <Foundation/NSURLResponse.h>
-#import <WebCore/Document.h>
-#import <WebCore/DocumentLoader.h>
-#import <WebCore/Frame.h>
-#import <WebCore/FrameLoader.h>
-#import <WebCore/FrameLoaderClient.h>
-#import <WebCore/HTMLFormControlElement.h>
-#import <WebCore/HTMLInputElement.h>
-#import <WebCore/HTMLNames.h>
-#import <WebCore/MIMETypeRegistry.h>
-#import <WebCore/Range.h>
-#import <WebCore/TextResourceDecoder.h>
-#import <WebKit/DOMHTMLInputElement.h>
-#import <wtf/Assertions.h>
-
-using namespace WebCore;
-using namespace HTMLNames;
-
-@interface WebHTMLRepresentationPrivate : NSObject {
-@public
- WebDataSource *dataSource;
-
- BOOL hasSentResponseToPlugin;
- id <WebPluginManualLoader> manualLoader;
- NSView *pluginView;
-}
-@end
-
-@implementation WebHTMLRepresentationPrivate
-@end
-
-@implementation WebHTMLRepresentation
-
-static NSArray *stringArray(const HashSet<String>& set)
-{
- NSMutableArray *array = [NSMutableArray arrayWithCapacity:set.size()];
- HashSet<String>::const_iterator end = set.end();
- for (HashSet<String>::const_iterator it = set.begin(); it != end; ++it)
- [array addObject:(NSString *)(*it)];
- return array;
-}
-
-static NSArray *concatenateArrays(NSArray *first, NSArray *second)
-{
- NSMutableArray *result = [[first mutableCopy] autorelease];
- [result addObjectsFromArray:second];
- return result;
-}
-
-+ (NSArray *)supportedMIMETypes
-{
- static RetainPtr<NSArray> staticSupportedMIMETypes =
- concatenateArrays([self supportedNonImageMIMETypes], [self supportedImageMIMETypes]);
- return staticSupportedMIMETypes.get();
-}
-
-+ (NSArray *)supportedNonImageMIMETypes
-{
- static RetainPtr<NSArray> staticSupportedNonImageMIMETypes =
- stringArray(MIMETypeRegistry::getSupportedNonImageMIMETypes());
- return staticSupportedNonImageMIMETypes.get();
-}
-
-+ (NSArray *)supportedImageMIMETypes
-{
- static RetainPtr<NSArray> staticSupportedImageMIMETypes =
- stringArray(MIMETypeRegistry::getSupportedImageMIMETypes());
- return staticSupportedImageMIMETypes.get();
-}
-
-- init
-{
- self = [super init];
- if (!self)
- return nil;
-
- _private = [[WebHTMLRepresentationPrivate alloc] init];
-
- ++WebHTMLRepresentationCount;
-
- return self;
-}
-
-- (void)dealloc
-{
- --WebHTMLRepresentationCount;
-
- [_private release];
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- --WebHTMLRepresentationCount;
-
- [super finalize];
-}
-
-- (void)_redirectDataToManualLoader:(id<WebPluginManualLoader>)manualLoader forPluginView:(NSView *)pluginView;
-{
- _private->manualLoader = manualLoader;
- _private->pluginView = pluginView;
-}
-
-- (void)setDataSource:(WebDataSource *)dataSource
-{
- _private->dataSource = dataSource;
-}
-
-- (BOOL)_isDisplayingWebArchive
-{
- return [[[_private->dataSource response] MIMEType] _webkit_isCaseInsensitiveEqualToString:@"application/x-webarchive"];
-}
-
-- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource
-{
- WebFrame *webFrame = [dataSource webFrame];
- if (webFrame) {
- if (!_private->pluginView)
- [webFrame _receivedData:data textEncodingName:[[_private->dataSource response] textEncodingName]];
-
- // If the document is a stand-alone media document, now is the right time to cancel the WebKit load
- Frame* coreFrame = core(webFrame);
- if (coreFrame->document() && coreFrame->document()->isMediaDocument())
- coreFrame->loader()->documentLoader()->cancelMainResourceLoad(coreFrame->loader()->client()->pluginWillHandleLoadError(coreFrame->loader()->documentLoader()->response()));
-
- if (_private->pluginView) {
- if (!_private->hasSentResponseToPlugin) {
- [_private->manualLoader pluginView:_private->pluginView receivedResponse:[dataSource response]];
- _private->hasSentResponseToPlugin = YES;
- }
-
- [_private->manualLoader pluginView:_private->pluginView receivedData:data];
- }
- }
-}
-
-- (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSource
-{
- if (_private->pluginView) {
- [_private->manualLoader pluginView:_private->pluginView receivedError:error];
- }
-}
-
-- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
-{
- WebFrame *frame = [dataSource webFrame];
-
- if (_private->pluginView) {
- [_private->manualLoader pluginViewFinishedLoading:_private->pluginView];
- return;
- }
-
- if (frame) {
- if (![self _isDisplayingWebArchive]) {
- // Telling the frame we received some data and passing nil as the data is our
- // way to get work done that is normally done when the first bit of data is
- // received, even for the case of a document with no data (like about:blank).
- [frame _receivedData:nil textEncodingName:[[_private->dataSource response] textEncodingName]];
- }
-
- WebView *webView = [frame webView];
- if ([webView isEditable])
- core(frame)->applyEditingStyleToBodyElement();
- }
-}
-
-- (BOOL)canProvideDocumentSource
-{
- return [[_private->dataSource webFrame] _canProvideDocumentSource];
-}
-
-- (BOOL)canSaveAsWebArchive
-{
- return [[_private->dataSource webFrame] _canSaveAsWebArchive];
-}
-
-- (NSString *)documentSource
-{
- if ([self _isDisplayingWebArchive]) {
- SharedBuffer *parsedArchiveData = [_private->dataSource _documentLoader]->parsedArchiveData();
- NSData *nsData = parsedArchiveData ? parsedArchiveData->createNSData() : nil;
- NSString *result = [[NSString alloc] initWithData:nsData encoding:NSUTF8StringEncoding];
- [nsData release];
- return [result autorelease];
- }
-
- Frame* coreFrame = core([_private->dataSource webFrame]);
- if (!coreFrame)
- return nil;
- Document* document = coreFrame->document();
- if (!document)
- return nil;
- TextResourceDecoder* decoder = document->decoder();
- if (!decoder)
- return nil;
- NSData *data = [_private->dataSource data];
- if (!data)
- return nil;
- return decoder->encoding().decode(reinterpret_cast<const char*>([data bytes]), [data length]);
-}
-
-- (NSString *)title
-{
- return nsStringNilIfEmpty([_private->dataSource _documentLoader]->title());
-}
-
-- (DOMDocument *)DOMDocument
-{
- return [[_private->dataSource webFrame] DOMDocument];
-}
-
-- (NSAttributedString *)attributedText
-{
- // FIXME: Implement
- return nil;
-}
-
-- (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset
-{
- return [NSAttributedString _web_attributedStringFromRange:Range::create([startNode _node]->document(), [startNode _node], startOffset, [endNode _node], endOffset).get()];
-}
-
-static HTMLFormElement* formElementFromDOMElement(DOMElement *element)
-{
- Node* node = [element _node];
- return node && node->hasTagName(formTag) ? static_cast<HTMLFormElement *>(node) : 0;
-}
-
-- (DOMElement *)elementWithName:(NSString *)name inForm:(DOMElement *)form
-{
- HTMLFormElement* formElement = formElementFromDOMElement(form);
- if (!formElement)
- return nil;
- Vector<HTMLFormControlElement*>& elements = formElement->formElements;
- AtomicString targetName = name;
- for (unsigned i = 0; i < elements.size(); i++) {
- HTMLFormControlElement* elt = elements[i];
- if (elt->name() == targetName)
- return kit(elt);
- }
- return nil;
-}
-
-static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
-{
- Node* node = [element _node];
- return node && node->hasTagName(inputTag) ? static_cast<HTMLInputElement*>(node) : 0;
-}
-
-- (BOOL)elementDoesAutoComplete:(DOMElement *)element
-{
- HTMLInputElement* inputElement = inputElementFromDOMElement(element);
- return inputElement
- && inputElement->inputType() == HTMLInputElement::TEXT
- && inputElement->autoComplete();
-}
-
-- (BOOL)elementIsPassword:(DOMElement *)element
-{
- HTMLInputElement* inputElement = inputElementFromDOMElement(element);
- return inputElement
- && inputElement->inputType() == HTMLInputElement::PASSWORD;
-}
-
-- (DOMElement *)formForElement:(DOMElement *)element
-{
- HTMLInputElement* inputElement = inputElementFromDOMElement(element);
- return inputElement ? kit(inputElement->form()) : 0;
-}
-
-- (DOMElement *)currentForm
-{
- return kit(core([_private->dataSource webFrame])->currentForm());
-}
-
-- (NSArray *)controlsInForm:(DOMElement *)form
-{
- HTMLFormElement* formElement = formElementFromDOMElement(form);
- if (!formElement)
- return nil;
- NSMutableArray *results = nil;
- Vector<HTMLFormControlElement*>& elements = formElement->formElements;
- for (unsigned i = 0; i < elements.size(); i++) {
- if (elements[i]->isEnumeratable()) { // Skip option elements, other duds
- DOMElement* de = kit(elements[i]);
- if (!results)
- results = [NSMutableArray arrayWithObject:de];
- else
- [results addObject:de];
- }
- }
- return results;
-}
-
-- (NSString *)searchForLabels:(NSArray *)labels beforeElement:(DOMElement *)element
-{
- return core([_private->dataSource webFrame])->searchForLabelsBeforeElement(labels, core(element));
-}
-
-- (NSString *)matchLabels:(NSArray *)labels againstElement:(DOMElement *)element
-{
- return core([_private->dataSource webFrame])->matchLabelsAgainstElement(labels, core(element));
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebHTMLRepresentationInternal.h b/WebKit/mac/WebView/WebHTMLRepresentationInternal.h
deleted file mode 100644
index d42b400..0000000
--- a/WebKit/mac/WebView/WebHTMLRepresentationInternal.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebHTMLRepresentationPrivate.h>
-
-@interface WebHTMLRepresentation (WebInternal)
-+ (NSArray *)supportedNonImageMIMETypes;
-@end
diff --git a/WebKit/mac/WebView/WebHTMLRepresentationPrivate.h b/WebKit/mac/WebView/WebHTMLRepresentationPrivate.h
deleted file mode 100644
index d0c18ab..0000000
--- a/WebKit/mac/WebView/WebHTMLRepresentationPrivate.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebHTMLRepresentation.h>
-
-@protocol WebPluginManualLoader;
-
-@interface WebHTMLRepresentation (WebPrivate)
-- (void)_redirectDataToManualLoader:(id<WebPluginManualLoader>)manualLoader forPluginView:(NSView *)pluginView;
-- (void)printDOMTree;
-@end
diff --git a/WebKit/mac/WebView/WebHTMLView.h b/WebKit/mac/WebView/WebHTMLView.h
deleted file mode 100644
index a191cef..0000000
--- a/WebKit/mac/WebView/WebHTMLView.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebDocument.h>
-
-@class WebDataSource;
-@class WebHTMLViewPrivate;
-
-/*!
- @class WebHTMLView
- @discussion A document view of WebFrameView that displays HTML content.
- WebHTMLView is a NSControl because it hosts NSCells that are painted by WebCore's Aqua theme
- renderer (and those cells must be hosted by an enclosing NSControl in order to paint properly).
-*/
-@interface WebHTMLView : NSControl <WebDocumentView, WebDocumentSearching>
-{
-@private
- WebHTMLViewPrivate *_private;
-}
-
-/*!
- @method setNeedsToApplyStyles:
- @abstract Sets flag to cause reapplication of style information.
- @param flag YES to apply style information, NO to not apply style information.
-*/
-- (void)setNeedsToApplyStyles:(BOOL)flag;
-
-/*!
- @method reapplyStyles
- @discussion Immediately causes reapplication of style information to the view. This should not be called directly,
- instead call setNeedsToApplyStyles:.
-*/
-- (void)reapplyStyles;
-
-- (void)outdent:(id)sender;
-
-@end
-
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
deleted file mode 100644
index 4d9b3a8..0000000
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ /dev/null
@@ -1,5780 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * (C) 2006, 2007 Graham Dennis (graham.dennis@gmail.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebHTMLView.h"
-
-#import "DOMNodeInternal.h"
-#import "DOMRangeInternal.h"
-#import "WebArchive.h"
-#import "WebBaseNetscapePluginView.h"
-#import "WebClipView.h"
-#import "WebDOMOperationsPrivate.h"
-#import "WebDataSourceInternal.h"
-#import "WebDefaultUIDelegate.h"
-#import "WebDocumentInternal.h"
-#import "WebDynamicScrollBarsView.h"
-#import "WebEditingDelegate.h"
-#import "WebElementDictionary.h"
-#import "WebFrameInternal.h"
-#import "WebFramePrivate.h"
-#import "WebFrameViewInternal.h"
-#import "WebHTMLRepresentationPrivate.h"
-#import "WebHTMLViewInternal.h"
-#import "WebKitLogging.h"
-#import "WebKitNSStringExtras.h"
-#import "WebKitPluginContainerView.h"
-#import "WebKitVersionChecks.h"
-#import "WebLocalizableStrings.h"
-#import "WebNodeHighlight.h"
-#import "WebNSAttributedStringExtras.h"
-#import "WebNSEventExtras.h"
-#import "WebNSFileManagerExtras.h"
-#import "WebNSImageExtras.h"
-#import "WebNSObjectExtras.h"
-#import "WebNSPasteboardExtras.h"
-#import "WebNSPrintOperationExtras.h"
-#import "WebNSURLExtras.h"
-#import "WebNSViewExtras.h"
-#import "WebPluginController.h"
-#import "WebPreferences.h"
-#import "WebPreferencesPrivate.h"
-#import "WebResourcePrivate.h"
-#import "WebStringTruncator.h"
-#import "WebTypesInternal.h"
-#import "WebUIDelegatePrivate.h"
-#import "WebViewInternal.h"
-#import <AppKit/NSAccessibility.h>
-#import <ApplicationServices/ApplicationServices.h>
-#import <dlfcn.h>
-#import <WebCore/CachedImage.h>
-#import <WebCore/CachedResourceClient.h>
-#import <WebCore/ColorMac.h>
-#import <WebCore/ContextMenu.h>
-#import <WebCore/ContextMenuController.h>
-#import <WebCore/Document.h>
-#import <WebCore/DocumentFragment.h>
-#import <WebCore/Editor.h>
-#import <WebCore/EditorDeleteAction.h>
-#import <WebCore/Element.h>
-#import <WebCore/EventHandler.h>
-#import <WebCore/ExceptionHandlers.h>
-#import <WebCore/DragController.h>
-#import <WebCore/FloatRect.h>
-#import <WebCore/FocusController.h>
-#import <WebCore/Frame.h>
-#import <WebCore/FrameLoader.h>
-#import <WebCore/FrameView.h>
-#import <WebCore/HitTestResult.h>
-#import <WebCore/HTMLNames.h>
-#import <WebCore/Image.h>
-#import <WebCore/KeyboardEvent.h>
-#import <WebCore/LegacyWebArchive.h>
-#import <WebCore/MIMETypeRegistry.h>
-#import <WebCore/Page.h>
-#import <WebCore/PlatformKeyboardEvent.h>
-#import <WebCore/PlatformMouseEvent.h>
-#import <WebCore/Range.h>
-#import <WebCore/SelectionController.h>
-#import <WebCore/SharedBuffer.h>
-#import <WebCore/SimpleFontData.h>
-#import <WebCore/Text.h>
-#import <WebCore/WebCoreObjCExtras.h>
-#import <WebCore/WebCoreTextRenderer.h>
-#import <WebCore/markup.h>
-#import <WebKit/DOM.h>
-#import <WebKit/DOMExtensions.h>
-#import <WebKit/DOMPrivate.h>
-#import <WebKitSystemInterface.h>
-#import <limits>
-
-using namespace WebCore;
-using namespace HTMLNames;
-using namespace WTF;
-
-@interface NSWindow (BorderViewAccess)
-- (NSView*)_web_borderView;
-@end
-
-@implementation NSWindow (BorderViewAccess)
-- (NSView*)_web_borderView
-{
- return _borderView;
-}
-@end
-
-static IMP oldSetCursorIMP = NULL;
-
-#ifdef BUILDING_ON_TIGER
-static IMP oldResetCursorRectsIMP = NULL;
-static BOOL canSetCursor = YES;
-
-static void resetCursorRects(NSWindow* self, SEL cmd)
-{
- NSPoint point = [self mouseLocationOutsideOfEventStream];
- NSView* view = [[self _web_borderView] hitTest:point];
- if ([view isKindOfClass:[WebHTMLView class]]) {
- WebHTMLView *htmlView = (WebHTMLView*)view;
- NSPoint localPoint = [htmlView convertPoint:point fromView:nil];
- NSDictionary *dict = [htmlView elementAtPoint:point allowShadowContent:NO];
- DOMElement *element = [dict objectForKey:WebElementDOMNodeKey];
- if (![element isKindOfClass:[DOMHTMLAppletElement class]] && ![element isKindOfClass:[DOMHTMLObjectElement class]] &&
- ![element isKindOfClass:[DOMHTMLEmbedElement class]])
- canSetCursor = NO;
- }
- oldResetCursorRectsIMP(self, cmd);
- canSetCursor = YES;
-}
-
-static void setCursor(NSCursor* self, SEL cmd)
-{
- if (canSetCursor)
- oldSetCursorIMP(self, cmd);
-}
-#else
-static void setCursor(NSWindow* self, SEL cmd, NSPoint point)
-{
- NSView* view = [[self _web_borderView] hitTest:point];
- if ([view isKindOfClass:[WebHTMLView class]]) {
- WebHTMLView *htmlView = (WebHTMLView*)view;
- NSPoint localPoint = [htmlView convertPoint:point fromView:nil];
- NSDictionary *dict = [htmlView elementAtPoint:point allowShadowContent:NO];
- DOMElement *element = [dict objectForKey:WebElementDOMNodeKey];
- if (![element isKindOfClass:[DOMHTMLAppletElement class]] && ![element isKindOfClass:[DOMHTMLObjectElement class]] &&
- ![element isKindOfClass:[DOMHTMLEmbedElement class]])
- return;
- }
- oldSetCursorIMP(self, cmd, point);
-}
-#endif
-
-extern "C" {
-
-// Need to declare these attribute names because AppKit exports them but does not make them available in API or SPI headers.
-
-extern NSString *NSMarkedClauseSegmentAttributeName;
-extern NSString *NSTextInputReplacementRangeAttributeName;
-}
-
-@interface NSView (WebNSViewDetails)
-- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView;
-- (void)_recursiveDisplayAllDirtyWithLockFocus:(BOOL)needsLockFocus visRect:(NSRect)visRect;
-- (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)context topView:(BOOL)topView;
-- (NSRect)_dirtyRect;
-- (void)_setDrawsOwnDescendants:(BOOL)drawsOwnDescendants;
-- (void)_propagateDirtyRectsToOpaqueAncestors;
-- (void)_windowChangedKeyState;
-@end
-
-@interface NSApplication (WebNSApplicationDetails)
-- (void)speakString:(NSString *)string;
-@end
-
-@interface NSWindow (WebNSWindowDetails)
-- (id)_newFirstResponderAfterResigning;
-- (void)_setForceActiveControls:(BOOL)flag;
-@end
-
-@interface NSAttributedString (WebNSAttributedStringDetails)
-- (id)_initWithDOMRange:(DOMRange *)range;
-- (DOMDocumentFragment *)_documentFromRange:(NSRange)range document:(DOMDocument *)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources;
-@end
-
-@interface NSSpellChecker (WebNSSpellCheckerDetails)
-- (void)learnWord:(NSString *)word;
-@end
-
-// By imaging to a width a little wider than the available pixels,
-// thin pages will be scaled down a little, matching the way they
-// print in IE and Camino. This lets them use fewer sheets than they
-// would otherwise, which is presumably why other browsers do this.
-// Wide pages will be scaled down more than this.
-#define PrintingMinimumShrinkFactor 1.25f
-
-// This number determines how small we are willing to reduce the page content
-// in order to accommodate the widest line. If the page would have to be
-// reduced smaller to make the widest line fit, we just clip instead (this
-// behavior matches MacIE and Mozilla, at least)
-#define PrintingMaximumShrinkFactor 2.0f
-
-// This number determines how short the last printed page of a multi-page print session
-// can be before we try to shrink the scale in order to reduce the number of pages, and
-// thus eliminate the orphan.
-#define LastPrintedPageOrphanRatio 0.1f
-
-// This number determines the amount the scale factor is adjusted to try to eliminate orphans.
-// It has no direct mathematical relationship to LastPrintedPageOrphanRatio, due to variable
-// numbers of pages, logic to avoid breaking elements, and CSS-supplied hard page breaks.
-#define PrintingOrphanShrinkAdjustment 1.1f
-
-#define AUTOSCROLL_INTERVAL 0.1f
-
-#define DRAG_LABEL_BORDER_X 4.0f
-//Keep border_y in synch with DragController::LinkDragBorderInset
-#define DRAG_LABEL_BORDER_Y 2.0f
-#define DRAG_LABEL_RADIUS 5.0f
-#define DRAG_LABEL_BORDER_Y_OFFSET 2.0f
-
-#define MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP 120.0f
-#define MAX_DRAG_LABEL_WIDTH 320.0f
-
-#define DRAG_LINK_LABEL_FONT_SIZE 11.0f
-#define DRAG_LINK_URL_FONT_SIZE 10.0f
-
-// Any non-zero value will do, but using something recognizable might help us debug some day.
-#define TRACKING_RECT_TAG 0xBADFACE
-
-// FIXME: This constant is copied from AppKit's _NXSmartPaste constant.
-#define WebSmartPastePboardType @"NeXT smart paste pasteboard type"
-
-#define STANDARD_WEIGHT 5
-#define MIN_BOLD_WEIGHT 7
-#define STANDARD_BOLD_WEIGHT 9
-
-// Fake URL scheme.
-#define WebDataProtocolScheme @"webkit-fake-url"
-
-// <rdar://problem/4985524> References to WebCoreScrollView as a subview of a WebHTMLView may be present
-// in some NIB files, so NSUnarchiver must be still able to look up this now-unused class.
-@interface WebCoreScrollView : NSScrollView
-@end
-
-@implementation WebCoreScrollView
-@end
-
-// if YES, do the standard NSView hit test (which can't give the right result when HTML overlaps a view)
-static BOOL forceNSViewHitTest;
-
-// if YES, do the "top WebHTMLView" hit test (which we'd like to do all the time but can't because of Java requirements [see bug 4349721])
-static BOOL forceWebHTMLViewHitTest;
-
-static WebHTMLView *lastHitView;
-
-// We need this to be able to safely reference the CachedImage for the promised drag data
-static CachedResourceClient* promisedDataClient()
-{
- static CachedResourceClient* staticCachedResourceClient = new CachedResourceClient;
- return staticCachedResourceClient;
-}
-
-@interface WebHTMLView (WebHTMLViewFileInternal)
-- (BOOL)_imageExistsAtPaths:(NSArray *)paths;
-- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard inContext:(DOMRange *)context allowPlainText:(BOOL)allowPlainText;
-- (NSString *)_plainTextFromPasteboard:(NSPasteboard *)pasteboard;
-- (void)_pasteWithPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText;
-- (void)_pasteAsPlainTextWithPasteboard:(NSPasteboard *)pasteboard;
-- (BOOL)_shouldInsertFragment:(DOMDocumentFragment *)fragment replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action;
-- (BOOL)_shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action;
-- (BOOL)_shouldReplaceSelectionWithText:(NSString *)text givenAction:(WebViewInsertAction)action;
-- (float)_calculatePrintHeight;
-- (DOMRange *)_selectedRange;
-- (BOOL)_shouldDeleteRange:(DOMRange *)range;
-- (NSView *)_hitViewForEvent:(NSEvent *)event;
-- (void)_writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard cachedAttributedString:(NSAttributedString *)attributedString;
-- (DOMRange *)_documentRange;
-- (void)_setMouseDownEvent:(NSEvent *)event;
-- (WebHTMLView *)_topHTMLView;
-- (BOOL)_isTopHTMLView;
-- (void)_web_setPrintingModeRecursive;
-- (void)_web_setPrintingModeRecursiveAndAdjustViewSize;
-- (void)_web_clearPrintingModeRecursive;
-@end
-
-@interface WebHTMLView (WebForwardDeclaration) // FIXME: Put this in a normal category and stop doing the forward declaration trick.
-- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize;
-@end
-
-@class NSTextInputContext;
-@interface NSResponder (AppKitDetails)
-- (NSTextInputContext *)inputContext;
-@end
-
-@interface NSObject (NSTextInputContextDetails)
-- (BOOL)wantsToHandleMouseEvents;
-- (BOOL)handleMouseEvent:(NSEvent *)event;
-@end
-
-@interface WebHTMLView (WebNSTextInputSupport) <NSTextInput>
-- (void)_updateSelectionForInputManager;
-@end
-
-@interface WebHTMLView (WebEditingStyleSupport)
-- (DOMCSSStyleDeclaration *)_emptyStyle;
-- (NSString *)_colorAsString:(NSColor *)color;
-@end
-
-@interface NSView (WebHTMLViewFileInternal)
-- (void)_web_addDescendantWebHTMLViewsToArray:(NSMutableArray *) array;
-@end
-
-@interface NSMutableDictionary (WebHTMLViewFileInternal)
-- (void)_web_setObjectIfNotNil:(id)object forKey:(id)key;
-@end
-
-// Handles the complete: text command
-@interface WebTextCompleteController : NSObject <NSTableViewDelegate, NSTableViewDataSource> {
-@private
- WebHTMLView *_view;
- NSWindow *_popupWindow;
- NSTableView *_tableView;
- NSArray *_completions;
- NSString *_originalString;
- int prefixLength;
-}
-- (id)initWithHTMLView:(WebHTMLView *)view;
-- (void)doCompletion;
-- (void)endRevertingChange:(BOOL)revertChange moveLeft:(BOOL)goLeft;
-- (BOOL)popupWindowIsOpen;
-- (BOOL)filterKeyDown:(NSEvent *)event;
-- (void)_reflectSelection;
-@end
-
-struct WebHTMLViewInterpretKeyEventsParameters {
- KeyboardEvent* event;
- BOOL eventWasHandled;
- BOOL shouldSaveCommand;
- // The Input Method may consume an event and not tell us, in
- // which case we should not bubble the event up the DOM
- BOOL consumedByIM;
-};
-
-@interface WebHTMLViewPrivate : NSObject {
-@public
- BOOL closed;
- BOOL needsLayout;
- BOOL needsToApplyStyles;
- BOOL ignoringMouseDraggedEvents;
- BOOL printing;
- BOOL avoidingPrintOrphan;
-
- id savedSubviews;
- BOOL subviewsSetAside;
-
- NSEvent *mouseDownEvent; // Kept after handling the event.
- BOOL handlingMouseDownEvent;
- NSEvent *keyDownEvent; // Kept after handling the event.
-
- NSSize lastLayoutSize;
-
- NSPoint lastScrollPosition;
-
- WebPluginController *pluginController;
-
- NSString *toolTip;
- NSToolTipTag lastToolTipTag;
- id trackingRectOwner;
- void *trackingRectUserData;
-
- NSTimer *autoscrollTimer;
- NSEvent *autoscrollTriggerEvent;
-
- NSArray* pageRects;
-
- NSMutableDictionary* highlighters;
-
- BOOL resigningFirstResponder;
- BOOL nextResponderDisabledOnce;
-
- WebTextCompleteController *compController;
-
- BOOL transparentBackground;
-
- WebHTMLViewInterpretKeyEventsParameters *interpretKeyEventsParameters;
- BOOL receivedNOOP;
-
- WebDataSource *dataSource;
- WebCore::CachedImage *promisedDragTIFFDataSource;
-
- CFRunLoopTimerRef updateFocusedAndActiveStateTimer;
- CFRunLoopTimerRef updateMouseoverTimer;
-
- SEL selectorForDoCommandBySelector;
-
-#ifndef NDEBUG
- BOOL enumeratingSubviews;
-#endif
-}
-- (void)clear;
-@end
-
-static NSCellStateValue kit(TriState state)
-{
- switch (state) {
- case FalseTriState:
- return NSOffState;
- case TrueTriState:
- return NSOnState;
- case MixedTriState:
- return NSMixedState;
- }
- ASSERT_NOT_REACHED();
- return NSOffState;
-}
-
-@implementation WebHTMLViewPrivate
-
-+ (void)initialize
-{
-#ifndef BUILDING_ON_TIGER
- WebCoreObjCFinalizeOnMainThread(self);
-#endif
-
- if (!oldSetCursorIMP) {
-#ifdef BUILDING_ON_TIGER
- Method setCursorMethod = class_getInstanceMethod([NSCursor class], @selector(set));
-#else
- Method setCursorMethod = class_getInstanceMethod([NSWindow class], @selector(_setCursorForMouseLocation:));
-#endif
- ASSERT(setCursorMethod);
-
- oldSetCursorIMP = method_setImplementation(setCursorMethod, (IMP)setCursor);
- ASSERT(oldSetCursorIMP);
- }
-
-#ifdef BUILDING_ON_TIGER
- if (!oldResetCursorRectsIMP) {
- Method resetCursorRectsMethod = class_getInstanceMethod([NSWindow class], @selector(resetCursorRects));
- ASSERT(resetCursorRectsMethod);
- oldResetCursorRectsIMP = method_setImplementation(resetCursorRectsMethod, (IMP)resetCursorRects);
- ASSERT(oldResetCursorRectsIMP);
- }
-#endif
-
-}
-
-- (void)dealloc
-{
- if (WebCoreObjCScheduleDeallocateOnMainThread([WebHTMLViewPrivate class], self))
- return;
-
- ASSERT(!autoscrollTimer);
- ASSERT(!autoscrollTriggerEvent);
- ASSERT(!updateFocusedAndActiveStateTimer);
- ASSERT(!updateMouseoverTimer);
-
- [mouseDownEvent release];
- [keyDownEvent release];
- [pluginController release];
- [toolTip release];
- [compController release];
- [dataSource release];
- [highlighters release];
- if (promisedDragTIFFDataSource)
- promisedDragTIFFDataSource->removeClient(promisedDataClient());
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- ASSERT_MAIN_THREAD();
-
- if (promisedDragTIFFDataSource)
- promisedDragTIFFDataSource->removeClient(promisedDataClient());
-
- [super finalize];
-}
-
-- (void)clear
-{
- [mouseDownEvent release];
- [keyDownEvent release];
- [pluginController release];
- [toolTip release];
- [compController release];
- [dataSource release];
- [highlighters release];
- if (promisedDragTIFFDataSource)
- promisedDragTIFFDataSource->removeClient(promisedDataClient());
-
- mouseDownEvent = nil;
- keyDownEvent = nil;
- pluginController = nil;
- toolTip = nil;
- compController = nil;
- dataSource = nil;
- highlighters = nil;
- promisedDragTIFFDataSource = 0;
-}
-
-@end
-
-@implementation WebHTMLView (WebHTMLViewFileInternal)
-
-- (DOMRange *)_documentRange
-{
- return [[[self _frame] DOMDocument] _documentRange];
-}
-
-- (BOOL)_imageExistsAtPaths:(NSArray *)paths
-{
- NSEnumerator *enumerator = [paths objectEnumerator];
- NSString *path;
-
- while ((path = [enumerator nextObject]) != nil) {
- NSString *MIMEType = WKGetMIMETypeForExtension([path pathExtension]);
- if (MIMETypeRegistry::isSupportedImageResourceMIMEType(MIMEType))
- return YES;
- }
-
- return NO;
-}
-
-- (WebDataSource *)_dataSource
-{
- return _private->dataSource;
-}
-
-- (WebView *)_webView
-{
- return [_private->dataSource _webView];
-}
-
-- (WebFrameView *)_frameView
-{
- return [[_private->dataSource webFrame] frameView];
-}
-
-- (DOMDocumentFragment *)_documentFragmentWithPaths:(NSArray *)paths
-{
- DOMDocumentFragment *fragment;
- NSEnumerator *enumerator = [paths objectEnumerator];
- NSMutableArray *domNodes = [[NSMutableArray alloc] init];
- NSString *path;
-
- while ((path = [enumerator nextObject]) != nil) {
- // Non-image file types; _web_userVisibleString is appropriate here because this will
- // be pasted as visible text.
- NSString *url = [[[NSURL fileURLWithPath:path] _webkit_canonicalize] _web_userVisibleString];
- [domNodes addObject:[[[self _frame] DOMDocument] createTextNode: url]];
- }
-
- fragment = [[self _frame] _documentFragmentWithNodesAsParagraphs:domNodes];
-
- [domNodes release];
-
- return [fragment firstChild] != nil ? fragment : nil;
-}
-
-+ (NSArray *)_excludedElementsForAttributedStringConversion
-{
- static NSArray *elements = nil;
- if (elements == nil) {
- elements = [[NSArray alloc] initWithObjects:
- // Omit style since we want style to be inline so the fragment can be easily inserted.
- @"style",
- // Omit xml so the result is not XHTML.
- @"xml",
- // Omit tags that will get stripped when converted to a fragment anyway.
- @"doctype", @"html", @"head", @"body",
- // Omit deprecated tags.
- @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u",
- // Omit object so no file attachments are part of the fragment.
- @"object", nil];
- CFRetain(elements);
- }
- return elements;
-}
-
-static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
-{
- CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
- NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
- CFRelease(UUIDRef);
- NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@", WebDataProtocolScheme, UUIDString, relativePart]];
- CFRelease(UUIDString);
-
- return URL;
-}
-
-- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard
- inContext:(DOMRange *)context
- allowPlainText:(BOOL)allowPlainText
-{
- NSArray *types = [pasteboard types];
- DOMDocumentFragment *fragment = nil;
-
- if ([types containsObject:WebArchivePboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:WebArchivePboardType
- inContext:context
- subresources:0]))
- return fragment;
-
- if ([types containsObject:NSFilenamesPboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:NSFilenamesPboardType
- inContext:context
- subresources:0]))
- return fragment;
-
- if ([types containsObject:NSHTMLPboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:NSHTMLPboardType
- inContext:context
- subresources:0]))
- return fragment;
-
- if ([types containsObject:NSRTFPboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:NSRTFPboardType
- inContext:context
- subresources:0]))
- return fragment;
-
- if ([types containsObject:NSRTFDPboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:NSRTFDPboardType
- inContext:context
- subresources:0]))
- return fragment;
-
- if ([types containsObject:NSTIFFPboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:NSTIFFPboardType
- inContext:context
- subresources:0]))
- return fragment;
-
- if ([types containsObject:NSPICTPboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:NSPICTPboardType
- inContext:context
- subresources:0]))
- return fragment;
-
- // Only 10.5 and higher support setting and retrieving pasteboard types with UTIs, but we don't believe
- // that any applications on Tiger put types for which we only have a UTI, like PNG, on the pasteboard.
- if ([types containsObject:(NSString*)kUTTypePNG] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:(NSString*)kUTTypePNG
- inContext:context
- subresources:0]))
- return fragment;
-
- if ([types containsObject:NSURLPboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:NSURLPboardType
- inContext:context
- subresources:0]))
- return fragment;
-
- if (allowPlainText && [types containsObject:NSStringPboardType] &&
- (fragment = [self _documentFragmentFromPasteboard:pasteboard
- forType:NSStringPboardType
- inContext:context
- subresources:0])) {
- return fragment;
- }
-
- return nil;
-}
-
-- (NSString *)_plainTextFromPasteboard:(NSPasteboard *)pasteboard
-{
- NSArray *types = [pasteboard types];
-
- if ([types containsObject:NSStringPboardType])
- return [pasteboard stringForType:NSStringPboardType];
-
- NSAttributedString *attributedString = nil;
- NSString *string;
-
- if ([types containsObject:NSRTFDPboardType])
- attributedString = [[NSAttributedString alloc] initWithRTFD:[pasteboard dataForType:NSRTFDPboardType] documentAttributes:NULL];
- if (attributedString == nil && [types containsObject:NSRTFPboardType])
- attributedString = [[NSAttributedString alloc] initWithRTF:[pasteboard dataForType:NSRTFPboardType] documentAttributes:NULL];
- if (attributedString != nil) {
- string = [[attributedString string] copy];
- [attributedString release];
- return [string autorelease];
- }
-
- if ([types containsObject:NSFilenamesPboardType]) {
- string = [[pasteboard propertyListForType:NSFilenamesPboardType] componentsJoinedByString:@"\n"];
- if (string != nil)
- return string;
- }
-
- NSURL *URL;
-
- if ((URL = [NSURL URLFromPasteboard:pasteboard])) {
- string = [URL _web_userVisibleString];
- if ([string length] > 0)
- return string;
- }
-
- return nil;
-}
-
-- (void)_pasteWithPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText
-{
- DOMRange *range = [self _selectedRange];
- DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard
- inContext:range allowPlainText:allowPlainText];
- WebFrame *frame = [self _frame];
- if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:[self _selectedRange] givenAction:WebViewInsertActionPasted]) {
- [frame _replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:NO];
- }
-}
-
-- (void)_pasteAsPlainTextWithPasteboard:(NSPasteboard *)pasteboard
-{
- NSString *text = [self _plainTextFromPasteboard:pasteboard];
- if ([self _shouldReplaceSelectionWithText:text givenAction:WebViewInsertActionPasted])
- [[self _frame] _replaceSelectionWithText:text selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard]];
-}
-
-- (BOOL)_shouldInsertFragment:(DOMDocumentFragment *)fragment replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action
-{
- WebView *webView = [self _webView];
- DOMNode *child = [fragment firstChild];
- if ([fragment lastChild] == child && [child isKindOfClass:[DOMCharacterData class]])
- return [[webView _editingDelegateForwarder] webView:webView shouldInsertText:[(DOMCharacterData *)child data] replacingDOMRange:range givenAction:action];
- return [[webView _editingDelegateForwarder] webView:webView shouldInsertNode:fragment replacingDOMRange:range givenAction:action];
-}
-
-- (BOOL)_shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action
-{
- WebView *webView = [self _webView];
- return [[webView _editingDelegateForwarder] webView:webView shouldInsertText:text replacingDOMRange:range givenAction:action];
-}
-
-- (BOOL)_shouldReplaceSelectionWithText:(NSString *)text givenAction:(WebViewInsertAction)action
-{
- return [self _shouldInsertText:text replacingDOMRange:[self _selectedRange] givenAction:action];
-}
-
-// Calculate the vertical size of the view that fits on a single page
-- (float)_calculatePrintHeight
-{
- // Obtain the print info object for the current operation
- NSPrintInfo *pi = [[NSPrintOperation currentOperation] printInfo];
-
- // Calculate the page height in points
- NSSize paperSize = [pi paperSize];
- return paperSize.height - [pi topMargin] - [pi bottomMargin];
-}
-
-- (DOMRange *)_selectedRange
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame ? kit(coreFrame->selection()->toRange().get()) : nil;
-}
-
-- (BOOL)_shouldDeleteRange:(DOMRange *)range
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->editor()->shouldDeleteRange(core(range));
-}
-
-- (NSView *)_hitViewForEvent:(NSEvent *)event
-{
- // Usually, we hack AK's hitTest method to catch all events at the topmost WebHTMLView.
- // Callers of this method, however, want to query the deepest view instead.
- forceNSViewHitTest = YES;
- NSView *hitView = [[[self window] contentView] hitTest:[event locationInWindow]];
- forceNSViewHitTest = NO;
- return hitView;
-}
-
-- (void)_writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard cachedAttributedString:(NSAttributedString *)attributedString
-{
- // Put HTML on the pasteboard.
- if ([types containsObject:WebArchivePboardType]) {
- if (RefPtr<LegacyWebArchive> coreArchive = LegacyWebArchive::createFromSelection(core([self _frame]))) {
- if (RetainPtr<CFDataRef> data = coreArchive ? coreArchive->rawDataRepresentation() : 0)
- [pasteboard setData:(NSData *)data.get() forType:WebArchivePboardType];
- }
- }
-
- // Put the attributed string on the pasteboard (RTF/RTFD format).
- if ([types containsObject:NSRTFDPboardType]) {
- if (attributedString == nil) {
- attributedString = [self selectedAttributedString];
- }
- NSData *RTFDData = [attributedString RTFDFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
- [pasteboard setData:RTFDData forType:NSRTFDPboardType];
- }
- if ([types containsObject:NSRTFPboardType]) {
- if (attributedString == nil) {
- attributedString = [self selectedAttributedString];
- }
- if ([attributedString containsAttachments]) {
- attributedString = [attributedString _web_attributedStringByStrippingAttachmentCharacters];
- }
- NSData *RTFData = [attributedString RTFFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
- [pasteboard setData:RTFData forType:NSRTFPboardType];
- }
-
- // Put plain string on the pasteboard.
- if ([types containsObject:NSStringPboardType]) {
- // Map &nbsp; to a plain old space because this is better for source code, other browsers do it,
- // and because HTML forces you to do this any time you want two spaces in a row.
- NSMutableString *s = [[self selectedString] mutableCopy];
- const unichar NonBreakingSpaceCharacter = 0xA0;
- NSString *NonBreakingSpaceString = [NSString stringWithCharacters:&NonBreakingSpaceCharacter length:1];
- [s replaceOccurrencesOfString:NonBreakingSpaceString withString:@" " options:0 range:NSMakeRange(0, [s length])];
- [pasteboard setString:s forType:NSStringPboardType];
- [s release];
- }
-
- if ([self _canSmartCopyOrDelete] && [types containsObject:WebSmartPastePboardType]) {
- [pasteboard setData:nil forType:WebSmartPastePboardType];
- }
-}
-
-- (void)_setMouseDownEvent:(NSEvent *)event
-{
- ASSERT(!event || [event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown);
-
- if (event == _private->mouseDownEvent)
- return;
-
- [event retain];
- [_private->mouseDownEvent release];
- _private->mouseDownEvent = event;
-}
-
-- (void)_cancelUpdateFocusedAndActiveStateTimer
-{
- if (_private->updateFocusedAndActiveStateTimer) {
- CFRunLoopTimerInvalidate(_private->updateFocusedAndActiveStateTimer);
- CFRelease(_private->updateFocusedAndActiveStateTimer);
- _private->updateFocusedAndActiveStateTimer = NULL;
- }
-}
-
-- (void)_cancelUpdateMouseoverTimer
-{
- if (_private->updateMouseoverTimer) {
- CFRunLoopTimerInvalidate(_private->updateMouseoverTimer);
- CFRelease(_private->updateMouseoverTimer);
- _private->updateMouseoverTimer = NULL;
- }
-}
-
-- (WebHTMLView *)_topHTMLView
-{
- // FIXME: this can fail if the dataSource is nil, which happens when the WebView is tearing down from the window closing.
- WebHTMLView *view = (WebHTMLView *)[[[[_private->dataSource _webView] mainFrame] frameView] documentView];
- ASSERT(view);
- ASSERT([view isKindOfClass:[WebHTMLView class]]);
- return view;
-}
-
-- (BOOL)_isTopHTMLView
-{
- // FIXME: this should be a cached boolean that doesn't rely on _topHTMLView since that can fail (see _topHTMLView).
- return self == [self _topHTMLView];
-}
-
-- (void)_web_setPrintingModeRecursive
-{
- [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
-
-#ifndef NDEBUG
- _private->enumeratingSubviews = YES;
-#endif
-
- NSMutableArray *descendantWebHTMLViews = [[NSMutableArray alloc] init];
-
- [self _web_addDescendantWebHTMLViewsToArray:descendantWebHTMLViews];
-
- unsigned count = [descendantWebHTMLViews count];
- for (unsigned i = 0; i < count; ++i)
- [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
-
- [descendantWebHTMLViews release];
-
-#ifndef NDEBUG
- _private->enumeratingSubviews = NO;
-#endif
-}
-
-- (void)_web_clearPrintingModeRecursive
-{
- [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
-
-#ifndef NDEBUG
- _private->enumeratingSubviews = YES;
-#endif
-
- NSMutableArray *descendantWebHTMLViews = [[NSMutableArray alloc] init];
-
- [self _web_addDescendantWebHTMLViewsToArray:descendantWebHTMLViews];
-
- unsigned count = [descendantWebHTMLViews count];
- for (unsigned i = 0; i < count; ++i)
- [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
-
- [descendantWebHTMLViews release];
-
-#ifndef NDEBUG
- _private->enumeratingSubviews = NO;
-#endif
-}
-
-- (void)_web_setPrintingModeRecursiveAndAdjustViewSize
-{
- [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:YES];
-
-#ifndef NDEBUG
- _private->enumeratingSubviews = YES;
-#endif
-
- NSMutableArray *descendantWebHTMLViews = [[NSMutableArray alloc] init];
-
- [self _web_addDescendantWebHTMLViewsToArray:descendantWebHTMLViews];
-
- unsigned count = [descendantWebHTMLViews count];
- for (unsigned i = 0; i < count; ++i)
- [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:YES];
-
- [descendantWebHTMLViews release];
-
-#ifndef NDEBUG
- _private->enumeratingSubviews = NO;
-#endif
-}
-
-@end
-
-@implementation WebHTMLView (WebPrivate)
-
-+ (NSArray *)supportedMIMETypes
-{
- return [WebHTMLRepresentation supportedMIMETypes];
-}
-
-+ (NSArray *)supportedImageMIMETypes
-{
- return [WebHTMLRepresentation supportedImageMIMETypes];
-}
-
-+ (NSArray *)supportedNonImageMIMETypes
-{
- return [WebHTMLRepresentation supportedNonImageMIMETypes];
-}
-
-+ (NSArray *)unsupportedTextMIMETypes
-{
- return [NSArray arrayWithObjects:
- @"text/calendar", // iCal
- @"text/x-calendar",
- @"text/x-vcalendar",
- @"text/vcalendar",
- @"text/vcard", // vCard
- @"text/x-vcard",
- @"text/directory",
- @"text/ldif", // Netscape Address Book
- @"text/qif", // Quicken
- @"text/x-qif",
- @"text/x-csv", // CSV (for Address Book and Microsoft Outlook)
- @"text/x-vcf", // vCard type used in Sun affinity app
- @"text/rtf", // Rich Text Format
- nil];
-}
-
-+ (void)_postFlagsChangedEvent:(NSEvent *)flagsChangedEvent
-{
- // This is a workaround for: <rdar://problem/2981619> NSResponder_Private should include notification for FlagsChanged
- NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved
- location:[[flagsChangedEvent window] convertScreenToBase:[NSEvent mouseLocation]]
- modifierFlags:[flagsChangedEvent modifierFlags]
- timestamp:[flagsChangedEvent timestamp]
- windowNumber:[flagsChangedEvent windowNumber]
- context:[flagsChangedEvent context]
- eventNumber:0 clickCount:0 pressure:0];
-
- // Pretend it's a mouse move.
- [[NSNotificationCenter defaultCenter]
- postNotificationName:WKMouseMovedNotification() object:self
- userInfo:[NSDictionary dictionaryWithObject:fakeEvent forKey:@"NSEvent"]];
-}
-
-- (void)_updateMouseoverWithFakeEvent
-{
- [self _cancelUpdateMouseoverTimer];
-
- NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved
- location:[[self window] convertScreenToBase:[NSEvent mouseLocation]]
- modifierFlags:[[NSApp currentEvent] modifierFlags]
- timestamp:[NSDate timeIntervalSinceReferenceDate]
- windowNumber:[[self window] windowNumber]
- context:[[NSApp currentEvent] context]
- eventNumber:0 clickCount:0 pressure:0];
-
- [self _updateMouseoverWithEvent:fakeEvent];
-}
-
-static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
-{
- WebHTMLView *view = (WebHTMLView *)info;
-
- [view _updateMouseoverWithFakeEvent];
-}
-
-- (void)_frameOrBoundsChanged
-{
- if (!NSEqualSizes(_private->lastLayoutSize, [(NSClipView *)[self superview] documentVisibleRect].size)) {
- [self setNeedsLayout:YES];
- [self setNeedsDisplay:YES];
- [_private->compController endRevertingChange:NO moveLeft:NO];
- }
-
- NSPoint origin = [[self superview] bounds].origin;
- if (!NSEqualPoints(_private->lastScrollPosition, origin)) {
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->sendScrollEvent();
- [_private->compController endRevertingChange:NO moveLeft:NO];
-
- WebView *webView = [self _webView];
- [[webView _UIDelegateForwarder] webView:webView didScrollDocumentInFrameView:[self _frameView]];
- }
- _private->lastScrollPosition = origin;
-
- if ([self window] && !_private->closed && !_private->updateMouseoverTimer) {
- CFRunLoopTimerContext context = { 0, self, NULL, NULL, NULL };
-
- // Use a 100ms delay so that the synthetic mouse over update doesn't cause cursor thrashing when pages are loading
- // and scrolling rapidly back to back.
- _private->updateMouseoverTimer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + 0.1, 0, 0, 0,
- _updateMouseoverTimerCallback, &context);
- CFRunLoopAddTimer(CFRunLoopGetCurrent(), _private->updateMouseoverTimer, kCFRunLoopDefaultMode);
- }
-}
-
-- (void)_setAsideSubviews
-{
- ASSERT(!_private->subviewsSetAside);
- ASSERT(_private->savedSubviews == nil);
- _private->savedSubviews = _subviews;
- _subviews = nil;
- _private->subviewsSetAside = YES;
- }
-
- - (void)_restoreSubviews
- {
- ASSERT(_private->subviewsSetAside);
- ASSERT(_subviews == nil);
- _subviews = _private->savedSubviews;
- _private->savedSubviews = nil;
- _private->subviewsSetAside = NO;
-}
-
-#ifndef NDEBUG
-
-- (void)didAddSubview:(NSView *)subview
-{
- if (_private->enumeratingSubviews)
- LOG(View, "A view of class %s was added during subview enumeration for layout or printing mode change. This view might paint without first receiving layout.", object_getClassName([subview class]));
-}
-
-- (void)willRemoveSubview:(NSView *)subview
-{
- if (_private->enumeratingSubviews)
- LOG(View, "A view of class %s was removed during subview enumeration for layout or printing mode change. We will still do layout or the printing mode change even though this view is no longer in the view hierarchy.", object_getClassName([subview class]));
-}
-
-#endif
-
-#ifdef BUILDING_ON_TIGER
-
-// This is called when we are about to draw, but before our dirty rect is propagated to our ancestors.
-// That's the perfect time to do a layout, except that ideally we'd want to be sure that we're dirty
-// before doing it. As a compromise, when we're opaque we do the layout only when actually asked to
-// draw, but when we're transparent we do the layout at this stage so views behind us know that they
-// need to be redrawn (in case the layout causes some things to get dirtied).
-- (void)_propagateDirtyRectsToOpaqueAncestors
-{
- if (![[self _webView] drawsBackground])
- [self _web_layoutIfNeededRecursive];
- [super _propagateDirtyRectsToOpaqueAncestors];
-}
-
-#else
-
-- (void)viewWillDraw
-{
- // On window close we will be called when the datasource is nil, then hit an assert in _topHTMLView
- // So check if the dataSource is nil before calling [self _isTopHTMLView], this can be removed
- // once the FIXME in _isTopHTMLView is fixed.
- if (_private->dataSource && [self _isTopHTMLView])
- [self _web_layoutIfNeededRecursive];
- [super viewWillDraw];
-}
-
-#endif
-
-// Don't let AppKit even draw subviews. We take care of that.
-- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView
-{
- // This helps when we print as part of a larger print process.
- // If the WebHTMLView itself is what we're printing, then we will never have to do this.
- BOOL wasInPrintingMode = _private->printing;
- BOOL isPrinting = ![NSGraphicsContext currentContextDrawingToScreen];
- if (isPrinting) {
- if (!wasInPrintingMode)
- [self _web_setPrintingModeRecursive];
-#ifndef BUILDING_ON_TIGER
- else
- [self _web_layoutIfNeededRecursive];
-#endif
- } else if (wasInPrintingMode)
- [self _web_clearPrintingModeRecursive];
-
-#ifdef BUILDING_ON_TIGER
-
- // Because Tiger does not have viewWillDraw we need to do layout here.
- [self _web_layoutIfNeededRecursive];
- [_subviews makeObjectsPerformSelector:@selector(_propagateDirtyRectsToOpaqueAncestors)];
-
-#endif
-
- [self _setAsideSubviews];
- [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView topView:topView];
- [self _restoreSubviews];
-
- if (wasInPrintingMode != isPrinting) {
- if (wasInPrintingMode)
- [self _web_setPrintingModeRecursive];
- else
- [self _web_clearPrintingModeRecursive];
- }
-}
-
-// Don't let AppKit even draw subviews. We take care of that.
-- (void)_recursiveDisplayAllDirtyWithLockFocus:(BOOL)needsLockFocus visRect:(NSRect)visRect
-{
- BOOL needToSetAsideSubviews = !_private->subviewsSetAside;
-
- BOOL wasInPrintingMode = _private->printing;
- BOOL isPrinting = ![NSGraphicsContext currentContextDrawingToScreen];
-
- if (needToSetAsideSubviews) {
- // This helps when we print as part of a larger print process.
- // If the WebHTMLView itself is what we're printing, then we will never have to do this.
- if (isPrinting) {
- if (!wasInPrintingMode)
- [self _web_setPrintingModeRecursive];
-#ifndef BUILDING_ON_TIGER
- else
- [self _web_layoutIfNeededRecursive];
-#endif
- } else if (wasInPrintingMode)
- [self _web_clearPrintingModeRecursive];
-
-#ifdef BUILDING_ON_TIGER
-
- // Because Tiger does not have viewWillDraw we need to do layout here.
- NSRect boundsBeforeLayout = [self bounds];
- if (!NSIsEmptyRect(visRect))
- [self _web_layoutIfNeededRecursive];
-
- // If layout changes the view's bounds, then we need to recompute the visRect.
- // That's because the visRect passed to us was based on the bounds at the time
- // we were called. This method is only displayed to draw "all", so it's safe
- // to just call visibleRect to compute the entire rectangle.
- if (!NSEqualRects(boundsBeforeLayout, [self bounds]))
- visRect = [self visibleRect];
-
-#endif
-
- [self _setAsideSubviews];
- }
-
- [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus visRect:visRect];
-
- if (needToSetAsideSubviews) {
- if (wasInPrintingMode != isPrinting) {
- if (wasInPrintingMode)
- [self _web_setPrintingModeRecursive];
- else
- [self _web_clearPrintingModeRecursive];
- }
-
- [self _restoreSubviews];
- }
-}
-
-// Don't let AppKit even draw subviews. We take care of that.
-- (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)context topView:(BOOL)topView
-{
-#ifdef BUILDING_ON_TIGER
- // Because Tiger does not have viewWillDraw we need to do layout here.
- [self _web_layoutIfNeededRecursive];
-#endif
-
- [self _setAsideSubviews];
- [super _recursive:recurse displayRectIgnoringOpacity:displayRect inContext:context topView:topView];
- [self _restoreSubviews];
-}
-
-- (BOOL)_insideAnotherHTMLView
-{
- return self != [self _topHTMLView];
-}
-
-- (NSView *)hitTest:(NSPoint)point
-{
- // WebHTMLView objects handle all events for objects inside them.
- // To get those events, we prevent hit testing from AppKit.
-
- // But there are three exceptions to this:
- // 1) For right mouse clicks and control clicks we don't yet have an implementation
- // that works for nested views, so we let the hit testing go through the
- // standard NSView code path (needs to be fixed, see bug 4361618).
- // 2) Java depends on doing a hit test inside it's mouse moved handling,
- // so we let the hit testing go through the standard NSView code path
- // when the current event is a mouse move (except when we are calling
- // from _updateMouseoverWithEvent, so we have to use a global,
- // forceWebHTMLViewHitTest, for that)
- // 3) The acceptsFirstMouse: and shouldDelayWindowOrderingForEvent: methods
- // both need to figure out which view to check with inside the WebHTMLView.
- // They use a global to change the behavior of hitTest: so they can get the
- // right view. The global is forceNSViewHitTest and the method they use to
- // do the hit testing is _hitViewForEvent:. (But this does not work correctly
- // when there is HTML overlapping the view, see bug 4361626)
- // 4) NSAccessibilityHitTest relies on this for checking the cursor position.
- // Our check for that is whether the event is NSFlagsChanged. This works
- // for VoiceOver's cntl-opt-f5 command (move focus to item under cursor)
- // and Dictionary's cmd-cntl-D (open dictionary popup for item under cursor).
- // This is of course a hack.
-
- BOOL captureHitsOnSubviews;
- if (forceNSViewHitTest)
- captureHitsOnSubviews = NO;
- else if (forceWebHTMLViewHitTest)
- captureHitsOnSubviews = YES;
- else {
- NSEvent *event = [[self window] currentEvent];
- captureHitsOnSubviews = !([event type] == NSMouseMoved
- || [event type] == NSRightMouseDown
- || ([event type] == NSLeftMouseDown && ([event modifierFlags] & NSControlKeyMask) != 0)
- || [event type] == NSFlagsChanged);
- }
-
- if (!captureHitsOnSubviews)
- return [super hitTest:point];
- if ([[self superview] mouse:point inRect:[self frame]])
- return self;
- return nil;
-}
-
-- (void)_clearLastHitViewIfSelf
-{
- if (lastHitView == self)
- lastHitView = nil;
-}
-
-- (NSTrackingRectTag)addTrackingRect:(NSRect)rect owner:(id)owner userData:(void *)data assumeInside:(BOOL)assumeInside
-{
- ASSERT(_private->trackingRectOwner == nil);
- _private->trackingRectOwner = owner;
- _private->trackingRectUserData = data;
- return TRACKING_RECT_TAG;
-}
-
-- (NSTrackingRectTag)_addTrackingRect:(NSRect)rect owner:(id)owner userData:(void *)data assumeInside:(BOOL)assumeInside useTrackingNum:(int)tag
-{
- ASSERT(tag == 0 || tag == TRACKING_RECT_TAG);
- ASSERT(_private->trackingRectOwner == nil);
- _private->trackingRectOwner = owner;
- _private->trackingRectUserData = data;
- return TRACKING_RECT_TAG;
-}
-
-- (void)_addTrackingRects:(NSRect *)rects owner:(id)owner userDataList:(void **)userDataList assumeInsideList:(BOOL *)assumeInsideList trackingNums:(NSTrackingRectTag *)trackingNums count:(int)count
-{
- ASSERT(count == 1);
- ASSERT(trackingNums[0] == 0 || trackingNums[0] == TRACKING_RECT_TAG);
- ASSERT(_private->trackingRectOwner == nil);
- _private->trackingRectOwner = owner;
- _private->trackingRectUserData = userDataList[0];
- trackingNums[0] = TRACKING_RECT_TAG;
-}
-
-- (void)removeTrackingRect:(NSTrackingRectTag)tag
-{
- if (tag == 0)
- return;
-
- if (_private && (tag == TRACKING_RECT_TAG)) {
- _private->trackingRectOwner = nil;
- return;
- }
-
- if (_private && (tag == _private->lastToolTipTag)) {
- [super removeTrackingRect:tag];
- _private->lastToolTipTag = 0;
- return;
- }
-
- // If any other tracking rect is being removed, we don't know how it was created
- // and it's possible there's a leak involved (see 3500217)
- ASSERT_NOT_REACHED();
-}
-
-- (void)_removeTrackingRects:(NSTrackingRectTag *)tags count:(int)count
-{
- int i;
- for (i = 0; i < count; ++i) {
- int tag = tags[i];
- if (tag == 0)
- continue;
- ASSERT(tag == TRACKING_RECT_TAG);
- if (_private != nil) {
- _private->trackingRectOwner = nil;
- }
- }
-}
-
-- (void)_sendToolTipMouseExited
-{
- // Nothing matters except window, trackingNumber, and userData.
- NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseExited
- location:NSMakePoint(0, 0)
- modifierFlags:0
- timestamp:0
- windowNumber:[[self window] windowNumber]
- context:NULL
- eventNumber:0
- trackingNumber:TRACKING_RECT_TAG
- userData:_private->trackingRectUserData];
- [_private->trackingRectOwner mouseExited:fakeEvent];
-}
-
-- (void)_sendToolTipMouseEntered
-{
- // Nothing matters except window, trackingNumber, and userData.
- NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseEntered
- location:NSMakePoint(0, 0)
- modifierFlags:0
- timestamp:0
- windowNumber:[[self window] windowNumber]
- context:NULL
- eventNumber:0
- trackingNumber:TRACKING_RECT_TAG
- userData:_private->trackingRectUserData];
- [_private->trackingRectOwner mouseEntered:fakeEvent];
-}
-
-- (void)_setToolTip:(NSString *)string
-{
- NSString *toolTip = [string length] == 0 ? nil : string;
- NSString *oldToolTip = _private->toolTip;
- if ((toolTip == nil || oldToolTip == nil) ? toolTip == oldToolTip : [toolTip isEqualToString:oldToolTip]) {
- return;
- }
- if (oldToolTip) {
- [self _sendToolTipMouseExited];
- [oldToolTip release];
- }
- _private->toolTip = [toolTip copy];
- if (toolTip) {
- // See radar 3500217 for why we remove all tooltips rather than just the single one we created.
- [self removeAllToolTips];
- NSRect wideOpenRect = NSMakeRect(-100000, -100000, 200000, 200000);
- _private->lastToolTipTag = [self addToolTipRect:wideOpenRect owner:self userData:NULL];
- [self _sendToolTipMouseEntered];
- }
-}
-
-- (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)data
-{
- return [[_private->toolTip copy] autorelease];
-}
-
-- (void)_updateMouseoverWithEvent:(NSEvent *)event
-{
- if (_private->closed)
- return;
-
- NSView *contentView = [[event window] contentView];
- NSPoint locationForHitTest = [[contentView superview] convertPoint:[event locationInWindow] fromView:nil];
-
- forceWebHTMLViewHitTest = YES;
- NSView *hitView = [contentView hitTest:locationForHitTest];
- forceWebHTMLViewHitTest = NO;
-
- WebHTMLView *view = nil;
- if ([hitView isKindOfClass:[WebHTMLView class]] && ![[(WebHTMLView *)hitView _webView] isHoverFeedbackSuspended])
- view = (WebHTMLView *)hitView;
-
- if (view)
- [view retain];
-
- if (lastHitView != view && lastHitView && [lastHitView _frame]) {
- // If we are moving out of a view (or frame), let's pretend the mouse moved
- // all the way out of that view. But we have to account for scrolling, because
- // khtml doesn't understand our clipping.
- NSRect visibleRect = [[[[lastHitView _frame] frameView] _scrollView] documentVisibleRect];
- float yScroll = visibleRect.origin.y;
- float xScroll = visibleRect.origin.x;
-
- event = [NSEvent mouseEventWithType:NSMouseMoved
- location:NSMakePoint(-1 - xScroll, -1 - yScroll )
- modifierFlags:[[NSApp currentEvent] modifierFlags]
- timestamp:[NSDate timeIntervalSinceReferenceDate]
- windowNumber:[[view window] windowNumber]
- context:[[NSApp currentEvent] context]
- eventNumber:0 clickCount:0 pressure:0];
- if (Frame* lastHitCoreFrame = core([lastHitView _frame]))
- lastHitCoreFrame->eventHandler()->mouseMoved(event);
- }
-
- lastHitView = view;
-
- if (view) {
- if (Frame* coreFrame = core([view _frame]))
- coreFrame->eventHandler()->mouseMoved(event);
-
- [view release];
- }
-}
-
-// keep in sync with WebPasteboardHelper::insertablePasteboardTypes
-+ (NSArray *)_insertablePasteboardTypes
-{
- static NSArray *types = nil;
- if (!types) {
- types = [[NSArray alloc] initWithObjects:WebArchivePboardType, NSHTMLPboardType,
- NSFilenamesPboardType, NSTIFFPboardType, NSPICTPboardType, NSURLPboardType,
- NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType,
- kUTTypePNG, nil];
- CFRetain(types);
- }
- return types;
-}
-
-+ (NSArray *)_selectionPasteboardTypes
-{
- // FIXME: We should put data for NSHTMLPboardType on the pasteboard but Microsoft Excel doesn't like our format of HTML (3640423).
- return [NSArray arrayWithObjects:WebArchivePboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, nil];
-}
-
-- (NSImage *)_dragImageForURL:(NSString*)urlString withLabel:(NSString*)label
-{
- BOOL drawURLString = YES;
- BOOL clipURLString = NO, clipLabelString = NO;
-
- if (!label) {
- drawURLString = NO;
- label = urlString;
- }
-
- NSFont *labelFont = [[NSFontManager sharedFontManager] convertFont:[NSFont systemFontOfSize:DRAG_LINK_LABEL_FONT_SIZE]
- toHaveTrait:NSBoldFontMask];
- NSFont *urlFont = [NSFont systemFontOfSize: DRAG_LINK_URL_FONT_SIZE];
- NSSize labelSize;
- labelSize.width = [label _web_widthWithFont: labelFont];
- labelSize.height = [labelFont ascender] - [labelFont descender];
- if (labelSize.width > MAX_DRAG_LABEL_WIDTH){
- labelSize.width = MAX_DRAG_LABEL_WIDTH;
- clipLabelString = YES;
- }
-
- NSSize imageSize, urlStringSize;
- imageSize.width = labelSize.width + DRAG_LABEL_BORDER_X * 2.0f;
- imageSize.height = labelSize.height + DRAG_LABEL_BORDER_Y * 2.0f;
- if (drawURLString) {
- urlStringSize.width = [urlString _web_widthWithFont: urlFont];
- urlStringSize.height = [urlFont ascender] - [urlFont descender];
- imageSize.height += urlStringSize.height;
- if (urlStringSize.width > MAX_DRAG_LABEL_WIDTH) {
- imageSize.width = MAX(MAX_DRAG_LABEL_WIDTH + DRAG_LABEL_BORDER_X * 2.0f, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP);
- clipURLString = YES;
- } else {
- imageSize.width = MAX(labelSize.width + DRAG_LABEL_BORDER_X * 2.0f, urlStringSize.width + DRAG_LABEL_BORDER_X * 2.0f);
- }
- }
- NSImage *dragImage = [[[NSImage alloc] initWithSize: imageSize] autorelease];
- [dragImage lockFocus];
-
- [[NSColor colorWithCalibratedRed: 0.7f green: 0.7f blue: 0.7f alpha: 0.8f] set];
-
- // Drag a rectangle with rounded corners/
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path appendBezierPathWithOvalInRect: NSMakeRect(0.0f, 0.0f, DRAG_LABEL_RADIUS * 2.0f, DRAG_LABEL_RADIUS * 2.0f)];
- [path appendBezierPathWithOvalInRect: NSMakeRect(0, imageSize.height - DRAG_LABEL_RADIUS * 2.0f, DRAG_LABEL_RADIUS * 2.0f, DRAG_LABEL_RADIUS * 2.0f)];
- [path appendBezierPathWithOvalInRect: NSMakeRect(imageSize.width - DRAG_LABEL_RADIUS * 2.0f, imageSize.height - DRAG_LABEL_RADIUS * 2.0f, DRAG_LABEL_RADIUS * 2.0f, DRAG_LABEL_RADIUS * 2.0f)];
- [path appendBezierPathWithOvalInRect: NSMakeRect(imageSize.width - DRAG_LABEL_RADIUS * 2.0f, 0.0f, DRAG_LABEL_RADIUS * 2.0f, DRAG_LABEL_RADIUS * 2.0f)];
-
- [path appendBezierPathWithRect: NSMakeRect(DRAG_LABEL_RADIUS, 0.0f, imageSize.width - DRAG_LABEL_RADIUS * 2.0f, imageSize.height)];
- [path appendBezierPathWithRect: NSMakeRect(0.0f, DRAG_LABEL_RADIUS, DRAG_LABEL_RADIUS + 10.0f, imageSize.height - 2.0f * DRAG_LABEL_RADIUS)];
- [path appendBezierPathWithRect: NSMakeRect(imageSize.width - DRAG_LABEL_RADIUS - 20.0f, DRAG_LABEL_RADIUS, DRAG_LABEL_RADIUS + 20.0f, imageSize.height - 2.0f * DRAG_LABEL_RADIUS)];
- [path fill];
-
- NSColor *topColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.75f];
- NSColor *bottomColor = [NSColor colorWithCalibratedWhite:1.0f alpha:0.5f];
- if (drawURLString) {
- if (clipURLString)
- urlString = [WebStringTruncator centerTruncateString: urlString toWidth:imageSize.width - (DRAG_LABEL_BORDER_X * 2.0f) withFont:urlFont];
-
- [urlString _web_drawDoubledAtPoint:NSMakePoint(DRAG_LABEL_BORDER_X, DRAG_LABEL_BORDER_Y - [urlFont descender])
- withTopColor:topColor bottomColor:bottomColor font:urlFont];
- }
-
- if (clipLabelString)
- label = [WebStringTruncator rightTruncateString: label toWidth:imageSize.width - (DRAG_LABEL_BORDER_X * 2.0f) withFont:labelFont];
- [label _web_drawDoubledAtPoint:NSMakePoint (DRAG_LABEL_BORDER_X, imageSize.height - DRAG_LABEL_BORDER_Y_OFFSET - [labelFont pointSize])
- withTopColor:topColor bottomColor:bottomColor font:labelFont];
-
- [dragImage unlockFocus];
-
- return dragImage;
-}
-
-- (NSImage *)_dragImageForLinkElement:(NSDictionary *)element
-{
- NSURL *linkURL = [element objectForKey: WebElementLinkURLKey];
-
- NSString *label = [element objectForKey: WebElementLinkLabelKey];
- NSString *urlString = [linkURL _web_userVisibleString];
- return [self _dragImageForURL:urlString withLabel:label];
-}
-
-- (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard
-{
- [self setPromisedDragTIFFDataSource:0];
-}
-
-- (void)pasteboard:(NSPasteboard *)pasteboard provideDataForType:(NSString *)type
-{
- if ([type isEqual:NSRTFDPboardType] && [[pasteboard types] containsObject:WebArchivePboardType]) {
- WebArchive *archive = [[WebArchive alloc] initWithData:[pasteboard dataForType:WebArchivePboardType]];
- [pasteboard _web_writePromisedRTFDFromArchive:archive containsImage:[[pasteboard types] containsObject:NSTIFFPboardType]];
- [archive release];
- } else if ([type isEqual:NSTIFFPboardType] && [self promisedDragTIFFDataSource]) {
- if (Image* image = [self promisedDragTIFFDataSource]->image())
- [pasteboard setData:(NSData *)image->getTIFFRepresentation() forType:NSTIFFPboardType];
- [self setPromisedDragTIFFDataSource:0];
- }
-}
-
-- (void)_handleAutoscrollForMouseDragged:(NSEvent *)event
-{
- [self autoscroll:event];
- [self _startAutoscrollTimer:event];
-}
-
-- (WebPluginController *)_pluginController
-{
- return _private->pluginController;
-}
-
-- (void)_layoutForPrinting
-{
- // Set printing mode temporarily so we can adjust the size of the view. This will allow
- // AppKit's pagination code to use the correct height for the page content. Leaving printing
- // mode on indefinitely would interfere with Mail's printing mechanism (at least), so we just
- // turn it off again after adjusting the size.
- [self _web_setPrintingModeRecursiveAndAdjustViewSize];
- [self _web_clearPrintingModeRecursive];
-}
-
-- (void)_smartInsertForString:(NSString *)pasteString replacingRange:(DOMRange *)rangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString
-{
- if (!pasteString || !rangeToReplace || ![[self _webView] smartInsertDeleteEnabled]) {
- if (beforeString)
- *beforeString = nil;
- if (afterString)
- *afterString = nil;
- return;
- }
-
- [[self _frame] _smartInsertForString:pasteString replacingRange:rangeToReplace beforeString:beforeString afterString:afterString];
-}
-
-- (BOOL)_canSmartReplaceWithPasteboard:(NSPasteboard *)pasteboard
-{
- return [[self _webView] smartInsertDeleteEnabled] && [[pasteboard types] containsObject:WebSmartPastePboardType];
-}
-
-- (void)_startAutoscrollTimer: (NSEvent *)triggerEvent
-{
- if (_private->autoscrollTimer == nil) {
- _private->autoscrollTimer = [[NSTimer scheduledTimerWithTimeInterval:AUTOSCROLL_INTERVAL
- target:self selector:@selector(_autoscroll) userInfo:nil repeats:YES] retain];
- _private->autoscrollTriggerEvent = [triggerEvent retain];
- }
-}
-
-// FIXME: _selectionRect is deprecated in favor of selectionRect, which is in protocol WebDocumentSelection.
-// We can't remove this yet because it's still in use by Mail.
-- (NSRect)_selectionRect
-{
- return [self selectionRect];
-}
-
-- (void)_stopAutoscrollTimer
-{
- NSTimer *timer = _private->autoscrollTimer;
- _private->autoscrollTimer = nil;
- [_private->autoscrollTriggerEvent release];
- _private->autoscrollTriggerEvent = nil;
- [timer invalidate];
- [timer release];
-}
-
-- (void)_autoscroll
-{
- // Guarantee that the autoscroll timer is invalidated, even if we don't receive
- // a mouse up event.
- BOOL isStillDown = CGEventSourceButtonState(kCGEventSourceStateCombinedSessionState, kCGMouseButtonLeft);
- if (!isStillDown){
- [self _stopAutoscrollTimer];
- return;
- }
-
- NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSLeftMouseDragged
- location:[[self window] convertScreenToBase:[NSEvent mouseLocation]]
- modifierFlags:[[NSApp currentEvent] modifierFlags]
- timestamp:[NSDate timeIntervalSinceReferenceDate]
- windowNumber:[[self window] windowNumber]
- context:[[NSApp currentEvent] context]
- eventNumber:0 clickCount:0 pressure:0];
- [self mouseDragged:fakeEvent];
-}
-
-- (BOOL)_canEdit
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->editor()->canEdit();
-}
-
-- (BOOL)_canEditRichly
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->editor()->canEditRichly();
-}
-
-- (BOOL)_canAlterCurrentSelection
-{
- return [self _hasSelectionOrInsertionPoint] && [self _isEditable];
-}
-
-- (BOOL)_hasSelection
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->selection()->isRange();
-}
-
-- (BOOL)_hasSelectionOrInsertionPoint
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->selection()->isCaretOrRange();
-}
-
-- (BOOL)_hasInsertionPoint
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->selection()->isCaret();
-}
-
-- (BOOL)_isEditable
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->selection()->isContentEditable();
-}
-
-- (BOOL)_transparentBackground
-{
- return _private->transparentBackground;
-}
-
-- (void)_setTransparentBackground:(BOOL)f
-{
- _private->transparentBackground = f;
-}
-
-- (NSImage *)_selectionDraggingImage
-{
- if ([self _hasSelection]) {
- NSImage *dragImage = core([self _frame])->selectionImage();
- [dragImage _web_dissolveToFraction:WebDragImageAlpha];
- return dragImage;
- }
- return nil;
-}
-
-- (NSRect)_selectionDraggingRect
-{
- // Mail currently calls this method. We can eliminate it when Mail no longer calls it.
- return [self selectionRect];
-}
-
-- (DOMNode *)_insertOrderedList
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame ? kit(coreFrame->editor()->insertOrderedList().get()) : nil;
-}
-
-- (DOMNode *)_insertUnorderedList
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame ? kit(coreFrame->editor()->insertUnorderedList().get()) : nil;
-}
-
-- (BOOL)_canIncreaseSelectionListLevel
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->editor()->canIncreaseSelectionListLevel();
-}
-
-- (BOOL)_canDecreaseSelectionListLevel
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->editor()->canDecreaseSelectionListLevel();
-}
-
-- (DOMNode *)_increaseSelectionListLevel
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame ? kit(coreFrame->editor()->increaseSelectionListLevel().get()) : nil;
-}
-
-- (DOMNode *)_increaseSelectionListLevelOrdered
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame ? kit(coreFrame->editor()->increaseSelectionListLevelOrdered().get()) : nil;
-}
-
-- (DOMNode *)_increaseSelectionListLevelUnordered
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame ? kit(coreFrame->editor()->increaseSelectionListLevelUnordered().get()) : nil;
-}
-
-- (void)_decreaseSelectionListLevel
-{
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->editor()->decreaseSelectionListLevel();
-}
-
-- (void)_setHighlighter:(id<WebHTMLHighlighter>)highlighter ofType:(NSString*)type
-{
- if (!_private->highlighters)
- _private->highlighters = [[NSMutableDictionary alloc] init];
- [_private->highlighters setObject:highlighter forKey:type];
-}
-
-- (void)_removeHighlighterOfType:(NSString*)type
-{
- [_private->highlighters removeObjectForKey:type];
-}
-
-- (void)_updateFocusedAndActiveState
-{
- [self _cancelUpdateFocusedAndActiveStateTimer];
-
- [[self _webView] _updateFocusedAndActiveStateForFrame:[self _frame]];
-}
-
-- (void)_writeSelectionToPasteboard:(NSPasteboard *)pasteboard
-{
- ASSERT([self _hasSelection]);
- NSArray *types = [self pasteboardTypesForSelection];
-
- // Don't write RTFD to the pasteboard when the copied attributed string has no attachments.
- NSAttributedString *attributedString = [self selectedAttributedString];
- NSMutableArray *mutableTypes = nil;
- if (![attributedString containsAttachments]) {
- mutableTypes = [types mutableCopy];
- [mutableTypes removeObject:NSRTFDPboardType];
- types = mutableTypes;
- }
-
- [pasteboard declareTypes:types owner:[self _topHTMLView]];
- [self _writeSelectionWithPasteboardTypes:types toPasteboard:pasteboard cachedAttributedString:attributedString];
- [mutableTypes release];
-}
-
-- (void)close
-{
- // Check for a nil _private here incase we were created with initWithCoder. In that case, the WebView is just throwing
- // out the archived WebHTMLView and recreating a new one if needed. So close doesn't need to do anything in that case.
- if (!_private || _private->closed)
- return;
-
- _private->closed = YES;
-
- [self _cancelUpdateMouseoverTimer];
- [self _cancelUpdateFocusedAndActiveStateTimer];
- [self _clearLastHitViewIfSelf];
- // FIXME: This is slow; should remove individual observers instead.
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [_private->pluginController destroyAllPlugins];
- [_private->pluginController setDataSource:nil];
- // remove tooltips before clearing _private so removeTrackingRect: will work correctly
- [self removeAllToolTips];
- [_private clear];
-
- Page* page = core([self _webView]);
- if (page)
- page->dragController()->setDraggingImageURL(KURL());
-}
-
-- (BOOL)_hasHTMLDocument
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return NO;
- Document* document = coreFrame->document();
- return document && document->isHTMLDocument();
-}
-
-- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard
- forType:(NSString *)pboardType
- inContext:(DOMRange *)context
- subresources:(NSArray **)subresources
-{
- if (pboardType == WebArchivePboardType) {
- WebArchive *archive = [[WebArchive alloc] initWithData:[pasteboard dataForType:WebArchivePboardType]];
- if (subresources)
- *subresources = [archive subresources];
- DOMDocumentFragment *fragment = [[self _dataSource] _documentFragmentWithArchive:archive];
- [archive release];
- return fragment;
- }
- if (pboardType == NSFilenamesPboardType)
- return [self _documentFragmentWithPaths:[pasteboard propertyListForType:NSFilenamesPboardType]];
-
- if (pboardType == NSHTMLPboardType) {
- NSString *HTMLString = [pasteboard stringForType:NSHTMLPboardType];
- // This is a hack to make Microsoft's HTML pasteboard data work. See 3778785.
- if ([HTMLString hasPrefix:@"Version:"]) {
- NSRange range = [HTMLString rangeOfString:@"<html" options:NSCaseInsensitiveSearch];
- if (range.location != NSNotFound)
- HTMLString = [HTMLString substringFromIndex:range.location];
- }
- if ([HTMLString length] == 0)
- return nil;
-
- return [[self _frame] _documentFragmentWithMarkupString:HTMLString baseURLString:nil];
- }
-
- // The _hasHTMLDocument clause here is a workaround for a bug in NSAttributedString: Radar 5052369.
- // If we call _documentFromRange on an XML document we'll get "setInnerHTML: method not found".
- // FIXME: Remove this once bug 5052369 is fixed.
- if ([self _hasHTMLDocument] && pboardType == NSRTFPboardType || pboardType == NSRTFDPboardType) {
- NSAttributedString *string = nil;
- if (pboardType == NSRTFDPboardType)
- string = [[NSAttributedString alloc] initWithRTFD:[pasteboard dataForType:NSRTFDPboardType] documentAttributes:NULL];
- if (string == nil)
- string = [[NSAttributedString alloc] initWithRTF:[pasteboard dataForType:NSRTFPboardType] documentAttributes:NULL];
- if (string == nil)
- return nil;
-
- NSDictionary *documentAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
- [[self class] _excludedElementsForAttributedStringConversion], NSExcludedElementsDocumentAttribute,
- self, @"WebResourceHandler", nil];
- NSArray *s;
-
- BOOL wasDeferringCallbacks = [[self _webView] defersCallbacks];
- if (!wasDeferringCallbacks)
- [[self _webView] setDefersCallbacks:YES];
-
- DOMDocumentFragment *fragment = [string _documentFromRange:NSMakeRange(0, [string length])
- document:[[self _frame] DOMDocument]
- documentAttributes:documentAttributes
- subresources:&s];
- if (subresources)
- *subresources = s;
-
- NSEnumerator *e = [s objectEnumerator];
- WebResource *r;
- while ((r = [e nextObject]))
- [[self _dataSource] addSubresource:r];
-
- if (!wasDeferringCallbacks)
- [[self _webView] setDefersCallbacks:NO];
-
- [documentAttributes release];
- [string release];
- return fragment;
- }
- if (pboardType == NSTIFFPboardType) {
- WebResource *resource = [[WebResource alloc] initWithData:[pasteboard dataForType:NSTIFFPboardType]
- URL:uniqueURLWithRelativePart(@"image.tiff")
- MIMEType:@"image/tiff"
- textEncodingName:nil
- frameName:nil];
- DOMDocumentFragment *fragment = [[self _dataSource] _documentFragmentWithImageResource:resource];
- [resource release];
- return fragment;
- }
- if (pboardType == NSPICTPboardType) {
- WebResource *resource = [[WebResource alloc] initWithData:[pasteboard dataForType:NSPICTPboardType]
- URL:uniqueURLWithRelativePart(@"image.pict")
- MIMEType:@"image/pict"
- textEncodingName:nil
- frameName:nil];
- DOMDocumentFragment *fragment = [[self _dataSource] _documentFragmentWithImageResource:resource];
- [resource release];
- return fragment;
- }
- // Only 10.5 and higher support setting and retrieving pasteboard types with UTIs, but we don't believe
- // that any applications on Tiger put types for which we only have a UTI, like PNG, on the pasteboard.
- if ([pboardType isEqualToString:(NSString*)kUTTypePNG]) {
- WebResource *resource = [[WebResource alloc] initWithData:[pasteboard dataForType:(NSString*)kUTTypePNG]
- URL:uniqueURLWithRelativePart(@"image.png")
- MIMEType:@"image/png"
- textEncodingName:nil
- frameName:nil];
- DOMDocumentFragment *fragment = [[self _dataSource] _documentFragmentWithImageResource:resource];
- [resource release];
- return fragment;
- }
- if (pboardType == NSURLPboardType) {
- NSURL *URL = [NSURL URLFromPasteboard:pasteboard];
- DOMDocument* document = [[self _frame] DOMDocument];
- ASSERT(document);
- if (!document)
- return nil;
- DOMHTMLAnchorElement *anchor = (DOMHTMLAnchorElement *)[document createElement:@"a"];
- NSString *URLString = [URL _web_originalDataAsString];
- if ([URLString length] == 0)
- return nil;
- NSString *URLTitleString = [pasteboard stringForType:WebURLNamePboardType];
- DOMText *text = [document createTextNode:URLTitleString];
- [anchor setHref:URLString];
- [anchor appendChild:text];
- DOMDocumentFragment *fragment = [document createDocumentFragment];
- [fragment appendChild:anchor];
- return fragment;
- }
- if (pboardType == NSStringPboardType)
- return kit(createFragmentFromText(core(context), [pasteboard stringForType:NSStringPboardType]).get());
- return nil;
-}
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-- (void)_pauseNullEventsForAllNetscapePlugins
-{
- NSArray *subviews = [self subviews];
- unsigned int subviewCount = [subviews count];
- unsigned int subviewIndex;
-
- for (subviewIndex = 0; subviewIndex < subviewCount; subviewIndex++) {
- NSView *subview = [subviews objectAtIndex:subviewIndex];
- if ([subview isKindOfClass:[WebBaseNetscapePluginView class]])
- [(WebBaseNetscapePluginView *)subview stopTimers];
- }
-}
-#endif
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-- (void)_resumeNullEventsForAllNetscapePlugins
-{
- NSArray *subviews = [self subviews];
- unsigned int subviewCount = [subviews count];
- unsigned int subviewIndex;
-
- for (subviewIndex = 0; subviewIndex < subviewCount; subviewIndex++) {
- NSView *subview = [subviews objectAtIndex:subviewIndex];
- if ([subview isKindOfClass:[WebBaseNetscapePluginView class]])
- [(WebBaseNetscapePluginView *)subview restartTimers];
- }
-}
-#endif
-
-@end
-
-@implementation NSView (WebHTMLViewFileInternal)
-
-- (void)_web_addDescendantWebHTMLViewsToArray:(NSMutableArray *)array
-{
- unsigned count = [_subviews count];
- for (unsigned i = 0; i < count; ++i) {
- NSView *child = [_subviews objectAtIndex:i];
- if ([child isKindOfClass:[WebHTMLView class]])
- [array addObject:child];
- [child _web_addDescendantWebHTMLViewsToArray:array];
- }
-}
-
-@end
-
-@implementation NSMutableDictionary (WebHTMLViewFileInternal)
-
-- (void)_web_setObjectIfNotNil:(id)object forKey:(id)key
-{
- if (object == nil) {
- [self removeObjectForKey:key];
- } else {
- [self setObject:object forKey:key];
- }
-}
-
-@end
-
-#ifdef BUILDING_ON_TIGER
-
-// The following is a workaround for
-// <rdar://problem/3429631> window stops getting mouse moved events after first tooltip appears
-// The trick is to define a category on NSToolTipPanel that implements setAcceptsMouseMovedEvents:.
-// Since the category will be searched before the real class, we'll prevent the flag from being
-// set on the tool tip panel.
-
-@interface NSToolTipPanel : NSPanel
-@end
-
-@interface NSToolTipPanel (WebHTMLViewFileInternal)
-@end
-
-@implementation NSToolTipPanel (WebHTMLViewFileInternal)
-
-- (void)setAcceptsMouseMovedEvents:(BOOL)flag
-{
- // Do nothing, preventing the tool tip panel from trying to accept mouse-moved events.
-}
-
-@end
-
-#endif
-
-@interface NSArray (WebHTMLView)
-- (void)_web_makePluginViewsPerformSelector:(SEL)selector withObject:(id)object;
-@end
-
-@implementation WebHTMLView
-
-+ (void)initialize
-{
- [NSApp registerServicesMenuSendTypes:[[self class] _selectionPasteboardTypes]
- returnTypes:[[self class] _insertablePasteboardTypes]];
-#ifndef BUILDING_ON_TIGER
- WebCoreObjCFinalizeOnMainThread(self);
-#endif
-}
-
-- (id)initWithFrame:(NSRect)frame
-{
- self = [super initWithFrame:frame];
- if (!self)
- return nil;
-
- [self setFocusRingType:NSFocusRingTypeNone];
-
- // Make all drawing go through us instead of subviews.
- [self _setDrawsOwnDescendants:YES];
-
- _private = [[WebHTMLViewPrivate alloc] init];
-
- _private->pluginController = [[WebPluginController alloc] initWithDocumentView:self];
- _private->needsLayout = YES;
-
- return self;
-}
-
-- (void)dealloc
-{
- if (WebCoreObjCScheduleDeallocateOnMainThread([WebHTMLView class], self))
- return;
-
- // We can't assert that close has already been called because
- // this view can be removed from it's superview, even though
- // it could be needed later, so close if needed.
- [self close];
- [_private release];
- _private = nil;
- [super dealloc];
-}
-
-- (void)finalize
-{
- ASSERT_MAIN_THREAD();
- // We can't assert that close has already been called because
- // this view can be removed from it's superview, even though
- // it could be needed later, so close if needed.
- [self close];
- [super finalize];
-}
-
-// Returns YES if the delegate returns YES (so we should do no more work).
-- (BOOL)callDelegateDoCommandBySelectorIfNeeded:(SEL)selector
-{
- BOOL callerAlreadyCalledDelegate = _private->selectorForDoCommandBySelector == selector;
- _private->selectorForDoCommandBySelector = 0;
- if (callerAlreadyCalledDelegate)
- return NO;
- WebView *webView = [self _webView];
- return [[webView _editingDelegateForwarder] webView:webView doCommandBySelector:selector];
-}
-
-static String commandNameForSelector(SEL selector)
-{
- // Change a few command names into ones supported by WebCore::Editor.
- // If this list gets too long we might decide we need to use a hash table.
- if (selector == @selector(insertParagraphSeparator:) || selector == @selector(insertNewlineIgnoringFieldEditor:))
- return "InsertNewline";
- if (selector == @selector(insertTabIgnoringFieldEditor:))
- return "InsertTab";
- if (selector == @selector(pageDown:))
- return "MovePageDown";
- if (selector == @selector(pageDownAndModifySelection:))
- return "MovePageDownAndModifySelection";
- if (selector == @selector(pageUp:))
- return "MovePageUp";
- if (selector == @selector(pageUpAndModifySelection:))
- return "MovePageUpAndModifySelection";
-
- // Remove the trailing colon.
- const char* selectorName = sel_getName(selector);
- size_t selectorNameLength = strlen(selectorName);
- ASSERT(selectorNameLength >= 2);
- ASSERT(selectorName[selectorNameLength - 1] == ':');
- return String(selectorName, selectorNameLength - 1);
-}
-
-- (Editor::Command)coreCommandBySelector:(SEL)selector
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return Editor::Command();
- return coreFrame->editor()->command(commandNameForSelector(selector));
-}
-
-- (Editor::Command)coreCommandByName:(const char*)name
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return Editor::Command();
- return coreFrame->editor()->command(name);
-}
-
-- (void)executeCoreCommandBySelector:(SEL)selector
-{
- if ([self callDelegateDoCommandBySelectorIfNeeded:selector])
- return;
- [self coreCommandBySelector:selector].execute();
-}
-
-- (void)executeCoreCommandByName:(const char*)name
-{
- [self coreCommandByName:name].execute();
-}
-
-// These commands are forwarded to the Editor object in WebCore.
-// Ideally we'd do this for all editing commands; more of the code
-// should be moved from here to there, and more commands should be
-// added to this list.
-
-// FIXME: Maybe we should set things up so that all these share a single method implementation function.
-// The functions are identical.
-
-#define WEBCORE_COMMAND(command) - (void)command:(id)sender { [self executeCoreCommandBySelector:_cmd]; }
-
-WEBCORE_COMMAND(alignCenter)
-WEBCORE_COMMAND(alignJustified)
-WEBCORE_COMMAND(alignLeft)
-WEBCORE_COMMAND(alignRight)
-WEBCORE_COMMAND(copy)
-WEBCORE_COMMAND(cut)
-WEBCORE_COMMAND(delete)
-WEBCORE_COMMAND(deleteBackward)
-WEBCORE_COMMAND(deleteBackwardByDecomposingPreviousCharacter)
-WEBCORE_COMMAND(deleteForward)
-WEBCORE_COMMAND(deleteToBeginningOfLine)
-WEBCORE_COMMAND(deleteToBeginningOfParagraph)
-WEBCORE_COMMAND(deleteToEndOfLine)
-WEBCORE_COMMAND(deleteToEndOfParagraph)
-WEBCORE_COMMAND(deleteToMark)
-WEBCORE_COMMAND(deleteWordBackward)
-WEBCORE_COMMAND(deleteWordForward)
-WEBCORE_COMMAND(ignoreSpelling)
-WEBCORE_COMMAND(indent)
-WEBCORE_COMMAND(insertBacktab)
-WEBCORE_COMMAND(insertLineBreak)
-WEBCORE_COMMAND(insertNewline)
-WEBCORE_COMMAND(insertNewlineIgnoringFieldEditor)
-WEBCORE_COMMAND(insertParagraphSeparator)
-WEBCORE_COMMAND(insertTab)
-WEBCORE_COMMAND(insertTabIgnoringFieldEditor)
-WEBCORE_COMMAND(moveBackward)
-WEBCORE_COMMAND(moveBackwardAndModifySelection)
-WEBCORE_COMMAND(moveDown)
-WEBCORE_COMMAND(moveDownAndModifySelection)
-WEBCORE_COMMAND(moveForward)
-WEBCORE_COMMAND(moveForwardAndModifySelection)
-WEBCORE_COMMAND(moveLeft)
-WEBCORE_COMMAND(moveLeftAndModifySelection)
-WEBCORE_COMMAND(moveParagraphBackwardAndModifySelection)
-WEBCORE_COMMAND(moveParagraphForwardAndModifySelection)
-WEBCORE_COMMAND(moveRight)
-WEBCORE_COMMAND(moveRightAndModifySelection)
-WEBCORE_COMMAND(moveToBeginningOfDocument)
-WEBCORE_COMMAND(moveToBeginningOfDocumentAndModifySelection)
-WEBCORE_COMMAND(moveToBeginningOfLine)
-WEBCORE_COMMAND(moveToBeginningOfLineAndModifySelection)
-WEBCORE_COMMAND(moveToBeginningOfParagraph)
-WEBCORE_COMMAND(moveToBeginningOfParagraphAndModifySelection)
-WEBCORE_COMMAND(moveToBeginningOfSentence)
-WEBCORE_COMMAND(moveToBeginningOfSentenceAndModifySelection)
-WEBCORE_COMMAND(moveToEndOfDocument)
-WEBCORE_COMMAND(moveToEndOfDocumentAndModifySelection)
-WEBCORE_COMMAND(moveToEndOfLine)
-WEBCORE_COMMAND(moveToEndOfLineAndModifySelection)
-WEBCORE_COMMAND(moveToEndOfParagraph)
-WEBCORE_COMMAND(moveToEndOfParagraphAndModifySelection)
-WEBCORE_COMMAND(moveToEndOfSentence)
-WEBCORE_COMMAND(moveToEndOfSentenceAndModifySelection)
-WEBCORE_COMMAND(moveUp)
-WEBCORE_COMMAND(moveUpAndModifySelection)
-WEBCORE_COMMAND(moveWordBackward)
-WEBCORE_COMMAND(moveWordBackwardAndModifySelection)
-WEBCORE_COMMAND(moveWordForward)
-WEBCORE_COMMAND(moveWordForwardAndModifySelection)
-WEBCORE_COMMAND(moveWordLeft)
-WEBCORE_COMMAND(moveWordLeftAndModifySelection)
-WEBCORE_COMMAND(moveWordRight)
-WEBCORE_COMMAND(moveWordRightAndModifySelection)
-WEBCORE_COMMAND(outdent)
-WEBCORE_COMMAND(pageDown)
-WEBCORE_COMMAND(pageDownAndModifySelection)
-WEBCORE_COMMAND(pageUp)
-WEBCORE_COMMAND(pageUpAndModifySelection)
-WEBCORE_COMMAND(selectAll)
-WEBCORE_COMMAND(selectLine)
-WEBCORE_COMMAND(selectParagraph)
-WEBCORE_COMMAND(selectSentence)
-WEBCORE_COMMAND(selectToMark)
-WEBCORE_COMMAND(selectWord)
-WEBCORE_COMMAND(setMark)
-WEBCORE_COMMAND(subscript)
-WEBCORE_COMMAND(superscript)
-WEBCORE_COMMAND(swapWithMark)
-WEBCORE_COMMAND(transpose)
-WEBCORE_COMMAND(underline)
-WEBCORE_COMMAND(unscript)
-WEBCORE_COMMAND(yank)
-WEBCORE_COMMAND(yankAndSelect)
-
-#undef WEBCORE_COMMAND
-
-#define COMMAND_PROLOGUE if ([self callDelegateDoCommandBySelectorIfNeeded:_cmd]) return;
-
-- (IBAction)takeFindStringFromSelection:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (![self _hasSelection]) {
- NSBeep();
- return;
- }
-
- [NSPasteboard _web_setFindPasteboardString:[self selectedString] withOwner:self];
-}
-
-- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
-{
- [pasteboard declareTypes:types owner:[self _topHTMLView]];
- [self writeSelectionWithPasteboardTypes:types toPasteboard:pasteboard];
- return YES;
-}
-
-- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pasteboard
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return NO;
- if (coreFrame->selection()->isContentRichlyEditable())
- [self _pasteWithPasteboard:pasteboard allowPlainText:YES];
- else
- [self _pasteAsPlainTextWithPasteboard:pasteboard];
- return YES;
-}
-
-- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
-{
- if (sendType != nil && [[self pasteboardTypesForSelection] containsObject:sendType] && [self _hasSelection]) {
- return self;
- } else if (returnType != nil && [[[self class] _insertablePasteboardTypes] containsObject:returnType] && [self _isEditable]) {
- return self;
- }
- return [[self nextResponder] validRequestorForSendType:sendType returnType:returnType];
-}
-
-// jumpToSelection is the old name for what AppKit now calls centerSelectionInVisibleArea. Safari
-// was using the old jumpToSelection selector in its menu. Newer versions of Safari will use the
-// selector centerSelectionInVisibleArea. We'll leave the old selector in place for two reasons:
-// (1) Compatibility between older Safari and newer WebKit; (2) other WebKit-based applications
-// might be using the selector, and we don't want to break them.
-- (void)jumpToSelection:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->revealSelection(RenderLayer::gAlignCenterAlways);
-}
-
-- (NSCellStateValue)selectionHasStyle:(CSSStyleDeclaration*)style
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return NSOffState;
- return kit(coreFrame->editor()->selectionHasStyle(style));
-}
-
-- (BOOL)validateUserInterfaceItemWithoutDelegate:(id <NSValidatedUserInterfaceItem>)item
-{
- SEL action = [item action];
- RefPtr<Frame> frame = core([self _frame]);
-
- if (!frame)
- return NO;
-
- if (Document* doc = frame->document()) {
- if (doc->isPluginDocument())
- return NO;
- if (doc->isImageDocument()) {
- if (action == @selector(copy:))
- return frame->loader()->isComplete();
- return NO;
- }
- }
-
- if (action == @selector(changeSpelling:)
- || action == @selector(_changeSpellingFromMenu:)
- || action == @selector(checkSpelling:)
- || action == @selector(complete:)
- || action == @selector(pasteFont:))
- return [self _canEdit];
-
- if (action == @selector(showGuessPanel:)) {
-#ifndef BUILDING_ON_TIGER
- // Match OS X AppKit behavior for post-Tiger. Don't change Tiger behavior.
- NSMenuItem *menuItem = (NSMenuItem *)item;
- if ([menuItem isKindOfClass:[NSMenuItem class]]) {
- BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
- [menuItem setTitle:panelShowing
- ? UI_STRING("Hide Spelling and Grammar", "menu item title")
- : UI_STRING("Show Spelling and Grammar", "menu item title")];
- }
-#endif
- return [self _canEdit];
- }
-
- if (action == @selector(changeBaseWritingDirection:)) {
- NSWritingDirection writingDirection = static_cast<NSWritingDirection>([item tag]);
- if (writingDirection == NSWritingDirectionNatural)
- return NO;
- NSMenuItem *menuItem = (NSMenuItem *)item;
- if ([menuItem isKindOfClass:[NSMenuItem class]]) {
- RefPtr<CSSStyleDeclaration> style = CSSMutableStyleDeclaration::create();
- ExceptionCode ec;
- style->setProperty("direction", writingDirection == NSWritingDirectionLeftToRight ? "LTR" : "RTL", ec);
- [menuItem setState:frame->editor()->selectionHasStyle(style.get())];
- }
- return [self _canEdit];
- }
-
- if (action == @selector(toggleBaseWritingDirection:)) {
- NSMenuItem *menuItem = (NSMenuItem *)item;
- if ([menuItem isKindOfClass:[NSMenuItem class]]) {
- RefPtr<CSSStyleDeclaration> style = CSSMutableStyleDeclaration::create();
- ExceptionCode ec;
- style->setProperty("direction", "RTL", ec);
- // Take control of the title of the menu item instead of just checking/unchecking it because
- // a check would be ambiguous.
- [menuItem setTitle:frame->editor()->selectionHasStyle(style.get())
- ? UI_STRING("Left to Right", "Left to Right context menu item")
- : UI_STRING("Right to Left", "Right to Left context menu item")];
- }
- return [self _canEdit];
- }
-
- if (action == @selector(changeAttributes:)
- || action == @selector(changeColor:)
- || action == @selector(changeFont:))
- return [self _canEditRichly];
-
- if (action == @selector(capitalizeWord:)
- || action == @selector(lowercaseWord:)
- || action == @selector(uppercaseWord:))
- return [self _hasSelection] && [self _isEditable];
-
- if (action == @selector(centerSelectionInVisibleArea:)
- || action == @selector(jumpToSelection:)
- || action == @selector(copyFont:))
- return [self _hasSelection] || ([self _isEditable] && [self _hasInsertionPoint]);
-
- if (action == @selector(changeDocumentBackgroundColor:))
- return [[self _webView] isEditable] && [self _canEditRichly];
-
- if (action == @selector(_ignoreSpellingFromMenu:)
- || action == @selector(_learnSpellingFromMenu:)
- || action == @selector(takeFindStringFromSelection:))
- return [self _hasSelection];
-
- if (action == @selector(paste:) || action == @selector(pasteAsPlainText:))
- return frame && (frame->editor()->canDHTMLPaste() || frame->editor()->canPaste());
-
- if (action == @selector(pasteAsRichText:))
- return frame && (frame->editor()->canDHTMLPaste()
- || (frame->editor()->canPaste() && frame->selection()->isContentRichlyEditable()));
-
- if (action == @selector(performFindPanelAction:))
- return NO;
-
- if (action == @selector(_lookUpInDictionaryFromMenu:))
- return [self _hasSelection];
-
-#ifndef BUILDING_ON_TIGER
- if (action == @selector(toggleGrammarChecking:)) {
- // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must validate
- // the selector here because we implement it here, and we must implement it here because the AppKit
- // code checks the first responder.
- NSMenuItem *menuItem = (NSMenuItem *)item;
- if ([menuItem isKindOfClass:[NSMenuItem class]])
- [menuItem setState:[self isGrammarCheckingEnabled] ? NSOnState : NSOffState];
- return YES;
- }
-#endif
-
- Editor::Command command = [self coreCommandBySelector:action];
- if (command.isSupported()) {
- NSMenuItem *menuItem = (NSMenuItem *)item;
- if ([menuItem isKindOfClass:[NSMenuItem class]])
- [menuItem setState:kit(command.state())];
- return command.isEnabled();
- }
-
- return YES;
-}
-
-- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
-{
- // This can be called during teardown when _webView is nil. Return NO when this happens, because CallUIDelegateReturningBoolean
- // assumes the WebVIew is non-nil.
- if (![self _webView])
- return NO;
- BOOL result = [self validateUserInterfaceItemWithoutDelegate:item];
- return CallUIDelegateReturningBoolean(result, [self _webView], @selector(webView:validateUserInterfaceItem:defaultValidation:), item, result);
-}
-
-- (BOOL)acceptsFirstResponder
-{
- // Don't accept first responder when we first click on this view.
- // We have to pass the event down through WebCore first to be sure we don't hit a subview.
- // Do accept first responder at any other time, for example from keyboard events,
- // or from calls back from WebCore once we begin mouse-down event handling.
- NSEvent *event = [NSApp currentEvent];
- if ([event type] == NSLeftMouseDown
- && !_private->handlingMouseDownEvent
- && NSPointInRect([event locationInWindow], [self convertRect:[self visibleRect] toView:nil])) {
- return NO;
- }
- return YES;
-}
-
-- (BOOL)maintainsInactiveSelection
-{
- // This method helps to determine whether the WebHTMLView should maintain
- // an inactive selection when it's not first responder.
- // Traditionally, these views have not maintained such selections,
- // clearing them when the view was not first responder. However,
- // to fix bugs like this one:
- // <rdar://problem/3672088>: "Editable WebViews should maintain a selection even
- // when they're not firstResponder"
- // it was decided to add a switch to act more like an NSTextView.
-
- if ([[self _webView] maintainsInactiveSelection])
- return YES;
-
- // Predict the case where we are losing first responder status only to
- // gain it back again. Want to keep the selection in that case.
- id nextResponder = [[self window] _newFirstResponderAfterResigning];
- if ([nextResponder isKindOfClass:[NSScrollView class]]) {
- id contentView = [nextResponder contentView];
- if (contentView)
- nextResponder = contentView;
- }
- if ([nextResponder isKindOfClass:[NSClipView class]]) {
- id documentView = [nextResponder documentView];
- if (documentView)
- nextResponder = documentView;
- }
- if (nextResponder == self)
- return YES;
-
- Frame* coreFrame = core([self _frame]);
- bool selectionIsEditable = coreFrame && coreFrame->selection()->isContentEditable();
- bool nextResponderIsInWebView = [nextResponder isKindOfClass:[NSView class]]
- && [nextResponder isDescendantOf:[[[self _webView] mainFrame] frameView]];
-
- return selectionIsEditable && nextResponderIsInWebView;
-}
-
-- (void)addMouseMovedObserver
-{
- if (!_private->dataSource || ![self _isTopHTMLView])
- return;
-
- // Unless the Dashboard asks us to do this for all windows, keep an observer going only for the key window.
- if (!([[self window] isKeyWindow]
-#if ENABLE(DASHBOARD_SUPPORT)
- || [[self _webView] _dashboardBehavior:WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows]
-#endif
- ))
- return;
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mouseMovedNotification:)
- name:WKMouseMovedNotification() object:nil];
- [self _frameOrBoundsChanged];
-}
-
-- (void)removeMouseMovedObserverUnconditionally
-{
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:WKMouseMovedNotification() object:nil];
-}
-
-- (void)removeMouseMovedObserver
-{
-#if ENABLE(DASHBOARD_SUPPORT)
- // Don't remove the observer if we're running the Dashboard.
- if ([[self _webView] _dashboardBehavior:WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows])
- return;
-#endif
-
- [[self _webView] _mouseDidMoveOverElement:nil modifierFlags:0];
- [self removeMouseMovedObserverUnconditionally];
-}
-
-- (void)addSuperviewObservers
-{
- // We watch the bounds of our superview, so that we can do a layout when the size
- // of the superview changes. This is different from other scrollable things that don't
- // need this kind of thing because their layout doesn't change.
-
- // We need to pay attention to both height and width because our "layout" has to change
- // to extend the background the full height of the space and because some elements have
- // sizes that are based on the total size of the view.
-
- NSView *superview = [self superview];
- if (superview && [self window]) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_frameOrBoundsChanged)
- name:NSViewFrameDidChangeNotification object:superview];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_frameOrBoundsChanged)
- name:NSViewBoundsDidChangeNotification object:superview];
-
- // In addition to registering for frame/bounds change notifications, call -_frameOrBoundsChanged.
- // It will check the current size/scroll against the previous layout's size/scroll. We need to
- // do this here to catch the case where the WebView is laid out at one size, removed from its
- // window, resized, and inserted into another window. Our frame/bounds changed notifications
- // will not be sent in that situation, since we only watch for changes while in the view hierarchy.
- [self _frameOrBoundsChanged];
- }
-}
-
-- (void)removeSuperviewObservers
-{
- NSView *superview = [self superview];
- if (superview && [self window]) {
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSViewFrameDidChangeNotification object:superview];
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSViewBoundsDidChangeNotification object:superview];
- }
-}
-
-- (void)addWindowObservers
-{
- NSWindow *window = [self window];
- if (window) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:)
- name:NSWindowDidBecomeKeyNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResignKey:)
- name:NSWindowDidResignKeyNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillClose:)
- name:NSWindowWillCloseNotification object:window];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillOrderOnScreen:)
- name:WKWindowWillOrderOnScreenNotification() object:window];
- }
-}
-
-- (void)removeWindowObservers
-{
- NSWindow *window = [self window];
- if (window) {
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSWindowDidBecomeKeyNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSWindowDidResignKeyNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSWindowWillCloseNotification object:window];
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:WKWindowWillOrderOnScreenNotification() object:window];
- }
-}
-
-- (void)viewWillMoveToSuperview:(NSView *)newSuperview
-{
- [self removeSuperviewObservers];
-}
-
-- (void)viewDidMoveToSuperview
-{
- if ([self superview] != nil)
- [self addSuperviewObservers];
-}
-
-static void _updateFocusedAndActiveStateTimerCallback(CFRunLoopTimerRef timer, void *info)
-{
- WebHTMLView *view = (WebHTMLView *)info;
- [view _updateFocusedAndActiveState];
-}
-
-- (void)viewWillMoveToWindow:(NSWindow *)window
-{
- // Don't do anything if we aren't initialized. This happens
- // when decoding a WebView. When WebViews are decoded their subviews
- // are created by initWithCoder: and so won't be normally
- // initialized. The stub views are discarded by WebView.
- if (!_private)
- return;
-
- // FIXME: Some of these calls may not work because this view may be already removed from it's superview.
- [self removeMouseMovedObserverUnconditionally];
- [self removeWindowObservers];
- [self removeSuperviewObservers];
- [self _cancelUpdateMouseoverTimer];
- [self _cancelUpdateFocusedAndActiveStateTimer];
-
- [[self _pluginController] stopAllPlugins];
-}
-
-- (void)viewDidMoveToWindow
-{
- // Don't do anything if we aren't initialized. This happens
- // when decoding a WebView. When WebViews are decoded their subviews
- // are created by initWithCoder: and so won't be normally
- // initialized. The stub views are discarded by WebView.
- if (!_private || _private->closed)
- return;
-
- [self _stopAutoscrollTimer];
- if ([self window]) {
- _private->lastScrollPosition = [[self superview] bounds].origin;
- [self addWindowObservers];
- [self addSuperviewObservers];
- [self addMouseMovedObserver];
-
- // Schedule this update, rather than making the call right now.
- // The reason is that placing the caret in the just-installed view requires
- // the HTML/XML document to be available on the WebCore side, but it is not
- // at the time this code is running. However, it will be there on the next
- // crank of the run loop. Doing this helps to make a blinking caret appear
- // in a new, empty window "automatic".
- if (!_private->updateFocusedAndActiveStateTimer) {
- CFRunLoopTimerContext context = { 0, self, NULL, NULL, NULL };
- _private->updateFocusedAndActiveStateTimer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent(), 0, 0, 0,
- _updateFocusedAndActiveStateTimerCallback, &context);
- CFRunLoopAddTimer(CFRunLoopGetCurrent(), _private->updateFocusedAndActiveStateTimer, kCFRunLoopDefaultMode);
- }
-
- [[self _pluginController] startAllPlugins];
-
- _private->lastScrollPosition = NSZeroPoint;
- }
-}
-
-- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
-{
- [[self subviews] _web_makePluginViewsPerformSelector:@selector(viewWillMoveToHostWindow:) withObject:hostWindow];
-}
-
-- (void)viewDidMoveToHostWindow
-{
- [[self subviews] _web_makePluginViewsPerformSelector:@selector(viewDidMoveToHostWindow) withObject:nil];
-}
-
-
-- (void)addSubview:(NSView *)view
-{
- [super addSubview:view];
-
- if ([WebPluginController isPlugInView:view])
- [[self _pluginController] addPlugin:view];
-}
-
-- (void)willRemoveSubview:(NSView *)subview
-{
- if ([WebPluginController isPlugInView:subview])
- [[self _pluginController] destroyPlugin:subview];
-
- [super willRemoveSubview:subview];
-}
-
-- (void)reapplyStyles
-{
- if (!_private->needsToApplyStyles)
- return;
-
-#ifdef LOG_TIMES
- double start = CFAbsoluteTimeGetCurrent();
-#endif
-
- Frame* coreFrame = core([self _frame]);
- if (FrameView* coreView = coreFrame->view())
- coreView->setMediaType(_private->printing ? "print" : "screen");
- if (Document* document = coreFrame->document())
- document->setPrinting(_private->printing);
- coreFrame->reapplyStyles();
-
-#ifdef LOG_TIMES
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- LOG(Timing, "%s apply style seconds = %f", [self URL], thisTime);
-#endif
-
- _private->needsToApplyStyles = NO;
-}
-
-// Do a layout, but set up a new fixed width for the purposes of doing printing layout.
-// minPageWidth==0 implies a non-printing layout
-- (void)layoutToMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustViewSize
-{
- [self reapplyStyles];
-
- if (!_private->needsLayout && ![[self _frame] _needsLayout])
- return;
-
-#ifdef LOG_TIMES
- double start = CFAbsoluteTimeGetCurrent();
-#endif
-
- LOG(View, "%@ doing layout", self);
-
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame) {
- _private->needsLayout = NO;
- return;
- }
-
- if (minPageWidth > 0.0)
- coreFrame->forceLayoutWithPageWidthRange(minPageWidth, maxPageWidth, adjustViewSize);
- else {
- coreFrame->forceLayout(!adjustViewSize);
- if (adjustViewSize)
- coreFrame->view()->adjustViewSize();
- }
- _private->needsLayout = NO;
-
- if (!_private->printing)
- _private->lastLayoutSize = [(NSClipView *)[self superview] documentVisibleRect].size;
-
-#ifdef LOG_TIMES
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- LOG(Timing, "%s layout seconds = %f", [self URL], thisTime);
-#endif
-}
-
-- (void)layout
-{
- [self layoutToMinimumPageWidth:0.0f maximumPageWidth:0.0f adjustingViewSize:NO];
-}
-
-// Deliver mouseup events to the DOM for button 2.
-- (void)rightMouseUp:(NSEvent *)event
-{
- [super rightMouseUp:event];
- if (Frame* coreframe = core([self _frame]))
- coreframe->eventHandler()->mouseUp(event);
-}
-
-- (NSMenu *)menuForEvent:(NSEvent *)event
-{
- [_private->compController endRevertingChange:NO moveLeft:NO];
-
- _private->handlingMouseDownEvent = YES;
- BOOL handledEvent = NO;
- Frame* coreFrame = core([self _frame]);
-
- if (!coreFrame) {
- _private->handlingMouseDownEvent = NO;
- return nil;
- }
-
- Page* page = coreFrame->page();
- if (!page)
- return nil;
-
- page->contextMenuController()->clearContextMenu();
- // Match behavior of other browsers by sending an onmousedown event for right clicks.
- coreFrame->eventHandler()->mouseDown(event);
- handledEvent = coreFrame->eventHandler()->sendContextMenuEvent(PlatformMouseEvent(event));
- _private->handlingMouseDownEvent = NO;
-
- if (!handledEvent)
- return nil;
-
- ContextMenu* coreMenu = page->contextMenuController()->contextMenu();
- if (!coreMenu)
- return nil;
-
- NSArray* menuItems = coreMenu->platformDescription();
- NSMenu* menu = nil;
- if (menuItems && [menuItems count] > 0) {
- menu = [[[NSMenu alloc] init] autorelease];
- for (unsigned i = 0; i < [menuItems count]; i++)
- [menu addItem:[menuItems objectAtIndex:i]];
- }
-
- return menu;
-}
-
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag
-{
- return [self searchFor:string direction:forward caseSensitive:caseFlag wrap:wrapFlag startInSelection:NO];
-}
-
-- (void)clearFocus
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
- Document* document = coreFrame->document();
- if (!document)
- return;
-
- document->setFocusedNode(0);
-}
-
-- (BOOL)isOpaque
-{
- return [[self _webView] drawsBackground];
-}
-
-- (void)setNeedsDisplay:(BOOL)flag
-{
- LOG(View, "%@ setNeedsDisplay:%@", self, flag ? @"YES" : @"NO");
- [super setNeedsDisplay:flag];
-}
-
-- (void)setNeedsLayout: (BOOL)flag
-{
- LOG(View, "%@ setNeedsLayout:%@", self, flag ? @"YES" : @"NO");
- _private->needsLayout = flag;
-}
-
-- (void)setNeedsToApplyStyles: (BOOL)flag
-{
- LOG(View, "%@ setNeedsToApplyStyles:%@", self, flag ? @"YES" : @"NO");
- _private->needsToApplyStyles = flag;
-}
-
-- (void)drawSingleRect:(NSRect)rect
-{
- [NSGraphicsContext saveGraphicsState];
- NSRectClip(rect);
-
- ASSERT([[self superview] isKindOfClass:[WebClipView class]]);
-
- [(WebClipView *)[self superview] setAdditionalClip:rect];
-
- @try {
- if ([self _transparentBackground]) {
- [[NSColor clearColor] set];
- NSRectFill (rect);
- }
-
- [[self _frame] _drawRect:rect contentsOnly:YES];
-
- WebView *webView = [self _webView];
-
- // This hack is needed for <rdar://problem/5023545>. We can hit a race condition where drawRect will be
- // called after the WebView has closed. If the client did not properly close the WebView and set the
- // UIDelegate to nil, then the UIDelegate will be stale and this code will crash.
- static BOOL version3OrLaterClient = WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITHOUT_QUICKBOOKS_QUIRK);
- if (version3OrLaterClient)
- [[webView _UIDelegateForwarder] webView:webView didDrawRect:[webView convertRect:rect fromView:self]];
-
- if (WebNodeHighlight *currentHighlight = [webView currentNodeHighlight])
- [currentHighlight setNeedsUpdateInTargetViewRect:[self convertRect:rect toView:[currentHighlight targetView]]];
-
- [(WebClipView *)[self superview] resetAdditionalClip];
-
- [NSGraphicsContext restoreGraphicsState];
- } @catch (NSException *localException) {
- [(WebClipView *)[self superview] resetAdditionalClip];
- [NSGraphicsContext restoreGraphicsState];
- LOG_ERROR("Exception caught while drawing: %@", localException);
- [localException raise];
- }
-}
-
-- (void)drawRect:(NSRect)rect
-{
- ASSERT_MAIN_THREAD();
- LOG(View, "%@ drawing", self);
-
- const NSRect *rects;
- NSInteger count;
- [self getRectsBeingDrawn:&rects count:&count];
-
- BOOL subviewsWereSetAside = _private->subviewsSetAside;
- if (subviewsWereSetAside)
- [self _restoreSubviews];
-
-#ifdef LOG_TIMES
- double start = CFAbsoluteTimeGetCurrent();
-#endif
-
- if ([[self _webView] _mustDrawUnionedRect:rect singleRects:rects count:count])
- [self drawSingleRect:rect];
- else
- for (int i = 0; i < count; ++i)
- [self drawSingleRect:rects[i]];
-
-#ifdef LOG_TIMES
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- LOG(Timing, "%s draw seconds = %f", widget->part()->baseURL().URL().latin1(), thisTime);
-#endif
-
- if (subviewsWereSetAside)
- [self _setAsideSubviews];
-}
-
-// Turn off the additional clip while computing our visibleRect.
-- (NSRect)visibleRect
-{
- if (!([[self superview] isKindOfClass:[WebClipView class]]))
- return [super visibleRect];
-
- WebClipView *clipView = (WebClipView *)[self superview];
-
- BOOL hasAdditionalClip = [clipView hasAdditionalClip];
- if (!hasAdditionalClip) {
- return [super visibleRect];
- }
-
- NSRect additionalClip = [clipView additionalClip];
- [clipView resetAdditionalClip];
- NSRect visibleRect = [super visibleRect];
- [clipView setAdditionalClip:additionalClip];
- return visibleRect;
-}
-
-- (BOOL)isFlipped
-{
- return YES;
-}
-
-- (void)windowDidBecomeKey:(NSNotification *)notification
-{
- NSWindow *keyWindow = [notification object];
-
- if (keyWindow == [self window])
- [self addMouseMovedObserver];
-
- if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet])
- [self _updateFocusedAndActiveState];
-}
-
-- (void)windowDidResignKey:(NSNotification *)notification
-{
- NSWindow *formerKeyWindow = [notification object];
-
- if (formerKeyWindow == [self window])
- [self removeMouseMovedObserver];
-
- if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet]) {
- [self _updateFocusedAndActiveState];
- [_private->compController endRevertingChange:NO moveLeft:NO];
- }
-}
-
-- (void)windowWillClose:(NSNotification *)notification
-{
- [_private->compController endRevertingChange:NO moveLeft:NO];
- [[self _pluginController] destroyAllPlugins];
-}
-
-- (void)windowWillOrderOnScreen:(NSNotification *)notification
-{
- if (![[self _webView] shouldUpdateWhileOffscreen])
- [self setNeedsDisplay:YES];
-}
-
-- (void)scrollWheel:(NSEvent *)event
-{
- [self retain];
- Frame* frame = core([self _frame]);
- if (!frame || !frame->eventHandler()->wheelEvent(event))
- [super scrollWheel:event];
- [self release];
-}
-
-- (BOOL)_isSelectionEvent:(NSEvent *)event
-{
- NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
- return [[[self elementAtPoint:point allowShadowContent:YES] objectForKey:WebElementIsSelectedKey] boolValue];
-}
-
-- (BOOL)acceptsFirstMouse:(NSEvent *)event
-{
- NSView *hitView = [self _hitViewForEvent:event];
- WebHTMLView *hitHTMLView = [hitView isKindOfClass:[self class]] ? (WebHTMLView *)hitView : nil;
-
-#if ENABLE(DASHBOARD_SUPPORT)
- if ([[self _webView] _dashboardBehavior:WebDashboardBehaviorAlwaysAcceptsFirstMouse])
- return YES;
-#endif
-
- if (hitHTMLView) {
- bool result = false;
- if (Frame* coreFrame = core([hitHTMLView _frame])) {
- coreFrame->eventHandler()->setActivationEventNumber([event eventNumber]);
- [hitHTMLView _setMouseDownEvent:event];
- if ([hitHTMLView _isSelectionEvent:event])
- result = coreFrame->eventHandler()->eventMayStartDrag(event);
- [hitHTMLView _setMouseDownEvent:nil];
- }
- return result;
- }
- return [hitView acceptsFirstMouse:event];
-}
-
-- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)event
-{
- NSView *hitView = [self _hitViewForEvent:event];
- WebHTMLView *hitHTMLView = [hitView isKindOfClass:[self class]] ? (WebHTMLView *)hitView : nil;
- if (hitHTMLView) {
- bool result = false;
- if ([hitHTMLView _isSelectionEvent:event])
- if (Frame* coreFrame = core([hitHTMLView _frame])) {
- [hitHTMLView _setMouseDownEvent:event];
- result = coreFrame->eventHandler()->eventMayStartDrag(event);
- [hitHTMLView _setMouseDownEvent:nil];
- }
- return result;
- }
- return [hitView shouldDelayWindowOrderingForEvent:event];
-}
-
-- (void)mouseDown:(NSEvent *)event
-{
- RetainPtr<WebHTMLView> protector = self;
- if ([[self inputContext] wantsToHandleMouseEvents] && [[self inputContext] handleMouseEvent:event])
- return;
-
- _private->handlingMouseDownEvent = YES;
-
- // Record the mouse down position so we can determine drag hysteresis.
- [self _setMouseDownEvent:event];
-
- NSInputManager *currentInputManager = [NSInputManager currentInputManager];
- if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:event])
- goto done;
-
- [_private->compController endRevertingChange:NO moveLeft:NO];
-
- // If the web page handles the context menu event and menuForEvent: returns nil, we'll get control click events here.
- // We don't want to pass them along to KHTML a second time.
- if (!([event modifierFlags] & NSControlKeyMask)) {
- _private->ignoringMouseDraggedEvents = NO;
-
- // Don't do any mouseover while the mouse is down.
- [self _cancelUpdateMouseoverTimer];
-
- // Let WebCore get a chance to deal with the event. This will call back to us
- // to start the autoscroll timer if appropriate.
- if (Frame* coreframe = core([self _frame]))
- coreframe->eventHandler()->mouseDown(event);
- }
-
-done:
- _private->handlingMouseDownEvent = NO;
-}
-
-- (void)dragImage:(NSImage *)dragImage
- at:(NSPoint)at
- offset:(NSSize)offset
- event:(NSEvent *)event
- pasteboard:(NSPasteboard *)pasteboard
- source:(id)source
- slideBack:(BOOL)slideBack
-{
- ASSERT(self == [self _topHTMLView]);
- [super dragImage:dragImage at:at offset:offset event:event pasteboard:pasteboard source:source slideBack:slideBack];
-}
-
-- (void)mouseDragged:(NSEvent *)event
-{
- NSInputManager *currentInputManager = [NSInputManager currentInputManager];
- if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:event])
- return;
-
- [self retain];
-
- if (!_private->ignoringMouseDraggedEvents)
- if (Frame* coreframe = core([self _frame]))
- coreframe->eventHandler()->mouseDragged(event);
-
- [self release];
-}
-
-- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
-{
- ASSERT(![self _webView] || [self _isTopHTMLView]);
-
- Page *page = core([self _webView]);
-
- if (!page)
- return NSDragOperationNone;
-
- if (page->dragController()->dragOperation() == DragOperationNone)
- return NSDragOperationGeneric | NSDragOperationCopy;
-
- return (NSDragOperation)page->dragController()->dragOperation();
-}
-
-- (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenLoc
-{
- ASSERT(![self _webView] || [self _isTopHTMLView]);
-
- NSPoint windowImageLoc = [[self window] convertScreenToBase:screenLoc];
- NSPoint windowMouseLoc = windowImageLoc;
-
- if (Page* page = core([self _webView])) {
- DragController* dragController = page->dragController();
- NSPoint windowMouseLoc = NSMakePoint(windowImageLoc.x + dragController->dragOffset().x(), windowImageLoc.y + dragController->dragOffset().y());
- }
-
- [[self _frame] _dragSourceMovedTo:windowMouseLoc];
-}
-
-- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
-{
- ASSERT(![self _webView] || [self _isTopHTMLView]);
-
- NSPoint windowImageLoc = [[self window] convertScreenToBase:aPoint];
- NSPoint windowMouseLoc = windowImageLoc;
-
- if (Page* page = core([self _webView])) {
- DragController* dragController = page->dragController();
- windowMouseLoc = NSMakePoint(windowImageLoc.x + dragController->dragOffset().x(), windowImageLoc.y + dragController->dragOffset().y());
- dragController->dragEnded();
- }
-
- [[self _frame] _dragSourceEndedAt:windowMouseLoc operation:operation];
-
- // Prevent queued mouseDragged events from coming after the drag and fake mouseUp event.
- _private->ignoringMouseDraggedEvents = YES;
-
- // Once the dragging machinery kicks in, we no longer get mouse drags or the up event.
- // WebCore expects to get balanced down/up's, so we must fake up a mouseup.
- NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
- location:windowMouseLoc
- modifierFlags:[[NSApp currentEvent] modifierFlags]
- timestamp:[NSDate timeIntervalSinceReferenceDate]
- windowNumber:[[self window] windowNumber]
- context:[[NSApp currentEvent] context]
- eventNumber:0 clickCount:0 pressure:0];
- [self mouseUp:fakeEvent]; // This will also update the mouseover state.
-}
-
-- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
-{
- NSFileWrapper *wrapper = nil;
- NSURL *draggingImageURL = nil;
-
- if (WebCore::CachedResource* tiffResource = [self promisedDragTIFFDataSource]) {
-
- SharedBuffer *buffer = tiffResource->data();
- if (!buffer)
- goto noPromisedData;
-
- NSData *data = buffer->createNSData();
- NSURLResponse *response = tiffResource->response().nsURLResponse();
- draggingImageURL = [response URL];
- wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
- [wrapper setPreferredFilename:[response suggestedFilename]];
- }
-
-noPromisedData:
-
- if (!wrapper) {
- ASSERT(![self _webView] || [self _isTopHTMLView]);
- Page* page = core([self _webView]);
-
- //If a load occurs midway through a drag, the view may be detached, which gives
- //us no ability to get to the original Page, so we cannot access any drag state
- //FIXME: is there a way to recover?
- if (!page)
- return nil;
-
- const KURL& imageURL = page->dragController()->draggingImageURL();
- ASSERT(!imageURL.isEmpty());
- draggingImageURL = imageURL;
-
- wrapper = [[self _dataSource] _fileWrapperForURL:draggingImageURL];
- }
-
- if (wrapper == nil) {
- LOG_ERROR("Failed to create image file.");
- return nil;
- }
-
- // FIXME: Report an error if we fail to create a file.
- NSString *path = [[dropDestination path] stringByAppendingPathComponent:[wrapper preferredFilename]];
- path = [[NSFileManager defaultManager] _webkit_pathWithUniqueFilenameForPath:path];
- if (![wrapper writeToFile:path atomically:NO updateFilenames:YES])
- LOG_ERROR("Failed to create image file via -[NSFileWrapper writeToFile:atomically:updateFilenames:]");
-
- if (draggingImageURL)
- [[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingImageURL absoluteString] referrer:nil atPath:path];
-
- return [NSArray arrayWithObject:[path lastPathComponent]];
-}
-
-- (void)mouseUp:(NSEvent *)event
-{
- [self _setMouseDownEvent:nil];
-
- NSInputManager *currentInputManager = [NSInputManager currentInputManager];
- if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:event])
- return;
-
- [self retain];
-
- [self _stopAutoscrollTimer];
- if (Frame* coreframe = core([self _frame]))
- coreframe->eventHandler()->mouseUp(event);
- [self _updateMouseoverWithFakeEvent];
-
- [self release];
-}
-
-- (void)mouseMovedNotification:(NSNotification *)notification
-{
- [self _updateMouseoverWithEvent:[[notification userInfo] objectForKey:@"NSEvent"]];
-}
-
-// returning YES from this method is the way we tell AppKit that it is ok for this view
-// to be in the key loop even when "tab to all controls" is not on.
-- (BOOL)needsPanelToBecomeKey
-{
- return YES;
-}
-
-- (BOOL)becomeFirstResponder
-{
- NSSelectionDirection direction = NSDirectSelection;
- if (![[self _webView] _isPerformingProgrammaticFocus])
- direction = [[self window] keyViewSelectionDirection];
-
- [self _updateFocusedAndActiveState];
- [self _updateFontPanel];
-
- Frame* frame = core([self _frame]);
- if (!frame)
- return YES;
-
- frame->editor()->setStartNewKillRingSequence(true);
-
- if (direction == NSDirectSelection)
- return YES;
-
- Page* page = frame->page();
- if (!page)
- return YES;
-
- page->focusController()->setFocusedFrame(frame);
- if (Document* document = frame->document())
- document->setFocusedNode(0);
- page->focusController()->setInitialFocus(direction == NSSelectingNext ? FocusDirectionForward : FocusDirectionBackward,
- frame->eventHandler()->currentKeyboardEvent().get());
- return YES;
-}
-
-- (BOOL)resignFirstResponder
-{
- BOOL resign = [super resignFirstResponder];
- if (resign) {
- [_private->compController endRevertingChange:NO moveLeft:NO];
- _private->resigningFirstResponder = YES;
- if (![self maintainsInactiveSelection]) {
- [self deselectAll];
- if (![[self _webView] _isPerformingProgrammaticFocus])
- [self clearFocus];
- }
- [self _updateFocusedAndActiveState];
- _private->resigningFirstResponder = NO;
- }
- return resign;
-}
-
-- (void)setDataSource:(WebDataSource *)dataSource
-{
- ASSERT(dataSource);
- if (_private->dataSource != dataSource) {
- ASSERT(!_private->closed);
- BOOL hadDataSource = _private->dataSource != nil;
-
- [dataSource retain];
- [_private->dataSource release];
- _private->dataSource = dataSource;
- [_private->pluginController setDataSource:dataSource];
-
- if (!hadDataSource)
- [self addMouseMovedObserver];
- }
-}
-
-- (void)dataSourceUpdated:(WebDataSource *)dataSource
-{
-}
-
-// This is an override of an NSControl method that wants to repaint the entire view when the window resigns/becomes
-// key. WebHTMLView is an NSControl only because it hosts NSCells that are painted by WebCore's Aqua theme
-// renderer (and those cells must be hosted by an enclosing NSControl in order to paint properly).
-- (void)updateCell:(NSCell*)cell
-{
-}
-
-// Does setNeedsDisplay:NO as a side effect when printing is ending.
-// pageWidth != 0 implies we will relayout to a new width
-- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize
-{
- WebFrame *frame = [self _frame];
- NSArray *subframes = [frame childFrames];
- unsigned n = [subframes count];
- unsigned i;
- for (i = 0; i != n; ++i) {
- WebFrame *subframe = [subframes objectAtIndex:i];
- WebFrameView *frameView = [subframe frameView];
- if ([[subframe _dataSource] _isDocumentHTML]) {
- [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:adjustViewSize];
- }
- }
-
- if (printing != _private->printing) {
- [_private->pageRects release];
- _private->pageRects = nil;
- _private->printing = printing;
- if (!printing)
- _private->avoidingPrintOrphan = NO;
- [self setNeedsToApplyStyles:YES];
- [self setNeedsLayout:YES];
- [self layoutToMinimumPageWidth:minPageWidth maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];
- if (!printing) {
- // Can't do this when starting printing or nested printing won't work, see 3491427.
- [self setNeedsDisplay:NO];
- }
- }
-}
-
-- (BOOL)canPrintHeadersAndFooters
-{
- return YES;
-}
-
-// This is needed for the case where the webview is embedded in the view that's being printed.
-// It shouldn't be called when the webview is being printed directly.
-- (void)adjustPageHeightNew:(CGFloat *)newBottom top:(CGFloat)oldTop bottom:(CGFloat)oldBottom limit:(CGFloat)bottomLimit
-{
- // This helps when we print as part of a larger print process.
- // If the WebHTMLView itself is what we're printing, then we will never have to do this.
- BOOL wasInPrintingMode = _private->printing;
- if (!wasInPrintingMode)
- [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
-
- float newBottomFloat = *newBottom;
- core([self _frame])->adjustPageHeight(&newBottomFloat, oldTop, oldBottom, bottomLimit);
-
-#ifdef __LP64__
- // If the new bottom is equal to the old bottom (when both are treated as floats), we just copy
- // oldBottom over to newBottom. This prevents rounding errors that can occur when converting newBottomFloat to a double.
- if (fabs((float)oldBottom - newBottomFloat) <= std::numeric_limits<float>::epsilon())
- *newBottom = oldBottom;
- else
-#endif
- *newBottom = newBottomFloat;
-
- if (!wasInPrintingMode) {
- NSPrintOperation *currenPrintOperation = [NSPrintOperation currentOperation];
- if (currenPrintOperation)
- // delay _setPrinting:NO until back to main loop as this method may get called repeatedly
- [self performSelector:@selector(_delayedEndPrintMode:) withObject:currenPrintOperation afterDelay:0];
- else
- // not sure if this is actually ever invoked, it probably shouldn't be
- [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
- }
-}
-
-- (float)_availablePaperWidthForPrintOperation:(NSPrintOperation *)printOperation
-{
- NSPrintInfo *printInfo = [printOperation printInfo];
- return [printInfo paperSize].width - [printInfo leftMargin] - [printInfo rightMargin];
-}
-
-- (float)_scaleFactorForPrintOperation:(NSPrintOperation *)printOperation
-{
- float viewWidth = NSWidth([self bounds]);
- if (viewWidth < 1) {
- LOG_ERROR("%@ has no width when printing", self);
- return 1.0f;
- }
-
- float userScaleFactor = [printOperation _web_pageSetupScaleFactor];
- float maxShrinkToFitScaleFactor = 1.0f / PrintingMaximumShrinkFactor;
- float shrinkToFitScaleFactor = [self _availablePaperWidthForPrintOperation:printOperation]/viewWidth;
- float shrinkToAvoidOrphan = _private->avoidingPrintOrphan ? (1.0f / PrintingOrphanShrinkAdjustment) : 1.0f;
- return userScaleFactor * MAX(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor) * shrinkToAvoidOrphan;
-}
-
-// FIXME 3491344: This is a secret AppKit-internal method that we need to override in order
-// to get our shrink-to-fit to work with a custom pagination scheme. We can do this better
-// if AppKit makes it SPI/API.
-- (CGFloat)_provideTotalScaleFactorForPrintOperation:(NSPrintOperation *)printOperation
-{
- return [self _scaleFactorForPrintOperation:printOperation];
-}
-
-// This is used for Carbon printing. At some point we might want to make this public API.
-- (void)setPageWidthForPrinting:(float)pageWidth
-{
- [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
- [self _setPrinting:YES minimumPageWidth:pageWidth maximumPageWidth:pageWidth adjustViewSize:YES];
-}
-
-- (void)_endPrintMode
-{
- [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:YES];
- [[self window] setAutodisplay:YES];
-}
-
-- (void)_delayedEndPrintMode:(NSPrintOperation *)initiatingOperation
-{
- ASSERT_ARG(initiatingOperation, initiatingOperation != nil);
- NSPrintOperation *currentOperation = [NSPrintOperation currentOperation];
- if (initiatingOperation == currentOperation) {
- // The print operation is still underway. We don't expect this to ever happen, hence the assert, but we're
- // being extra paranoid here since the printing code is so fragile. Delay the cleanup
- // further.
- ASSERT_NOT_REACHED();
- [self performSelector:@selector(_delayedEndPrintMode:) withObject:initiatingOperation afterDelay:0];
- } else if ([currentOperation view] == self) {
- // A new print job has started, but it is printing the same WebHTMLView again. We don't expect
- // this to ever happen, hence the assert, but we're being extra paranoid here since the printing code is so
- // fragile. Do nothing, because we don't want to break the print job currently in progress, and
- // the print job currently in progress is responsible for its own cleanup.
- ASSERT_NOT_REACHED();
- } else {
- // The print job that kicked off this delayed call has finished, and this view is not being
- // printed again. We expect that no other print job has started. Since this delayed call wasn't
- // cancelled, beginDocument and endDocument must not have been called, and we need to clean up
- // the print mode here.
- ASSERT(currentOperation == nil);
- [self _endPrintMode];
- }
-}
-
-// Return the number of pages available for printing
-- (BOOL)knowsPageRange:(NSRangePointer)range
-{
- // Must do this explicit display here, because otherwise the view might redisplay while the print
- // sheet was up, using printer fonts (and looking different).
- [self displayIfNeeded];
- [[self window] setAutodisplay:NO];
-
- // If we are a frameset just print with the layout we have onscreen, otherwise relayout
- // according to the paper size
- float minLayoutWidth = 0.0f;
- float maxLayoutWidth = 0.0f;
- Frame* frame = core([self _frame]);
- if (!frame)
- return NO;
- if (!frame->isFrameSet()) {
- float paperWidth = [self _availablePaperWidthForPrintOperation:[NSPrintOperation currentOperation]];
- minLayoutWidth = paperWidth * PrintingMinimumShrinkFactor;
- maxLayoutWidth = paperWidth * PrintingMaximumShrinkFactor;
- }
- [self _setPrinting:YES minimumPageWidth:minLayoutWidth maximumPageWidth:maxLayoutWidth adjustViewSize:YES]; // will relayout
- NSPrintOperation *printOperation = [NSPrintOperation currentOperation];
- // Certain types of errors, including invalid page ranges, can cause beginDocument and
- // endDocument to be skipped after we've put ourselves in print mode (see 4145905). In those cases
- // we need to get out of print mode without relying on any more callbacks from the printing mechanism.
- // If we get as far as beginDocument without trouble, then this delayed request will be cancelled.
- // If not cancelled, this delayed call will be invoked in the next pass through the main event loop,
- // which is after beginDocument and endDocument would be called.
- [self performSelector:@selector(_delayedEndPrintMode:) withObject:printOperation afterDelay:0];
- [[self _webView] _adjustPrintingMarginsForHeaderAndFooter];
-
- // There is a theoretical chance that someone could do some drawing between here and endDocument,
- // if something caused setNeedsDisplay after this point. If so, it's not a big tragedy, because
- // you'd simply see the printer fonts on screen. As of this writing, this does not happen with Safari.
-
- range->location = 1;
- float totalScaleFactor = [self _scaleFactorForPrintOperation:printOperation];
- float userScaleFactor = [printOperation _web_pageSetupScaleFactor];
- [_private->pageRects release];
- float fullPageHeight = floorf([self _calculatePrintHeight]/totalScaleFactor);
- NSArray *newPageRects = [[self _frame] _computePageRectsWithPrintWidthScaleFactor:userScaleFactor
- printHeight:fullPageHeight];
-
- // AppKit gets all messed up if you give it a zero-length page count (see 3576334), so if we
- // hit that case we'll pass along a degenerate 1 pixel square to print. This will print
- // a blank page (with correct-looking header and footer if that option is on), which matches
- // the behavior of IE and Camino at least.
- if ([newPageRects count] == 0)
- newPageRects = [NSArray arrayWithObject:[NSValue valueWithRect:NSMakeRect(0, 0, 1, 1)]];
- else if ([newPageRects count] > 1) {
- // If the last page is a short orphan, try adjusting the print height slightly to see if this will squeeze the
- // content onto one fewer page. If it does, use the adjusted scale. If not, use the original scale.
- float lastPageHeight = NSHeight([[newPageRects lastObject] rectValue]);
- if (lastPageHeight/fullPageHeight < LastPrintedPageOrphanRatio) {
- NSArray *adjustedPageRects = [[self _frame] _computePageRectsWithPrintWidthScaleFactor:userScaleFactor
- printHeight:fullPageHeight*PrintingOrphanShrinkAdjustment];
- // Use the adjusted rects only if the page count went down
- if ([adjustedPageRects count] < [newPageRects count]) {
- newPageRects = adjustedPageRects;
- _private->avoidingPrintOrphan = YES;
- }
- }
- }
-
- _private->pageRects = [newPageRects retain];
-
- range->length = [_private->pageRects count];
-
- return YES;
-}
-
-// Return the drawing rectangle for a particular page number
-- (NSRect)rectForPage:(NSInteger)page
-{
- return [[_private->pageRects objectAtIndex:page - 1] rectValue];
-}
-
-- (void)drawPageBorderWithSize:(NSSize)borderSize
-{
- ASSERT(NSEqualSizes(borderSize, [[[NSPrintOperation currentOperation] printInfo] paperSize]));
- [[self _webView] _drawHeaderAndFooter];
-}
-
-- (void)beginDocument
-{
- @try {
- // From now on we'll get a chance to call _endPrintMode in either beginDocument or
- // endDocument, so we can cancel the "just in case" pending call.
- [NSObject cancelPreviousPerformRequestsWithTarget:self
- selector:@selector(_delayedEndPrintMode:)
- object:[NSPrintOperation currentOperation]];
- [super beginDocument];
- } @catch (NSException *localException) {
- // Exception during [super beginDocument] means that endDocument will not get called,
- // so we need to clean up our "print mode" here.
- [self _endPrintMode];
- }
-}
-
-- (void)endDocument
-{
- [super endDocument];
- // Note sadly at this point [NSGraphicsContext currentContextDrawingToScreen] is still NO
- [self _endPrintMode];
-}
-
-- (void)keyDown:(NSEvent *)event
-{
- RetainPtr<WebHTMLView> selfProtector = self;
- BOOL eventWasSentToWebCore = (_private->keyDownEvent == event);
-
- BOOL callSuper = NO;
-
- [_private->keyDownEvent release];
- _private->keyDownEvent = [event retain];
-
- BOOL completionPopupWasOpen = _private->compController && [_private->compController popupWindowIsOpen];
- Frame* coreFrame = core([self _frame]);
- if (!eventWasSentToWebCore && coreFrame && coreFrame->eventHandler()->keyEvent(event)) {
- // WebCore processed a key event, bail on any preexisting complete: UI
- if (completionPopupWasOpen)
- [_private->compController endRevertingChange:YES moveLeft:NO];
- } else if (!_private->compController || ![_private->compController filterKeyDown:event]) {
- // Not consumed by complete: popup window
- [_private->compController endRevertingChange:YES moveLeft:NO];
- callSuper = YES;
- }
- if (callSuper)
- [super keyDown:event];
- else
- [NSCursor setHiddenUntilMouseMoves:YES];
-}
-
-- (void)keyUp:(NSEvent *)event
-{
- BOOL eventWasSentToWebCore = (_private->keyDownEvent == event);
-
- RetainPtr<WebHTMLView> selfProtector = self;
- Frame* coreFrame = core([self _frame]);
- if (coreFrame && !eventWasSentToWebCore)
- coreFrame->eventHandler()->keyEvent(event);
- else
- [super keyUp:event];
-}
-
-- (void)flagsChanged:(NSEvent *)event
-{
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->eventHandler()->capsLockStateMayHaveChanged();
-
- RetainPtr<WebHTMLView> selfProtector = self;
-
- unsigned short keyCode = [event keyCode];
-
- //Don't make an event from the num lock and function keys
- if (coreFrame && keyCode != 0 && keyCode != 10 && keyCode != 63) {
- coreFrame->eventHandler()->keyEvent(PlatformKeyboardEvent(event));
- return;
- }
-
- [super flagsChanged:event];
-}
-
-- (id)accessibilityAttributeValue:(NSString*)attributeName
-{
- if ([attributeName isEqualToString: NSAccessibilityChildrenAttribute]) {
- id accTree = [[self _frame] _accessibilityTree];
- if (accTree)
- return [NSArray arrayWithObject:accTree];
- return nil;
- }
- return [super accessibilityAttributeValue:attributeName];
-}
-
-- (id)accessibilityFocusedUIElement
-{
- id accTree = [[self _frame] _accessibilityTree];
- if (accTree)
- return [accTree accessibilityFocusedUIElement];
- return self;
-}
-
-- (id)accessibilityHitTest:(NSPoint)point
-{
- id accTree = [[self _frame] _accessibilityTree];
- if (accTree) {
- NSPoint windowCoord = [[self window] convertScreenToBase:point];
- return [accTree accessibilityHitTest:[self convertPoint:windowCoord fromView:nil]];
- }
- return self;
-}
-
-- (id)_accessibilityParentForSubview:(NSView *)subview
-{
- id accTree = [[self _frame] _accessibilityTree];
- if (!accTree)
- return self;
- id parent = [accTree _accessibilityParentForSubview:subview];
- if (!parent)
- return self;
- return parent;
-}
-
-- (void)centerSelectionInVisibleArea:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->revealSelection(RenderLayer::gAlignCenterAlways);
-}
-
-- (NSData *)_selectionStartFontAttributesAsRTF
-{
- Frame* coreFrame = core([self _frame]);
- NSAttributedString *string = [[NSAttributedString alloc] initWithString:@"x"
- attributes:coreFrame ? coreFrame->fontAttributesForSelectionStart() : nil];
- NSData *data = [string RTFFromRange:NSMakeRange(0, [string length]) documentAttributes:nil];
- [string release];
- return data;
-}
-
-- (NSDictionary *)_fontAttributesFromFontPasteboard
-{
- NSPasteboard *fontPasteboard = [NSPasteboard pasteboardWithName:NSFontPboard];
- if (fontPasteboard == nil)
- return nil;
- NSData *data = [fontPasteboard dataForType:NSFontPboardType];
- if (data == nil || [data length] == 0)
- return nil;
- // NSTextView does something more efficient by parsing the attributes only, but that's not available in API.
- NSAttributedString *string = [[[NSAttributedString alloc] initWithRTF:data documentAttributes:NULL] autorelease];
- if (string == nil || [string length] == 0)
- return nil;
- return [string fontAttributesInRange:NSMakeRange(0, 1)];
-}
-
-- (DOMCSSStyleDeclaration *)_emptyStyle
-{
- return [[[self _frame] DOMDocument] createCSSStyleDeclaration];
-}
-
-- (NSString *)_colorAsString:(NSColor *)color
-{
- NSColor *rgbColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
- // FIXME: If color is non-nil and rgbColor is nil, that means we got some kind
- // of fancy color that can't be converted to RGB. Changing that to "transparent"
- // might not be great, but it's probably OK.
- if (rgbColor == nil)
- return @"transparent";
- float r = [rgbColor redComponent];
- float g = [rgbColor greenComponent];
- float b = [rgbColor blueComponent];
- float a = [rgbColor alphaComponent];
- if (a == 0)
- return @"transparent";
- if (r == 0 && g == 0 && b == 0 && a == 1)
- return @"black";
- if (r == 1 && g == 1 && b == 1 && a == 1)
- return @"white";
- // FIXME: Lots more named colors. Maybe we could use the table in WebCore?
- if (a == 1)
- return [NSString stringWithFormat:@"rgb(%.0f,%.0f,%.0f)", r * 255, g * 255, b * 255];
- return [NSString stringWithFormat:@"rgba(%.0f,%.0f,%.0f,%f)", r * 255, g * 255, b * 255, a];
-}
-
-- (NSString *)_shadowAsString:(NSShadow *)shadow
-{
- if (shadow == nil)
- return @"none";
- NSSize offset = [shadow shadowOffset];
- float blurRadius = [shadow shadowBlurRadius];
- if (offset.width == 0 && offset.height == 0 && blurRadius == 0)
- return @"none";
- NSColor *color = [shadow shadowColor];
- if (color == nil)
- return @"none";
- // FIXME: Handle non-integral values here?
- if (blurRadius == 0)
- return [NSString stringWithFormat:@"%@ %.0fpx %.0fpx", [self _colorAsString:color], offset.width, offset.height];
- return [NSString stringWithFormat:@"%@ %.0fpx %.0fpx %.0fpx", [self _colorAsString:color], offset.width, offset.height, blurRadius];
-}
-
-- (DOMCSSStyleDeclaration *)_styleFromFontAttributes:(NSDictionary *)dictionary
-{
- DOMCSSStyleDeclaration *style = [self _emptyStyle];
-
- NSColor *color = [dictionary objectForKey:NSBackgroundColorAttributeName];
- [style setBackgroundColor:[self _colorAsString:color]];
-
- NSFont *font = [dictionary objectForKey:NSFontAttributeName];
- if (!font) {
- [style setFontFamily:@"Helvetica"];
- [style setFontSize:@"12px"];
- [style setFontWeight:@"normal"];
- [style setFontStyle:@"normal"];
- } else {
- NSFontManager *fm = [NSFontManager sharedFontManager];
- // FIXME: Need more sophisticated escaping code if we want to handle family names
- // with characters like single quote or backslash in their names.
- [style setFontFamily:[NSString stringWithFormat:@"'%@'", [font familyName]]];
- [style setFontSize:[NSString stringWithFormat:@"%0.fpx", [font pointSize]]];
- // FIXME: Map to the entire range of CSS weight values.
- if ([fm weightOfFont:font] >= MIN_BOLD_WEIGHT)
- [style setFontWeight:@"bold"];
- else
- [style setFontWeight:@"normal"];
- if ([fm traitsOfFont:font] & NSItalicFontMask)
- [style setFontStyle:@"italic"];
- else
- [style setFontStyle:@"normal"];
- }
-
- color = [dictionary objectForKey:NSForegroundColorAttributeName];
- [style setColor:color ? [self _colorAsString:color] : (NSString *)@"black"];
-
- NSShadow *shadow = [dictionary objectForKey:NSShadowAttributeName];
- [style setTextShadow:[self _shadowAsString:shadow]];
-
- int strikethroughInt = [[dictionary objectForKey:NSStrikethroughStyleAttributeName] intValue];
-
- int superscriptInt = [[dictionary objectForKey:NSSuperscriptAttributeName] intValue];
- if (superscriptInt > 0)
- [style setVerticalAlign:@"super"];
- else if (superscriptInt < 0)
- [style setVerticalAlign:@"sub"];
- else
- [style setVerticalAlign:@"baseline"];
- int underlineInt = [[dictionary objectForKey:NSUnderlineStyleAttributeName] intValue];
- // FIXME: Underline wins here if we have both (see bug 3790443).
- if (strikethroughInt == NSUnderlineStyleNone && underlineInt == NSUnderlineStyleNone)
- [style setProperty:@"-khtml-text-decorations-in-effect" value:@"none" priority:@""];
- else if (underlineInt == NSUnderlineStyleNone)
- [style setProperty:@"-khtml-text-decorations-in-effect" value:@"line-through" priority:@""];
- else
- [style setProperty:@"-khtml-text-decorations-in-effect" value:@"underline" priority:@""];
-
- return style;
-}
-
-- (void)_applyStyleToSelection:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
-{
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->applyStyleToSelection(core(style), undoAction);
-}
-
-- (void)_applyParagraphStyleToSelection:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
-{
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->applyParagraphStyleToSelection(core(style), undoAction);
-}
-
-- (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
-{
- ASSERT([self _webView]);
- if (![[[self _webView] preferences] respectStandardStyleKeyEquivalents])
- return NO;
-
- if (![self _canEdit])
- return NO;
-
- if (([event modifierFlags] & NSDeviceIndependentModifierFlagsMask) != NSCommandKeyMask)
- return NO;
-
- NSString *string = [event characters];
- if ([string caseInsensitiveCompare:@"b"] == NSOrderedSame) {
- [self executeCoreCommandByName:"ToggleBold"];
- return YES;
- }
- if ([string caseInsensitiveCompare:@"i"] == NSOrderedSame) {
- [self executeCoreCommandByName:"ToggleItalic"];
- return YES;
- }
-
- return NO;
-}
-
-- (BOOL)performKeyEquivalent:(NSEvent *)event
-{
- if ([self _handleStyleKeyEquivalent:event])
- return YES;
-
- BOOL eventWasSentToWebCore = (_private->keyDownEvent == event);
- BOOL ret = NO;
-
- [_private->keyDownEvent release];
- _private->keyDownEvent = [event retain];
-
- [self retain];
-
- // Pass command-key combos through WebCore if there is a key binding available for
- // this event. This lets web pages have a crack at intercepting command-modified keypresses.
- // But don't do it if we have already handled the event.
- // Pressing Esc results in a fake event being sent - don't pass it to WebCore.
- if (!eventWasSentToWebCore && event == [NSApp currentEvent] && self == [[self window] firstResponder])
- if (Frame* frame = core([self _frame]))
- ret = frame->eventHandler()->keyEvent(event);
-
- if (!ret)
- ret = [super performKeyEquivalent:event];
-
- [self release];
-
- return ret;
-}
-
-- (void)copyFont:(id)sender
-{
- COMMAND_PROLOGUE
-
- // Put RTF with font attributes on the pasteboard.
- // Maybe later we should add a pasteboard type that contains CSS text for "native" copy and paste font.
- NSPasteboard *fontPasteboard = [NSPasteboard pasteboardWithName:NSFontPboard];
- [fontPasteboard declareTypes:[NSArray arrayWithObject:NSFontPboardType] owner:nil];
- [fontPasteboard setData:[self _selectionStartFontAttributesAsRTF] forType:NSFontPboardType];
-}
-
-- (void)pasteFont:(id)sender
-{
- COMMAND_PROLOGUE
-
- // Read RTF with font attributes from the pasteboard.
- // Maybe later we should add a pasteboard type that contains CSS text for "native" copy and paste font.
- [self _applyStyleToSelection:[self _styleFromFontAttributes:[self _fontAttributesFromFontPasteboard]] withUndoAction:EditActionPasteFont];
-}
-
-- (void)pasteAsRichText:(id)sender
-{
- COMMAND_PROLOGUE
-
- // Since rich text always beats plain text when both are on the pasteboard, it's not
- // clear how this is different from plain old paste.
- [self _pasteWithPasteboard:[NSPasteboard generalPasteboard] allowPlainText:NO];
-}
-
-- (NSFont *)_originalFontA
-{
- return [[NSFontManager sharedFontManager] fontWithFamily:@"Helvetica" traits:0 weight:STANDARD_WEIGHT size:10.0f];
-}
-
-- (NSFont *)_originalFontB
-{
- return [[NSFontManager sharedFontManager] fontWithFamily:@"Times" traits:NSFontItalicTrait weight:STANDARD_BOLD_WEIGHT size:12.0f];
-}
-
-- (void)_addToStyle:(DOMCSSStyleDeclaration *)style fontA:(NSFont *)a fontB:(NSFont *)b
-{
- // Since there's no way to directly ask NSFontManager what style change it's going to do
- // we instead pass two "specimen" fonts to it and let it change them. We then deduce what
- // style change it was doing by looking at what happened to each of the two fonts.
- // So if it was making the text bold, both fonts will be bold after the fact.
-
- if (a == nil || b == nil)
- return;
-
- NSFontManager *fm = [NSFontManager sharedFontManager];
-
- NSFont *oa = [self _originalFontA];
-
- NSString *aFamilyName = [a familyName];
- NSString *bFamilyName = [b familyName];
-
- int aPointSize = (int)[a pointSize];
- int bPointSize = (int)[b pointSize];
-
- int aWeight = [fm weightOfFont:a];
- int bWeight = [fm weightOfFont:b];
-
- BOOL aIsItalic = ([fm traitsOfFont:a] & NSItalicFontMask) != 0;
- BOOL bIsItalic = ([fm traitsOfFont:b] & NSItalicFontMask) != 0;
-
- if ([aFamilyName isEqualToString:bFamilyName]) {
- NSString *familyNameForCSS = aFamilyName;
-
- // The family name may not be specific enough to get us the font specified.
- // In some cases, the only way to get exactly what we are looking for is to use
- // the Postscript name.
-
- // Find the font the same way the rendering code would later if it encountered this CSS.
- NSFontTraitMask traits = aIsItalic ? NSFontItalicTrait : 0;
- NSFont *foundFont = WebCoreFindFont(aFamilyName, traits, aWeight, aPointSize);
-
- // If we don't find a font with the same Postscript name, then we'll have to use the
- // Postscript name to make the CSS specific enough.
- if (![[foundFont fontName] isEqualToString:[a fontName]])
- familyNameForCSS = [a fontName];
-
- // FIXME: Need more sophisticated escaping code if we want to handle family names
- // with characters like single quote or backslash in their names.
- [style setFontFamily:[NSString stringWithFormat:@"'%@'", familyNameForCSS]];
- }
-
- int soa = (int)[oa pointSize];
- if (aPointSize == bPointSize)
- [style setFontSize:[NSString stringWithFormat:@"%dpx", aPointSize]];
- else if (aPointSize < soa)
- [style _setFontSizeDelta:@"-1px"];
- else if (aPointSize > soa)
- [style _setFontSizeDelta:@"1px"];
-
- if (aWeight == bWeight)
- [style setFontWeight:aWeight > MIN_BOLD_WEIGHT ? @"bold" : @"normal"];
-
- if (aIsItalic == bIsItalic)
- [style setFontStyle:aIsItalic ? @"italic" : @"normal"];
-}
-
-- (DOMCSSStyleDeclaration *)_styleFromFontManagerOperation
-{
- DOMCSSStyleDeclaration *style = [self _emptyStyle];
-
- NSFontManager *fm = [NSFontManager sharedFontManager];
-
- NSFont *oa = [self _originalFontA];
- NSFont *ob = [self _originalFontB];
- [self _addToStyle:style fontA:[fm convertFont:oa] fontB:[fm convertFont:ob]];
-
- return style;
-}
-
-- (void)changeFont:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _applyStyleToSelection:[self _styleFromFontManagerOperation] withUndoAction:EditActionSetFont];
-}
-
-- (DOMCSSStyleDeclaration *)_styleForAttributeChange:(id)sender
-{
- DOMCSSStyleDeclaration *style = [self _emptyStyle];
-
- NSShadow *shadow = [[NSShadow alloc] init];
- [shadow setShadowOffset:NSMakeSize(1, 1)];
-
- NSDictionary *oa = [NSDictionary dictionaryWithObjectsAndKeys:
- [self _originalFontA], NSFontAttributeName,
- nil];
- NSDictionary *ob = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSColor blackColor], NSBackgroundColorAttributeName,
- [self _originalFontB], NSFontAttributeName,
- [NSColor whiteColor], NSForegroundColorAttributeName,
- shadow, NSShadowAttributeName,
- [NSNumber numberWithInt:NSUnderlineStyleSingle], NSStrikethroughStyleAttributeName,
- [NSNumber numberWithInt:1], NSSuperscriptAttributeName,
- [NSNumber numberWithInt:NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
- nil];
-
- [shadow release];
-
-#if 0
-
-NSObliquenessAttributeName /* float; skew to be applied to glyphs, default 0: no skew */
- // font-style, but that is just an on-off switch
-
-NSExpansionAttributeName /* float; log of expansion factor to be applied to glyphs, default 0: no expansion */
- // font-stretch?
-
-NSKernAttributeName /* float, amount to modify default kerning, if 0, kerning off */
- // letter-spacing? probably not good enough
-
-NSUnderlineColorAttributeName /* NSColor, default nil: same as foreground color */
-NSStrikethroughColorAttributeName /* NSColor, default nil: same as foreground color */
- // text-decoration-color?
-
-NSLigatureAttributeName /* int, default 1: default ligatures, 0: no ligatures, 2: all ligatures */
-NSBaselineOffsetAttributeName /* float, in points; offset from baseline, default 0 */
-NSStrokeWidthAttributeName /* float, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0) */
-NSStrokeColorAttributeName /* NSColor, default nil: same as foreground color */
- // need extensions?
-
-#endif
-
- NSDictionary *a = [sender convertAttributes:oa];
- NSDictionary *b = [sender convertAttributes:ob];
-
- NSColor *ca = [a objectForKey:NSBackgroundColorAttributeName];
- NSColor *cb = [b objectForKey:NSBackgroundColorAttributeName];
- if (ca == cb) {
- [style setBackgroundColor:[self _colorAsString:ca]];
- }
-
- [self _addToStyle:style fontA:[a objectForKey:NSFontAttributeName] fontB:[b objectForKey:NSFontAttributeName]];
-
- ca = [a objectForKey:NSForegroundColorAttributeName];
- cb = [b objectForKey:NSForegroundColorAttributeName];
- if (ca == cb) {
- [style setColor:[self _colorAsString:ca]];
- }
-
- NSShadow *sha = [a objectForKey:NSShadowAttributeName];
- if (sha)
- [style setTextShadow:[self _shadowAsString:sha]];
- else if ([b objectForKey:NSShadowAttributeName] == nil)
- [style setTextShadow:@"none"];
-
- int sa = [[a objectForKey:NSStrikethroughStyleAttributeName] intValue];
- int sb = [[b objectForKey:NSStrikethroughStyleAttributeName] intValue];
- if (sa == sb) {
- if (sa == NSUnderlineStyleNone)
- [style setProperty:@"-khtml-text-decorations-in-effect" value:@"none" priority:@""];
- // we really mean "no line-through" rather than "none"
- else
- [style setProperty:@"-khtml-text-decorations-in-effect" value:@"line-through" priority:@""];
- // we really mean "add line-through" rather than "line-through"
- }
-
- sa = [[a objectForKey:NSSuperscriptAttributeName] intValue];
- sb = [[b objectForKey:NSSuperscriptAttributeName] intValue];
- if (sa == sb) {
- if (sa > 0)
- [style setVerticalAlign:@"super"];
- else if (sa < 0)
- [style setVerticalAlign:@"sub"];
- else
- [style setVerticalAlign:@"baseline"];
- }
-
- int ua = [[a objectForKey:NSUnderlineStyleAttributeName] intValue];
- int ub = [[b objectForKey:NSUnderlineStyleAttributeName] intValue];
- if (ua == ub) {
- if (ua == NSUnderlineStyleNone)
- [style setProperty:@"-khtml-text-decorations-in-effect" value:@"none" priority:@""];
- // we really mean "no underline" rather than "none"
- else
- [style setProperty:@"-khtml-text-decorations-in-effect" value:@"underline" priority:@""];
- // we really mean "add underline" rather than "underline"
- }
-
- return style;
-}
-
-- (void)changeAttributes:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _applyStyleToSelection:[self _styleForAttributeChange:sender] withUndoAction:EditActionChangeAttributes];
-}
-
-- (DOMCSSStyleDeclaration *)_styleFromColorPanelWithSelector:(SEL)selector
-{
- DOMCSSStyleDeclaration *style = [self _emptyStyle];
-
- ASSERT([style respondsToSelector:selector]);
- [style performSelector:selector withObject:[self _colorAsString:[[NSColorPanel sharedColorPanel] color]]];
-
- return style;
-}
-
-- (EditAction)_undoActionFromColorPanelWithSelector:(SEL)selector
-{
- if (selector == @selector(setBackgroundColor:))
- return EditActionSetBackgroundColor;
- return EditActionSetColor;
-}
-
-- (void)_changeCSSColorUsingSelector:(SEL)selector inRange:(DOMRange *)range
-{
- DOMCSSStyleDeclaration *style = [self _styleFromColorPanelWithSelector:selector];
- WebView *webView = [self _webView];
- if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:range])
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->applyStyle(core(style), [self _undoActionFromColorPanelWithSelector:selector]);
-}
-
-- (void)changeDocumentBackgroundColor:(id)sender
-{
- COMMAND_PROLOGUE
-
- // Mimicking NSTextView, this method sets the background color for the
- // entire document. There is no NSTextView API for setting the background
- // color on the selected range only. Note that this method is currently
- // never called from the UI (see comment in changeColor:).
- // FIXME: this actually has no effect when called, probably due to 3654850. _documentRange seems
- // to do the right thing because it works in startSpeaking:, and I know setBackgroundColor: does the
- // right thing because I tested it with [self _selectedRange].
- // FIXME: This won't actually apply the style to the entire range here, because it ends up calling
- // [frame _applyStyle:], which operates on the current selection. To make this work right, we'll
- // need to save off the selection, temporarily set it to the entire range, make the change, then
- // restore the old selection.
- [self _changeCSSColorUsingSelector:@selector(setBackgroundColor:) inRange:[self _documentRange]];
-}
-
-- (void)changeColor:(id)sender
-{
- COMMAND_PROLOGUE
-
- // FIXME: in NSTextView, this method calls changeDocumentBackgroundColor: when a
- // private call has earlier been made by [NSFontFontEffectsBox changeColor:], see 3674493.
- // AppKit will have to be revised to allow this to work with anything that isn't an
- // NSTextView. However, this might not be required for Tiger, since the background-color
- // changing box in the font panel doesn't work in Mail (3674481), though it does in TextEdit.
- [self _applyStyleToSelection:[self _styleFromColorPanelWithSelector:@selector(setColor:)]
- withUndoAction:EditActionSetColor];
-}
-
-- (void)_changeWordCaseWithSelector:(SEL)selector
-{
- if (![self _canEdit])
- return;
-
- WebFrame *frame = [self _frame];
- [self selectWord:nil];
- NSString *word = [[frame _selectedString] performSelector:selector];
- // FIXME: Does this need a different action context other than "typed"?
- if ([self _shouldReplaceSelectionWithText:word givenAction:WebViewInsertActionTyped])
- [frame _replaceSelectionWithText:word selectReplacement:NO smartReplace:NO];
-}
-
-- (void)uppercaseWord:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _changeWordCaseWithSelector:@selector(uppercaseString)];
-}
-
-- (void)lowercaseWord:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _changeWordCaseWithSelector:@selector(lowercaseString)];
-}
-
-- (void)capitalizeWord:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _changeWordCaseWithSelector:@selector(capitalizedString)];
-}
-
-- (void)complete:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (![self _canEdit])
- return;
- if (!_private->compController)
- _private->compController = [[WebTextCompleteController alloc] initWithHTMLView:self];
- [_private->compController doCompletion];
-}
-
-- (void)checkSpelling:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->advanceToNextMisspelling();
-}
-
-- (void)showGuessPanel:(id)sender
-{
- COMMAND_PROLOGUE
-
- NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
- if (!checker) {
- LOG_ERROR("No NSSpellChecker");
- return;
- }
-
- NSPanel *spellingPanel = [checker spellingPanel];
-#ifndef BUILDING_ON_TIGER
- // Post-Tiger, this menu item is a show/hide toggle, to match AppKit. Leave Tiger behavior alone
- // to match rest of OS X.
- if ([spellingPanel isVisible]) {
- [spellingPanel orderOut:sender];
- return;
- }
-#endif
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->advanceToNextMisspelling(true);
- [spellingPanel orderFront:sender];
-}
-
-- (void)_changeSpellingToWord:(NSString *)newWord
-{
- if (![self _canEdit])
- return;
-
- // Don't correct to empty string. (AppKit checked this, we might as well too.)
- if (![NSSpellChecker sharedSpellChecker]) {
- LOG_ERROR("No NSSpellChecker");
- return;
- }
-
- if ([newWord isEqualToString:@""])
- return;
-
- if ([self _shouldReplaceSelectionWithText:newWord givenAction:WebViewInsertActionPasted])
- [[self _frame] _replaceSelectionWithText:newWord selectReplacement:YES smartReplace:NO];
-}
-
-- (void)changeSpelling:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _changeSpellingToWord:[[sender selectedCell] stringValue]];
-}
-
-- (void)performFindPanelAction:(id)sender
-{
- COMMAND_PROLOGUE
-
- // Implementing this will probably require copying all of NSFindPanel.h and .m.
- // We need *almost* the same thing as AppKit, but not quite.
- LOG_ERROR("unimplemented");
-}
-
-- (void)startSpeaking:(id)sender
-{
- COMMAND_PROLOGUE
-
- WebFrame *frame = [self _frame];
- DOMRange *range = [self _selectedRange];
- if (!range || [range collapsed])
- range = [self _documentRange];
- [NSApp speakString:[frame _stringForRange:range]];
-}
-
-- (void)stopSpeaking:(id)sender
-{
- COMMAND_PROLOGUE
-
- [NSApp stopSpeaking:sender];
-}
-
-- (void)toggleBaseWritingDirection:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (![self _canEdit])
- return;
-
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
-
- WritingDirection direction = RightToLeftWritingDirection;
- switch (coreFrame->baseWritingDirectionForSelectionStart()) {
- case NSWritingDirectionLeftToRight:
- break;
- case NSWritingDirectionRightToLeft:
- direction = LeftToRightWritingDirection;
- break;
- // The writingDirectionForSelectionStart method will never return "natural". It
- // will always return a concrete direction. So, keep the compiler happy, and assert not reached.
- case NSWritingDirectionNatural:
- ASSERT_NOT_REACHED();
- break;
- }
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->setBaseWritingDirection(direction);
-}
-
-- (void)changeBaseWritingDirection:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (![self _canEdit])
- return;
-
- NSWritingDirection writingDirection = static_cast<NSWritingDirection>([sender tag]);
-
- // We disable the menu item that performs this action because we can't implement
- // NSWritingDirectionNatural's behavior using CSS.
- ASSERT(writingDirection != NSWritingDirectionNatural);
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->setBaseWritingDirection(writingDirection == NSWritingDirectionLeftToRight ? LeftToRightWritingDirection : RightToLeftWritingDirection);
-}
-
-static BOOL writingDirectionKeyBindingsEnabled()
-{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- return [defaults boolForKey:@"NSAllowsBaseWritingDirectionKeyBindings"] || [defaults boolForKey:@"AppleTextDirection"];
-}
-
-- (void)_changeBaseWritingDirectionTo:(NSWritingDirection)direction
-{
- if (![self _canEdit])
- return;
-
- static BOOL bindingsEnabled = writingDirectionKeyBindingsEnabled();
-
- if (!bindingsEnabled) {
- NSBeep();
- return;
- }
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->setBaseWritingDirection(direction == NSWritingDirectionLeftToRight ? LeftToRightWritingDirection : RightToLeftWritingDirection);
-}
-
-- (void)changeBaseWritingDirectionToLTR:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _changeBaseWritingDirectionTo:NSWritingDirectionLeftToRight];
-}
-
-- (void)changeBaseWritingDirectionToRTL:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _changeBaseWritingDirectionTo:NSWritingDirectionRightToLeft];
-}
-
-#if 0
-
-// CSS does not have a way to specify an outline font, which may make this difficult to implement.
-// Maybe a special case of text-shadow?
-- (void)outline:(id)sender;
-
-// This is part of table support, which may be in NSTextView for Tiger.
-// It's probably simple to do the equivalent thing for WebKit.
-- (void)insertTable:(id)sender;
-
-// This could be important.
-- (void)toggleTraditionalCharacterShape:(id)sender;
-
-// I'm not sure what the equivalents of these in the web world are.
-- (void)insertLineSeparator:(id)sender;
-- (void)insertPageBreak:(id)sender;
-
-// These methods are not implemented in NSTextView yet at the time of this writing.
-- (void)changeCaseOfLetter:(id)sender;
-- (void)transposeWords:(id)sender;
-
-#endif
-
-// Super-hack alert.
-// Workaround for bug 3789278.
-
-// Returns a selector only if called while:
-// 1) first responder is self
-// 2) handling a key down event
-// 3) not yet inside keyDown: method
-// 4) key is an arrow key
-// The selector is the one that gets sent by -[NSWindow _processKeyboardUIKey] for this key.
-- (SEL)_arrowKeyDownEventSelectorIfPreprocessing
-{
- NSWindow *w = [self window];
- if ([w firstResponder] != self)
- return NULL;
- NSEvent *e = [w currentEvent];
- if ([e type] != NSKeyDown)
- return NULL;
- if (e == _private->keyDownEvent)
- return NULL;
- NSString *s = [e charactersIgnoringModifiers];
- if ([s length] == 0)
- return NULL;
- switch ([s characterAtIndex:0]) {
- case NSDownArrowFunctionKey:
- return @selector(moveDown:);
- case NSLeftArrowFunctionKey:
- return @selector(moveLeft:);
- case NSRightArrowFunctionKey:
- return @selector(moveRight:);
- case NSUpArrowFunctionKey:
- return @selector(moveUp:);
- default:
- return NULL;
- }
-}
-
-// Returns NO instead of YES if called on the selector that the
-// _arrowKeyDownEventSelectorIfPreprocessing method returns.
-// This should only happen inside -[NSWindow _processKeyboardUIKey],
-// and together with the change below should cause that method
-// to return NO rather than handling the key.
-// Also set a 1-shot flag for the nextResponder check below.
-- (BOOL)respondsToSelector:(SEL)selector
-{
- if (![super respondsToSelector:selector])
- return NO;
- SEL arrowKeySelector = [self _arrowKeyDownEventSelectorIfPreprocessing];
- if (selector != arrowKeySelector)
- return YES;
- _private->nextResponderDisabledOnce = YES;
- return NO;
-}
-
-// Returns nil instead of the next responder if called when the
-// one-shot flag is set, and _arrowKeyDownEventSelectorIfPreprocessing
-// returns something other than NULL. This should only happen inside
-// -[NSWindow _processKeyboardUIKey] and together with the change above
-// should cause that method to return NO rather than handling the key.
-- (NSResponder *)nextResponder
-{
- BOOL disabled = _private->nextResponderDisabledOnce;
- _private->nextResponderDisabledOnce = NO;
- if (disabled && [self _arrowKeyDownEventSelectorIfPreprocessing] != NULL)
- return nil;
- return [super nextResponder];
-}
-
-// Despite its name, this is called at different times than windowDidBecomeKey is.
-// It takes into account all the other factors that determine when NSCell draws
-// with different tints, so it's the right call to use for control tints. We'd prefer
-// to do this with API. <rdar://problem/5136760>
-- (void)_windowChangedKeyState
-{
- if (Frame* frame = core([self _frame]))
- if (FrameView* view = frame->view())
- view->updateControlTints();
- [super _windowChangedKeyState];
-}
-
-- (void)otherMouseDown:(NSEvent *)event
-{
- if ([event buttonNumber] == 2)
- [self mouseDown:event];
- else
- [super otherMouseDown:event];
-}
-
-- (void)otherMouseDragged:(NSEvent *)event
-{
- if ([event buttonNumber] == 2)
- [self mouseDragged:event];
- else
- [super otherMouseDragged:event];
-}
-
-- (void)otherMouseUp:(NSEvent *)event
-{
- if ([event buttonNumber] == 2)
- [self mouseUp:event];
- else
- [super otherMouseUp:event];
-}
-
-@end
-
-@implementation NSArray (WebHTMLView)
-
-- (void)_web_makePluginViewsPerformSelector:(SEL)selector withObject:(id)object
-{
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NSEnumerator *enumerator = [self objectEnumerator];
- WebBaseNetscapePluginView *view;
- while ((view = [enumerator nextObject]) != nil)
- if ([view isKindOfClass:[WebBaseNetscapePluginView class]])
- [view performSelector:selector withObject:object];
-#endif
-}
-
-@end
-
-@implementation WebHTMLView (WebInternal)
-
-- (void)_selectionChanged
-{
- [self _updateSelectionForInputManager];
- [self _updateFontPanel];
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->setStartNewKillRingSequence(true);
-}
-
-- (void)_updateFontPanel
-{
- // FIXME: NSTextView bails out if becoming or resigning first responder, for which it has ivar flags. Not
- // sure if we need to do something similar.
-
- if (![self _canEdit])
- return;
-
- NSWindow *window = [self window];
- // FIXME: is this first-responder check correct? What happens if a subframe is editable and is first responder?
- if ([NSApp keyWindow] != window || [window firstResponder] != self)
- return;
-
- bool multipleFonts = false;
- NSFont *font = nil;
- if (Frame* coreFrame = core([self _frame])) {
- if (const SimpleFontData* fd = coreFrame->editor()->fontForSelection(multipleFonts))
- font = fd->getNSFont();
- }
-
-
- // FIXME: for now, return a bogus font that distinguishes the empty selection from the non-empty
- // selection. We should be able to remove this once the rest of this code works properly.
- if (font == nil)
- font = [self _hasSelection] ? [NSFont menuFontOfSize:23] : [NSFont toolTipsFontOfSize:17];
- ASSERT(font != nil);
-
- [[NSFontManager sharedFontManager] setSelectedFont:font isMultiple:multipleFonts];
-
- // FIXME: we don't keep track of selected attributes, or set them on the font panel. This
- // appears to have no effect on the UI. E.g., underlined text in Mail or TextEdit is
- // not reflected in the font panel. Maybe someday this will change.
-}
-
-- (BOOL)_canSmartCopyOrDelete
-{
- if (![[self _webView] smartInsertDeleteEnabled])
- return NO;
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->selectionGranularity() == WordGranularity;
-}
-
-- (NSEvent *)_mouseDownEvent
-{
- return _private->mouseDownEvent;
-}
-
-- (id<WebHTMLHighlighter>)_highlighterForType:(NSString*)type
-{
- return [_private->highlighters objectForKey:type];
-}
-
-- (WebFrame *)_frame
-{
- return [_private->dataSource webFrame];
-}
-
-- (void)paste:(id)sender
-{
- COMMAND_PROLOGUE
-
- RetainPtr<WebHTMLView> selfProtector = self;
- RefPtr<Frame> coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
- if (coreFrame->editor()->tryDHTMLPaste())
- return; // DHTML did the whole operation
- if (!coreFrame->editor()->canPaste())
- return;
- if (coreFrame->selection()->isContentRichlyEditable())
- [self _pasteWithPasteboard:[NSPasteboard generalPasteboard] allowPlainText:YES];
- else
- coreFrame->editor()->pasteAsPlainText();
-}
-
-- (void)pasteAsPlainText:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (![self _canEdit])
- return;
- [self _pasteAsPlainTextWithPasteboard:[NSPasteboard generalPasteboard]];
-}
-
-- (void)closeIfNotCurrentView
-{
- if ([[[self _frame] frameView] documentView] != self)
- [self close];
-}
-
-- (DOMDocumentFragment*)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard
-{
- return [self _documentFragmentFromPasteboard:pasteboard inContext:nil allowPlainText:NO];
-}
-
-#ifndef BUILDING_ON_TIGER
-
-- (BOOL)isGrammarCheckingEnabled
-{
- // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must implement the method here because
- // the AppKit code checks the first responder.
- return [[self _webView] isGrammarCheckingEnabled];
-}
-
-- (void)setGrammarCheckingEnabled:(BOOL)flag
-{
- // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must implement the method here because
- // the AppKit code checks the first responder.
- [[self _webView] setGrammarCheckingEnabled:flag];
-}
-
-- (void)toggleGrammarChecking:(id)sender
-{
- // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must implement the method here because
- // the AppKit code checks the first responder.
- [[self _webView] toggleGrammarChecking:sender];
-}
-
-
-static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
-{
- NSArray *screens = [NSScreen screens];
-
- if ([screens count] == 0) {
- // You could theoretically get here if running with no monitor, in which case it doesn't matter
- // much where the "on-screen" point is.
- return CGPointMake(point.x, point.y);
- }
-
- // Flip the y coordinate from the top of the menu bar screen -- see 4636390
- return CGPointMake(point.x, NSMaxY([[screens objectAtIndex:0] frame]) - point.y);
-}
-
-#endif
-
-- (void)_lookUpInDictionaryFromMenu:(id)sender
-{
- // Dictionary API will accept a whitespace-only string and display UI as if it were real text,
- // so bail out early to avoid that.
- if ([[[self selectedString] _webkit_stringByTrimmingWhitespace] length] == 0)
- return;
-
- // We soft link to get the function that displays the dictionary (either pop-up window or app) to avoid the performance
- // penalty of linking to another framework. This function changed signature as well as framework between Tiger and Leopard,
- // so the two cases are handled separately.
-
-#ifdef BUILDING_ON_TIGER
- typedef OSStatus (*ServiceWindowShowFunction)(id inWordString, NSRect inWordBoundary, UInt16 inLineDirection);
- const char *frameworkPath = "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LangAnalysis.framework/LangAnalysis";
- const char *functionName = "DCMDictionaryServiceWindowShow";
-#else
- typedef void (*ServiceWindowShowFunction)(id unusedDictionaryRef, id inWordString, CFRange selectionRange, id unusedFont, CGPoint textOrigin, Boolean verticalText, id unusedTransform);
- const char *frameworkPath = "/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/HIToolbox";
- const char *functionName = "HIDictionaryWindowShow";
-#endif
-
- static bool lookedForFunction = false;
- static ServiceWindowShowFunction dictionaryServiceWindowShow = NULL;
-
- if (!lookedForFunction) {
- void* langAnalysisFramework = dlopen(frameworkPath, RTLD_LAZY);
- ASSERT(langAnalysisFramework);
- if (langAnalysisFramework)
- dictionaryServiceWindowShow = (ServiceWindowShowFunction)dlsym(langAnalysisFramework, functionName);
- lookedForFunction = true;
- }
-
- ASSERT(dictionaryServiceWindowShow);
- if (!dictionaryServiceWindowShow) {
- NSLog(@"Couldn't find the %s function in %s", functionName, frameworkPath);
- return;
- }
-
- NSAttributedString *attrString = [self selectedAttributedString];
-
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
-
-#ifdef BUILDING_ON_TIGER
- // FIXME: must check for right-to-left here
- NSWritingDirection writingDirection = NSWritingDirectionLeftToRight;
-
- // FIXME: the dictionary API expects the rect for the first line of selection. Passing
- // the rect for the entire selection, as we do here, positions the pop-up window near
- // the bottom of the selection rather than at the selected word.
- NSRect rect = [self convertRect:coreFrame->selectionRect() toView:nil];
- rect.origin = [[self window] convertBaseToScreen:rect.origin];
- NSData *data = [attrString RTFFromRange:NSMakeRange(0, [attrString length]) documentAttributes:nil];
- dictionaryServiceWindowShow(data, rect, (writingDirection == NSWritingDirectionRightToLeft) ? 1 : 0);
-#else
- // The HIDictionaryWindowShow function requires the origin, in CG screen coordinates, of the first character of text in the selection.
- // FIXME 4945808: We approximate this in a way that works well when a single word is selected, and less well in some other cases
- // (but no worse than we did in Tiger)
- NSRect rect = coreFrame->selectionRect();
-
- NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0,1)];
- NSFont *font = [attributes objectForKey:NSFontAttributeName];
- if (font)
- rect.origin.y += [font ascender];
-
- NSPoint windowPoint = [self convertPoint:rect.origin toView:nil];
- NSPoint screenPoint = [[self window] convertBaseToScreen:windowPoint];
-
- dictionaryServiceWindowShow(nil, attrString, CFRangeMake(0, [attrString length]), nil,
- coreGraphicsScreenPointForAppKitScreenPoint(screenPoint), false, nil);
-#endif
-}
-
-- (void)_hoverFeedbackSuspendedChanged
-{
- [self _updateMouseoverWithFakeEvent];
-}
-
-- (BOOL)_interceptEditingKeyEvent:(KeyboardEvent*)event shouldSaveCommand:(BOOL)shouldSave
-{
- // Ask AppKit to process the key event -- it will call back with either insertText or doCommandBySelector.
- WebHTMLViewInterpretKeyEventsParameters parameters;
- parameters.eventWasHandled = false;
- parameters.shouldSaveCommand = shouldSave;
- // If we're intercepting the initial IM call we assume that the IM has consumed the event,
- // and only change this assumption if one of the NSTextInput/Responder callbacks is used.
- // We assume the IM will *not* consume hotkey sequences
- parameters.consumedByIM = !event->metaKey() && shouldSave;
-
- if (const PlatformKeyboardEvent* platformEvent = event->keyEvent()) {
- NSEvent *macEvent = platformEvent->macEvent();
- if ([macEvent type] == NSKeyDown && [_private->compController filterKeyDown:macEvent])
- return true;
-
- if ([macEvent type] == NSFlagsChanged)
- return false;
-
- parameters.event = event;
- _private->interpretKeyEventsParameters = &parameters;
- _private->receivedNOOP = NO;
- const Vector<KeypressCommand>& commands = event->keypressCommands();
- bool hasKeypressCommand = !commands.isEmpty();
-
- // FIXME: interpretKeyEvents doesn't match application key equivalents (such as Cmd+A),
- // and sends noop: for those. As a result, we don't handle those from within WebCore,
- // but send a full sequence of DOM events, including an unneeded keypress.
- if (parameters.shouldSaveCommand || !hasKeypressCommand)
- [self interpretKeyEvents:[NSArray arrayWithObject:macEvent]];
- else {
- size_t size = commands.size();
- // Are there commands that would just cause text insertion if executed via Editor?
- // WebKit doesn't have enough information about mode to decide how they should be treated, so we leave it upon WebCore
- // to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
- // (e.g. Tab that inserts a Tab character, or Enter).
- bool haveTextInsertionCommands = false;
- for (size_t i = 0; i < size; ++i) {
- if ([self coreCommandBySelector:NSSelectorFromString(commands[i].commandName)].isTextInsertion())
- haveTextInsertionCommands = true;
- }
- if (!haveTextInsertionCommands || platformEvent->type() == PlatformKeyboardEvent::Char)
- for (size_t i = 0; i < size; ++i)
- if (commands[i].commandName == "insertText:")
- [self insertText:commands[i].text];
- else
- [self doCommandBySelector:NSSelectorFromString(commands[i].commandName)];
- }
- _private->interpretKeyEventsParameters = 0;
- }
- return (!_private->receivedNOOP && parameters.eventWasHandled) || parameters.consumedByIM;
-}
-
-- (WebCore::CachedImage*)promisedDragTIFFDataSource
-{
- return _private->promisedDragTIFFDataSource;
-}
-
-- (void)setPromisedDragTIFFDataSource:(WebCore::CachedImage*)source
-{
- if (source)
- source->addClient(promisedDataClient());
-
- if (_private->promisedDragTIFFDataSource)
- _private->promisedDragTIFFDataSource->removeClient(promisedDataClient());
- _private->promisedDragTIFFDataSource = source;
-}
-
-#undef COMMAND_PROLOGUE
-
-- (void)_layoutIfNeeded
-{
- ASSERT(!_private->subviewsSetAside);
-
- if ([[self _frame] _needsLayout])
- _private->needsLayout = YES;
- if (_private->needsToApplyStyles || _private->needsLayout)
- [self layout];
-}
-
-- (void)_web_layoutIfNeededRecursive
-{
- [self _layoutIfNeeded];
-
-#ifndef NDEBUG
- _private->enumeratingSubviews = YES;
-#endif
-
- NSMutableArray *descendantWebHTMLViews = [[NSMutableArray alloc] init];
-
- [self _web_addDescendantWebHTMLViewsToArray:descendantWebHTMLViews];
-
- unsigned count = [descendantWebHTMLViews count];
- for (unsigned i = 0; i < count; ++i)
- [[descendantWebHTMLViews objectAtIndex:i] _layoutIfNeeded];
-
- [descendantWebHTMLViews release];
-
-#ifndef NDEBUG
- _private->enumeratingSubviews = NO;
-#endif
-}
-
-- (void) _destroyAllWebPlugins
-{
- [[self _pluginController] destroyAllPlugins];
-}
-
-@end
-
-@implementation WebHTMLView (WebNSTextInputSupport)
-
-- (NSArray *)validAttributesForMarkedText
-{
- static NSArray *validAttributes;
- if (!validAttributes) {
- validAttributes = [[NSArray alloc] initWithObjects:
- NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
- NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName, nil];
- // NSText also supports the following attributes, but it's
- // hard to tell which are really required for text input to
- // work well; I have not seen any input method make use of them yet.
- // NSFontAttributeName, NSForegroundColorAttributeName,
- // NSBackgroundColorAttributeName, NSLanguageAttributeName.
- CFRetain(validAttributes);
- }
- LOG(TextInput, "validAttributesForMarkedText -> (...)");
- return validAttributes;
-}
-
-// Utility function to make sure we don't return anything through the NSTextInput
-// API when an editable region is not currently focused.
-static BOOL isTextInput(Frame* coreFrame)
-{
- return coreFrame && !coreFrame->selection()->isNone() && coreFrame->selection()->isContentEditable();
-}
-
-static BOOL isInPasswordField(Frame* coreFrame)
-{
- return coreFrame && coreFrame->selection()->isInPasswordField();
-}
-
-- (NSAttributedString *)textStorage
-{
- Frame* coreFrame = core([self _frame]);
- if (!isTextInput(coreFrame) || isInPasswordField(coreFrame)) {
- LOG(TextInput, "textStorage -> nil");
- return nil;
- }
- NSAttributedString *result = [self attributedSubstringFromRange:NSMakeRange(0, UINT_MAX)];
-
- LOG(TextInput, "textStorage -> \"%@\"", result ? [result string] : @"");
-
- // We have to return an empty string rather than null to prevent TSM from calling -string
- return result ? result : [[[NSAttributedString alloc] initWithString:@""] autorelease];
-}
-
-- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
-{
- NSWindow *window = [self window];
- WebFrame *frame = [self _frame];
-
- if (window)
- thePoint = [window convertScreenToBase:thePoint];
- thePoint = [self convertPoint:thePoint fromView:nil];
-
- DOMRange *range = [frame _characterRangeAtPoint:thePoint];
- if (!range) {
- LOG(TextInput, "characterIndexForPoint:(%f, %f) -> NSNotFound", thePoint.x, thePoint.y);
- return NSNotFound;
- }
-
- unsigned result = [frame _convertDOMRangeToNSRange:range].location;
- LOG(TextInput, "characterIndexForPoint:(%f, %f) -> %u", thePoint.x, thePoint.y, result);
- return result;
-}
-
-- (NSRect)firstRectForCharacterRange:(NSRange)theRange
-{
- WebFrame *frame = [self _frame];
-
- // Just to match NSTextView's behavior. Regression tests cannot detect this;
- // to reproduce, use a test application from http://bugs.webkit.org/show_bug.cgi?id=4682
- // (type something; try ranges (1, -1) and (2, -1).
- if ((theRange.location + theRange.length < theRange.location) && (theRange.location + theRange.length != 0))
- theRange.length = 0;
-
- DOMRange *range = [frame _convertNSRangeToDOMRange:theRange];
- if (!range) {
- LOG(TextInput, "firstRectForCharacterRange:(%u, %u) -> (0, 0, 0, 0)", theRange.location, theRange.length);
- return NSMakeRect(0, 0, 0, 0);
- }
-
- ASSERT([range startContainer]);
- ASSERT([range endContainer]);
-
- NSRect resultRect = [frame _firstRectForDOMRange:range];
- resultRect = [self convertRect:resultRect toView:nil];
-
- NSWindow *window = [self window];
- if (window)
- resultRect.origin = [window convertBaseToScreen:resultRect.origin];
-
- LOG(TextInput, "firstRectForCharacterRange:(%u, %u) -> (%f, %f, %f, %f)", theRange.location, theRange.length, resultRect.origin.x, resultRect.origin.y, resultRect.size.width, resultRect.size.height);
- return resultRect;
-}
-
-- (NSRange)selectedRange
-{
- if (!isTextInput(core([self _frame]))) {
- LOG(TextInput, "selectedRange -> (NSNotFound, 0)");
- return NSMakeRange(NSNotFound, 0);
- }
- NSRange result = [[self _frame] _selectedNSRange];
-
- LOG(TextInput, "selectedRange -> (%u, %u)", result.location, result.length);
- return result;
-}
-
-- (NSRange)markedRange
-{
- WebFrame *webFrame = [self _frame];
- NSRange result = [webFrame _convertToNSRange:core(webFrame)->editor()->compositionRange().get()];
- LOG(TextInput, "markedRange -> (%u, %u)", result.location, result.length);
- return result;
-}
-
-- (NSAttributedString *)attributedSubstringFromRange:(NSRange)nsRange
-{
- WebFrame *frame = [self _frame];
- Frame* coreFrame = core(frame);
- if (!isTextInput(coreFrame) || isInPasswordField(coreFrame)) {
- LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> nil", nsRange.location, nsRange.length);
- return nil;
- }
- DOMRange *domRange = [frame _convertNSRangeToDOMRange:nsRange];
- if (!domRange) {
- LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> nil", nsRange.location, nsRange.length);
- return nil;
- }
-
- NSAttributedString *result = [NSAttributedString _web_attributedStringFromRange:core(domRange)];
-
- // [NSAttributedString(WebKitExtras) _web_attributedStringFromRange:] insists on inserting a trailing
- // whitespace at the end of the string which breaks the ATOK input method. <rdar://problem/5400551>
- // To work around this we truncate the resultant string to the correct length.
- if ([result length] > nsRange.length) {
- ASSERT([result length] == nsRange.length + 1);
- ASSERT([[result string] characterAtIndex:nsRange.length] == '\n' || [[result string] characterAtIndex:nsRange.length] == ' ');
- result = [result attributedSubstringFromRange:NSMakeRange(0, nsRange.length)];
- }
- LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> \"%@\"", nsRange.location, nsRange.length, [result string]);
- return result;
-}
-
-// test for 10.4 because of <rdar://problem/4243463>
-#ifdef BUILDING_ON_TIGER
-- (long)conversationIdentifier
-{
- return (long)self;
-}
-#else
-- (NSInteger)conversationIdentifier
-{
- return (NSInteger)self;
-}
-#endif
-
-- (BOOL)hasMarkedText
-{
- Frame* coreFrame = core([self _frame]);
- BOOL result = coreFrame && coreFrame->editor()->hasComposition();
- LOG(TextInput, "hasMarkedText -> %u", result);
- return result;
-}
-
-- (void)unmarkText
-{
- LOG(TextInput, "unmarkText");
-
- // Use pointer to get parameters passed to us by the caller of interpretKeyEvents.
- WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters;
- _private->interpretKeyEventsParameters = 0;
-
- if (parameters) {
- parameters->eventWasHandled = YES;
- parameters->consumedByIM = NO;
- }
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->confirmComposition();
-}
-
-static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnderline>& result)
-{
- int length = [[string string] length];
-
- int i = 0;
- while (i < length) {
- NSRange range;
- NSDictionary *attrs = [string attributesAtIndex:i longestEffectiveRange:&range inRange:NSMakeRange(i, length - i)];
-
- if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) {
- Color color = Color::black;
- if (NSColor *colorAttr = [attrs objectForKey:NSUnderlineColorAttributeName])
- color = colorFromNSColor([colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
- result.append(CompositionUnderline(range.location, NSMaxRange(range), color, [style intValue] > 1));
- }
-
- i = range.location + range.length;
- }
-}
-
-- (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange
-{
- BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString
-
- LOG(TextInput, "setMarkedText:\"%@\" selectedRange:(%u, %u)", isAttributedString ? [string string] : string, newSelRange.location, newSelRange.length);
-
- // Use pointer to get parameters passed to us by the caller of interpretKeyEvents.
- WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters;
- _private->interpretKeyEventsParameters = 0;
-
- if (parameters) {
- parameters->eventWasHandled = YES;
- parameters->consumedByIM = NO;
- }
-
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
-
- if (![self _isEditable])
- return;
-
- Vector<CompositionUnderline> underlines;
- NSString *text = string;
-
- if (isAttributedString) {
- unsigned markedTextLength = [(NSString *)string length];
- NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:NULL inRange:NSMakeRange(0, markedTextLength)];
- LOG(TextInput, " ReplacementRange: %@", rangeString);
- // The AppKit adds a 'secret' property to the string that contains the replacement range.
- // The replacement range is the range of the the text that should be replaced with the new string.
- if (rangeString)
- [[self _frame] _selectNSRange:NSRangeFromString(rangeString)];
-
- text = [string string];
- extractUnderlines(string, underlines);
- }
-
- coreFrame->editor()->setComposition(text, underlines, newSelRange.location, NSMaxRange(newSelRange));
-}
-
-- (void)doCommandBySelector:(SEL)selector
-{
- LOG(TextInput, "doCommandBySelector:\"%s\"", sel_getName(selector));
-
- // Use pointer to get parameters passed to us by the caller of interpretKeyEvents.
- // The same call to interpretKeyEvents can do more than one command.
- WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters;
- if (parameters)
- parameters->consumedByIM = NO;
-
- if (selector == @selector(noop:)) {
- _private->receivedNOOP = YES;
- return;
- }
-
- KeyboardEvent* event = parameters ? parameters->event : 0;
- bool shouldSaveCommand = parameters && parameters->shouldSaveCommand;
-
- if (event && shouldSaveCommand)
- event->keypressCommands().append(KeypressCommand(NSStringFromSelector(selector)));
- else {
- // Make sure that only direct calls to doCommandBySelector: see the parameters by setting to 0.
- _private->interpretKeyEventsParameters = 0;
-
- bool eventWasHandled = true;
-
- WebView *webView = [self _webView];
- Frame* coreFrame = core([self _frame]);
- if (![[webView _editingDelegateForwarder] webView:webView doCommandBySelector:selector] && coreFrame) {
- Editor::Command command = [self coreCommandBySelector:selector];
- if (command.isSupported())
- eventWasHandled = command.execute(event);
- else {
- _private->selectorForDoCommandBySelector = selector;
- [super doCommandBySelector:selector];
- _private->selectorForDoCommandBySelector = 0;
- }
- }
-
- if (parameters)
- parameters->eventWasHandled = eventWasHandled;
-
- // Restore the parameters so that other calls to doCommandBySelector: see them,
- // and other commands can participate in setting the "eventWasHandled" flag.
- _private->interpretKeyEventsParameters = parameters;
- }
-}
-
-- (void)insertText:(id)string
-{
- BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString
-
- LOG(TextInput, "insertText:\"%@\"", isAttributedString ? [string string] : string);
-
- WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters;
- _private->interpretKeyEventsParameters = 0;
- if (parameters)
- parameters->consumedByIM = NO;
-
- // We don't support inserting an attributed string but input methods don't appear to require this.
- RefPtr<Frame> coreFrame = core([self _frame]);
- NSString *text;
- bool isFromInputMethod = coreFrame && coreFrame->editor()->hasComposition();
- if (isAttributedString) {
- text = [string string];
- // We deal with the NSTextInputReplacementRangeAttributeName attribute from NSAttributedString here
- // simply because it is used by at least one Input Method -- it corresonds to the kEventParamTextInputSendReplaceRange
- // event in TSM. This behaviour matches that of -[WebHTMLView setMarkedText:selectedRange:] when it receives an
- // NSAttributedString
- NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:NULL inRange:NSMakeRange(0, [text length])];
- LOG(TextInput, " ReplacementRange: %@", rangeString);
- if (rangeString) {
- [[self _frame] _selectNSRange:NSRangeFromString(rangeString)];
- isFromInputMethod = YES;
- }
- } else
- text = string;
-
- bool eventHandled = false;
- if ([text length]) {
- KeyboardEvent* event = parameters ? parameters->event : 0;
-
- // insertText can be called from an input method or from normal key event processing
- // If its from normal key event processing, we may need to save the action to perform it later.
- // If its from an input method, then we should go ahead and insert the text now.
- // We assume it's from the input method if we have marked text.
- // FIXME: In theory, this could be wrong for some input methods, so we should try to find
- // another way to determine if the call is from the input method
- bool shouldSaveCommand = parameters && parameters->shouldSaveCommand;
- if (event && shouldSaveCommand && !isFromInputMethod) {
- event->keypressCommands().append(KeypressCommand("insertText:", text));
- _private->interpretKeyEventsParameters = parameters;
- return;
- }
-
- String eventText = text;
- eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
- if (coreFrame) {
- if (!coreFrame->editor()->hasComposition())
- eventHandled = coreFrame->editor()->insertText(eventText, event);
- else {
- eventHandled = true;
- coreFrame->editor()->confirmComposition(eventText);
- }
- }
- }
-
- if (!parameters)
- return;
-
- if (isFromInputMethod) {
- // Allow doCommandBySelector: to be called after insertText: by resetting interpretKeyEventsParameters
- _private->interpretKeyEventsParameters = parameters;
- parameters->consumedByIM = YES;
- return;
- }
-
- parameters->eventWasHandled = eventHandled;
-}
-
-- (void)_updateSelectionForInputManager
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
-
- if (!coreFrame->editor()->hasComposition())
- return;
-
- if (coreFrame->editor()->ignoreCompositionSelectionChange())
- return;
-
- unsigned start;
- unsigned end;
- if (coreFrame->editor()->getCompositionSelection(start, end))
- [[NSInputManager currentInputManager] markedTextSelectionChanged:NSMakeRange(start, end - start) client:self];
- else {
- coreFrame->editor()->confirmCompositionWithoutDisturbingSelection();
- [[NSInputManager currentInputManager] markedTextAbandoned:self];
- }
-}
-
-@end
-
-/*
- This class runs the show for handing the complete: NSTextView operation. It counts on its HTML view
- to call endRevertingChange: whenever the current completion needs to be aborted.
-
- The class is in one of two modes: PopupWindow showing, or not. It is shown when a completion yields
- more than one match. If a completion yields one or zero matches, it is not shown, and **there is no
- state carried across to the next completion**.
- */
-
-@implementation WebTextCompleteController
-
-- (id)initWithHTMLView:(WebHTMLView *)view
-{
- self = [super init];
- if (!self)
- return nil;
- _view = view;
- return self;
-}
-
-- (void)dealloc
-{
- [_popupWindow release];
- [_completions release];
- [_originalString release];
-
- [super dealloc];
-}
-
-- (void)_insertMatch:(NSString *)match
-{
- // FIXME: 3769654 - We should preserve case of string being inserted, even in prefix (but then also be
- // able to revert that). Mimic NSText.
- WebFrame *frame = [_view _frame];
- NSString *newText = [match substringFromIndex:prefixLength];
- [frame _replaceSelectionWithText:newText selectReplacement:YES smartReplace:NO];
-}
-
-// mostly lifted from NSTextView_KeyBinding.m
-- (void)_buildUI
-{
- NSRect scrollFrame = NSMakeRect(0, 0, 100, 100);
- NSRect tableFrame = NSZeroRect;
- tableFrame.size = [NSScrollView contentSizeForFrameSize:scrollFrame.size hasHorizontalScroller:NO hasVerticalScroller:YES borderType:NSNoBorder];
- // Added cast to work around problem with multiple Foundation initWithIdentifier: methods with different parameter types.
- NSTableColumn *column = [(NSTableColumn *)[NSTableColumn alloc] initWithIdentifier:[NSNumber numberWithInt:0]];
- [column setWidth:tableFrame.size.width];
- [column setEditable:NO];
-
- _tableView = [[NSTableView alloc] initWithFrame:tableFrame];
- [_tableView setAutoresizingMask:NSViewWidthSizable];
- [_tableView addTableColumn:column];
- [column release];
- [_tableView setGridStyleMask:NSTableViewGridNone];
- [_tableView setCornerView:nil];
- [_tableView setHeaderView:nil];
- [_tableView setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle];
- [_tableView setDelegate:self];
- [_tableView setDataSource:self];
- [_tableView setTarget:self];
- [_tableView setDoubleAction:@selector(tableAction:)];
-
- NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame:scrollFrame];
- [scrollView setBorderType:NSNoBorder];
- [scrollView setHasVerticalScroller:YES];
- [scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
- [scrollView setDocumentView:_tableView];
- [_tableView release];
-
- _popupWindow = [[NSWindow alloc] initWithContentRect:scrollFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
- [_popupWindow setAlphaValue:0.88f];
- [_popupWindow setContentView:scrollView];
- [scrollView release];
- [_popupWindow setHasShadow:YES];
- [_popupWindow setOneShot:YES];
- [_popupWindow _setForceActiveControls:YES];
- [_popupWindow setReleasedWhenClosed:NO];
-}
-
-// mostly lifted from NSTextView_KeyBinding.m
-- (void)_placePopupWindow:(NSPoint)topLeft
-{
- int numberToShow = [_completions count];
- if (numberToShow > 20) {
- numberToShow = 20;
- }
-
- NSRect windowFrame;
- NSPoint wordStart = topLeft;
- windowFrame.origin = [[_view window] convertBaseToScreen:[_view convertPoint:wordStart toView:nil]];
- windowFrame.size.height = numberToShow * [_tableView rowHeight] + (numberToShow + 1) * [_tableView intercellSpacing].height;
- windowFrame.origin.y -= windowFrame.size.height;
- NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:12.0f], NSFontAttributeName, nil];
- float maxWidth = 0.0f;
- int maxIndex = -1;
- int i;
- for (i = 0; i < numberToShow; i++) {
- float width = ceilf([[_completions objectAtIndex:i] sizeWithAttributes:attributes].width);
- if (width > maxWidth) {
- maxWidth = width;
- maxIndex = i;
- }
- }
- windowFrame.size.width = 100;
- if (maxIndex >= 0) {
- maxWidth = ceilf([NSScrollView frameSizeForContentSize:NSMakeSize(maxWidth, 100.0f) hasHorizontalScroller:NO hasVerticalScroller:YES borderType:NSNoBorder].width);
- maxWidth = ceilf([NSWindow frameRectForContentRect:NSMakeRect(0.0f, 0.0f, maxWidth, 100.0f) styleMask:NSBorderlessWindowMask].size.width);
- maxWidth += 5.0f;
- windowFrame.size.width = MAX(maxWidth, windowFrame.size.width);
- maxWidth = MIN(400.0f, windowFrame.size.width);
- }
- [_popupWindow setFrame:windowFrame display:NO];
-
- [_tableView reloadData];
- [_tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
- [_tableView scrollRowToVisible:0];
- [self _reflectSelection];
- [_popupWindow setLevel:NSPopUpMenuWindowLevel];
- [_popupWindow orderFront:nil];
- [[_view window] addChildWindow:_popupWindow ordered:NSWindowAbove];
-}
-
-- (void)doCompletion
-{
- if (!_popupWindow) {
- NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
- if (!checker) {
- LOG_ERROR("No NSSpellChecker");
- return;
- }
-
- // Get preceeding word stem
- WebFrame *frame = [_view _frame];
- DOMRange *selection = kit(core(frame)->selection()->toRange().get());
- DOMRange *wholeWord = [frame _rangeByAlteringCurrentSelection:SelectionController::EXTEND
- direction:SelectionController::BACKWARD granularity:WordGranularity];
- DOMRange *prefix = [wholeWord cloneRange];
- [prefix setEnd:[selection startContainer] offset:[selection startOffset]];
-
- // Reject some NOP cases
- if ([prefix collapsed]) {
- NSBeep();
- return;
- }
- NSString *prefixStr = [frame _stringForRange:prefix];
- NSString *trimmedPrefix = [prefixStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- if ([trimmedPrefix length] == 0) {
- NSBeep();
- return;
- }
- prefixLength = [prefixStr length];
-
- // Lookup matches
- [_completions release];
- _completions = [checker completionsForPartialWordRange:NSMakeRange(0, [prefixStr length]) inString:prefixStr language:nil inSpellDocumentWithTag:[[_view _webView] spellCheckerDocumentTag]];
- [_completions retain];
-
- if (!_completions || [_completions count] == 0) {
- NSBeep();
- } else if ([_completions count] == 1) {
- [self _insertMatch:[_completions objectAtIndex:0]];
- } else {
- ASSERT(!_originalString); // this should only be set IFF we have a popup window
- _originalString = [[frame _stringForRange:selection] retain];
- [self _buildUI];
- NSRect wordRect = [frame _caretRectAtNode:[wholeWord startContainer] offset:[wholeWord startOffset] affinity:NSSelectionAffinityDownstream];
- // +1 to be under the word, not the caret
- // FIXME - 3769652 - Wrong positioning for right to left languages. We should line up the upper
- // right corner with the caret instead of upper left, and the +1 would be a -1.
- NSPoint wordLowerLeft = { NSMinX(wordRect)+1, NSMaxY(wordRect) };
- [self _placePopupWindow:wordLowerLeft];
- }
- } else {
- [self endRevertingChange:YES moveLeft:NO];
- }
-}
-
-- (void)endRevertingChange:(BOOL)revertChange moveLeft:(BOOL)goLeft
-{
- if (_popupWindow) {
- // tear down UI
- [[_view window] removeChildWindow:_popupWindow];
- [_popupWindow orderOut:self];
- // Must autorelease because event tracking code may be on the stack touching UI
- [_popupWindow autorelease];
- _popupWindow = nil;
-
- if (revertChange) {
- WebFrame *frame = [_view _frame];
- [frame _replaceSelectionWithText:_originalString selectReplacement:YES smartReplace:NO];
- } else if ([_view _hasSelection]) {
- if (goLeft)
- [_view moveBackward:nil];
- else
- [_view moveForward:nil];
- }
- [_originalString release];
- _originalString = nil;
- }
- // else there is no state to abort if the window was not up
-}
-
-- (BOOL)popupWindowIsOpen
-{
- return _popupWindow != nil;
-}
-
-// WebHTMLView gives us a crack at key events it sees. Return whether we consumed the event.
-// The features for the various keys mimic NSTextView.
-- (BOOL)filterKeyDown:(NSEvent *)event
-{
- if (!_popupWindow)
- return NO;
- NSString *string = [event charactersIgnoringModifiers];
- if (![string length])
- return NO;
- unichar c = [string characterAtIndex:0];
- if (c == NSUpArrowFunctionKey) {
- int selectedRow = [_tableView selectedRow];
- if (0 < selectedRow) {
- [_tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:selectedRow - 1] byExtendingSelection:NO];
- [_tableView scrollRowToVisible:selectedRow - 1];
- }
- return YES;
- }
- if (c == NSDownArrowFunctionKey) {
- int selectedRow = [_tableView selectedRow];
- if (selectedRow < (int)[_completions count] - 1) {
- [_tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:selectedRow + 1] byExtendingSelection:NO];
- [_tableView scrollRowToVisible:selectedRow + 1];
- }
- return YES;
- }
- if (c == NSRightArrowFunctionKey || c == '\n' || c == '\r' || c == '\t') {
- // FIXME: What about backtab?
- [self endRevertingChange:NO moveLeft:NO];
- return YES;
- }
- if (c == NSLeftArrowFunctionKey) {
- [self endRevertingChange:NO moveLeft:YES];
- return YES;
- }
- if (c == 0x1B || c == NSF5FunctionKey) {
- // FIXME: F5?
- [self endRevertingChange:YES moveLeft:NO];
- return YES;
- }
- if (c == ' ' || c >= 0x21 && c <= 0x2F || c >= 0x3A && c <= 0x40 || c >= 0x5B && c <= 0x60 || c >= 0x7B && c <= 0x7D) {
- // FIXME: Is the above list of keys really definitive?
- // Originally this code called ispunct; aren't there other punctuation keys on international keyboards?
- [self endRevertingChange:NO moveLeft:NO];
- return NO; // let the char get inserted
- }
- return NO;
-}
-
-- (void)_reflectSelection
-{
- int selectedRow = [_tableView selectedRow];
- ASSERT(selectedRow >= 0 && selectedRow < (int)[_completions count]);
- [self _insertMatch:[_completions objectAtIndex:selectedRow]];
-}
-
-- (void)tableAction:(id)sender
-{
- [self _reflectSelection];
- [self endRevertingChange:NO moveLeft:NO];
-}
-
-- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
-{
- return [_completions count];
-}
-
-- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
-{
- return [_completions objectAtIndex:row];
-}
-
-- (void)tableViewSelectionDidChange:(NSNotification *)notification
-{
- [self _reflectSelection];
-}
-
-@end
-
-@implementation WebHTMLView (WebDocumentPrivateProtocols)
-
-- (NSRect)selectionRect
-{
- if ([self _hasSelection])
- return core([self _frame])->selectionRect();
- return NSZeroRect;
-}
-
-- (NSArray *)selectionTextRects
-{
- if (![self _hasSelection])
- return nil;
-
- Vector<FloatRect> list;
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->selectionTextRects(list);
-
- unsigned size = list.size();
- NSMutableArray *result = [[[NSMutableArray alloc] initWithCapacity:size] autorelease];
- for (unsigned i = 0; i < size; ++i)
- [result addObject:[NSValue valueWithRect:list[i]]];
-
- return result;
-}
-
-- (NSView *)selectionView
-{
- return self;
-}
-
-- (NSImage *)selectionImageForcingBlackText:(BOOL)forceBlackText
-{
- if ([self _hasSelection])
- return core([self _frame])->selectionImage(forceBlackText);
- return nil;
-}
-
-- (NSRect)selectionImageRect
-{
- if ([self _hasSelection])
- return core([self _frame])->selectionRect();
- return NSZeroRect;
-}
-
-- (NSArray *)pasteboardTypesForSelection
-{
- if ([self _canSmartCopyOrDelete]) {
- NSMutableArray *types = [[[[self class] _selectionPasteboardTypes] mutableCopy] autorelease];
- [types addObject:WebSmartPastePboardType];
- return types;
- } else {
- return [[self class] _selectionPasteboardTypes];
- }
-}
-
-- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
-{
- [self _writeSelectionWithPasteboardTypes:types toPasteboard:pasteboard cachedAttributedString:nil];
-}
-
-- (void)selectAll
-{
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->selection()->selectAll();
-}
-
-- (void)deselectAll
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
- coreFrame->selection()->clear();
-}
-
-- (NSString *)string
-{
- return [[self _frame] _stringForRange:[self _documentRange]];
-}
-
-- (NSAttributedString *)_attributeStringFromDOMRange:(DOMRange *)range
-{
- NSAttributedString *attributedString;
-#if !LOG_DISABLED
- double start = CFAbsoluteTimeGetCurrent();
-#endif
- attributedString = [[[NSAttributedString alloc] _initWithDOMRange:range] autorelease];
-#if !LOG_DISABLED
- double duration = CFAbsoluteTimeGetCurrent() - start;
- LOG(Timing, "creating attributed string from selection took %f seconds.", duration);
-#endif
- return attributedString;
-}
-
-- (NSAttributedString *)attributedString
-{
- DOMDocument *document = [[self _frame] DOMDocument];
- NSAttributedString *attributedString = [self _attributeStringFromDOMRange:[document _documentRange]];
- if (!attributedString) {
- Document* coreDocument = core(document);
- attributedString = [NSAttributedString _web_attributedStringFromRange:Range::create(coreDocument, coreDocument, 0, coreDocument, coreDocument->childNodeCount()).get()];
- }
- return attributedString;
-}
-
-- (NSString *)selectedString
-{
- return [[self _frame] _selectedString];
-}
-
-- (NSAttributedString *)selectedAttributedString
-{
- NSAttributedString *attributedString = [self _attributeStringFromDOMRange:[self _selectedRange]];
- if (!attributedString) {
- Frame* coreFrame = core([self _frame]);
- if (coreFrame) {
- RefPtr<Range> range = coreFrame->selection()->selection().toRange();
- attributedString = [NSAttributedString _web_attributedStringFromRange:range.get()];
- }
- }
- return attributedString;
-}
-
-- (BOOL)supportsTextEncoding
-{
- return YES;
-}
-
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection
-{
- if (![string length])
- return NO;
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->findString(string, forward, caseFlag, wrapFlag, startInSelection);
-}
-
-@end
-
-@implementation WebHTMLView (WebDocumentInternalProtocols)
-
-- (NSDictionary *)elementAtPoint:(NSPoint)point
-{
- return [self elementAtPoint:point allowShadowContent:NO];
-}
-
-- (NSDictionary *)elementAtPoint:(NSPoint)point allowShadowContent:(BOOL)allow;
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return nil;
- return [[[WebElementDictionary alloc] initWithHitTestResult:coreFrame->eventHandler()->hitTestResultAtPoint(IntPoint(point), allow)] autorelease];
-}
-
-- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(NSUInteger)limit
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return 0;
- return coreFrame->markAllMatchesForText(string, caseFlag, limit);
-}
-
-- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
- coreFrame->setMarkedTextMatchesAreHighlighted(newValue);
-}
-
-- (BOOL)markedTextMatchesAreHighlighted
-{
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->markedTextMatchesAreHighlighted();
-}
-
-- (void)unmarkAllTextMatches
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
- Document* document = coreFrame->document();
- if (!document)
- return;
- document->removeMarkers(DocumentMarker::TextMatch);
-}
-
-- (NSArray *)rectsForTextMatches
-{
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame)
- return [NSArray array];
- Document* document = coreFrame->document();
- if (!document)
- return [NSArray array];
-
- Vector<IntRect> rects = document->renderedRectsForMarkers(DocumentMarker::TextMatch);
- unsigned count = rects.size();
- NSMutableArray *result = [NSMutableArray arrayWithCapacity:count];
- for (unsigned index = 0; index < count; ++index)
- [result addObject:[NSValue valueWithRect:rects[index]]];
- return result;
-}
-
-@end
-
-// This is used by AppKit and is included here so that WebDataProtocolScheme is only defined once.
-@implementation NSURL (WebDataURL)
-
-+ (NSURL *)_web_uniqueWebDataURL
-{
- CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
- NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
- CFRelease(UUIDRef);
- NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@", WebDataProtocolScheme, UUIDString]];
- CFRelease(UUIDString);
- return URL;
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebHTMLViewInternal.h b/WebKit/mac/WebView/WebHTMLViewInternal.h
deleted file mode 100644
index 0fb0cdc..0000000
--- a/WebKit/mac/WebView/WebHTMLViewInternal.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// Things internal to the WebKit framework; not SPI.
-
-#import "WebHTMLViewPrivate.h"
-
-@class WebFrame;
-
-namespace WebCore {
- class CachedImage;
- class KeyboardEvent;
-}
-
-@interface WebHTMLView (WebInternal)
-- (void)_selectionChanged;
-- (void)_updateFontPanel;
-- (BOOL)_canSmartCopyOrDelete;
-
-- (id <WebHTMLHighlighter>)_highlighterForType:(NSString*)type;
-- (WebFrame *)_frame;
-- (void)_lookUpInDictionaryFromMenu:(id)sender;
-- (void)_hoverFeedbackSuspendedChanged;
-- (BOOL)_interceptEditingKeyEvent:(WebCore::KeyboardEvent *)event shouldSaveCommand:(BOOL)shouldSave;
-- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard;
-- (NSEvent *)_mouseDownEvent;
-#ifndef BUILDING_ON_TIGER
-- (BOOL)isGrammarCheckingEnabled;
-- (void)setGrammarCheckingEnabled:(BOOL)flag;
-- (void)toggleGrammarChecking:(id)sender;
-#endif
-- (WebCore::CachedImage*)promisedDragTIFFDataSource;
-- (void)setPromisedDragTIFFDataSource:(WebCore::CachedImage*)source;
-- (void)_web_layoutIfNeededRecursive;
-- (void)_destroyAllWebPlugins;
-@end
diff --git a/WebKit/mac/WebView/WebHTMLViewPrivate.h b/WebKit/mac/WebView/WebHTMLViewPrivate.h
deleted file mode 100644
index 40de97f..0000000
--- a/WebKit/mac/WebView/WebHTMLViewPrivate.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebHTMLView.h>
-
-#if !defined(ENABLE_NETSCAPE_PLUGIN_API)
-#define ENABLE_NETSCAPE_PLUGIN_API 1
-#endif
-
-@class DOMDocumentFragment;
-@class DOMNode;
-@class DOMRange;
-@class WebPluginController;
-
-@protocol WebHTMLHighlighter
-- (NSRect)highlightRectForLine:(NSRect)lineRect representedNode:(DOMNode *)node;
-- (void)paintHighlightForBox:(NSRect)boxRect onLine:(NSRect)lineRect behindText:(BOOL)text entireLine:(BOOL)line representedNode:(DOMNode *)node;
-
-// the following methods are deprecated and will be removed once Mail switches to the new methods <rdar://problem/5050528>
-- (NSRect)highlightRectForLine:(NSRect)lineRect;
-- (void)paintHighlightForBox:(NSRect)boxRect onLine:(NSRect)lineRect behindText:(BOOL)text entireLine:(BOOL)line;
-@end
-
-@interface WebHTMLView (WebPrivate)
-
-+ (NSArray *)supportedMIMETypes;
-+ (NSArray *)supportedImageMIMETypes;
-+ (NSArray *)supportedNonImageMIMETypes;
-+ (NSArray *)unsupportedTextMIMETypes;
-
-- (void)close;
-
-// Modifier (flagsChanged) tracking SPI
-+ (void)_postFlagsChangedEvent:(NSEvent *)flagsChangedEvent;
-- (void)_updateMouseoverWithFakeEvent;
-
-- (void)_setAsideSubviews;
-- (void)_restoreSubviews;
-
-- (BOOL)_insideAnotherHTMLView;
-- (void)_clearLastHitViewIfSelf;
-- (void)_updateMouseoverWithEvent:(NSEvent *)event;
-
-+ (NSArray *)_insertablePasteboardTypes;
-+ (NSArray *)_selectionPasteboardTypes;
-- (void)_writeSelectionToPasteboard:(NSPasteboard *)pasteboard;
-
-- (void)_frameOrBoundsChanged;
-
-- (NSImage *)_dragImageForLinkElement:(NSDictionary *)element;
-- (NSImage *)_dragImageForURL:(NSString*)linkURL withLabel:(NSString*)label;
-- (void)_handleAutoscrollForMouseDragged:(NSEvent *)event;
-- (WebPluginController *)_pluginController;
-
-// FIXME: _selectionRect is deprecated in favor of selectionRect, which is in protocol WebDocumentSelection.
-// We can't remove this yet because it's still in use by Mail.
-- (NSRect)_selectionRect;
-
-- (void)_startAutoscrollTimer:(NSEvent *)event;
-- (void)_stopAutoscrollTimer;
-
-- (BOOL)_canEdit;
-- (BOOL)_canEditRichly;
-- (BOOL)_canAlterCurrentSelection;
-- (BOOL)_hasSelection;
-- (BOOL)_hasSelectionOrInsertionPoint;
-- (BOOL)_isEditable;
-
-- (BOOL)_transparentBackground;
-- (void)_setTransparentBackground:(BOOL)isBackgroundTransparent;
-
-- (void)_setToolTip:(NSString *)string;
-
-// SPI used by Mail.
-// FIXME: These should all be moved to WebView; we won't always have a WebHTMLView.
-- (NSImage *)_selectionDraggingImage;
-- (NSRect)_selectionDraggingRect;
-- (DOMNode *)_insertOrderedList;
-- (DOMNode *)_insertUnorderedList;
-- (BOOL)_canIncreaseSelectionListLevel;
-- (BOOL)_canDecreaseSelectionListLevel;
-- (DOMNode *)_increaseSelectionListLevel;
-- (DOMNode *)_increaseSelectionListLevelOrdered;
-- (DOMNode *)_increaseSelectionListLevelUnordered;
-- (void)_decreaseSelectionListLevel;
-- (void)_setHighlighter:(id <WebHTMLHighlighter>)highlighter ofType:(NSString *)type;
-- (void)_removeHighlighterOfType:(NSString *)type;
-- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard forType:(NSString *)pboardType inContext:(DOMRange *)context subresources:(NSArray **)subresources;
-
-#if ENABLE_NETSCAPE_PLUGIN_API
-- (void)_resumeNullEventsForAllNetscapePlugins;
-- (void)_pauseNullEventsForAllNetscapePlugins;
-#endif
-
-// SPI for DumpRenderTree
-- (void)_updateFocusedAndActiveState;
-
-// SPI for printing (should be converted to API someday). When the WebHTMLView isn't being printed
-// directly, this method must be called before paginating, or the computed height might be incorrect.
-// Typically this would be called from inside an override of -[NSView knowsPageRange:].
-- (void)_layoutForPrinting;
-
-- (BOOL)_canSmartReplaceWithPasteboard:(NSPasteboard *)pasteboard;
-
-@end
diff --git a/WebKit/mac/WebView/WebPDFRepresentation.h b/WebKit/mac/WebView/WebPDFRepresentation.h
deleted file mode 100644
index 6b60d4c..0000000
--- a/WebKit/mac/WebView/WebPDFRepresentation.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-@protocol WebDocumentRepresentation;
-
-@interface WebPDFRepresentation : NSObject <WebDocumentRepresentation>
-+ (NSArray *)supportedMIMETypes;
-@end
diff --git a/WebKit/mac/WebView/WebPDFRepresentation.m b/WebKit/mac/WebView/WebPDFRepresentation.m
deleted file mode 100644
index 1a2ddab..0000000
--- a/WebKit/mac/WebView/WebPDFRepresentation.m
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebDataSource.h>
-#import <WebKit/WebFrame.h>
-#import <WebKit/WebFrameView.h>
-#import <WebKit/WebNSObjectExtras.h>
-#import <WebKit/WebPDFRepresentation.h>
-#import <WebKit/WebPDFView.h>
-#import <wtf/Assertions.h>
-
-#import <PDFKit/PDFDocument.h>
-
-@implementation WebPDFRepresentation
-
-+ (NSArray *)postScriptMIMETypes
-{
- return [NSArray arrayWithObjects:
- @"application/postscript",
- nil];
-}
-
-+ (NSArray *)supportedMIMETypes
-{
- return [[[self class] postScriptMIMETypes] arrayByAddingObjectsFromArray:
- [NSArray arrayWithObjects:
- @"text/pdf",
- @"application/pdf",
- nil]];
-}
-
-+ (Class)PDFDocumentClass
-{
- static Class PDFDocumentClass = nil;
- if (PDFDocumentClass == nil) {
- PDFDocumentClass = [[WebPDFView PDFKitBundle] classNamed:@"PDFDocument"];
- if (PDFDocumentClass == nil) {
- LOG_ERROR("Couldn't find PDFDocument class in PDFKit.framework");
- }
- }
- return PDFDocumentClass;
-}
-
-- (void)setDataSource:(WebDataSource *)dataSource;
-{
-}
-
-- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource;
-{
-}
-
-- (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSource;
-{
-}
-
-- (NSData *)convertPostScriptDataSourceToPDF:(NSData *)data
-{
- // Convert PostScript to PDF using Quartz 2D API
- // http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_ps_convert/chapter_16_section_1.html
-
- CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 };
- CGPSConverterRef converter = CGPSConverterCreate(0, &callbacks, 0);
- ASSERT(converter);
-
- CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)data);
- ASSERT(provider);
-
- CFMutableDataRef result = CFDataCreateMutable(kCFAllocatorDefault, 0);
- ASSERT(result);
-
- CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(result);
- ASSERT(consumer);
-
- // Error handled by detecting zero-length 'result' in caller
- CGPSConverterConvert(converter, provider, consumer, 0);
-
- CFRelease(converter);
- CFRelease(provider);
- CFRelease(consumer);
-
- return WebCFAutorelease(result);
-}
-
-- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
-{
- NSData *data = [dataSource data];
-
- NSArray *postScriptMIMETypes = [[self class] postScriptMIMETypes];
- NSString *mimeType = [[dataSource response] MIMEType];
- if ([postScriptMIMETypes containsObject:mimeType]) {
- data = [self convertPostScriptDataSourceToPDF:data];
- if ([data length] == 0)
- return;
- }
-
- WebPDFView *view = (WebPDFView *)[[[dataSource webFrame] frameView] documentView];
- PDFDocument *doc = [[[[self class] PDFDocumentClass] alloc] initWithData:data];
- [view setPDFDocument:doc];
- [doc release];
-}
-
-
-- (BOOL)canProvideDocumentSource
-{
- return NO;
-}
-
-
-- (NSString *)documentSource
-{
- return nil;
-}
-
-
-- (NSString *)title
-{
- return nil;
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebPDFView.h b/WebKit/mac/WebView/WebPDFView.h
deleted file mode 100644
index 55d2a08..0000000
--- a/WebKit/mac/WebView/WebPDFView.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebDocumentInternal.h>
-
-@class PDFDocument;
-@class PDFView;
-@class WebDataSource;
-
-@interface WebPDFView : NSView <WebDocumentView, WebDocumentSearching, WebDocumentIncrementalSearching, WebMultipleTextMatches, WebDocumentSelection, WebDocumentElement, _WebDocumentViewState, _WebDocumentZooming>
-{
- NSView *previewView;
- PDFView *PDFSubview;
- NSString *path;
- id trackedFirstResponder;
- BOOL written;
- BOOL _ignoreScaleAndDisplayModeAndPageNotifications;
- BOOL _willUpdatePreferencesSoon;
- PDFView *PDFSubviewProxy;
- WebDataSource *dataSource;
- NSArray *textMatches;
- NSPoint lastScrollPosition;
-}
-
-+ (NSArray *)supportedMIMETypes;
-+ (NSBundle *)PDFKitBundle;
-
-- (void)setPDFDocument:(PDFDocument *)doc;
-
-@end
diff --git a/WebKit/mac/WebView/WebPDFView.mm b/WebKit/mac/WebView/WebPDFView.mm
deleted file mode 100644
index 1009cdd..0000000
--- a/WebKit/mac/WebView/WebPDFView.mm
+++ /dev/null
@@ -1,1485 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebPDFView.h"
-
-#import "WebDataSourceInternal.h"
-#import "WebDocumentInternal.h"
-#import "WebDocumentPrivate.h"
-#import "WebFrame.h"
-#import "WebFrameInternal.h"
-#import "WebFrameView.h"
-#import "WebLocalizableStrings.h"
-#import "WebNSArrayExtras.h"
-#import "WebNSAttributedStringExtras.h"
-#import "WebNSPasteboardExtras.h"
-#import "WebNSViewExtras.h"
-#import "WebPDFRepresentation.h"
-#import "WebPreferencesPrivate.h"
-#import "WebUIDelegate.h"
-#import "WebUIDelegatePrivate.h"
-#import "WebView.h"
-#import "WebViewInternal.h"
-#import <PDFKit/PDFKit.h>
-#import <WebCore/EventNames.h>
-#import <WebCore/Frame.h>
-#import <WebCore/FrameLoader.h>
-#import <WebCore/FrameLoadRequest.h>
-#import <WebCore/KURL.h>
-#import <WebCore/KeyboardEvent.h>
-#import <WebCore/MouseEvent.h>
-#import <WebCore/PlatformKeyboardEvent.h>
-#import <wtf/Assertions.h>
-
-using namespace WebCore;
-
-// Redeclarations of PDFKit notifications. We can't use the API since we use a weak link to the framework.
-#define _webkit_PDFViewDisplayModeChangedNotification @"PDFViewDisplayModeChanged"
-#define _webkit_PDFViewScaleChangedNotification @"PDFViewScaleChanged"
-#define _webkit_PDFViewPageChangedNotification @"PDFViewChangedPage"
-
-@interface PDFDocument (PDFKitSecretsIKnow)
-- (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate;
-@end
-
-extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
-
-@interface WebPDFView (FileInternal)
-+ (Class)_PDFPreviewViewClass;
-+ (Class)_PDFViewClass;
-- (BOOL)_anyPDFTagsFoundInMenu:(NSMenu *)menu;
-- (void)_applyPDFDefaults;
-- (BOOL)_canLookUpInDictionary;
-- (NSClipView *)_clipViewForPDFDocumentView;
-- (NSEvent *)_fakeKeyEventWithFunctionKey:(unichar)functionKey;
-- (NSMutableArray *)_menuItemsFromPDFKitForEvent:(NSEvent *)theEvent;
-- (PDFSelection *)_nextMatchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag fromSelection:(PDFSelection *)initialSelection startInSelection:(BOOL)startInSelection;
-- (void)_openWithFinder:(id)sender;
-- (NSString *)_path;
-- (void)_PDFDocumentViewMightHaveScrolled:(NSNotification *)notification;
-- (BOOL)_pointIsInSelection:(NSPoint)point;
-- (NSAttributedString *)_scaledAttributedString:(NSAttributedString *)unscaledAttributedString;
-- (void)_setTextMatches:(NSArray *)array;
-- (NSString *)_temporaryPDFDirectoryPath;
-- (void)_trackFirstResponder;
-- (void)_updatePreferencesSoon;
-- (NSSet *)_visiblePDFPages;
-@end;
-
-// PDFPrefUpdatingProxy is a class that forwards everything it gets to a target and updates the PDF viewing prefs
-// after each of those messages. We use it as a way to hook all the places that the PDF viewing attrs change.
-@interface PDFPrefUpdatingProxy : NSProxy {
- WebPDFView *view;
-}
-- (id)initWithView:(WebPDFView *)view;
-@end
-
-#pragma mark C UTILITY FUNCTIONS
-
-static void _applicationInfoForMIMEType(NSString *type, NSString **name, NSImage **image)
-{
- NSURL *appURL = nil;
-
- OSStatus error = LSCopyApplicationForMIMEType((CFStringRef)type, kLSRolesAll, (CFURLRef *)&appURL);
- if (error != noErr)
- return;
-
- NSString *appPath = [appURL path];
- CFRelease (appURL);
-
- *image = [[NSWorkspace sharedWorkspace] iconForFile:appPath];
- [*image setSize:NSMakeSize(16.f,16.f)];
-
- NSString *appName = [[NSFileManager defaultManager] displayNameAtPath:appPath];
- *name = appName;
-}
-
-// 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)
-{
- NSArray *aPages = [selectionA pages];
- NSArray *bPages = [selectionB pages];
-
- if (![aPages isEqual:bPages])
- return NO;
-
- int count = [aPages count];
- int i;
- for (i = 0; i < count; ++i) {
- NSRect aBounds = [selectionA boundsForPage:[aPages objectAtIndex:i]];
- NSRect bBounds = [selectionB boundsForPage:[bPages objectAtIndex:i]];
- if (!NSEqualRects(aBounds, bBounds)) {
- return NO;
- }
- }
-
- return YES;
-}
-
-@implementation WebPDFView
-
-#pragma mark WebPDFView API
-
-+ (NSBundle *)PDFKitBundle
-{
- static NSBundle *PDFKitBundle = nil;
- if (PDFKitBundle == nil) {
- NSString *PDFKitPath = [_NSPathForSystemFramework(@"Quartz.framework") stringByAppendingString:@"/Frameworks/PDFKit.framework"];
- if (PDFKitPath == nil) {
- LOG_ERROR("Couldn't find PDFKit.framework");
- return nil;
- }
- PDFKitBundle = [NSBundle bundleWithPath:PDFKitPath];
- if (![PDFKitBundle load]) {
- LOG_ERROR("Couldn't load PDFKit.framework");
- }
- }
- return PDFKitBundle;
-}
-
-+ (NSArray *)supportedMIMETypes
-{
- return [WebPDFRepresentation supportedMIMETypes];
-}
-
-- (void)setPDFDocument:(PDFDocument *)doc
-{
- // Both setDocument: and _applyPDFDefaults will trigger scale and mode-changed notifications.
- // Those aren't reflecting user actions, so we need to ignore them.
- _ignoreScaleAndDisplayModeAndPageNotifications = YES;
- [PDFSubview setDocument:doc];
- [self _applyPDFDefaults];
- _ignoreScaleAndDisplayModeAndPageNotifications = NO;
-}
-
-#pragma mark NSObject OVERRIDES
-
-- (void)dealloc
-{
- ASSERT(!trackedFirstResponder);
- [dataSource release];
- [previewView release];
- [PDFSubview release];
- [path release];
- [PDFSubviewProxy release];
- [textMatches release];
- [super dealloc];
-}
-
-#pragma mark NSResponder OVERRIDES
-
-- (void)centerSelectionInVisibleArea:(id)sender
-{
- [PDFSubview scrollSelectionToVisible:nil];
-}
-
-- (void)scrollPageDown:(id)sender
-{
- // PDFView doesn't support this responder method directly, so we pass it a fake key event
- [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSPageDownFunctionKey]];
-}
-
-- (void)scrollPageUp:(id)sender
-{
- // PDFView doesn't support this responder method directly, so we pass it a fake key event
- [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSPageUpFunctionKey]];
-}
-
-- (void)scrollLineDown:(id)sender
-{
- // PDFView doesn't support this responder method directly, so we pass it a fake key event
- [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSDownArrowFunctionKey]];
-}
-
-- (void)scrollLineUp:(id)sender
-{
- // PDFView doesn't support this responder method directly, so we pass it a fake key event
- [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSUpArrowFunctionKey]];
-}
-
-- (void)scrollToBeginningOfDocument:(id)sender
-{
- // PDFView doesn't support this responder method directly, so we pass it a fake key event
- [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSHomeFunctionKey]];
-}
-
-- (void)scrollToEndOfDocument:(id)sender
-{
- // PDFView doesn't support this responder method directly, so we pass it a fake key event
- [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSEndFunctionKey]];
-}
-
-// jumpToSelection is the old name for what AppKit now calls centerSelectionInVisibleArea. Safari
-// was using the old jumpToSelection selector in its menu. Newer versions of Safari will us the
-// selector centerSelectionInVisibleArea. We'll leave this old selector in place for two reasons:
-// (1) compatibility between older Safari and newer WebKit; (2) other WebKit-based applications
-// might be using the jumpToSelection: selector, and we don't want to break them.
-- (void)jumpToSelection:(id)sender
-{
- [self centerSelectionInVisibleArea:nil];
-}
-
-#pragma mark NSView OVERRIDES
-
-- (BOOL)acceptsFirstResponder {
- return YES;
-}
-
-- (BOOL)becomeFirstResponder
-{
- // This works together with setNextKeyView to splice our PDFSubview into
- // the key loop similar to the way NSScrollView does this.
- NSWindow *window = [self window];
- id newFirstResponder = nil;
-
- if ([window keyViewSelectionDirection] == NSSelectingPrevious) {
- NSView *previousValidKeyView = [self previousValidKeyView];
- if ((previousValidKeyView != self) && (previousValidKeyView != PDFSubview))
- newFirstResponder = previousValidKeyView;
- } else {
- NSView *PDFDocumentView = [PDFSubview documentView];
- if ([PDFDocumentView acceptsFirstResponder])
- newFirstResponder = PDFDocumentView;
- }
-
- if (!newFirstResponder)
- return NO;
-
- if (![window makeFirstResponder:newFirstResponder])
- return NO;
-
- [[dataSource webFrame] _clearSelectionInOtherFrames];
-
- return YES;
-}
-
-- (NSView *)hitTest:(NSPoint)point
-{
- // Override hitTest so we can override menuForEvent.
- NSEvent *event = [NSApp currentEvent];
- NSEventType type = [event type];
- if (type == NSRightMouseDown || (type == NSLeftMouseDown && ([event modifierFlags] & NSControlKeyMask)))
- return self;
-
- return [super hitTest:point];
-}
-
-- (id)initWithFrame:(NSRect)frame
-{
- self = [super initWithFrame:frame];
- if (self) {
- [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
-
- Class previewViewClass = [[self class] _PDFPreviewViewClass];
-
- // We might not have found a previewViewClass, but if we did find it
- // then we should be able to create an instance.
- if (previewViewClass) {
- previewView = [[previewViewClass alloc] initWithFrame:frame];
- ASSERT(previewView);
- }
-
- NSView *topLevelPDFKitView = nil;
- if (previewView) {
- // We'll retain the PDFSubview here so that it is equally retained in all
- // code paths. That way we don't need to worry about conditionally releasing
- // it later.
- PDFSubview = [[previewView performSelector:@selector(pdfView)] retain];
- 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
- // PDF viewing defaults are updated afterwards
- PDFSubviewProxy = (PDFView *)[[PDFPrefUpdatingProxy alloc] initWithView:self];
- }
-
- return self;
-}
-
-- (NSMenu *)menuForEvent:(NSEvent *)theEvent
-{
- // Start with the menu items supplied by PDFKit, with WebKit tags applied
- NSMutableArray *items = [self _menuItemsFromPDFKitForEvent:theEvent];
-
- // Add in an "Open with <default PDF viewer>" item
- NSString *appName = nil;
- NSImage *appIcon = nil;
-
- _applicationInfoForMIMEType([[dataSource response] MIMEType], &appName, &appIcon);
- if (!appName)
- appName = UI_STRING("Finder", "Default application name for Open With context menu");
-
- // To match the PDFKit style, we'll add Open with Preview even when there's no document yet to view, and
- // disable it using validateUserInterfaceItem.
- NSString *title = [NSString stringWithFormat:UI_STRING("Open with %@", "context menu item for PDF"), appName];
- NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:@selector(_openWithFinder:) keyEquivalent:@""];
- [item setTag:WebMenuItemTagOpenWithDefaultApplication];
- if (appIcon)
- [item setImage:appIcon];
- [items insertObject:item atIndex:0];
- [item release];
-
- [items insertObject:[NSMenuItem separatorItem] atIndex:1];
-
- // pass the items off to the WebKit context menu mechanism
- WebView *webView = [[dataSource webFrame] webView];
- ASSERT(webView);
- NSMenu *menu = [webView _menuForElement:[self elementAtPoint:[self convertPoint:[theEvent locationInWindow] fromView:nil]] defaultItems:items];
-
- // The delegate has now had the opportunity to add items to the standard PDF-related items, or to
- // remove or modify some of the PDF-related items. In 10.4, the PDF context menu did not go through
- // the standard WebKit delegate path, and so the standard PDF-related items always appeared. For
- // clients that create their own context menu by hand-picking specific items from the default list, such as
- // Safari, none of the PDF-related items will appear until the client is rewritten to explicitly
- // include these items. For backwards compatibility of tip-of-tree WebKit with the 10.4 version of Safari
- // (the configuration that people building open source WebKit use), we'll use the entire set of PDFKit-supplied
- // menu items. This backward-compatibility hack won't work with any non-Safari clients, but this seems OK since
- // (1) the symptom is fairly minor, and (2) we suspect that non-Safari clients are probably using the entire
- // set of default items, rather than manually choosing from them. We can remove this code entirely when we
- // ship a version of Safari that includes the fix for radar 3796579.
- if (![self _anyPDFTagsFoundInMenu:menu] && [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"]) {
- [menu addItem:[NSMenuItem separatorItem]];
- NSEnumerator *e = [items objectEnumerator];
- NSMenuItem *menuItem;
- while ((menuItem = [e nextObject]) != nil) {
- // copy menuItem since a given menuItem can be in only one menu at a time, and we don't
- // want to mess with the menu returned from PDFKit.
- [menu addItem:[menuItem copy]];
- }
- }
-
- return menu;
-}
-
-- (void)setNextKeyView:(NSView *)aView
-{
- // This works together with becomeFirstResponder to splice PDFSubview into
- // the key loop similar to the way NSScrollView and NSClipView do this.
- NSView *documentView = [PDFSubview documentView];
- if (documentView) {
- [documentView setNextKeyView:aView];
-
- // We need to make the documentView be the next view in the keyview loop.
- // It would seem more sensible to do this in our init method, but it turns out
- // that [NSClipView setDocumentView] won't call this method if our next key view
- // is already set, so we wait until we're called before adding this connection.
- // We'll also clear it when we're called with nil, so this could go through the
- // same code path more than once successfully.
- [super setNextKeyView: aView ? documentView : nil];
- } else
- [super setNextKeyView:aView];
-}
-
-- (void)viewDidMoveToWindow
-{
- // FIXME 2573089: we can observe a notification for first responder changes
- // instead of the very frequent NSWindowDidUpdateNotification if/when 2573089 is addressed.
- NSWindow *newWindow = [self window];
- if (!newWindow)
- return;
-
- [self _trackFirstResponder];
- NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
- [notificationCenter addObserver:self
- selector:@selector(_trackFirstResponder)
- name:NSWindowDidUpdateNotification
- object:newWindow];
-
- [notificationCenter addObserver:self
- selector:@selector(_scaleOrDisplayModeOrPageChanged:)
- name:_webkit_PDFViewScaleChangedNotification
- object:PDFSubview];
-
- [notificationCenter addObserver:self
- selector:@selector(_scaleOrDisplayModeOrPageChanged:)
- name:_webkit_PDFViewDisplayModeChangedNotification
- object:PDFSubview];
-
- [notificationCenter addObserver:self
- selector:@selector(_scaleOrDisplayModeOrPageChanged:)
- name:_webkit_PDFViewPageChangedNotification
- object:PDFSubview];
-
- [notificationCenter addObserver:self
- selector:@selector(_PDFDocumentViewMightHaveScrolled:)
- name:NSViewBoundsDidChangeNotification
- object:[self _clipViewForPDFDocumentView]];
-}
-
-- (void)viewWillMoveToWindow:(NSWindow *)window
-{
- // FIXME 2573089: we can observe a notification for changes to the first responder
- // instead of the very frequent NSWindowDidUpdateNotification if/when 2573089 is addressed.
- NSWindow *oldWindow = [self window];
- if (!oldWindow)
- return;
-
- NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
- [notificationCenter removeObserver:self
- name:NSWindowDidUpdateNotification
- object:oldWindow];
- [notificationCenter removeObserver:self
- name:_webkit_PDFViewScaleChangedNotification
- object:PDFSubview];
- [notificationCenter removeObserver:self
- name:_webkit_PDFViewDisplayModeChangedNotification
- object:PDFSubview];
- [notificationCenter removeObserver:self
- name:_webkit_PDFViewPageChangedNotification
- object:PDFSubview];
-
- [notificationCenter removeObserver:self
- name:NSViewBoundsDidChangeNotification
- object:[self _clipViewForPDFDocumentView]];
-
- [trackedFirstResponder release];
- trackedFirstResponder = nil;
-}
-
-#pragma mark NSUserInterfaceValidations PROTOCOL IMPLEMENTATION
-
-- (BOOL)validateUserInterfaceItemWithoutDelegate:(id <NSValidatedUserInterfaceItem>)item
-{
- SEL action = [item action];
- if (action == @selector(takeFindStringFromSelection:) || action == @selector(centerSelectionInVisibleArea:) || action == @selector(jumpToSelection:))
- return [PDFSubview currentSelection] != nil;
-
- if (action == @selector(_openWithFinder:))
- return [PDFSubview document] != nil;
-
- if (action == @selector(_lookUpInDictionaryFromMenu:))
- return [self _canLookUpInDictionary];
-
- return YES;
-}
-
-- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
-{
- // This can be called during teardown when _webView is nil. Return NO when this happens, because CallUIDelegateReturningBoolean
- // assumes the WebVIew is non-nil.
- if (![self _webView])
- return NO;
- BOOL result = [self validateUserInterfaceItemWithoutDelegate:item];
- return CallUIDelegateReturningBoolean(result, [self _webView], @selector(webView:validateUserInterfaceItem:defaultValidation:), item, result);
-}
-
-#pragma mark INTERFACE BUILDER ACTIONS FOR SAFARI
-
-// Surprisingly enough, this isn't defined in any superclass, though it is defined in assorted AppKit classes since
-// it's a standard menu item IBAction.
-- (IBAction)copy:(id)sender
-{
- [PDFSubview copy:sender];
-}
-
-// This used to be a standard IBAction (for Use Selection For Find), but AppKit now uses performFindPanelAction:
-// with a menu item tag for this purpose.
-- (IBAction)takeFindStringFromSelection:(id)sender
-{
- [NSPasteboard _web_setFindPasteboardString:[[PDFSubview currentSelection] string] withOwner:self];
-}
-
-#pragma mark WebFrameView UNDECLARED "DELEGATE METHODS"
-
-// This is tested in -[WebFrameView canPrintHeadersAndFooters], but isn't declared anywhere (yuck)
-- (BOOL)canPrintHeadersAndFooters
-{
- return NO;
-}
-
-// This is tested in -[WebFrameView printOperationWithPrintInfo:], but isn't declared anywhere (yuck)
-- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo
-{
- return [[PDFSubview document] getPrintOperationForPrintInfo:printInfo autoRotate:YES];
-}
-
-#pragma mark WebDocumentView PROTOCOL IMPLEMENTATION
-
-- (void)setDataSource:(WebDataSource *)ds
-{
- if (dataSource == ds)
- return;
-
- dataSource = [ds retain];
-
- // FIXME: There must be some better place to put this. There is no comment in ChangeLog
- // explaining why it's in this method.
- [self setFrame:[[self superview] frame]];
-}
-
-- (void)dataSourceUpdated:(WebDataSource *)dataSource
-{
-}
-
-- (void)setNeedsLayout:(BOOL)flag
-{
-}
-
-- (void)layout
-{
-}
-
-- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
-{
-}
-
-- (void)viewDidMoveToHostWindow
-{
-}
-
-#pragma mark WebDocumentElement PROTOCOL IMPLEMENTATION
-
-- (NSDictionary *)elementAtPoint:(NSPoint)point
-{
- WebFrame *frame = [dataSource webFrame];
- ASSERT(frame);
-
- return [NSDictionary dictionaryWithObjectsAndKeys:
- frame, WebElementFrameKey,
- [NSNumber numberWithBool:[self _pointIsInSelection:point]], WebElementIsSelectedKey,
- nil];
-}
-
-- (NSDictionary *)elementAtPoint:(NSPoint)point allowShadowContent:(BOOL)allow
-{
- return [self elementAtPoint:point];
-}
-
-#pragma mark WebDocumentSearching PROTOCOL IMPLEMENTATION
-
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag
-{
- return [self searchFor:string direction:forward caseSensitive:caseFlag wrap:wrapFlag startInSelection:NO];
-}
-
-#pragma mark WebDocumentIncrementalSearching PROTOCOL IMPLEMENTATION
-
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection
-{
- PDFSelection *selection = [self _nextMatchFor:string direction:forward caseSensitive:caseFlag wrap:wrapFlag fromSelection:[PDFSubview currentSelection] startInSelection:startInSelection];
- if (!selection)
- return NO;
-
- [PDFSubview setCurrentSelection:selection];
- [PDFSubview scrollSelectionToVisible:nil];
- return YES;
-}
-
-#pragma mark WebMultipleTextMatches PROTOCOL IMPLEMENTATION
-
-- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue
-{
- // This method is part of the WebMultipleTextMatches algorithm, but this class doesn't support
- // highlighting text matches inline.
-#ifndef NDEBUG
- if (newValue)
- LOG_ERROR("[WebPDFView setMarkedTextMatchesAreHighlighted:] called with YES, which isn't supported");
-#endif
-}
-
-- (BOOL)markedTextMatchesAreHighlighted
-{
- return NO;
-}
-
-- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(NSUInteger)limit
-{
- PDFSelection *previousMatch = nil;
- PDFSelection *nextMatch = nil;
- NSMutableArray *matches = [[NSMutableArray alloc] initWithCapacity:limit];
-
- for (;;) {
- nextMatch = [self _nextMatchFor:string direction:YES caseSensitive:caseFlag wrap:NO fromSelection:previousMatch startInSelection:NO];
- if (!nextMatch)
- break;
-
- [matches addObject:nextMatch];
- previousMatch = nextMatch;
-
- if ([matches count] >= limit)
- break;
- }
-
- [self _setTextMatches:matches];
- [matches release];
-
- return [matches count];
-}
-
-- (void)unmarkAllTextMatches
-{
- [self _setTextMatches:nil];
-}
-
-- (NSArray *)rectsForTextMatches
-{
- NSMutableArray *result = [NSMutableArray arrayWithCapacity:[textMatches count]];
- NSSet *visiblePages = [self _visiblePDFPages];
- NSEnumerator *matchEnumerator = [textMatches objectEnumerator];
- PDFSelection *match;
-
- while ((match = [matchEnumerator nextObject]) != nil) {
- NSEnumerator *pages = [[match pages] objectEnumerator];
- PDFPage *page;
- while ((page = [pages nextObject]) != nil) {
-
- // Skip pages that aren't visible (needed for non-continuous modes, see 5362989)
- if (![visiblePages containsObject:page])
- continue;
-
- NSRect selectionOnPageInPDFViewCoordinates = [PDFSubview convertRect:[match boundsForPage:page] fromPage:page];
- [result addObject:[NSValue valueWithRect:selectionOnPageInPDFViewCoordinates]];
- }
- }
-
- return result;
-}
-
-#pragma mark WebDocumentText PROTOCOL IMPLEMENTATION
-
-- (BOOL)supportsTextEncoding
-{
- return NO;
-}
-
-- (NSString *)string
-{
- return [[PDFSubview document] string];
-}
-
-- (NSAttributedString *)attributedString
-{
- // changing the selection is a hack, but the only way to get an attr string is via PDFSelection
-
- // must copy this selection object because we change the selection which seems to release it
- PDFSelection *savedSelection = [[PDFSubview currentSelection] copy];
- [PDFSubview selectAll:nil];
- NSAttributedString *result = [[PDFSubview currentSelection] attributedString];
- if (savedSelection) {
- [PDFSubview setCurrentSelection:savedSelection];
- [savedSelection release];
- } else {
- // FIXME: behavior of setCurrentSelection:nil is not documented - check 4182934 for progress
- // Otherwise, we could collapse this code with the case above.
- [PDFSubview clearSelection];
- }
-
- result = [self _scaledAttributedString:result];
-
- return result;
-}
-
-- (NSString *)selectedString
-{
- return [[PDFSubview currentSelection] string];
-}
-
-- (NSAttributedString *)selectedAttributedString
-{
- return [self _scaledAttributedString:[[PDFSubview currentSelection] attributedString]];
-}
-
-- (void)selectAll
-{
- [PDFSubview selectAll:nil];
-}
-
-- (void)deselectAll
-{
- [PDFSubview clearSelection];
-}
-
-#pragma mark WebDocumentViewState PROTOCOL IMPLEMENTATION
-
-// Even though to WebKit we are the "docView", in reality a PDFView contains its own scrollview and docView.
-// And it even turns out there is another PDFKit view between the docView and its enclosing ScrollView, so
-// we have to be sure to do our calculations based on that view, immediately inside the ClipView. We try
-// to make as few assumptions about the PDFKit view hierarchy as possible.
-
-- (NSPoint)scrollPoint
-{
- NSView *realDocView = [PDFSubview documentView];
- NSClipView *clipView = [[realDocView enclosingScrollView] contentView];
- return [clipView bounds].origin;
-}
-
-- (void)setScrollPoint:(NSPoint)p
-{
- WebFrame *frame = [dataSource webFrame];
- //FIXME: We only restore scroll state in the non-frames case because otherwise we get a crash due to
- // PDFKit calling display from within its drawRect:. See bugzilla 4164.
- if (![frame parentFrame]) {
- NSView *realDocView = [PDFSubview documentView];
- [[[realDocView enclosingScrollView] documentView] scrollPoint:p];
- }
-}
-
-- (id)viewState
-{
- NSMutableArray *state = [NSMutableArray arrayWithCapacity:4];
- PDFDisplayMode mode = [PDFSubview displayMode];
- [state addObject:[NSNumber numberWithInt:mode]];
- if (mode == kPDFDisplaySinglePage || mode == kPDFDisplayTwoUp) {
- unsigned int pageIndex = [[PDFSubview document] indexForPage:[PDFSubview currentPage]];
- [state addObject:[NSNumber numberWithUnsignedInt:pageIndex]];
- } // else in continuous modes, scroll position gets us to the right page
- BOOL autoScaleFlag = [PDFSubview autoScales];
- [state addObject:[NSNumber numberWithBool:autoScaleFlag]];
- if (!autoScaleFlag)
- [state addObject:[NSNumber numberWithFloat:[PDFSubview scaleFactor]]];
-
- return state;
-}
-
-- (void)setViewState:(id)statePList
-{
- ASSERT([statePList isKindOfClass:[NSArray class]]);
- NSArray *state = statePList;
- int i = 0;
- PDFDisplayMode mode = [[state objectAtIndex:i++] intValue];
- [PDFSubview setDisplayMode:mode];
- if (mode == kPDFDisplaySinglePage || mode == kPDFDisplayTwoUp) {
- unsigned int pageIndex = [[state objectAtIndex:i++] unsignedIntValue];
- [PDFSubview goToPage:[[PDFSubview document] pageAtIndex:pageIndex]];
- } // else in continuous modes, scroll position gets us to the right page
- BOOL autoScaleFlag = [[state objectAtIndex:i++] boolValue];
- [PDFSubview setAutoScales:autoScaleFlag];
- if (!autoScaleFlag)
- [PDFSubview setScaleFactor:[[state objectAtIndex:i++] floatValue]];
-}
-
-#pragma mark _WebDocumentTextSizing PROTOCOL IMPLEMENTATION
-
-- (IBAction)_zoomOut:(id)sender
-{
- [PDFSubviewProxy zoomOut:sender];
-}
-
-- (IBAction)_zoomIn:(id)sender
-{
- [PDFSubviewProxy zoomIn:sender];
-}
-
-- (IBAction)_resetZoom:(id)sender
-{
- [PDFSubviewProxy setScaleFactor:1.0f];
-}
-
-- (BOOL)_canZoomOut
-{
- return [PDFSubview canZoomOut];
-}
-
-- (BOOL)_canZoomIn
-{
- return [PDFSubview canZoomIn];
-}
-
-- (BOOL)_canResetZoom
-{
- return [PDFSubview scaleFactor] != 1.0;
-}
-
-#pragma mark WebDocumentSelection PROTOCOL IMPLEMENTATION
-
-- (NSRect)selectionRect
-{
- NSRect result = NSZeroRect;
- PDFSelection *selection = [PDFSubview currentSelection];
- NSEnumerator *pages = [[selection pages] objectEnumerator];
- PDFPage *page;
- while ((page = [pages nextObject]) != nil) {
- NSRect selectionOnPageInPDFViewCoordinates = [PDFSubview convertRect:[selection boundsForPage:page] fromPage:page];
- if (NSIsEmptyRect(result))
- result = selectionOnPageInPDFViewCoordinates;
- else
- result = NSUnionRect(result, selectionOnPageInPDFViewCoordinates);
- }
-
- // Convert result to be in documentView (selectionView) coordinates
- result = [PDFSubview convertRect:result toView:[PDFSubview documentView]];
-
- return result;
-}
-
-- (NSArray *)selectionTextRects
-{
- // FIXME: We'd need new PDFKit API/SPI to get multiple text rects for selections that intersect more than one line
- return [NSArray arrayWithObject:[NSValue valueWithRect:[self selectionRect]]];
-}
-
-- (NSView *)selectionView
-{
- return [PDFSubview documentView];
-}
-
-- (NSImage *)selectionImageForcingBlackText:(BOOL)forceBlackText
-{
- // Convert the selection to an attributed string, and draw that.
- // FIXME 4621154: this doesn't handle italics (and maybe other styles)
- // FIXME 4604366: this doesn't handle text at non-actual size
- NSMutableAttributedString *attributedString = [[self selectedAttributedString] mutableCopy];
- NSRange wholeStringRange = NSMakeRange(0, [attributedString length]);
-
- // Modify the styles in the attributed string to draw black text, no background, and no underline. We draw
- // no underline because it would look ugly.
- [attributedString beginEditing];
- [attributedString removeAttribute:NSBackgroundColorAttributeName range:wholeStringRange];
- [attributedString removeAttribute:NSUnderlineStyleAttributeName range:wholeStringRange];
- if (forceBlackText)
- [attributedString addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithDeviceWhite:0.0f alpha:1.0f] range:wholeStringRange];
- [attributedString endEditing];
-
- NSImage* selectionImage = [[[NSImage alloc] initWithSize:[self selectionRect].size] autorelease];
-
- [selectionImage lockFocus];
- [attributedString drawAtPoint:NSZeroPoint];
- [selectionImage unlockFocus];
-
- [attributedString release];
-
- return selectionImage;
-}
-
-- (NSRect)selectionImageRect
-{
- // FIXME: deal with clipping?
- return [self selectionRect];
-}
-
-- (NSArray *)pasteboardTypesForSelection
-{
- return [NSArray arrayWithObjects:NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, nil];
-}
-
-- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
-{
- NSAttributedString *attributedString = [self selectedAttributedString];
-
- if ([types containsObject:NSRTFDPboardType]) {
- NSData *RTFDData = [attributedString RTFDFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
- [pasteboard setData:RTFDData forType:NSRTFDPboardType];
- }
-
- if ([types containsObject:NSRTFPboardType]) {
- if ([attributedString containsAttachments])
- attributedString = [attributedString _web_attributedStringByStrippingAttachmentCharacters];
-
- NSData *RTFData = [attributedString RTFFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
- [pasteboard setData:RTFData forType:NSRTFPboardType];
- }
-
- if ([types containsObject:NSStringPboardType])
- [pasteboard setString:[self selectedString] forType:NSStringPboardType];
-}
-
-#pragma mark PDFView DELEGATE METHODS
-
-- (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)URL
-{
- if (!URL)
- return;
-
- NSWindow *window = [sender window];
- NSEvent *nsEvent = [window currentEvent];
- const int noButton = -1;
- int button = noButton;
- RefPtr<Event> event;
- switch ([nsEvent type]) {
- case NSLeftMouseUp:
- button = 0;
- break;
- case NSRightMouseUp:
- button = 1;
- break;
- case NSOtherMouseUp:
- button = [nsEvent buttonNumber];
- break;
- case NSKeyDown: {
- PlatformKeyboardEvent pe(nsEvent);
- pe.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown);
- event = KeyboardEvent::create(eventNames().keydownEvent, true, true, 0,
- pe.keyIdentifier(), pe.windowsVirtualKeyCode(),
- pe.ctrlKey(), pe.altKey(), pe.shiftKey(), pe.metaKey(), false);
- }
- default:
- break;
- }
- if (button != noButton)
- event = MouseEvent::create(eventNames().clickEvent, true, true, 0, [nsEvent clickCount], 0, 0, 0, 0,
- [nsEvent modifierFlags] & NSControlKeyMask,
- [nsEvent modifierFlags] & NSAlternateKeyMask,
- [nsEvent modifierFlags] & NSShiftKeyMask,
- [nsEvent modifierFlags] & NSCommandKeyMask,
- button, 0, 0, true);
-
- // Call to the frame loader because this is where our security checks are made.
- core([dataSource webFrame])->loader()->loadFrameRequestWithFormAndValues(ResourceRequest(URL), false, event.get(), 0, HashMap<String, String>());
-}
-
-- (void)PDFViewOpenPDFInNativeApplication:(PDFView *)sender
-{
- // Delegate method sent when the user requests opening the PDF file in the system's default app
- [self _openWithFinder:sender];
-}
-
-- (void)PDFViewPerformPrint:(PDFView *)sender
-{
- CallUIDelegate([self _webView], @selector(webView:printFrameView:), [[dataSource webFrame] frameView]);
-}
-
-- (void)PDFViewSavePDFToDownloadFolder:(PDFView *)sender
-{
- // We don't want to write the file until we have a document to write (see 5267607).
- if (![PDFSubview document]) {
- NSBeep();
- return;
- }
-
- // Delegate method sent when the user requests downloading the PDF file to disk. We pass NO for
- // showingPanel: so that the PDF file is saved to the standard location without user intervention.
- CallUIDelegate([self _webView], @selector(webView:saveFrameView:showingPanel:), [[dataSource webFrame] frameView], NO);
-}
-
-@end
-
-@implementation WebPDFView (FileInternal)
-
-+ (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;
-}
-
-+ (Class)_PDFViewClass
-{
- static Class PDFViewClass = nil;
- if (PDFViewClass == nil) {
- PDFViewClass = [[WebPDFView PDFKitBundle] classNamed:@"PDFView"];
- if (!PDFViewClass)
- LOG_ERROR("Couldn't find PDFView class in PDFKit.framework");
- }
- return PDFViewClass;
-}
-
-- (BOOL)_anyPDFTagsFoundInMenu:(NSMenu *)menu
-{
- NSEnumerator *e = [[menu itemArray] objectEnumerator];
- NSMenuItem *item;
- while ((item = [e nextObject]) != nil) {
- switch ([item tag]) {
- case WebMenuItemTagOpenWithDefaultApplication:
- case WebMenuItemPDFActualSize:
- case WebMenuItemPDFZoomIn:
- case WebMenuItemPDFZoomOut:
- case WebMenuItemPDFAutoSize:
- case WebMenuItemPDFSinglePage:
- case WebMenuItemPDFSinglePageScrolling:
- case WebMenuItemPDFFacingPages:
- case WebMenuItemPDFFacingPagesScrolling:
- case WebMenuItemPDFContinuous:
- case WebMenuItemPDFNextPage:
- case WebMenuItemPDFPreviousPage:
- return YES;
- }
- }
- return NO;
-}
-
-- (void)_applyPDFDefaults
-{
- // Set up default viewing params
- WebPreferences *prefs = [[dataSource _webView] preferences];
- float scaleFactor = [prefs PDFScaleFactor];
- if (scaleFactor == 0)
- [PDFSubview setAutoScales:YES];
- else {
- [PDFSubview setAutoScales:NO];
- [PDFSubview setScaleFactor:scaleFactor];
- }
- [PDFSubview setDisplayMode:[prefs PDFDisplayMode]];
-}
-
-- (BOOL)_canLookUpInDictionary
-{
- return [PDFSubview respondsToSelector:@selector(_searchInDictionary:)];
-}
-
-- (NSClipView *)_clipViewForPDFDocumentView
-{
- NSClipView *clipView = (NSClipView *)[[PDFSubview documentView] _web_superviewOfClass:[NSClipView class]];
- ASSERT(clipView);
- return clipView;
-}
-
-- (NSEvent *)_fakeKeyEventWithFunctionKey:(unichar)functionKey
-{
- // FIXME 4400480: when PDFView implements the standard scrolling selectors that this
- // method is used to mimic, we can eliminate this method and call them directly.
- NSString *keyAsString = [NSString stringWithCharacters:&functionKey length:1];
- return [NSEvent keyEventWithType:NSKeyDown
- location:NSZeroPoint
- modifierFlags:0
- timestamp:0
- windowNumber:0
- context:nil
- characters:keyAsString
- charactersIgnoringModifiers:keyAsString
- isARepeat:NO
- keyCode:0];
-}
-
-- (void)_lookUpInDictionaryFromMenu:(id)sender
-{
- // This method is used by WebKit's context menu item. Here we map to the method that
- // PDFView uses. Since the PDFView method isn't API, and isn't available on all versions
- // of PDFKit, we use performSelector after a respondsToSelector check, rather than calling it directly.
- if ([self _canLookUpInDictionary])
- [PDFSubview performSelector:@selector(_searchInDictionary:) withObject:sender];
-}
-
-- (NSMutableArray *)_menuItemsFromPDFKitForEvent:(NSEvent *)theEvent
-{
- NSMutableArray *copiedItems = [NSMutableArray array];
- NSDictionary *actionsToTags = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:WebMenuItemPDFActualSize], NSStringFromSelector(@selector(_setActualSize:)),
- [NSNumber numberWithInt:WebMenuItemPDFZoomIn], NSStringFromSelector(@selector(zoomIn:)),
- [NSNumber numberWithInt:WebMenuItemPDFZoomOut], NSStringFromSelector(@selector(zoomOut:)),
- [NSNumber numberWithInt:WebMenuItemPDFAutoSize], NSStringFromSelector(@selector(_setAutoSize:)),
- [NSNumber numberWithInt:WebMenuItemPDFSinglePage], NSStringFromSelector(@selector(_setSinglePage:)),
- [NSNumber numberWithInt:WebMenuItemPDFSinglePageScrolling], NSStringFromSelector(@selector(_setSinglePageScrolling:)),
- [NSNumber numberWithInt:WebMenuItemPDFFacingPages], NSStringFromSelector(@selector(_setDoublePage:)),
- [NSNumber numberWithInt:WebMenuItemPDFFacingPagesScrolling], NSStringFromSelector(@selector(_setDoublePageScrolling:)),
- [NSNumber numberWithInt:WebMenuItemPDFContinuous], NSStringFromSelector(@selector(_toggleContinuous:)),
- [NSNumber numberWithInt:WebMenuItemPDFNextPage], NSStringFromSelector(@selector(goToNextPage:)),
- [NSNumber numberWithInt:WebMenuItemPDFPreviousPage], NSStringFromSelector(@selector(goToPreviousPage:)),
- nil];
-
- // Leave these menu items out, since WebKit inserts equivalent ones. Note that we leave out PDFKit's "Look Up in Dictionary"
- // item here because WebKit already includes an item with the same title and purpose. We map WebKit's to PDFKit's
- // "Look Up in Dictionary" via the implementation of -[WebPDFView _lookUpInDictionaryFromMenu:].
- NSSet *unwantedActions = [[NSSet alloc] initWithObjects:
- NSStringFromSelector(@selector(_searchInSpotlight:)),
- NSStringFromSelector(@selector(_searchInGoogle:)),
- NSStringFromSelector(@selector(_searchInDictionary:)),
- NSStringFromSelector(@selector(copy:)),
- nil];
-
- NSEnumerator *e = [[[PDFSubview menuForEvent:theEvent] itemArray] objectEnumerator];
- NSMenuItem *item;
- while ((item = [e nextObject]) != nil) {
-
- NSString *actionString = NSStringFromSelector([item action]);
-
- if ([unwantedActions containsObject:actionString])
- continue;
-
- // Copy items since a menu item can be in only one menu at a time, and we don't
- // want to modify the original menu supplied by PDFKit.
- NSMenuItem *itemCopy = [item copy];
- [copiedItems addObject:itemCopy];
-
- // Include all of PDFKit's separators for now. At the end we'll remove any ones that were made
- // useless by removing PDFKit's menu items.
- if ([itemCopy isSeparatorItem])
- continue;
-
- NSNumber *tagNumber = [actionsToTags objectForKey:actionString];
-
- int tag;
- if (tagNumber != nil)
- tag = [tagNumber intValue];
- else {
- // This should happen only if PDFKit updates behind WebKit's back. It's non-ideal because clients that only include tags
- // that they recognize (like Safari) won't get these PDFKit additions until WebKit is updated to match.
- tag = WebMenuItemTagOther;
- LOG_ERROR("no WebKit menu item tag found for PDF context menu item action \"%@\", using WebMenuItemTagOther", actionString);
- }
-
- if ([itemCopy tag] == 0) {
- [itemCopy setTag:tag];
- if ([itemCopy target] == PDFSubview) {
- // Note that updating the defaults is cheap because it catches redundant settings, so installing
- // the proxy for actions that don't impact the defaults is OK
- [itemCopy setTarget:PDFSubviewProxy];
- }
- } else
- LOG_ERROR("PDF context menu item %@ came with tag %d, so no WebKit tag was applied. This could mean that the item doesn't appear in clients such as Safari.", [itemCopy title], [itemCopy tag]);
- }
-
- [actionsToTags release];
- [unwantedActions release];
-
- // Since we might have removed elements supplied by PDFKit, and we want to minimize our hardwired
- // knowledge of the order and arrangement of PDFKit's menu items, we need to remove any bogus
- // separators that were left behind.
- [copiedItems _webkit_removeUselessMenuItemSeparators];
-
- return copiedItems;
-}
-
-- (PDFSelection *)_nextMatchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag fromSelection:(PDFSelection *)initialSelection startInSelection:(BOOL)startInSelection
-{
- if (![string length])
- return nil;
-
- int options = 0;
- if (!forward)
- options |= NSBackwardsSearch;
-
- if (!caseFlag)
- options |= NSCaseInsensitiveSearch;
-
- PDFDocument *document = [PDFSubview document];
-
- PDFSelection *selectionForInitialSearch = [initialSelection copy];
- if (startInSelection) {
- // Initially we want to include the selected text in the search. PDFDocument's API always searches from just
- // past the passed-in selection, so we need to pass a selection that's modified appropriately.
- // FIXME 4182863: Ideally we'd use a zero-length selection at the edge of the current selection, but zero-length
- // selections don't work in PDFDocument. So instead we make a one-length selection just before or after the
- // current selection, which works for our purposes even when the current selection is at an edge of the
- // document.
- int initialSelectionLength = [[initialSelection string] length];
- if (forward) {
- [selectionForInitialSearch extendSelectionAtStart:1];
- [selectionForInitialSearch extendSelectionAtEnd:-initialSelectionLength];
- } else {
- [selectionForInitialSearch extendSelectionAtEnd:1];
- [selectionForInitialSearch extendSelectionAtStart:-initialSelectionLength];
- }
- }
- PDFSelection *foundSelection = [document findString:string fromSelection:selectionForInitialSearch withOptions:options];
- [selectionForInitialSearch release];
-
- // If we first searched in the selection, and we found the selection, search again from just past the selection
- if (startInSelection && _PDFSelectionsAreEqual(foundSelection, initialSelection))
- foundSelection = [document findString:string fromSelection:initialSelection withOptions:options];
-
- if (!foundSelection && wrapFlag)
- foundSelection = [document findString:string fromSelection:nil withOptions:options];
-
- return foundSelection;
-}
-
-- (void)_openWithFinder:(id)sender
-{
- // We don't want to write the file until we have a document to write (see 4892525).
- if (![PDFSubview document]) {
- NSBeep();
- return;
- }
-
- NSString *opath = [self _path];
-
- if (opath) {
- if (!written) {
- // Create a PDF file with the minimal permissions (only accessible to the current user, see 4145714)
- NSNumber *permissions = [[NSNumber alloc] initWithInt:S_IRUSR];
- NSDictionary *fileAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:permissions, NSFilePosixPermissions, nil];
- [permissions release];
-
- [[NSFileManager defaultManager] createFileAtPath:opath contents:[dataSource data] attributes:fileAttributes];
-
- [fileAttributes release];
- written = YES;
- }
-
- if (![[NSWorkspace sharedWorkspace] openFile:opath]) {
- // NSWorkspace couldn't open file. Do we need an alert
- // here? We ignore the error elsewhere.
- }
- }
-}
-
-- (NSString *)_path
-{
- // Generate path once.
- if (path)
- return path;
-
- NSString *filename = [[dataSource response] suggestedFilename];
- NSFileManager *manager = [NSFileManager defaultManager];
- NSString *temporaryPDFDirectoryPath = [self _temporaryPDFDirectoryPath];
-
- if (!temporaryPDFDirectoryPath) {
- // This should never happen; if it does we'll fail silently on non-debug builds.
- ASSERT_NOT_REACHED();
- return nil;
- }
-
- path = [temporaryPDFDirectoryPath stringByAppendingPathComponent:filename];
- if ([manager fileExistsAtPath:path]) {
- NSString *pathTemplatePrefix = [temporaryPDFDirectoryPath stringByAppendingPathComponent:@"XXXXXX-"];
- NSString *pathTemplate = [pathTemplatePrefix stringByAppendingString:filename];
- // fileSystemRepresentation returns a const char *; copy it into a char * so we can modify it safely
- char *cPath = strdup([pathTemplate fileSystemRepresentation]);
- int fd = mkstemps(cPath, strlen(cPath) - strlen([pathTemplatePrefix fileSystemRepresentation]) + 1);
- if (fd < 0) {
- // Couldn't create a temporary file! Should never happen; if it does we'll fail silently on non-debug builds.
- ASSERT_NOT_REACHED();
- path = nil;
- } else {
- close(fd);
- path = [manager stringWithFileSystemRepresentation:cPath length:strlen(cPath)];
- }
- free(cPath);
- }
-
- [path retain];
-
- return path;
-}
-
-- (void)_PDFDocumentViewMightHaveScrolled:(NSNotification *)notification
-{
- NSClipView *clipView = [self _clipViewForPDFDocumentView];
- ASSERT([notification object] == clipView);
-
- NSPoint scrollPosition = [clipView bounds].origin;
- if (NSEqualPoints(scrollPosition, lastScrollPosition))
- return;
-
- lastScrollPosition = scrollPosition;
- WebView *webView = [self _webView];
- [[webView _UIDelegateForwarder] webView:webView didScrollDocumentInFrameView:[[dataSource webFrame] frameView]];
-}
-
-- (PDFView *)_PDFSubview
-{
- return PDFSubview;
-}
-
-- (BOOL)_pointIsInSelection:(NSPoint)point
-{
- PDFPage *page = [PDFSubview pageForPoint:point nearest:NO];
- if (!page)
- return NO;
-
- NSRect selectionRect = [PDFSubview convertRect:[[PDFSubview currentSelection] boundsForPage:page] fromPage:page];
-
- return NSPointInRect(point, selectionRect);
-}
-
-- (void)_scaleOrDisplayModeOrPageChanged:(NSNotification *)notification
-{
- ASSERT([notification object] == PDFSubview);
- if (!_ignoreScaleAndDisplayModeAndPageNotifications) {
- [self _updatePreferencesSoon];
- // Notify UI delegate that the entire page has been redrawn, since (unlike for WebHTMLView)
- // we can't hook into the drawing mechanism itself. This fixes 5337529.
- WebView *webView = [self _webView];
- [[webView _UIDelegateForwarder] webView:webView didDrawRect:[webView bounds]];
- }
-}
-
-- (NSAttributedString *)_scaledAttributedString:(NSAttributedString *)unscaledAttributedString
-{
- if (!unscaledAttributedString)
- return nil;
-
- float scaleFactor = [PDFSubview scaleFactor];
- if (scaleFactor == 1.0)
- return unscaledAttributedString;
-
- NSMutableAttributedString *result = [[unscaledAttributedString mutableCopy] autorelease];
- unsigned int length = [result length];
- NSRange effectiveRange = NSMakeRange(0,0);
-
- [result beginEditing];
- while (NSMaxRange(effectiveRange) < length) {
- NSFont *unscaledFont = [result attribute:NSFontAttributeName atIndex:NSMaxRange(effectiveRange) effectiveRange:&effectiveRange];
-
- if (!unscaledFont) {
- // FIXME: We can't scale the font if we don't know what it is. We should always know what it is,
- // but sometimes don't due to PDFKit issue 5089411. When that's addressed, we can remove this
- // early continue.
- LOG_ERROR("no font attribute found in range %@ for attributed string \"%@\" on page %@ (see radar 5089411)", NSStringFromRange(effectiveRange), result, [[dataSource request] URL]);
- continue;
- }
-
- NSFont *scaledFont = [NSFont fontWithName:[unscaledFont fontName] size:[unscaledFont pointSize]*scaleFactor];
- [result addAttribute:NSFontAttributeName value:scaledFont range:effectiveRange];
- }
- [result endEditing];
-
- return result;
-}
-
-- (void)_setTextMatches:(NSArray *)array
-{
- [array retain];
- [textMatches release];
- textMatches = array;
-}
-
-- (NSString *)_temporaryPDFDirectoryPath
-{
- // Returns nil if the temporary PDF directory didn't exist and couldn't be created
-
- static NSString *_temporaryPDFDirectoryPath = nil;
-
- if (!_temporaryPDFDirectoryPath) {
- NSString *temporaryDirectoryTemplate = [NSTemporaryDirectory() stringByAppendingPathComponent:@"WebKitPDFs-XXXXXX"];
- char *cTemplate = strdup([temporaryDirectoryTemplate fileSystemRepresentation]);
-
- if (!mkdtemp(cTemplate)) {
- // This should never happen; if it does we'll fail silently on non-debug builds.
- ASSERT_NOT_REACHED();
- } else {
- // cTemplate has now been modified to be the just-created directory name. This directory has 700 permissions,
- // so only the current user can add to it or view its contents.
- _temporaryPDFDirectoryPath = [[[NSFileManager defaultManager] stringWithFileSystemRepresentation:cTemplate length:strlen(cTemplate)] retain];
- }
-
- free(cTemplate);
- }
-
- return _temporaryPDFDirectoryPath;
-}
-
-- (void)_trackFirstResponder
-{
- ASSERT([self window]);
-
- id newFirstResponder = [[self window] firstResponder];
- if (newFirstResponder == trackedFirstResponder)
- return;
-
- // This next clause is the entire purpose of _trackFirstResponder. In other WebDocument
- // view classes this is done in a resignFirstResponder override, but in this case the
- // first responder view is a PDFKit class that we can't subclass.
- if (trackedFirstResponder == [PDFSubview documentView] && ![[dataSource _webView] maintainsInactiveSelection])
- [self deselectAll];
-
-
- [trackedFirstResponder release];
- trackedFirstResponder = [newFirstResponder retain];
-}
-
-- (void)_updatePreferences:(WebPreferences *)prefs
-{
- float scaleFactor = [PDFSubview autoScales] ? 0.0f : [PDFSubview scaleFactor];
- [prefs setPDFScaleFactor:scaleFactor];
- [prefs setPDFDisplayMode:[PDFSubview displayMode]];
- _willUpdatePreferencesSoon = NO;
- [prefs release];
- [self release];
-}
-
-- (void)_updatePreferencesSoon
-{
- // Consolidate calls; due to the PDFPrefUpdatingProxy method, this can be called multiple times with a single user action
- // such as showing the context menu.
- if (_willUpdatePreferencesSoon)
- return;
-
- WebPreferences *prefs = [[dataSource _webView] preferences];
-
- [self retain];
- [prefs retain];
- [self performSelector:@selector(_updatePreferences:) withObject:prefs afterDelay:0];
- _willUpdatePreferencesSoon = YES;
-}
-
-- (NSSet *)_visiblePDFPages
-{
- // Returns the set of pages that are at least partly visible, used to avoid processing non-visible pages
- PDFDocument *pdfDocument = [PDFSubview document];
- if (!pdfDocument)
- return nil;
-
- NSRect pdfViewBounds = [PDFSubview bounds];
- PDFPage *topLeftPage = [PDFSubview pageForPoint:NSMakePoint(NSMinX(pdfViewBounds), NSMaxY(pdfViewBounds)) nearest:YES];
- PDFPage *bottomRightPage = [PDFSubview pageForPoint:NSMakePoint(NSMaxX(pdfViewBounds), NSMinY(pdfViewBounds)) nearest:YES];
-
- // only page-free documents should return nil for either of these two since we passed YES for nearest:
- if (!topLeftPage) {
- ASSERT(!bottomRightPage);
- return nil;
- }
-
- NSUInteger firstVisiblePageIndex = [pdfDocument indexForPage:topLeftPage];
- NSUInteger lastVisiblePageIndex = [pdfDocument indexForPage:bottomRightPage];
-
- if (firstVisiblePageIndex > lastVisiblePageIndex) {
- NSUInteger swap = firstVisiblePageIndex;
- firstVisiblePageIndex = lastVisiblePageIndex;
- lastVisiblePageIndex = swap;
- }
-
- NSMutableSet *result = [NSMutableSet set];
- NSUInteger pageIndex;
- for (pageIndex = firstVisiblePageIndex; pageIndex <= lastVisiblePageIndex; ++pageIndex)
- [result addObject:[pdfDocument pageAtIndex:pageIndex]];
-
- return result;
-}
-
-@end
-
-@implementation PDFPrefUpdatingProxy
-
-- (id)initWithView:(WebPDFView *)aView
-{
- // No [super init], since we inherit from NSProxy
- view = aView;
- return self;
-}
-
-- (void)forwardInvocation:(NSInvocation *)invocation
-{
- [invocation invokeWithTarget:[view _PDFSubview]];
- [view _updatePreferencesSoon];
-}
-
-- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel
-{
- return [[view _PDFSubview] methodSignatureForSelector:sel];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebPolicyDelegate.h b/WebKit/mac/WebView/WebPolicyDelegate.h
deleted file mode 100644
index 01d0843..0000000
--- a/WebKit/mac/WebView/WebPolicyDelegate.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-@class NSError;
-@class NSURLResponse;
-@class NSURLRequest;
-@class WebView;
-@class WebFrame;
-@class WebPolicyPrivate;
-
-/*!
- @enum WebNavigationType
- @abstract The type of action that triggered a possible navigation.
- @constant WebNavigationTypeLinkClicked A link with an href was clicked.
- @constant WebNavigationTypeFormSubmitted A form was submitted.
- @constant WebNavigationTypeBackForward The user chose back or forward.
- @constant WebNavigationTypeReload The User hit the reload button.
- @constant WebNavigationTypeFormResubmitted A form was resubmitted (by virtue of doing back, forward or reload).
- @constant WebNavigationTypeOther Navigation is taking place for some other reason.
-*/
-
-typedef enum {
- WebNavigationTypeLinkClicked,
- WebNavigationTypeFormSubmitted,
- WebNavigationTypeBackForward,
- WebNavigationTypeReload,
- WebNavigationTypeFormResubmitted,
- WebNavigationTypeOther
-} WebNavigationType;
-
-extern NSString *WebActionNavigationTypeKey; // NSNumber (WebNavigationType)
-extern NSString *WebActionElementKey; // NSDictionary of element info
-extern NSString *WebActionButtonKey; // NSNumber (0 for left button, 1 for middle button, 2 for right button)
-extern NSString *WebActionModifierFlagsKey; // NSNumber (unsigned)
-extern NSString *WebActionOriginalURLKey; // NSURL
-
-/*!
- @protocol WebPolicyDecisionListener
- @discussion This protocol is used to call back with the results of a
- policy decision. This provides the ability to make these decisions
- asyncrhonously, which means the decision can be made by prompting
- with a sheet, for example.
-*/
-
-@protocol WebPolicyDecisionListener <NSObject>
-
-/*!
- @method use
- @abstract Use the resource
- @discussion If there remain more policy decisions to be made, then
- the next policy delegate method gets to decide. This will be
- either the next navigation policy delegate if there is a redirect,
- or the content policy delegate. If there are no more policy
- decisions to be made, the resource will be displayed inline if
- possible. If there is no view available to display the resource
- inline, then unableToImplementPolicyWithError:frame: will be
- called with an appropriate error.
-
- <p>If a new window is going to be created for this navigation as a
- result of frame targetting, then it will be created once you call
- this method.
-*/
-- (void)use;
-/*!
- @method download
- @abstract Download the resource instead of displaying it.
- @discussion This method is more than just a convenience because it
- allows an in-progress navigation to be converted to a download
- based on content type, without having to stop and restart the
- load.
-*/
-- (void)download;
-
-/*!
- @method ignore
- @abstract Do nothing (but the client may choose to handle the request itself)
- @discussion A policy of ignore prevents WebKit from doing anything
- further with the load, however, the client is still free to handle
- the request in some other way, such as opening a new window,
- opening a new window behind the current one, opening the URL in an
- external app, revealing the location in Finder if a file URL, etc.
-*/
-- (void)ignore;
-
-@end
-
-
-/*!
- @category WebPolicyDelegate
- @discussion While loading a URL, WebKit asks the WebPolicyDelegate for
- policies that determine the action of what to do with the URL or the data that
- the URL represents. Typically, the policy handler methods are called in this order:
-
- decidePolicyForNewWindowAction:request:newFrameName:decisionListener: (at most once)<BR>
- decidePolicyForNavigationAction:request:frame:decisionListener: (zero or more times)<BR>
- decidePolicyForMIMEType:request:frame: (zero or more times)<BR>
-
- New window policy is always checked. Navigation policy is checked
- for the initial load and every redirect unless blocked by an
- earlier policy. Content policy is checked once the content type is
- known, unless an earlier policy prevented it.
-
- In rare cases, content policy might be checked more than
- once. This occurs when loading a "multipart/x-mixed-replace"
- document, also known as "server push". In this case, multiple
- documents come in one navigation, with each replacing the last. In
- this case, conent policy will be checked for each one.
-*/
-@interface NSObject (WebPolicyDelegate)
-
-/*!
- @method webView:decidePolicyForNavigationAction:request:frame:decisionListener:
- @abstract This method is called to decide what to do with a proposed navigation.
- @param actionInformation Dictionary that describes the action that triggered this navigation.
- @param request The request for the proposed navigation
- @param frame The WebFrame in which the navigation is happening
- @param listener The object to call when the decision is made
- @discussion This method will be called before loading starts, and
- on every redirect.
-*/
-- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation
- request:(NSURLRequest *)request
- frame:(WebFrame *)frame
- decisionListener:(id<WebPolicyDecisionListener>)listener;
-
-/*!
- @method webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:
- @discussion This method is called to decide what to do with an targetted nagivation that would open a new window.
- @param actionInformation Dictionary that describes the action that triggered this navigation.
- @param request The request for the proposed navigation
- @param frame The frame in which the navigation is taking place
- @param listener The object to call when the decision is made
- @discussion This method is provided so that modified clicks on a targetted link which
- opens a new frame can prevent the new window from being opened if they decide to
- do something else, like download or present the new frame in a specialized way.
-
- <p>If this method picks a policy of Use, the new window will be
- opened, and decidePolicyForNavigationAction:request:frame:decisionListner:
- will be called with a WebNavigationType of WebNavigationTypeOther
- in its action. This is to avoid possible confusion about the modifiers.
-*/
-- (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation
- request:(NSURLRequest *)request
- newFrameName:(NSString *)frameName
- decisionListener:(id<WebPolicyDecisionListener>)listener;
-
-/*!
- @method webView:decidePolicyForMIMEType:request:frame:
- @discussion Returns the policy for content which has been partially loaded.
- Sent after webView:didStartProvisionalLoadForFrame: is sent on the WebFrameLoadDelegate.
- @param type MIME type for the resource.
- @param request A NSURLRequest for the partially loaded content.
- @param frame The frame which is loading the URL.
- @param listener The object to call when the decision is made
-*/
-- (void)webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type
- request:(NSURLRequest *)request
- frame:(WebFrame *)frame
- decisionListener:(id<WebPolicyDecisionListener>)listener;
-
-/*!
- @method webView:unableToImplementPolicy:error:forURL:inFrame:
- @discussion Called when a WebPolicy could not be implemented. It is up to the client to display appropriate feedback.
- @param policy The policy that could not be implemented.
- @param error The error that caused the policy to not be implemented.
- @param URL The URL of the resource for which a particular action was requested but failed.
- @param frame The frame in which the policy could not be implemented.
-*/
-- (void)webView:(WebView *)webView unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame;
-
-@end
diff --git a/WebKit/mac/WebView/WebPolicyDelegate.mm b/WebKit/mac/WebView/WebPolicyDelegate.mm
deleted file mode 100644
index f2df744..0000000
--- a/WebKit/mac/WebView/WebPolicyDelegate.mm
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebPolicyDelegatePrivate.h"
-
-#import <WebCore/FrameLoaderTypes.h>
-#import <objc/objc-runtime.h>
-
-using namespace WebCore;
-
-NSString *WebActionButtonKey = @"WebActionButtonKey";
-NSString *WebActionElementKey = @"WebActionElementKey";
-NSString *WebActionFormKey = @"WebActionFormKey";
-NSString *WebActionModifierFlagsKey = @"WebActionModifierFlagsKey";
-NSString *WebActionNavigationTypeKey = @"WebActionNavigationTypeKey";
-NSString *WebActionOriginalURLKey = @"WebActionOriginalURLKey";
-
-@interface WebPolicyDecisionListenerPrivate : NSObject
-{
-@public
- id target;
- SEL action;
-}
-
-- (id)initWithTarget:(id)target action:(SEL)action;
-
-@end
-
-@implementation WebPolicyDecisionListenerPrivate
-
-- (id)initWithTarget:(id)t action:(SEL)a
-{
- self = [super init];
- if (!self)
- return nil;
- target = [t retain];
- action = a;
- return self;
-}
-
-- (void)dealloc
-{
- [target release];
- [super dealloc];
-}
-
-@end
-
-@implementation WebPolicyDecisionListener
-
-- (id)_initWithTarget:(id)target action:(SEL)action
-{
- self = [super init];
- if (!self)
- return nil;
- _private = [[WebPolicyDecisionListenerPrivate alloc] initWithTarget:target action:action];
- return self;
-}
-
--(void)dealloc
-{
- [_private release];
- [super dealloc];
-}
-
-- (void)_usePolicy:(PolicyAction)policy
-{
- if (_private->target)
- ((void (*)(id, SEL, PolicyAction))objc_msgSend)(_private->target, _private->action, policy);
-}
-
-- (void)_invalidate
-{
- id target = _private->target;
- _private->target = nil;
- [target release];
-}
-
-// WebPolicyDecisionListener implementation
-
-- (void)use
-{
- [self _usePolicy:PolicyUse];
-}
-
-- (void)ignore
-{
- [self _usePolicy:PolicyIgnore];
-}
-
-- (void)download
-{
- [self _usePolicy:PolicyDownload];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebPolicyDelegatePrivate.h b/WebKit/mac/WebView/WebPolicyDelegatePrivate.h
deleted file mode 100644
index 45f8f45..0000000
--- a/WebKit/mac/WebView/WebPolicyDelegatePrivate.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebPolicyDelegate.h>
-
-@class WebHistoryItem;
-@class WebPolicyDecisionListenerPrivate;
-
-extern NSString *WebActionFormKey; // HTMLFormElement
-
-typedef enum {
- WebNavigationTypePlugInRequest = WebNavigationTypeOther + 1
-} WebExtraNavigationType;
-
-@interface WebPolicyDecisionListener : NSObject <WebPolicyDecisionListener>
-{
-@private
- WebPolicyDecisionListenerPrivate *_private;
-}
-- (id)_initWithTarget:(id)target action:(SEL)action;
-- (void)_invalidate;
-@end
-
-@interface NSObject (WebPolicyDelegatePrivate)
-// Needed for <rdar://problem/3951283> can view pages from the back/forward cache that should be disallowed by Parental Controls
-- (BOOL)webView:(WebView *)webView shouldGoToHistoryItem:(WebHistoryItem *)item;
-@end
diff --git a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
deleted file mode 100644
index bcb17db..0000000
--- a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// These are private because callers should be using the cover methods. They are in
-// a Private (as opposed to Internal) header file because Safari uses some of them
-// for managed preferences.
-#define WebKitLogLevelPreferenceKey @"WebKitLogLevel"
-#define WebKitStandardFontPreferenceKey @"WebKitStandardFont"
-#define WebKitFixedFontPreferenceKey @"WebKitFixedFont"
-#define WebKitSerifFontPreferenceKey @"WebKitSerifFont"
-#define WebKitSansSerifFontPreferenceKey @"WebKitSansSerifFont"
-#define WebKitCursiveFontPreferenceKey @"WebKitCursiveFont"
-#define WebKitFantasyFontPreferenceKey @"WebKitFantasyFont"
-#define WebKitMinimumFontSizePreferenceKey @"WebKitMinimumFontSize"
-#define WebKitMinimumLogicalFontSizePreferenceKey @"WebKitMinimumLogicalFontSize"
-#define WebKitDefaultFontSizePreferenceKey @"WebKitDefaultFontSize"
-#define WebKitDefaultFixedFontSizePreferenceKey @"WebKitDefaultFixedFontSize"
-#define WebKitDefaultTextEncodingNamePreferenceKey @"WebKitDefaultTextEncodingName"
-#define WebKitUserStyleSheetEnabledPreferenceKey @"WebKitUserStyleSheetEnabledPreferenceKey"
-#define WebKitUserStyleSheetLocationPreferenceKey @"WebKitUserStyleSheetLocationPreferenceKey"
-#define WebKitShouldPrintBackgroundsPreferenceKey @"WebKitShouldPrintBackgroundsPreferenceKey"
-#define WebKitTextAreasAreResizablePreferenceKey @"WebKitTextAreasAreResizable"
-#define WebKitShrinksStandaloneImagesToFitPreferenceKey @"WebKitShrinksStandaloneImagesToFit"
-#define WebKitJavaEnabledPreferenceKey @"WebKitJavaEnabled"
-#define WebKitJavaScriptEnabledPreferenceKey @"WebKitJavaScriptEnabled"
-#define WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey @"WebKitJavaScriptCanOpenWindowsAutomatically"
-#define WebKitPluginsEnabledPreferenceKey @"WebKitPluginsEnabled"
-#define WebKitAllowAnimatedImagesPreferenceKey @"WebKitAllowAnimatedImagesPreferenceKey"
-#define WebKitAllowAnimatedImageLoopingPreferenceKey @"WebKitAllowAnimatedImageLoopingPreferenceKey"
-#define WebKitDisplayImagesKey @"WebKitDisplayImagesKey"
-#define WebKitBackForwardCacheExpirationIntervalKey @"WebKitBackForwardCacheExpirationIntervalKey"
-#define WebKitTabToLinksPreferenceKey @"WebKitTabToLinksPreferenceKey"
-#define WebKitPrivateBrowsingEnabledPreferenceKey @"WebKitPrivateBrowsingEnabled"
-#define WebContinuousSpellCheckingEnabled @"WebContinuousSpellCheckingEnabled"
-#define WebGrammarCheckingEnabled @"WebGrammarCheckingEnabled"
-#define WebKitDOMPasteAllowedPreferenceKey @"WebKitDOMPasteAllowedPreferenceKey"
-#define WebKitUsesPageCachePreferenceKey @"WebKitUsesPageCachePreferenceKey"
-#define WebKitFTPDirectoryTemplatePath @"WebKitFTPDirectoryTemplatePath"
-#define WebKitForceFTPDirectoryListings @"WebKitForceFTPDirectoryListings"
-#define WebKitDeveloperExtrasEnabledPreferenceKey @"WebKitDeveloperExtrasEnabledPreferenceKey"
-#define WebKitAuthorAndUserStylesEnabledPreferenceKey @"WebKitAuthorAndUserStylesEnabledPreferenceKey"
-#define WebKitApplicationChromeModeEnabledPreferenceKey @"WebKitApplicationChromeModeEnabledPreferenceKey"
-#define WebKitWebArchiveDebugModeEnabledPreferenceKey @"WebKitWebArchiveDebugModeEnabledPreferenceKey"
-#define WebKitLocalStorageDatabasePathPreferenceKey @"WebKitLocalStorageDatabasePathPreferenceKey"
-#define WebKitEnableFullDocumentTeardownPreferenceKey @"WebKitEnableFullDocumentTeardown"
-#define WebKitOfflineWebApplicationCacheEnabledPreferenceKey @"WebKitOfflineWebApplicationCacheEnabled"
-#define WebKitZoomsTextOnlyPreferenceKey @"WebKitZoomsTextOnly"
-
-// These are private both because callers should be using the cover methods and because the
-// cover methods themselves are private.
-#define WebKitRespectStandardStyleKeyEquivalentsPreferenceKey @"WebKitRespectStandardStyleKeyEquivalents"
-#define WebKitShowsURLsInToolTipsPreferenceKey @"WebKitShowsURLsInToolTips"
-#define WebKitPDFDisplayModePreferenceKey @"WebKitPDFDisplayMode"
-#define WebKitPDFScaleFactorPreferenceKey @"WebKitPDFScaleFactor"
-#define WebKitUseSiteSpecificSpoofingPreferenceKey @"WebKitUseSiteSpecificSpoofing"
-#define WebKitEditableLinkBehaviorPreferenceKey @"WebKitEditableLinkBehavior"
-#define WebKitCacheModelPreferenceKey @"WebKitCacheModelPreferenceKey"
-
-// CoreGraphics deferred updates are disabled if WebKitEnableCoalescedUpdatesPreferenceKey is set
-// to NO, or has no value. For compatibility with Mac OS X 10.4.6, deferred updates are OFF by
-// default.
-#define WebKitEnableDeferredUpdatesPreferenceKey @"WebKitEnableDeferredUpdates"
-
-// For debugging only. Don't use these.
-#define WebKitPageCacheSizePreferenceKey @"WebKitPageCacheSizePreferenceKey"
-#define WebKitObjectCacheSizePreferenceKey @"WebKitObjectCacheSizePreferenceKey"
-#define WebKitDebugFullPageZoomPreferenceKey @"WebKitDebugFullPageZoomPreferenceKey"
diff --git a/WebKit/mac/WebView/WebPreferences.h b/WebKit/mac/WebView/WebPreferences.h
deleted file mode 100644
index 1988acc..0000000
--- a/WebKit/mac/WebView/WebPreferences.h
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSUInteger unsigned int
-#else
-#define WebNSUInteger NSUInteger
-#endif
-
-/*!
-@enum WebCacheModel
-
-@abstract Specifies a usage model for a WebView, which WebKit will use to
-determine its caching behavior.
-
-@constant WebCacheModelDocumentViewer Appropriate for a WebView displaying
-a fixed document -- like a splash screen, a chat document, or a word processing
-document -- with no UI for navigation. The WebView will behave like any other
-view, releasing resources when they are no longer referenced. Remote resources,
-if any, will be cached to disk. This is the most memory-efficient setting.
-
-Examples: iChat, Mail, TextMate, Growl.
-
-@constant WebCacheModelDocumentBrowser Appropriate for a WebView displaying
-a browsable series of documents with a UI for navigating between them -- for
-example, a reference materials browser or a website designer. The WebView will
-cache a reasonable number of resources and previously viewed documents in
-memory and/or on disk.
-
-Examples: Dictionary, Help Viewer, Coda.
-
-@constant WebCacheModelPrimaryWebBrowser Appropriate for a WebView in the
-application that acts as the user's primary web browser. The WebView will cache
-a very large number of resources and previously viewed documents in memory
-and/or on disk.
-
-Examples: Safari, OmniWeb, Shiira.
-*/
-enum {
- WebCacheModelDocumentViewer = 0,
- WebCacheModelDocumentBrowser = 1,
- WebCacheModelPrimaryWebBrowser = 2
-};
-typedef WebNSUInteger WebCacheModel;
-
-@class WebPreferencesPrivate;
-
-extern NSString *WebPreferencesChangedNotification;
-
-/*!
- @class WebPreferences
-*/
-@interface WebPreferences: NSObject <NSCoding>
-{
-@private
- WebPreferencesPrivate *_private;
-}
-
-/*!
- @method standardPreferences
-*/
-+ (WebPreferences *)standardPreferences;
-
-/*!
- @method initWithIdentifier:
- @param anIdentifier A string used to identify the WebPreferences.
- @discussion WebViews can share instances of WebPreferences by using an instance of WebPreferences with
- the same identifier. Typically, instance are not created directly. Instead you set the preferences
- identifier on a WebView. The identifier is used as a prefix that is added to the user defaults keys
- for the WebPreferences.
- @result Returns a new instance of WebPreferences or a previously allocated instance with the same identifier.
-*/
-- (id)initWithIdentifier:(NSString *)anIdentifier;
-
-/*!
- @method identifier
- @result Returns the identifier for this WebPreferences.
-*/
-- (NSString *)identifier;
-
-/*!
- @method standardFontFamily
-*/
-- (NSString *)standardFontFamily;
-
-/*!
- @method setStandardFontFamily:
- @param family
-*/
-- (void)setStandardFontFamily:(NSString *)family;
-
-/*!
- @method fixedFontFamily
-*/
-- (NSString *)fixedFontFamily;
-
-/*!
- @method setFixedFontFamily:
- @param family
-*/
-- (void)setFixedFontFamily:(NSString *)family;
-
-/*!
- @method serifFontFamily
-*/
-- (NSString *)serifFontFamily;
-
-/*!
- @method setSerifFontFamily:
- @param family
-*/
-- (void)setSerifFontFamily:(NSString *)family;
-
-/*!
- @method sansSerifFontFamily
-*/
-- (NSString *)sansSerifFontFamily;
-
-/*!
- @method setSansSerifFontFamily:
- @param family
-*/
-- (void)setSansSerifFontFamily:(NSString *)family;
-
-/*!
- @method cursiveFontFamily
-*/
-- (NSString *)cursiveFontFamily;
-
-/*!
- @method setCursiveFontFamily:
- @param family
-*/
-- (void)setCursiveFontFamily:(NSString *)family;
-
-/*!
- @method fantasyFontFamily
-*/
-- (NSString *)fantasyFontFamily;
-
-/*!
- @method setFantasyFontFamily:
- @param family
-*/
-- (void)setFantasyFontFamily:(NSString *)family;
-
-/*!
- @method defaultFontSize
-*/
-- (int)defaultFontSize;
-
-/*!
- @method setDefaultFontSize:
- @param size
-*/
-- (void)setDefaultFontSize:(int)size;
-
-/*!
- @method defaultFixedFontSize
-*/
-- (int)defaultFixedFontSize;
-
-/*!
- @method setDefaultFixedFontSize:
- @param size
-*/
-- (void)setDefaultFixedFontSize:(int)size;
-
-/*!
- @method minimumFontSize
-*/
-- (int)minimumFontSize;
-
-/*!
- @method setMinimumFontSize:
- @param size
-*/
-- (void)setMinimumFontSize:(int)size;
-
-/*!
- @method minimumLogicalFontSize
-*/
-- (int)minimumLogicalFontSize;
-
-/*!
- @method setMinimumLogicalFontSize:
- @param size
-*/
-- (void)setMinimumLogicalFontSize:(int)size;
-
-/*!
- @method defaultTextEncodingName
-*/
-- (NSString *)defaultTextEncodingName;
-
-/*!
- @method setDefaultTextEncodingName:
- @param encoding
-*/
-- (void)setDefaultTextEncodingName:(NSString *)encoding;
-
-/*!
- @method userStyleSheetEnabled
-*/
-- (BOOL)userStyleSheetEnabled;
-
-/*!
- @method setUserStyleSheetEnabled:
- @param flag
-*/
-- (void)setUserStyleSheetEnabled:(BOOL)flag;
-
-/*!
- @method userStyleSheetLocation
- @discussion The location of the user style sheet.
-*/
-- (NSURL *)userStyleSheetLocation;
-
-/*!
- @method setUserStyleSheetLocation:
- @param URL The location of the user style sheet.
-*/
-- (void)setUserStyleSheetLocation:(NSURL *)URL;
-
-/*!
- @method isJavaEnabled
-*/
-- (BOOL)isJavaEnabled;
-
-/*!
- @method setJavaEnabled:
- @param flag
-*/
-- (void)setJavaEnabled:(BOOL)flag;
-
-/*!
- @method isJavaScriptEnabled
-*/
-- (BOOL)isJavaScriptEnabled;
-
-/*!
- @method setJavaScriptEnabled:
- @param flag
-*/
-- (void)setJavaScriptEnabled:(BOOL)flag;
-
-/*!
- @method JavaScriptCanOpenWindowsAutomatically
-*/
-- (BOOL)javaScriptCanOpenWindowsAutomatically;
-
-/*!
- @method setJavaScriptCanOpenWindowsAutomatically:
- @param flag
-*/
-- (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag;
-
-/*!
- @method arePlugInsEnabled
-*/
-- (BOOL)arePlugInsEnabled;
-
-/*!
- @method setPlugInsEnabled:
- @param flag
-*/
-- (void)setPlugInsEnabled:(BOOL)flag;
-
-/*!
- @method allowAnimatedImages
-*/
-- (BOOL)allowsAnimatedImages;
-
-/*!
- @method setAllowAnimatedImages:
- @param flag
-*/
-- (void)setAllowsAnimatedImages:(BOOL)flag;
-
-/*!
- @method allowAnimatedImageLooping
-*/
-- (BOOL)allowsAnimatedImageLooping;
-
-/*!
- @method setAllowAnimatedImageLooping:
- @param flag
-*/
-- (void)setAllowsAnimatedImageLooping: (BOOL)flag;
-
-/*!
- @method setWillLoadImagesAutomatically:
- @param flag
-*/
-- (void)setLoadsImagesAutomatically: (BOOL)flag;
-
-/*!
- @method willLoadImagesAutomatically
-*/
-- (BOOL)loadsImagesAutomatically;
-
-/*!
- @method setAutosaves:
- @param flag
- @discussion If autosave preferences is YES the settings represented by
- WebPreferences will be stored in the user defaults database.
-*/
-- (void)setAutosaves:(BOOL)flag;
-
-/*!
- @method autosaves
- @result The value of the autosave preferences flag.
-*/
-- (BOOL)autosaves;
-
-/*!
- @method setShouldPrintBackgrounds:
- @param flag
-*/
-- (void)setShouldPrintBackgrounds:(BOOL)flag;
-
-/*!
- @method shouldPrintBackgrounds
- @result The value of the shouldPrintBackgrounds preferences flag
-*/
-- (BOOL)shouldPrintBackgrounds;
-
-/*!
- @method setPrivateBrowsingEnabled:
- @param flag
- @abstract If private browsing is enabled, WebKit will not store information
- about sites the user visits.
- */
-- (void)setPrivateBrowsingEnabled:(BOOL)flag;
-
-/*!
- @method privateBrowsingEnabled
- */
-- (BOOL)privateBrowsingEnabled;
-
-/*!
- @method setTabsToLinks:
- @param flag
- @abstract If tabsToLinks is YES, the tab key will focus links and form controls.
- The option key temporarily reverses this preference.
-*/
-- (void)setTabsToLinks:(BOOL)flag;
-
-/*!
- @method tabsToLinks
-*/
-- (BOOL)tabsToLinks;
-
-/*!
- @method setUsesPageCache:
- @abstract Sets whether the receiver's associated WebViews use the shared
- page cache.
- @param UsesPageCache Whether the receiver's associated WebViews use the
- shared page cache.
- @discussion Pages are cached as they are added to a WebBackForwardList, and
- removed from the cache as they are removed from a WebBackForwardList. Because
- the page cache is global, caching a page in one WebBackForwardList may cause
- a page in another WebBackForwardList to be evicted from the cache.
-*/
-- (void)setUsesPageCache:(BOOL)usesPageCache;
-
-/*!
- @method usesPageCache
- @abstract Returns whether the receiver should use the shared page cache.
- @result Whether the receiver should use the shared page cache.
- @discussion Pages are cached as they are added to a WebBackForwardList, and
- removed from the cache as they are removed from a WebBackForwardList. Because
- the page cache is global, caching a page in one WebBackForwardList may cause
- a page in another WebBackForwardList to be evicted from the cache.
-*/
-- (BOOL)usesPageCache;
-
-/*!
-@method setCacheModel:
-
-@abstract Specifies a usage model for a WebView, which WebKit will use to
-determine its caching behavior.
-
-@param cacheModel The WebView's usage model for WebKit. If necessary, WebKit
-will prune its caches to match cacheModel.
-
-@discussion Research indicates that users tend to browse within clusters of
-documents that hold resources in common, and to revisit previously visited
-documents. WebKit and the frameworks below it include built-in caches that take
-advantage of these patterns, substantially improving document load speed in
-browsing situations. The WebKit cache model controls the behaviors of all of
-these caches, including NSURLCache and the various WebCore caches.
-
-Applications with a browsing interface can improve document load speed
-substantially by specifying WebCacheModelDocumentBrowser. Applications without
-a browsing interface can reduce memory usage substantially by specifying
-WebCacheModelDocumentViewer.
-
-If setCacheModel: is not called, WebKit will select a cache model automatically.
-*/
-- (void)setCacheModel:(WebCacheModel)cacheModel;
-
-/*!
-@method cacheModel:
-
-@abstract Returns the usage model according to which WebKit determines its
-caching behavior.
-
-@result The usage model.
-*/
-- (WebCacheModel)cacheModel;
-
-@end
-
-#undef WebNSUInteger
diff --git a/WebKit/mac/WebView/WebPreferences.mm b/WebKit/mac/WebView/WebPreferences.mm
deleted file mode 100644
index 8b2f43e..0000000
--- a/WebKit/mac/WebView/WebPreferences.mm
+++ /dev/null
@@ -1,1070 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebPreferencesPrivate.h"
-#import "WebPreferenceKeysPrivate.h"
-
-#import "WebKitLogging.h"
-#import "WebKitNSStringExtras.h"
-#import "WebKitSystemBits.h"
-#import "WebKitSystemInterface.h"
-#import "WebKitVersionChecks.h"
-#import "WebNSDictionaryExtras.h"
-#import "WebNSURLExtras.h"
-
-NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotification";
-NSString *WebPreferencesRemovedNotification = @"WebPreferencesRemovedNotification";
-
-#define KEY(x) (_private->identifier ? [_private->identifier stringByAppendingString:(x)] : (x))
-
-enum { WebPreferencesVersion = 1 };
-
-static WebPreferences *_standardPreferences;
-static NSMutableDictionary *webPreferencesInstances;
-
-static bool contains(const char* const array[], int count, const char* item)
-{
- if (!item)
- return false;
-
- for (int i = 0; i < count; i++)
- if (!strcasecmp(array[i], item))
- return true;
- return false;
-}
-
-static WebCacheModel cacheModelForMainBundle(void)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- // Apps that probably need the small setting
- static const char* const documentViewerIDs[] = {
- "Microsoft/com.microsoft.Messenger",
- "com.adiumX.adiumX",
- "com.alientechnology.Proteus",
- "com.apple.Dashcode",
- "com.apple.iChat",
- "com.barebones.bbedit",
- "com.barebones.textwrangler",
- "com.barebones.yojimbo",
- "com.equinux.iSale4",
- "com.growl.growlframework",
- "com.intrarts.PandoraMan",
- "com.karelia.Sandvox",
- "com.macromates.textmate",
- "com.realmacsoftware.rapidweaverpro",
- "com.red-sweater.marsedit",
- "com.yahoo.messenger3",
- "de.codingmonkeys.SubEthaEdit",
- "fi.karppinen.Pyro",
- "info.colloquy",
- "kungfoo.tv.ecto",
- };
-
- // Apps that probably need the medium setting
- static const char* const documentBrowserIDs[] = {
- "com.apple.Dictionary",
- "com.apple.Xcode",
- "com.apple.dashboard.client",
- "com.apple.helpviewer",
- "com.culturedcode.xyle",
- "com.macrabbit.CSSEdit",
- "com.panic.Coda",
- "com.ranchero.NetNewsWire",
- "com.thinkmac.NewsLife",
- "org.xlife.NewsFire",
- "uk.co.opencommunity.vienna2",
- };
-
- // Apps that probably need the large setting
- static const char* const primaryWebBrowserIDs[] = {
- "com.app4mac.KidsBrowser"
- "com.app4mac.wKiosk",
- "com.freeverse.bumpercar",
- "com.omnigroup.OmniWeb5",
- "com.sunrisebrowser.Sunrise",
- "net.hmdt-web.Shiira",
- };
-
- WebCacheModel cacheModel;
-
- const char* bundleID = [[[NSBundle mainBundle] bundleIdentifier] UTF8String];
- if (contains(documentViewerIDs, sizeof(documentViewerIDs) / sizeof(documentViewerIDs[0]), bundleID))
- cacheModel = WebCacheModelDocumentViewer;
- else if (contains(documentBrowserIDs, sizeof(documentBrowserIDs) / sizeof(documentBrowserIDs[0]), bundleID))
- cacheModel = WebCacheModelDocumentBrowser;
- else if (contains(primaryWebBrowserIDs, sizeof(primaryWebBrowserIDs) / sizeof(primaryWebBrowserIDs[0]), bundleID))
- cacheModel = WebCacheModelPrimaryWebBrowser;
- else {
- bool isLegacyApp = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_CACHE_MODEL_API);
- if (isLegacyApp)
- cacheModel = WebCacheModelDocumentBrowser; // To avoid regressions in apps that depended on old WebKit's large cache.
- else
- cacheModel = WebCacheModelDocumentViewer; // To save memory.
- }
-
- [pool drain];
-
- return cacheModel;
-}
-
-@interface WebPreferencesPrivate : NSObject
-{
-@public
- NSMutableDictionary *values;
- NSString *identifier;
- NSString *IBCreatorID;
- BOOL autosaves;
- BOOL automaticallyDetectsCacheModel;
- unsigned numWebViews;
-}
-@end
-
-@implementation WebPreferencesPrivate
-- (void)dealloc
-{
- [values release];
- [identifier release];
- [IBCreatorID release];
- [super dealloc];
-}
-@end
-
-@interface WebPreferences (WebInternal)
-+ (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key;
-+ (NSString *)_IBCreatorID;
-@end
-
-@interface WebPreferences (WebForwardDeclarations)
-// This pseudo-category is needed so these methods can be used from within other category implementations
-// without being in the public header file.
-- (BOOL)_boolValueForKey:(NSString *)key;
-- (void)_setBoolValue:(BOOL)value forKey:(NSString *)key;
-- (int)_integerValueForKey:(NSString *)key;
-- (void)_setIntegerValue:(int)value forKey:(NSString *)key;
-- (float)_floatValueForKey:(NSString *)key;
-- (void)_setFloatValue:(float)value forKey:(NSString *)key;
-- (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key;
-- (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key;
-@end
-
-@implementation WebPreferences
-
-- init
-{
- // Create fake identifier
- static int instanceCount = 1;
- NSString *fakeIdentifier;
-
- // At least ensure that identifier hasn't been already used.
- fakeIdentifier = [NSString stringWithFormat:@"WebPreferences%d", instanceCount++];
- while ([[self class] _getInstanceForIdentifier:fakeIdentifier]){
- fakeIdentifier = [NSString stringWithFormat:@"WebPreferences%d", instanceCount++];
- }
-
- return [self initWithIdentifier:fakeIdentifier];
-}
-
-- (id)initWithIdentifier:(NSString *)anIdentifier
-{
- self = [super init];
- if (!self)
- return nil;
-
- _private = [[WebPreferencesPrivate alloc] init];
- _private->IBCreatorID = [[WebPreferences _IBCreatorID] retain];
-
- WebPreferences *instance = [[self class] _getInstanceForIdentifier:anIdentifier];
- if (instance){
- [self release];
- return [instance retain];
- }
-
- _private->values = [[NSMutableDictionary alloc] init];
- _private->identifier = [anIdentifier copy];
- _private->automaticallyDetectsCacheModel = YES;
-
- [[self class] _setInstance:self forIdentifier:_private->identifier];
-
- [self _postPreferencesChangesNotification];
-
- return self;
-}
-
-- (id)initWithCoder:(NSCoder *)decoder
-{
- self = [super init];
- if (!self)
- return nil;
-
- _private = [[WebPreferencesPrivate alloc] init];
- _private->IBCreatorID = [[WebPreferences _IBCreatorID] retain];
- _private->automaticallyDetectsCacheModel = YES;
-
- @try {
- id identifier = nil;
- id values = nil;
- if ([decoder allowsKeyedCoding]) {
- identifier = [decoder decodeObjectForKey:@"Identifier"];
- values = [decoder decodeObjectForKey:@"Values"];
- } else {
- int version;
- [decoder decodeValueOfObjCType:@encode(int) at:&version];
- if (version == 1) {
- identifier = [decoder decodeObject];
- values = [decoder decodeObject];
- }
- }
-
- if ([identifier isKindOfClass:[NSString class]])
- _private->identifier = [identifier copy];
- if ([values isKindOfClass:[NSDictionary class]])
- _private->values = [values mutableCopy]; // ensure dictionary is mutable
-
- LOG(Encoding, "Identifier = %@, Values = %@\n", _private->identifier, _private->values);
- } @catch(id) {
- [self release];
- return nil;
- }
-
- // If we load a nib multiple times, or have instances in multiple
- // nibs with the same name, the first guy up wins.
- WebPreferences *instance = [[self class] _getInstanceForIdentifier:_private->identifier];
- if (instance) {
- [self release];
- self = [instance retain];
- } else {
- [[self class] _setInstance:self forIdentifier:_private->identifier];
- }
-
- return self;
-}
-
-- (void)encodeWithCoder:(NSCoder *)encoder
-{
- if ([encoder allowsKeyedCoding]){
- [encoder encodeObject:_private->identifier forKey:@"Identifier"];
- [encoder encodeObject:_private->values forKey:@"Values"];
- LOG (Encoding, "Identifier = %@, Values = %@\n", _private->identifier, _private->values);
- }
- else {
- int version = WebPreferencesVersion;
- [encoder encodeValueOfObjCType:@encode(int) at:&version];
- [encoder encodeObject:_private->identifier];
- [encoder encodeObject:_private->values];
- }
-}
-
-+ (WebPreferences *)standardPreferences
-{
- if (_standardPreferences == nil) {
- _standardPreferences = [[WebPreferences alloc] initWithIdentifier:nil];
- [_standardPreferences setAutosaves:YES];
- }
-
- return _standardPreferences;
-}
-
-// if we ever have more than one WebPreferences object, this would move to init
-+ (void)initialize
-{
- NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
- @"Times", WebKitStandardFontPreferenceKey,
- @"Courier", WebKitFixedFontPreferenceKey,
- @"Times", WebKitSerifFontPreferenceKey,
- @"Helvetica", WebKitSansSerifFontPreferenceKey,
- @"Apple Chancery", WebKitCursiveFontPreferenceKey,
- @"Papyrus", WebKitFantasyFontPreferenceKey,
- @"1", WebKitMinimumFontSizePreferenceKey,
- @"9", WebKitMinimumLogicalFontSizePreferenceKey,
- @"16", WebKitDefaultFontSizePreferenceKey,
- @"13", WebKitDefaultFixedFontSizePreferenceKey,
- @"ISO-8859-1", WebKitDefaultTextEncodingNamePreferenceKey,
- [NSNumber numberWithBool:NO], WebKitUserStyleSheetEnabledPreferenceKey,
- @"", WebKitUserStyleSheetLocationPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitShouldPrintBackgroundsPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitTextAreasAreResizablePreferenceKey,
- [NSNumber numberWithBool:NO], WebKitShrinksStandaloneImagesToFitPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitJavaEnabledPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitJavaScriptEnabledPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitPluginsEnabledPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitAllowAnimatedImagesPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitAllowAnimatedImageLoopingPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitDisplayImagesKey,
- @"1800", WebKitBackForwardCacheExpirationIntervalKey,
- [NSNumber numberWithBool:NO], WebKitTabToLinksPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitPrivateBrowsingEnabledPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitRespectStandardStyleKeyEquivalentsPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitShowsURLsInToolTipsPreferenceKey,
- @"1", WebKitPDFDisplayModePreferenceKey,
- @"0", WebKitPDFScaleFactorPreferenceKey,
- @"0", WebKitUseSiteSpecificSpoofingPreferenceKey,
- [NSNumber numberWithInt:WebKitEditableLinkDefaultBehavior], WebKitEditableLinkBehaviorPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitDOMPasteAllowedPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitUsesPageCachePreferenceKey,
- [NSNumber numberWithInt:cacheModelForMainBundle()], WebKitCacheModelPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitDeveloperExtrasEnabledPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitAuthorAndUserStylesEnabledPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitApplicationChromeModeEnabledPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitWebArchiveDebugModeEnabledPreferenceKey,
- [NSNumber numberWithBool:NO], WebKitOfflineWebApplicationCacheEnabledPreferenceKey,
- [NSNumber numberWithBool:YES], WebKitZoomsTextOnlyPreferenceKey,
-#ifndef NDEBUG
- // In Release and Production we skip a lot of object teardown during quit to speed up shutdown time. This breaks
- // our RefCount Leak tracking, and so for Debug we will use the full document teardown.
- [NSNumber numberWithBool:YES], WebKitEnableFullDocumentTeardownPreferenceKey,
-#endif
- nil];
-
- // This value shouldn't ever change, which is assumed in the initialization of WebKitPDFDisplayModePreferenceKey above
- ASSERT(kPDFDisplaySinglePageContinuous == 1);
- [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
-}
-
-- (void)dealloc
-{
- [_private release];
- [super dealloc];
-}
-
-- (NSString *)identifier
-{
- return _private->identifier;
-}
-
-- (id)_valueForKey:(NSString *)key
-{
- NSString *_key = KEY(key);
- id o = [_private->values objectForKey:_key];
- if (o)
- return o;
- o = [[NSUserDefaults standardUserDefaults] objectForKey:_key];
- if (!o && key != _key)
- o = [[NSUserDefaults standardUserDefaults] objectForKey:key];
- return o;
-}
-
-- (NSString *)_stringValueForKey:(NSString *)key
-{
- id s = [self _valueForKey:key];
- return [s isKindOfClass:[NSString class]] ? (NSString *)s : nil;
-}
-
-- (void)_setStringValue:(NSString *)value forKey:(NSString *)key
-{
- if ([[self _stringValueForKey:key] isEqualToString:value])
- return;
- NSString *_key = KEY(key);
- [_private->values setObject:value forKey:_key];
- if (_private->autosaves)
- [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key];
- [self _postPreferencesChangesNotification];
-}
-
-- (int)_integerValueForKey:(NSString *)key
-{
- id o = [self _valueForKey:key];
- return [o respondsToSelector:@selector(intValue)] ? [o intValue] : 0;
-}
-
-- (void)_setIntegerValue:(int)value forKey:(NSString *)key
-{
- if ([self _integerValueForKey:key] == value)
- return;
- NSString *_key = KEY(key);
- [_private->values _webkit_setInt:value forKey:_key];
- if (_private->autosaves)
- [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
- [self _postPreferencesChangesNotification];
-}
-
-- (float)_floatValueForKey:(NSString *)key
-{
- id o = [self _valueForKey:key];
- return [o respondsToSelector:@selector(floatValue)] ? [o floatValue] : 0.0f;
-}
-
-- (void)_setFloatValue:(float)value forKey:(NSString *)key
-{
- if ([self _floatValueForKey:key] == value)
- return;
- NSString *_key = KEY(key);
- [_private->values _webkit_setFloat:value forKey:_key];
- if (_private->autosaves)
- [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key];
- [self _postPreferencesChangesNotification];
-}
-
-- (BOOL)_boolValueForKey:(NSString *)key
-{
- return [self _integerValueForKey:key] != 0;
-}
-
-- (void)_setBoolValue:(BOOL)value forKey:(NSString *)key
-{
- if ([self _boolValueForKey:key] == value)
- return;
- NSString *_key = KEY(key);
- [_private->values _webkit_setBool:value forKey:_key];
- if (_private->autosaves)
- [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key];
- [self _postPreferencesChangesNotification];
-}
-
-- (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key
-{
- id o = [self _valueForKey:key];
- return [o respondsToSelector:@selector(unsignedLongLongValue)] ? [o unsignedLongLongValue] : 0;
-}
-
-- (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key
-{
- if ([self _unsignedLongLongValueForKey:key] == value)
- return;
- NSString *_key = KEY(key);
- [_private->values _webkit_setUnsignedLongLong:value forKey:_key];
- if (_private->autosaves)
- [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:_key];
- [self _postPreferencesChangesNotification];
-}
-
-- (NSString *)standardFontFamily
-{
- return [self _stringValueForKey: WebKitStandardFontPreferenceKey];
-}
-
-- (void)setStandardFontFamily:(NSString *)family
-{
- [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];
-}
-
-- (NSString *)fixedFontFamily
-{
- return [self _stringValueForKey: WebKitFixedFontPreferenceKey];
-}
-
-- (void)setFixedFontFamily:(NSString *)family
-{
- [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];
-}
-
-- (NSString *)serifFontFamily
-{
- return [self _stringValueForKey: WebKitSerifFontPreferenceKey];
-}
-
-- (void)setSerifFontFamily:(NSString *)family
-{
- [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];
-}
-
-- (NSString *)sansSerifFontFamily
-{
- return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];
-}
-
-- (void)setSansSerifFontFamily:(NSString *)family
-{
- [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];
-}
-
-- (NSString *)cursiveFontFamily
-{
- return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];
-}
-
-- (void)setCursiveFontFamily:(NSString *)family
-{
- [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];
-}
-
-- (NSString *)fantasyFontFamily
-{
- return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];
-}
-
-- (void)setFantasyFontFamily:(NSString *)family
-{
- [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];
-}
-
-- (int)defaultFontSize
-{
- return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];
-}
-
-- (void)setDefaultFontSize:(int)size
-{
- [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];
-}
-
-- (int)defaultFixedFontSize
-{
- return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];
-}
-
-- (void)setDefaultFixedFontSize:(int)size
-{
- [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];
-}
-
-- (int)minimumFontSize
-{
- return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];
-}
-
-- (void)setMinimumFontSize:(int)size
-{
- [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];
-}
-
-- (int)minimumLogicalFontSize
-{
- return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];
-}
-
-- (void)setMinimumLogicalFontSize:(int)size
-{
- [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];
-}
-
-- (NSString *)defaultTextEncodingName
-{
- return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];
-}
-
-- (void)setDefaultTextEncodingName:(NSString *)encoding
-{
- [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];
-}
-
-- (BOOL)userStyleSheetEnabled
-{
- return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];
-}
-
-- (void)setUserStyleSheetEnabled:(BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];
-}
-
-- (NSURL *)userStyleSheetLocation
-{
- NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey];
-
- if ([locationString _webkit_looksLikeAbsoluteURL]) {
- return [NSURL _web_URLWithDataAsString:locationString];
- } else {
- locationString = [locationString stringByExpandingTildeInPath];
- return [NSURL fileURLWithPath:locationString];
- }
-}
-
-- (void)setUserStyleSheetLocation:(NSURL *)URL
-{
- NSString *locationString;
-
- if ([URL isFileURL]) {
- locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath];
- } else {
- locationString = [URL _web_originalDataAsString];
- }
-
- [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
-}
-
-- (BOOL)shouldPrintBackgrounds
-{
- return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];
-}
-
-- (void)setShouldPrintBackgrounds:(BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];
-}
-
-- (BOOL)isJavaEnabled
-{
- return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];
-}
-
-- (void)setJavaEnabled:(BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];
-}
-
-- (BOOL)isJavaScriptEnabled
-{
- return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];
-}
-
-- (void)setJavaScriptEnabled:(BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];
-}
-
-- (BOOL)javaScriptCanOpenWindowsAutomatically
-{
- return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
-}
-
-- (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
-}
-
-- (BOOL)arePlugInsEnabled
-{
- return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];
-}
-
-- (void)setPlugInsEnabled:(BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];
-}
-
-- (BOOL)allowsAnimatedImages
-{
- return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];
-}
-
-- (void)setAllowsAnimatedImages:(BOOL)flag;
-{
- [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];
-}
-
-- (BOOL)allowsAnimatedImageLooping
-{
- return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
-}
-
-- (void)setAllowsAnimatedImageLooping: (BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
-}
-
-- (void)setLoadsImagesAutomatically: (BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];
-}
-
-- (BOOL)loadsImagesAutomatically
-{
- return [self _boolValueForKey: WebKitDisplayImagesKey];
-}
-
-- (void)setAutosaves:(BOOL)flag;
-{
- _private->autosaves = flag;
-}
-
-- (BOOL)autosaves
-{
- return _private->autosaves;
-}
-
-- (void)setTabsToLinks:(BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];
-}
-
-- (BOOL)tabsToLinks
-{
- return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];
-}
-
-- (void)setPrivateBrowsingEnabled:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitPrivateBrowsingEnabledPreferenceKey];
-}
-
-- (BOOL)privateBrowsingEnabled
-{
- return [self _boolValueForKey:WebKitPrivateBrowsingEnabledPreferenceKey];
-}
-
-- (void)setUsesPageCache:(BOOL)usesPageCache
-{
- [self _setBoolValue:usesPageCache forKey:WebKitUsesPageCachePreferenceKey];
-}
-
-- (BOOL)usesPageCache
-{
- return [self _boolValueForKey:WebKitUsesPageCachePreferenceKey];
-}
-
-- (void)setCacheModel:(WebCacheModel)cacheModel
-{
- [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey];
- [self setAutomaticallyDetectsCacheModel:NO];
-}
-
-- (WebCacheModel)cacheModel
-{
- return [self _integerValueForKey:WebKitCacheModelPreferenceKey];
-}
-
-@end
-
-@implementation WebPreferences (WebPrivate)
-
-- (BOOL)developerExtrasEnabled
-{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- if ([defaults boolForKey:@"DisableWebKitDeveloperExtras"])
- return NO;
-#ifdef NDEBUG
- if ([defaults boolForKey:@"WebKitDeveloperExtras"] || [defaults boolForKey:@"IncludeDebugMenu"])
- return YES;
- return [self _boolValueForKey:WebKitDeveloperExtrasEnabledPreferenceKey];
-#else
- return YES; // always enable in debug builds
-#endif
-}
-
-- (void)setDeveloperExtrasEnabled:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitDeveloperExtrasEnabledPreferenceKey];
-}
-
-- (BOOL)authorAndUserStylesEnabled
-{
- return [self _boolValueForKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
-}
-
-- (void)setAuthorAndUserStylesEnabled:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
-}
-
-- (BOOL)applicationChromeModeEnabled
-{
- return [self _boolValueForKey:WebKitApplicationChromeModeEnabledPreferenceKey];
-}
-
-- (void)setApplicationChromeModeEnabled:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitApplicationChromeModeEnabledPreferenceKey];
-}
-
-- (BOOL)webArchiveDebugModeEnabled
-{
- return [self _boolValueForKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
-}
-
-- (void)setWebArchiveDebugModeEnabled:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
-}
-
-- (BOOL)offlineWebApplicationCacheEnabled
-{
- return [self _boolValueForKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
-}
-
-- (void)setOfflineWebApplicationCacheEnabled:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
-}
-
-- (BOOL)zoomsTextOnly
-{
- return [self _boolValueForKey:WebKitZoomsTextOnlyPreferenceKey];
-}
-
-- (void)setZoomsTextOnly:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitZoomsTextOnlyPreferenceKey];
-}
-
-- (BOOL)respectStandardStyleKeyEquivalents
-{
- return [self _boolValueForKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
-}
-
-- (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
-}
-
-- (BOOL)showsURLsInToolTips
-{
- return [self _boolValueForKey:WebKitShowsURLsInToolTipsPreferenceKey];
-}
-
-- (void)setShowsURLsInToolTips:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitShowsURLsInToolTipsPreferenceKey];
-}
-
-- (BOOL)textAreasAreResizable
-{
- return [self _boolValueForKey: WebKitTextAreasAreResizablePreferenceKey];
-}
-
-- (void)setTextAreasAreResizable:(BOOL)flag
-{
- [self _setBoolValue: flag forKey: WebKitTextAreasAreResizablePreferenceKey];
-}
-
-- (BOOL)shrinksStandaloneImagesToFit
-{
- return [self _boolValueForKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
-}
-
-- (void)setShrinksStandaloneImagesToFit:(BOOL)flag
-{
- [self _setBoolValue:flag forKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
-}
-
-- (BOOL)automaticallyDetectsCacheModel
-{
- return _private->automaticallyDetectsCacheModel;
-}
-
-- (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel
-{
- _private->automaticallyDetectsCacheModel = automaticallyDetectsCacheModel;
-}
-
-- (NSTimeInterval)_backForwardCacheExpirationInterval
-{
- // FIXME: There's probably no good reason to read from the standard user defaults instead of self.
- return (NSTimeInterval)[[NSUserDefaults standardUserDefaults] floatForKey:WebKitBackForwardCacheExpirationIntervalKey];
-}
-
-- (float)PDFScaleFactor
-{
- return [self _floatValueForKey:WebKitPDFScaleFactorPreferenceKey];
-}
-
-- (void)setPDFScaleFactor:(float)factor
-{
- [self _setFloatValue:factor forKey:WebKitPDFScaleFactorPreferenceKey];
-}
-
-- (PDFDisplayMode)PDFDisplayMode;
-{
- PDFDisplayMode value = [self _integerValueForKey:WebKitPDFDisplayModePreferenceKey];
- if (value != kPDFDisplaySinglePage && value != kPDFDisplaySinglePageContinuous && value != kPDFDisplayTwoUp && value != kPDFDisplayTwoUpContinuous) {
- // protect against new modes from future versions of OS X stored in defaults
- value = kPDFDisplaySinglePageContinuous;
- }
- return value;
-}
-
-- (void)setPDFDisplayMode:(PDFDisplayMode)mode
-{
- [self _setIntegerValue:mode forKey:WebKitPDFDisplayModePreferenceKey];
-}
-
-- (WebKitEditableLinkBehavior)editableLinkBehavior
-{
- WebKitEditableLinkBehavior value = static_cast<WebKitEditableLinkBehavior> ([self _integerValueForKey:WebKitEditableLinkBehaviorPreferenceKey]);
- if (value != WebKitEditableLinkDefaultBehavior &&
- value != WebKitEditableLinkAlwaysLive &&
- value != WebKitEditableLinkNeverLive &&
- value != WebKitEditableLinkOnlyLiveWithShiftKey &&
- value != WebKitEditableLinkLiveWhenNotFocused) {
- // ensure that a valid result is returned
- value = WebKitEditableLinkDefaultBehavior;
- }
-
- return value;
-}
-
-- (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior
-{
- [self _setIntegerValue:behavior forKey:WebKitEditableLinkBehaviorPreferenceKey];
-}
-
-- (BOOL)_useSiteSpecificSpoofing
-{
- return [self _boolValueForKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
-}
-
-- (void)_setUseSiteSpecificSpoofing:(BOOL)newValue
-{
- [self _setBoolValue:newValue forKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
-}
-
-+ (WebPreferences *)_getInstanceForIdentifier:(NSString *)ident
-{
- LOG(Encoding, "requesting for %@\n", ident);
-
- if (!ident)
- return _standardPreferences;
-
- WebPreferences *instance = [webPreferencesInstances objectForKey:[self _concatenateKeyWithIBCreatorID:ident]];
-
- return instance;
-}
-
-+ (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)ident
-{
- if (!webPreferencesInstances)
- webPreferencesInstances = [[NSMutableDictionary alloc] init];
- if (ident) {
- [webPreferencesInstances setObject:instance forKey:[self _concatenateKeyWithIBCreatorID:ident]];
- LOG(Encoding, "recording %p for %@\n", instance, [self _concatenateKeyWithIBCreatorID:ident]);
- }
-}
-
-+ (void)_checkLastReferenceForIdentifier:(id)identifier
-{
- // FIXME: This won't work at all under garbage collection because retainCount returns a constant.
- // We may need to change WebPreferences API so there's an explicit way to end the lifetime of one.
- WebPreferences *instance = [webPreferencesInstances objectForKey:identifier];
- if ([instance retainCount] == 1)
- [webPreferencesInstances removeObjectForKey:identifier];
-}
-
-+ (void)_removeReferenceForIdentifier:(NSString *)ident
-{
- if (ident)
- [self performSelector:@selector(_checkLastReferenceForIdentifier:) withObject:[self _concatenateKeyWithIBCreatorID:ident] afterDelay:0.1];
-}
-
-- (void)_postPreferencesChangesNotification
-{
- [[NSNotificationCenter defaultCenter]
- postNotificationName:WebPreferencesChangedNotification object:self
- userInfo:nil];
-}
-
-+ (CFStringEncoding)_systemCFStringEncoding
-{
- return WKGetWebDefaultCFStringEncoding();
-}
-
-+ (void)_setInitialDefaultTextEncodingToSystemEncoding
-{
- NSString *systemEncodingName = (NSString *)CFStringConvertEncodingToIANACharSetName([self _systemCFStringEncoding]);
-
- // CFStringConvertEncodingToIANACharSetName() returns CP949 for kTextEncodingDOSKorean AKA "extended EUC-KR" AKA windows-939.
- // ICU uses this name for a different encoding, so we need to change the name to a value that actually gives us windows-939.
- // In addition, this value must match what is used in Safari, see <rdar://problem/5579292>.
- if ([systemEncodingName isEqualToString:@"CP949"])
- systemEncodingName = @"ks_c_5601-1987";
- [[NSUserDefaults standardUserDefaults] registerDefaults:
- [NSDictionary dictionaryWithObject:systemEncodingName forKey:WebKitDefaultTextEncodingNamePreferenceKey]];
-}
-
-static NSString *classIBCreatorID = nil;
-
-+ (void)_setIBCreatorID:(NSString *)string
-{
- NSString *old = classIBCreatorID;
- classIBCreatorID = [string copy];
- [old release];
-}
-
-- (BOOL)isDOMPasteAllowed
-{
- return [self _boolValueForKey:WebKitDOMPasteAllowedPreferenceKey];
-}
-
-- (void)setDOMPasteAllowed:(BOOL)DOMPasteAllowed
-{
- [self _setBoolValue:DOMPasteAllowed forKey:WebKitDOMPasteAllowedPreferenceKey];
-}
-
-- (void)_setFTPDirectoryTemplatePath:(NSString *)path
-{
- [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitFTPDirectoryTemplatePath];
-}
-
-- (NSString *)_localStorageDatabasePath
-{
- return [[self _stringValueForKey:WebKitLocalStorageDatabasePathPreferenceKey] stringByStandardizingPath];
-}
-
-- (void)_setLocalStorageDatabasePath:(NSString *)path
-{
- [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitLocalStorageDatabasePathPreferenceKey];
-}
-
-- (NSString *)_ftpDirectoryTemplatePath
-{
- return [[self _stringValueForKey:WebKitFTPDirectoryTemplatePath] stringByStandardizingPath];
-}
-
-- (void)_setForceFTPDirectoryListings:(BOOL)force
-{
- [self _setBoolValue:force forKey:WebKitForceFTPDirectoryListings];
-}
-
-- (BOOL)_forceFTPDirectoryListings
-{
- return [self _boolValueForKey:WebKitForceFTPDirectoryListings];
-}
-
-- (void)didRemoveFromWebView
-{
- ASSERT(_private->numWebViews);
- if (--_private->numWebViews == 0)
- [[NSNotificationCenter defaultCenter]
- postNotificationName:WebPreferencesRemovedNotification
- object:self
- userInfo:nil];
-}
-
-- (void)willAddToWebView
-{
- ++_private->numWebViews;
-}
-
-- (void)setFullDocumentTeardownEnabled:(BOOL)fullDocumentTeardownEnabled
-{
- [self _setBoolValue:fullDocumentTeardownEnabled forKey:WebKitEnableFullDocumentTeardownPreferenceKey];
-}
-
-- (BOOL)fullDocumentTeardownEnabled
-{
- return [self _boolValueForKey:WebKitEnableFullDocumentTeardownPreferenceKey];
-}
-@end
-
-@implementation WebPreferences (WebInternal)
-
-+ (NSString *)_IBCreatorID
-{
- return classIBCreatorID;
-}
-
-+ (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key
-{
- NSString *IBCreatorID = [WebPreferences _IBCreatorID];
- if (!IBCreatorID)
- return key;
- return [IBCreatorID stringByAppendingString:key];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebPreferencesPrivate.h b/WebKit/mac/WebView/WebPreferencesPrivate.h
deleted file mode 100644
index 1981290..0000000
--- a/WebKit/mac/WebView/WebPreferencesPrivate.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2005, 2007 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebPreferences.h>
-#import <Quartz/Quartz.h>
-
-typedef enum {
- WebKitEditableLinkDefaultBehavior,
- WebKitEditableLinkAlwaysLive,
- WebKitEditableLinkOnlyLiveWithShiftKey,
- WebKitEditableLinkLiveWhenNotFocused,
- WebKitEditableLinkNeverLive
-} WebKitEditableLinkBehavior;
-
-extern NSString *WebPreferencesChangedNotification;
-extern NSString *WebPreferencesRemovedNotification;
-
-@interface WebPreferences (WebPrivate)
-
-// Preferences that might be public in a future release
-
-- (BOOL)developerExtrasEnabled;
-- (void)setDeveloperExtrasEnabled:(BOOL)flag;
-
-- (BOOL)authorAndUserStylesEnabled;
-- (void)setAuthorAndUserStylesEnabled:(BOOL)flag;
-
-- (BOOL)applicationChromeModeEnabled;
-- (void)setApplicationChromeModeEnabled:(BOOL)flag;
-
-- (BOOL)respectStandardStyleKeyEquivalents;
-- (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag;
-
-- (BOOL)showsURLsInToolTips;
-- (void)setShowsURLsInToolTips:(BOOL)flag;
-
-- (BOOL)textAreasAreResizable;
-- (void)setTextAreasAreResizable:(BOOL)flag;
-
-- (PDFDisplayMode)PDFDisplayMode;
-- (void)setPDFDisplayMode:(PDFDisplayMode)mode;
-
-- (BOOL)shrinksStandaloneImagesToFit;
-- (void)setShrinksStandaloneImagesToFit:(BOOL)flag;
-
-- (BOOL)automaticallyDetectsCacheModel;
-- (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel;
-
-- (BOOL)webArchiveDebugModeEnabled;
-- (void)setWebArchiveDebugModeEnabled:(BOOL)webArchiveDebugModeEnabled;
-
-- (BOOL)offlineWebApplicationCacheEnabled;
-- (void)setOfflineWebApplicationCacheEnabled:(BOOL)offlineWebApplicationCacheEnabled;
-
-- (BOOL)zoomsTextOnly;
-- (void)setZoomsTextOnly:(BOOL)zoomsTextOnly;
-
-// zero means do AutoScale
-- (float)PDFScaleFactor;
-- (void)setPDFScaleFactor:(float)scale;
-
-- (WebKitEditableLinkBehavior)editableLinkBehavior;
-- (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior;
-
-// If site-specific spoofing is enabled, some pages that do inappropriate user-agent string checks will be
-// passed a nonstandard user-agent string to get them to work correctly. This method might be removed in
-// the future when there's no more need for it.
-- (BOOL)_useSiteSpecificSpoofing;
-- (void)_setUseSiteSpecificSpoofing:(BOOL)newValue;
-
-// WARNING: Allowing paste through the DOM API opens a security hole. We only use it for testing purposes.
-- (BOOL)isDOMPasteAllowed;
-- (void)setDOMPasteAllowed:(BOOL)DOMPasteAllowed;
-
-- (NSString *)_ftpDirectoryTemplatePath;
-- (void)_setFTPDirectoryTemplatePath:(NSString *)path;
-- (void)_setForceFTPDirectoryListings:(BOOL)force;
-- (BOOL)_forceFTPDirectoryListings;
-- (NSString *)_localStorageDatabasePath;
-- (void)_setLocalStorageDatabasePath:(NSString *)path;
-
-// Other private methods
-- (void)_postPreferencesChangesNotification;
-+ (WebPreferences *)_getInstanceForIdentifier:(NSString *)identifier;
-+ (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)identifier;
-+ (void)_removeReferenceForIdentifier:(NSString *)identifier;
-- (NSTimeInterval)_backForwardCacheExpirationInterval;
-+ (CFStringEncoding)_systemCFStringEncoding;
-+ (void)_setInitialDefaultTextEncodingToSystemEncoding;
-+ (void)_setIBCreatorID:(NSString *)string;
-
-// For WebView's use only.
-- (void)willAddToWebView;
-- (void)didRemoveFromWebView;
-
-// Force document tear down at application quit
-- (void)setFullDocumentTeardownEnabled:(BOOL)fullDocumentTeardownEnabled;
-- (BOOL)fullDocumentTeardownEnabled;
-@end
diff --git a/WebKit/mac/WebView/WebRenderNode.h b/WebKit/mac/WebView/WebRenderNode.h
deleted file mode 100644
index 8e6b40f..0000000
--- a/WebKit/mac/WebView/WebRenderNode.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-@class WebFrameView;
-
-@interface WebRenderNode : NSObject
-{
- NSArray *children;
- NSString *name;
- NSRect rect;
- NSPoint absolutePosition;
-}
-
-- (id)initWithWebFrameView:(WebFrameView *)view;
-
-- (NSArray *)children;
-
-- (NSString *)name;
-- (NSString *)positionString;
-- (NSString *)absolutePositionString;
-- (NSString *)widthString;
-- (NSString *)heightString;
-
-@end
diff --git a/WebKit/mac/WebView/WebRenderNode.mm b/WebKit/mac/WebView/WebRenderNode.mm
deleted file mode 100644
index c34ac34..0000000
--- a/WebKit/mac/WebView/WebRenderNode.mm
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebRenderNode.h"
-
-#import "WebFrameInternal.h"
-#import "WebFrameView.h"
-#import "WebHTMLView.h"
-#import <WebCore/Frame.h>
-#import <WebCore/RenderWidget.h>
-#import <WebCore/RenderView.h>
-#import <WebCore/Widget.h>
-
-using namespace WebCore;
-
-@implementation WebRenderNode
-
-- (id)initWithName:(NSString *)n position:(NSPoint)p rect:(NSRect)r view:(NSView *)view children:(NSArray *)c
-{
- NSMutableArray *collectChildren;
-
- self = [super init];
- if (!self)
- return nil;
-
- collectChildren = [c mutableCopy];
-
- name = [n retain];
- rect = r;
- absolutePosition = p;
-
- if ([view isKindOfClass:[NSScrollView class]]) {
- NSScrollView *scrollView = (NSScrollView *)view;
- view = [scrollView superview];
- }
- if ([view isKindOfClass:[WebFrameView class]]) {
- WebFrameView *webFrameView = (WebFrameView *)view;
- WebRenderNode *node = [[WebRenderNode alloc] initWithWebFrameView:webFrameView];
- [collectChildren addObject:node];
- [node release];
- }
-
- children = [collectChildren copy];
- [collectChildren release];
-
- return self;
-}
-
-static WebRenderNode *copyRenderNode(RenderObject* node)
-{
- NSMutableArray *children = [[NSMutableArray alloc] init];
- for (RenderObject* child = node->firstChild(); child; child = child->nextSibling()) {
- WebRenderNode *childCopy = copyRenderNode(child);
- [children addObject:childCopy];
- [childCopy release];
- }
-
- NSString *name = [[NSString alloc] initWithUTF8String:node->renderName()];
-
- RenderWidget* renderWidget = node->isWidget() ? static_cast<RenderWidget*>(node) : 0;
- Widget* widget = renderWidget ? renderWidget->widget() : 0;
- NSView *view = widget ? widget->platformWidget() : nil;
-
- int nx, ny;
- node->absolutePosition(nx, ny);
- WebRenderNode *result = [[WebRenderNode alloc] initWithName:name
- position:NSMakePoint(nx, ny) rect:NSMakeRect(node->xPos(), node->yPos(), node->width(), node->height())
- view:view children:children];
-
- [name release];
- [children release];
-
- return result;
-}
-
-- (id)initWithWebFrameView:(WebFrameView *)view
-{
- [self release];
-
- if (![[view documentView] isMemberOfClass:[WebHTMLView class]])
- return nil;
-
- RenderObject* renderer = core([view webFrame])->contentRenderer();
- if (!renderer)
- return nil;
-
- return copyRenderNode(renderer);
-}
-
-- (void)dealloc
-{
- [children release];
- [name release];
- [super dealloc];
-}
-
-- (NSArray *)children
-{
- return children;
-}
-
-- (NSString *)name
-{
- return name;
-}
-
-- (NSString *)absolutePositionString
-{
- return [NSString stringWithFormat:@"(%.0f, %.0f)", absolutePosition.x, absolutePosition.y];
-}
-
-- (NSString *)positionString
-{
- return [NSString stringWithFormat:@"(%.0f, %.0f)", rect.origin.x, rect.origin.y];
-}
-
-- (NSString *)widthString
-{
- return [NSString stringWithFormat:@"%.0f", rect.size.width];
-}
-
-- (NSString *)heightString
-{
- return [NSString stringWithFormat:@"%.0f", rect.size.height];
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebResource.h b/WebKit/mac/WebView/WebResource.h
deleted file mode 100644
index 7d817b7..0000000
--- a/WebKit/mac/WebView/WebResource.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2004, 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-@class WebResourcePrivate;
-
-
-/*!
- @class WebResource
- @discussion A WebResource represents a fully downloaded URL.
- It includes the data of the resource as well as the metadata associated with the resource.
-*/
-@interface WebResource : NSObject <NSCoding, NSCopying>
-{
-@private
- WebResourcePrivate *_private;
-}
-
-/*!
- @method initWithData:URL:MIMEType:textEncodingName:frameName
- @abstract The initializer for WebResource.
- @param data The data of the resource.
- @param URL The URL of the resource.
- @param MIMEType The MIME type of the resource.
- @param textEncodingName The text encoding name of the resource (can be nil).
- @param frameName The frame name of the resource if the resource represents the contents of an entire HTML frame (can be nil).
- @result An initialized WebResource.
-*/
-- (id)initWithData:(NSData *)data URL:(NSURL *)URL MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName frameName:(NSString *)frameName;
-
-/*!
- @method data
- @result The data of the resource.
-*/
-- (NSData *)data;
-
-/*!
- @method URL
- @result The URL of the resource.
-*/
-- (NSURL *)URL;
-
-/*!
- @method MIMEType
- @result The MIME type of the resource.
-*/
-- (NSString *)MIMEType;
-
-/*!
- @method textEncodingName
- @result The text encoding name of the resource (can be nil).
-*/
-- (NSString *)textEncodingName;
-
-/*!
- @method frameName
- @result The frame name of the resource if the resource represents the contents of an entire HTML frame (can be nil).
-*/
-- (NSString *)frameName;
-
-@end
diff --git a/WebKit/mac/WebView/WebResource.mm b/WebKit/mac/WebView/WebResource.mm
deleted file mode 100644
index 6e0c9f0..0000000
--- a/WebKit/mac/WebView/WebResource.mm
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebResourcePrivate.h"
-
-#import "WebFrameInternal.h"
-#import "WebNSDictionaryExtras.h"
-#import "WebNSURLExtras.h"
-
-#import <WebCore/ArchiveResource.h>
-#import <WebCore/LegacyWebArchive.h>
-#import <WebCore/TextEncoding.h>
-#import <WebCore/WebCoreObjCExtras.h>
-#import <WebCore/WebCoreURLResponse.h>
-
-#import <wtf/PassRefPtr.h>
-
-using namespace WebCore;
-
-static NSString * const WebResourceDataKey = @"WebResourceData";
-static NSString * const WebResourceFrameNameKey = @"WebResourceFrameName";
-static NSString * const WebResourceMIMETypeKey = @"WebResourceMIMEType";
-static NSString * const WebResourceURLKey = @"WebResourceURL";
-static NSString * const WebResourceTextEncodingNameKey = @"WebResourceTextEncodingName";
-static NSString * const WebResourceResponseKey = @"WebResourceResponse";
-
-#define WebResourceVersion 1
-
-@interface WebResourcePrivate : NSObject
-{
-@public
- ArchiveResource* coreResource;
-}
-
-- (id)initWithCoreResource:(PassRefPtr<ArchiveResource>)coreResource;
-@end
-
-@implementation WebResourcePrivate
-
-#ifndef BUILDING_ON_TIGER
-+ (void)initialize
-{
- WebCoreObjCFinalizeOnMainThread(self);
-}
-#endif
-
-- (id)init
-{
- return [super init];
-}
-
-- (id)initWithCoreResource:(PassRefPtr<ArchiveResource>)passedResource
-{
- self = [super init];
- if (!self)
- return self;
-
- // Acquire the PassRefPtr<>'s ref as our own manual ref
- coreResource = passedResource.releaseRef();
-
- return self;
-}
-
-- (void)dealloc
-{
- if (WebCoreObjCScheduleDeallocateOnMainThread([WebResourcePrivate class], self))
- return;
-
- if (coreResource)
- coreResource->deref();
- [super dealloc];
-}
-
-- (void)finalize
-{
- if (coreResource)
- coreResource->deref();
- [super finalize];
-}
-
-@end
-
-@implementation WebResource
-
-- (id)init
-{
- self = [super init];
- if (!self)
- return nil;
- _private = [[WebResourcePrivate alloc] init];
- return self;
-}
-
-- (id)initWithData:(NSData *)data URL:(NSURL *)URL MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName frameName:(NSString *)frameName
-{
- return [self _initWithData:data URL:URL MIMEType:MIMEType textEncodingName:textEncodingName frameName:frameName response:nil copyData:YES];
-}
-
-- (id)initWithCoder:(NSCoder *)decoder
-{
- self = [super init];
- if (!self)
- return nil;
-
- NSData *data = nil;
- NSURL *url = nil;
- NSString *mimeType = nil, *textEncoding = nil, *frameName = nil;
- NSURLResponse *response = nil;
-
- @try {
- id object = [decoder decodeObjectForKey:WebResourceDataKey];
- if ([object isKindOfClass:[NSData class]])
- data = object;
- object = [decoder decodeObjectForKey:WebResourceURLKey];
- if ([object isKindOfClass:[NSURL class]])
- url = object;
- object = [decoder decodeObjectForKey:WebResourceMIMETypeKey];
- if ([object isKindOfClass:[NSString class]])
- mimeType = object;
- object = [decoder decodeObjectForKey:WebResourceTextEncodingNameKey];
- if ([object isKindOfClass:[NSString class]])
- textEncoding = object;
- object = [decoder decodeObjectForKey:WebResourceFrameNameKey];
- if ([object isKindOfClass:[NSString class]])
- frameName = object;
- object = [decoder decodeObjectForKey:WebResourceResponseKey];
- if ([object isKindOfClass:[NSURLResponse class]])
- response = object;
- } @catch(id) {
- [self release];
- return nil;
- }
-
- _private = [[WebResourcePrivate alloc] initWithCoreResource:ArchiveResource::create(SharedBuffer::wrapNSData(data), url, mimeType, textEncoding, frameName, response)];
-
- return self;
-}
-
-- (void)encodeWithCoder:(NSCoder *)encoder
-{
- ArchiveResource *resource = _private->coreResource;
-
- NSData *data = nil;
- NSURL *url = nil;
- NSString *mimeType = nil, *textEncoding = nil, *frameName = nil;
- NSURLResponse *response = nil;
-
- if (resource) {
- if (resource->data())
- data = [resource->data()->createNSData() autorelease];
- url = resource->url();
- mimeType = resource->mimeType();
- textEncoding = resource->textEncoding();
- frameName = resource->frameName();
- response = resource->response().nsURLResponse();
- }
- [encoder encodeObject:data forKey:WebResourceDataKey];
- [encoder encodeObject:url forKey:WebResourceURLKey];
- [encoder encodeObject:mimeType forKey:WebResourceMIMETypeKey];
- [encoder encodeObject:textEncoding forKey:WebResourceTextEncodingNameKey];
- [encoder encodeObject:frameName forKey:WebResourceFrameNameKey];
- [encoder encodeObject:response forKey:WebResourceResponseKey];
-}
-
-- (void)dealloc
-{
- [_private release];
- [super dealloc];
-}
-
-- (id)copyWithZone:(NSZone *)zone
-{
- return [self retain];
-}
-
-- (NSData *)data
-{
- if (_private->coreResource && _private->coreResource->data())
- return [_private->coreResource->data()->createNSData() autorelease];
- return 0;
-}
-
-- (NSURL *)URL
-{
- return _private->coreResource ? (NSURL *)_private->coreResource->url() : 0;
-}
-
-- (NSString *)MIMEType
-{
- return _private->coreResource ? (NSString *)_private->coreResource->mimeType() : 0;
-}
-
-- (NSString *)textEncodingName
-{
- return _private->coreResource ? (NSString *)_private->coreResource->textEncoding() : 0;
-}
-
-- (NSString *)frameName
-{
- return _private->coreResource ? (NSString *)_private->coreResource->frameName() : 0;
-}
-
-- (id)description
-{
- return [NSString stringWithFormat:@"<%@ %@>", [self className], [self URL]];
-}
-
-@end
-
-@implementation WebResource (WebResourceInternal)
-
-- (id)_initWithCoreResource:(PassRefPtr<ArchiveResource>)coreResource
-{
- self = [super init];
- if (!self)
- return nil;
-
- ASSERT(coreResource);
-
- // WebResources should not be init'ed with nil data, and doing so breaks certain uses of NSHTMLReader
- // See <rdar://problem/5820157> for more info
- if (!coreResource->data()) {
- [self release];
- return nil;
- }
-
- _private = [[WebResourcePrivate alloc] initWithCoreResource:coreResource];
-
- return self;
-}
-
-- (WebCore::ArchiveResource *)_coreResource
-{
- return _private->coreResource;
-}
-
-@end
-
-@implementation WebResource (WebResourcePrivate)
-
-// SPI for Mail (5066325)
-// FIXME: This "ignoreWhenUnarchiving" concept is an ugly one - can we find a cleaner solution for those who need this SPI?
-- (void)_ignoreWhenUnarchiving
-{
- if (_private->coreResource)
- _private->coreResource->ignoreWhenUnarchiving();
-}
-
-- (id)_initWithData:(NSData *)data
- URL:(NSURL *)URL
- MIMEType:(NSString *)MIMEType
- textEncodingName:(NSString *)textEncodingName
- frameName:(NSString *)frameName
- response:(NSURLResponse *)response
- copyData:(BOOL)copyData
-{
- self = [super init];
- if (!self)
- return nil;
-
- if (!data || !URL || !MIMEType) {
- [self release];
- return nil;
- }
-
- _private = [[WebResourcePrivate alloc] initWithCoreResource:ArchiveResource::create(SharedBuffer::wrapNSData(copyData ? [[data copy] autorelease] : data), URL, MIMEType, textEncodingName, frameName, response)];
-
- return self;
-}
-
-- (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response
-{
- // Pass NO for copyData since the data doesn't need to be copied since we know that callers will no longer modify it.
- // Copying it will also cause a performance regression.
- return [self _initWithData:data
- URL:URL
- MIMEType:[response _webcore_MIMEType]
- textEncodingName:[response textEncodingName]
- frameName:nil
- response:response
- copyData:NO];
-}
-
-- (NSFileWrapper *)_fileWrapperRepresentation
-{
- SharedBuffer* coreData = _private->coreResource ? _private->coreResource->data() : 0;
- NSData *data = coreData ? [coreData->createNSData() autorelease] : nil;
-
- NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
- NSString *preferredFilename = _private->coreResource ? (NSString *)_private->coreResource->response().suggestedFilename() : nil;
- if (!preferredFilename || ![preferredFilename length]) {
- NSURL *url = _private->coreResource ? (NSURL *)_private->coreResource->url() : nil;
- NSString *mimeType = _private->coreResource ? (NSString *)_private->coreResource->mimeType() : nil;
- preferredFilename = [url _webkit_suggestedFilenameWithMIMEType:mimeType];
- }
-
- [wrapper setPreferredFilename:preferredFilename];
- return wrapper;
-}
-
-- (NSURLResponse *)_response
-{
- NSURLResponse *response = nil;
- if (_private->coreResource)
- response = _private->coreResource->response().nsURLResponse();
-
- return response ? response : [[[NSURLResponse alloc] init] autorelease];
-}
-
-- (NSString *)_stringValue
-{
- WebCore::TextEncoding encoding(_private->coreResource ? (NSString *)_private->coreResource->textEncoding() : nil);
- if (!encoding.isValid())
- encoding = WindowsLatin1Encoding();
-
- SharedBuffer* coreData = _private->coreResource ? _private->coreResource->data() : 0;
-
- return encoding.decode(reinterpret_cast<const char*>(coreData ? coreData->data() : 0), coreData ? coreData->size() : 0);
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebResourceInternal.h b/WebKit/mac/WebView/WebResourceInternal.h
deleted file mode 100644
index 84f6aba..0000000
--- a/WebKit/mac/WebView/WebResourceInternal.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebResource.h"
-
-#import <wtf/PassRefPtr.h>
-
-namespace WebCore {
- class ArchiveResource;
-}
-
-@interface WebResource (WebResourceInternal)
-
-- (id)_initWithCoreResource:(WTF::PassRefPtr<WebCore::ArchiveResource>)coreResource;
-- (WebCore::ArchiveResource *)_coreResource;
-
-@end
diff --git a/WebKit/mac/WebView/WebResourceLoadDelegate.h b/WebKit/mac/WebView/WebResourceLoadDelegate.h
deleted file mode 100644
index f92466b..0000000
--- a/WebKit/mac/WebView/WebResourceLoadDelegate.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSInteger int
-#else
-#define WebNSInteger NSInteger
-#endif
-
-@class WebView;
-@class WebDataSource;
-@class NSURLAuthenticationChallenge;
-@class NSURLResponse;
-@class NSURLRequest;
-
-/*!
- @category WebResourceLoadDelegate
- @discussion Implementors of this protocol will receive messages indicating
- that a resource is about to be loaded, data has been received for a resource,
- an error has been received for a resource, and completion of a resource load.
- Implementors are also given the opportunity to mutate requests before they are sent.
- The various progress methods of this protocol all receive an identifier as the
- parameter. This identifier can be used to track messages associated with a single
- resource. For example, a single resource may generate multiple
- resource:willSendRequest:redirectResponse:fromDataSource: messages as it's URL is redirected.
-*/
-@interface NSObject (WebResourceLoadDelegate)
-
-/*!
- @method webView:identifierForInitialRequest:fromDataSource:
- @param webView The WebView sending the message.
- @param request The request about to be sent.
- @param dataSource The datasource that initiated the load.
- @discussion An implementor of WebResourceLoadDelegate should provide an identifier
- that can be used to track the load of a single resource. This identifier will be
- passed as the first argument for all of the other WebResourceLoadDelegate methods. The
- identifier is useful to track changes to a resources request, which will be
- provided by one or more calls to resource:willSendRequest:redirectResponse:fromDataSource:.
- @result An identifier that will be passed back to the implementor for each callback.
- The identifier will be retained.
-*/
-- (id)webView:(WebView *)sender identifierForInitialRequest:(NSURLRequest *)request fromDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method resource:willSendRequest:redirectResponse:fromDataSource:
- @discussion This message is sent before a load is initiated. The request may be modified
- as necessary by the receiver.
- @param webView The WebView sending the message.
- @param identifier An identifier that can be used to track the progress of a resource load across
- multiple call backs.
- @param request The request about to be sent.
- @param redirectResponse If the request is being made in response to a redirect we received,
- the response that conveyed that redirect.
- @param dataSource The dataSource that initiated the load.
- @result Returns the request, which may be mutated by the implementor, although typically
- will be request.
-*/
-- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method webView:resource:didReceiveAuthenticationChallenge:fromDataSource:
- @abstract Start authentication for the resource, providing a challenge
- @discussion Call useCredential::, continueWithoutCredential or
- cancel on the challenge when done.
- @param challenge The NSURLAuthenticationChallenge to start authentication for
- @discussion If you do not implement this delegate method, WebKit will handle authentication
- automatically by prompting with a sheet on the window that the WebView is associated with.
-*/
-- (void)webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method webView:resource:didCancelAuthenticationChallenge:fromDataSource:
- @abstract Cancel authentication for a given request
- @param challenge The NSURLAuthenticationChallenge for which to cancel authentication
-*/
-- (void)webView:(WebView *)sender resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method webView:resource:didReceiveResponse:fromDataSource:
- @abstract This message is sent after a response has been received for this load.
- @param webView The WebView sending the message.
- @param identifier An identifier that can be used to track the progress of a resource load across
- multiple call backs.
- @param response The response for the request.
- @param dataSource The dataSource that initiated the load.
- @discussion In some rare cases, multiple responses may be received for a single load.
- This occurs with multipart/x-mixed-replace, or "server push". In this case, the client
- should assume that each new response resets progress so far for the resource back to 0,
- and should check the new response for the expected content length.
-*/
-- (void)webView:(WebView *)sender resource:(id)identifier didReceiveResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method webView:resource:didReceiveContentLength:fromDataSource:
- @discussion Multiple of these messages may be sent as data arrives.
- @param webView The WebView sending the message.
- @param identifier An identifier that can be used to track the progress of a resource load across
- multiple call backs.
- @param length The amount of new data received. This is not the total amount, just the new amount received.
- @param dataSource The dataSource that initiated the load.
-*/
-- (void)webView:(WebView *)sender resource:(id)identifier didReceiveContentLength:(WebNSInteger)length fromDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method webView:resource:didFinishLoadingFromDataSource:
- @discussion This message is sent after a load has successfully completed.
- @param webView The WebView sending the message.
- @param identifier An identifier that can be used to track the progress of a resource load across
- multiple call backs.
- @param dataSource The dataSource that initiated the load.
-*/
-- (void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method webView:resource:didFailLoadingWithError:fromDataSource:
- @discussion This message is sent after a load has failed to load due to an error.
- @param webView The WebView sending the message.
- @param identifier An identifier that can be used to track the progress of a resource load across
- multiple call backs.
- @param error The error associated with this load.
- @param dataSource The dataSource that initiated the load.
-*/
-- (void)webView:(WebView *)sender resource:(id)identifier didFailLoadingWithError:(NSError *)error fromDataSource:(WebDataSource *)dataSource;
-
-/*!
- @method webView:plugInFailedWithError:dataSource:
- @discussion Called when a plug-in is not found, fails to load or is not available for some reason.
- @param webView The WebView sending the message.
- @param error The plug-in error. In the userInfo dictionary of the error, the object for the
- NSErrorFailingURLKey key is a URL string of the SRC attribute, the object for the WebKitErrorPlugInNameKey
- key is a string of the plug-in's name, the object for the WebKitErrorPlugInPageURLStringKey key is a URL string
- of the PLUGINSPAGE attribute and the object for the WebKitErrorMIMETypeKey key is a string of the TYPE attribute.
- Some, none or all of the mentioned attributes can be present in the userInfo. The error returns nil for userInfo
- when none are present.
- @param dataSource The dataSource that contains the plug-in.
-*/
-- (void)webView:(WebView *)sender plugInFailedWithError:(NSError *)error dataSource:(WebDataSource *)dataSource;
-
-@end
-
-#undef WebNSInteger
diff --git a/WebKit/mac/WebView/WebResourceLoadDelegatePrivate.h b/WebKit/mac/WebView/WebResourceLoadDelegatePrivate.h
deleted file mode 100644
index 5fd13ee..0000000
--- a/WebKit/mac/WebView/WebResourceLoadDelegatePrivate.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSInteger int
-#else
-#define WebNSInteger NSInteger
-#endif
-
-@class WebView;
-@class WebDataSource;
-@class NSURLAuthenticationChallenge;
-@class NSURLResponse;
-@class NSURLRequest;
-
-@interface NSObject (WebResourceLoadDelegatePrivate)
-
-- (void)webView:(WebView *)webView didLoadResourceFromMemoryCache:(NSURLRequest *)request response:(NSURLResponse *)response length:(WebNSInteger)length fromDataSource:(WebDataSource *)dataSource;
-
-@end
-
-#undef WebNSInteger
diff --git a/WebKit/mac/WebView/WebResourcePrivate.h b/WebKit/mac/WebView/WebResourcePrivate.h
deleted file mode 100644
index 80d9835..0000000
--- a/WebKit/mac/WebView/WebResourcePrivate.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebResource.h>
-
-@interface WebResource (WebResourcePrivate)
-
-- (id)_initWithData:(NSData *)data
- URL:(NSURL *)URL
- MIMEType:(NSString *)MIMEType
- textEncodingName:(NSString *)textEncodingName
- frameName:(NSString *)frameName
- response:(NSURLResponse *)response
- copyData:(BOOL)copyData;
-
-- (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response;
-
-- (void)_ignoreWhenUnarchiving;
-
-- (NSFileWrapper *)_fileWrapperRepresentation;
-- (NSURLResponse *)_response;
-- (NSString *)_stringValue;
-
-@end
diff --git a/WebKit/mac/WebView/WebScriptDebugDelegate.h b/WebKit/mac/WebView/WebScriptDebugDelegate.h
deleted file mode 100644
index fba48f6..0000000
--- a/WebKit/mac/WebView/WebScriptDebugDelegate.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSUInteger unsigned int
-#else
-#define WebNSUInteger NSUInteger
-#endif
-
-@class WebView;
-@class WebFrame;
-@class WebScriptCallFrame;
-@class WebScriptCallFramePrivate;
-@class WebScriptObject;
-
-extern NSString * const WebScriptErrorDomain;
-extern NSString * const WebScriptErrorDescriptionKey;
-extern NSString * const WebScriptErrorLineNumberKey;
-
-enum {
- WebScriptGeneralErrorCode = -100
-};
-
-// WebScriptDebugDelegate messages
-
-@interface NSObject (WebScriptDebugDelegate)
-
-// some source was parsed, establishing a "source ID" (>= 0) for future reference
-// this delegate method is deprecated, please switch to the new version below
-- (void)webView:(WebView *)webView didParseSource:(NSString *)source
- fromURL:(NSString *)url
- sourceId:(int)sid
- forWebFrame:(WebFrame *)webFrame;
-
-// some source was parsed, establishing a "source ID" (>= 0) for future reference
-- (void)webView:(WebView *)webView didParseSource:(NSString *)source
- baseLineNumber:(WebNSUInteger)lineNumber
- fromURL:(NSURL *)url
- sourceId:(int)sid
- forWebFrame:(WebFrame *)webFrame;
-
-// some source failed to parse
-- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source
- baseLineNumber:(WebNSUInteger)lineNumber
- fromURL:(NSURL *)url
- withError:(NSError *)error
- forWebFrame:(WebFrame *)webFrame;
-
-// just entered a stack frame (i.e. called a function, or started global scope)
-- (void)webView:(WebView *)webView didEnterCallFrame:(WebScriptCallFrame *)frame
- sourceId:(int)sid
- line:(int)lineno
- forWebFrame:(WebFrame *)webFrame;
-
-// about to execute some code
-- (void)webView:(WebView *)webView willExecuteStatement:(WebScriptCallFrame *)frame
- sourceId:(int)sid
- line:(int)lineno
- forWebFrame:(WebFrame *)webFrame;
-
-// about to leave a stack frame (i.e. return from a function)
-- (void)webView:(WebView *)webView willLeaveCallFrame:(WebScriptCallFrame *)frame
- sourceId:(int)sid
- line:(int)lineno
- forWebFrame:(WebFrame *)webFrame;
-
-// exception is being thrown
-- (void)webView:(WebView *)webView exceptionWasRaised:(WebScriptCallFrame *)frame
- sourceId:(int)sid
- line:(int)lineno
- forWebFrame:(WebFrame *)webFrame;
-@end
-
-
-
-// WebScriptCallFrame interface
-//
-// These objects are passed as arguments to the debug delegate.
-
-@interface WebScriptCallFrame : NSObject
-{
-@private
- WebScriptCallFramePrivate* _private;
- id _userInfo;
-}
-
-// associate user info with frame
-- (void)setUserInfo:(id)userInfo;
-
-// retrieve user info
-- (id)userInfo;
-
-// get next frame on call stack (or nil if this is already the "global" frame)
-- (WebScriptCallFrame *)caller;
-
-// get array of WebScriptObjects for each scope (innermost first, last is always global object)
-- (NSArray *)scopeChain;
-
-// get name of function (if available) or nil
-- (NSString *)functionName;
-
-// get pending exception (if any) or nil
-- (id)exception;
-
-// evaluate a script (as if by "eval") in the context of this frame
-- (id)evaluateWebScript:(NSString *)script;
-
-@end
-
-#undef WebNSUInteger
diff --git a/WebKit/mac/WebView/WebScriptDebugDelegate.mm b/WebKit/mac/WebView/WebScriptDebugDelegate.mm
deleted file mode 100644
index be0a0d5..0000000
--- a/WebKit/mac/WebView/WebScriptDebugDelegate.mm
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebScriptDebugger.h"
-#import "WebDataSource.h"
-#import "WebDataSourceInternal.h"
-#import "WebFrameInternal.h"
-#import "WebScriptDebugDelegate.h"
-#import "WebViewInternal.h"
-#import <debugger/DebuggerCallFrame.h>
-#import <runtime/ExecState.h>
-#import <runtime/JSGlobalObject.h>
-#import <runtime/JSFunction.h>
-#import <runtime/JSLock.h>
-#import <kjs/interpreter.h>
-#import <WebCore/Frame.h>
-#import <WebCore/WebScriptObjectPrivate.h>
-#import <WebCore/ScriptController.h>
-#import <WebCore/runtime_root.h>
-
-using namespace JSC;
-using namespace WebCore;
-
-// FIXME: these error strings should be public for future use by WebScriptObject and in WebScriptObject.h
-NSString * const WebScriptErrorDomain = @"WebScriptErrorDomain";
-NSString * const WebScriptErrorDescriptionKey = @"WebScriptErrorDescription";
-NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber";
-
-@interface WebScriptCallFrame (WebScriptDebugDelegateInternal)
-
-- (id)_convertValueToObjcValue:(JSValue*)value;
-
-@end
-
-@interface WebScriptCallFramePrivate : NSObject {
-@public
- WebScriptObject *globalObject; // the global object's proxy (not retained)
- WebScriptCallFrame *caller; // previous stack frame
- DebuggerCallFrame* debuggerCallFrame;
-}
-@end
-
-@implementation WebScriptCallFramePrivate
-- (void)dealloc
-{
- [caller release];
- delete debuggerCallFrame;
- [super dealloc];
-}
-@end
-
-// WebScriptCallFrame
-//
-// One of these is created to represent each stack frame. Additionally, there is a "global"
-// frame to represent the outermost scope. This global frame is always the last frame in
-// the chain of callers.
-//
-// The delegate can assign a "wrapper" to each frame object so it can relay calls through its
-// own exported interface. This class is private to WebCore (and the delegate).
-
-@implementation WebScriptCallFrame (WebScriptDebugDelegateInternal)
-
-- (WebScriptCallFrame *)_initWithGlobalObject:(WebScriptObject *)globalObj caller:(WebScriptCallFrame *)caller debuggerCallFrame:(const DebuggerCallFrame&)debuggerCallFrame
-{
- if ((self = [super init])) {
- _private = [[WebScriptCallFramePrivate alloc] init];
- _private->globalObject = globalObj;
- _private->caller = [caller retain];
- }
- return self;
-}
-
-- (void)_setDebuggerCallFrame:(const DebuggerCallFrame&)debuggerCallFrame
-{
- if (!_private->debuggerCallFrame)
- _private->debuggerCallFrame = new DebuggerCallFrame(debuggerCallFrame);
- else
- *_private->debuggerCallFrame = debuggerCallFrame;
-}
-
-- (void)_clearDebuggerCallFrame
-{
- delete _private->debuggerCallFrame;
- _private->debuggerCallFrame = 0;
-}
-
-- (id)_convertValueToObjcValue:(JSValue*)value
-{
- if (!value)
- return nil;
-
- WebScriptObject *globalObject = _private->globalObject;
- if (value == [globalObject _imp])
- return globalObject;
-
- Bindings::RootObject* root1 = [globalObject _originRootObject];
- if (!root1)
- return nil;
-
- Bindings::RootObject* root2 = [globalObject _rootObject];
- if (!root2)
- return nil;
-
- return [WebScriptObject _convertValueToObjcValue:value originRootObject:root1 rootObject:root2];
-}
-
-@end
-
-
-
-@implementation WebScriptCallFrame
-
-- (void) dealloc
-{
- [_userInfo release];
- [_private release];
- [super dealloc];
-}
-
-- (void)setUserInfo:(id)userInfo
-{
- if (userInfo != _userInfo) {
- [_userInfo release];
- _userInfo = [userInfo retain];
- }
-}
-
-- (id)userInfo
-{
- return _userInfo;
-}
-
-- (WebScriptCallFrame *)caller
-{
- return _private->caller;
-}
-
-// Returns an array of scope objects (most local first).
-// The properties of each scope object are the variables for that scope.
-// Note that the last entry in the array will _always_ be the global object (windowScriptObject),
-// whose properties are the global variables.
-
-- (NSArray *)scopeChain
-{
- if (!_private->debuggerCallFrame)
- return [NSArray array];
-
- const ScopeChainNode* scopeChain = _private->debuggerCallFrame->scopeChain();
- if (!scopeChain->next) // global frame
- return [NSArray arrayWithObject:_private->globalObject];
-
- NSMutableArray *scopes = [[NSMutableArray alloc] init];
-
- ScopeChainIterator end = scopeChain->end();
- for (ScopeChainIterator it = scopeChain->begin(); it != end; ++it)
- [scopes addObject:[self _convertValueToObjcValue:(*it)]];
-
- NSArray *result = [NSArray arrayWithArray:scopes];
- [scopes release];
- return result;
-}
-
-// Returns the name of the function for this frame, if available.
-// Returns nil for anonymous functions and for the global frame.
-
-- (NSString *)functionName
-{
- if (!_private->debuggerCallFrame)
- return nil;
-
- const UString* functionName = _private->debuggerCallFrame->functionName();
- return functionName ? toNSString(*functionName) : nil;
-}
-
-// Returns the pending exception for this frame (nil if none).
-
-- (id)exception
-{
- if (!_private->debuggerCallFrame)
- return nil;
-
- JSValue* exception = _private->debuggerCallFrame->exception();
- return exception ? [self _convertValueToObjcValue:exception] : nil;
-}
-
-// Evaluate some JavaScript code in the context of this frame.
-// The code is evaluated as if by "eval", and the result is returned.
-// If there is an (uncaught) exception, it is returned as though _it_ were the result.
-// Calling this method on the global frame is not quite the same as calling the WebScriptObject
-// method of the same name, due to the treatment of exceptions.
-
-- (id)evaluateWebScript:(NSString *)script
-{
- if (!_private->debuggerCallFrame)
- return nil;
-
- JSLock lock(false);
-
- JSValue* exception = noValue();
- JSValue* result = _private->debuggerCallFrame->evaluate(String(script), exception);
- if (exception)
- return [self _convertValueToObjcValue:exception];
- return result ? [self _convertValueToObjcValue:result] : nil;
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebScriptDebugger.h b/WebKit/mac/WebView/WebScriptDebugger.h
deleted file mode 100644
index caec994..0000000
--- a/WebKit/mac/WebView/WebScriptDebugger.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WebScriptDebugger_h
-#define WebScriptDebugger_h
-
-#include <debugger/Debugger.h>
-
-#include <wtf/RetainPtr.h>
-
-namespace JSC {
- class DebuggerCallFrame;
- class ExecState;
- class JSGlobalObject;
- class JSObject;
- class ArgList;
- class UString;
-}
-
-@class WebScriptCallFrame;
-
-NSString *toNSString(const JSC::UString&);
-
-class WebScriptDebugger : public JSC::Debugger {
-public:
- WebScriptDebugger(JSC::JSGlobalObject*);
-
- virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int errorLine, const JSC::UString& errorMsg);
- virtual void callEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
- virtual void atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
- virtual void returnEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
- virtual void exception(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
- virtual void willExecuteProgram(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno);
- virtual void didExecuteProgram(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno);
- virtual void didReachBreakpoint(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno);
-
-private:
- bool m_callingDelegate;
- RetainPtr<WebScriptCallFrame> m_topCallFrame;
-};
-
-#endif // WebScriptDebugger_h
diff --git a/WebKit/mac/WebView/WebScriptDebugger.mm b/WebKit/mac/WebView/WebScriptDebugger.mm
deleted file mode 100644
index 0dd6b0e..0000000
--- a/WebKit/mac/WebView/WebScriptDebugger.mm
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebScriptDebugger.h"
-
-#import "WebFrameInternal.h"
-#import "WebViewInternal.h"
-#import "WebScriptDebugDelegate.h"
-#import <runtime/JSGlobalObject.h>
-#import <debugger/DebuggerCallFrame.h>
-#import <WebCore/DOMWindow.h>
-#import <WebCore/Frame.h>
-#import <WebCore/JSDOMWindow.h>
-#import <WebCore/KURL.h>
-#import <WebCore/ScriptController.h>
-
-using namespace JSC;
-using namespace WebCore;
-
-@interface WebScriptCallFrame (WebScriptDebugDelegateInternal)
-- (WebScriptCallFrame *)_initWithGlobalObject:(WebScriptObject *)globalObj caller:(WebScriptCallFrame *)caller debuggerCallFrame:(const DebuggerCallFrame&)debuggerCallFrame;
-- (void)_setDebuggerCallFrame:(const DebuggerCallFrame&)debuggerCallFrame;
-- (void)_clearDebuggerCallFrame;
-@end
-
-NSString *toNSString(const UString& s)
-{
- if (s.isEmpty())
- return nil;
- return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s.data()) length:s.size()];
-}
-
-NSString *toNSString(const SourceCode& s)
-{
- if (!s.length())
- return nil;
- return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s.data()) length:s.length()];
-}
-
-// convert UString to NSURL
-static NSURL *toNSURL(const UString& s)
-{
- if (s.isEmpty())
- return nil;
- return KURL(s);
-}
-
-static WebFrame *toWebFrame(JSGlobalObject* globalObject)
-{
- JSDOMWindow* window = static_cast<JSDOMWindow*>(globalObject);
- return kit(window->impl()->frame());
-}
-
-WebScriptDebugger::WebScriptDebugger(JSGlobalObject* globalObject)
- : m_callingDelegate(false)
-{
- attach(globalObject);
- callEvent(globalObject->globalExec(), 0, -1);
-}
-
-// callbacks - relay to delegate
-void WebScriptDebugger::sourceParsed(ExecState* exec, const SourceCode& source, int errorLine, const UString& errorMsg)
-{
- if (m_callingDelegate)
- return;
-
- m_callingDelegate = true;
-
- NSString *nsSource = toNSString(source);
- NSURL *nsURL = toNSURL(source.provider()->url());
-
- WebFrame *webFrame = toWebFrame(exec->dynamicGlobalObject());
- WebView *webView = [webFrame webView];
- if (errorLine == -1) {
- [[webView _scriptDebugDelegateForwarder] webView:webView didParseSource:nsSource baseLineNumber:source.firstLine() fromURL:nsURL sourceId:static_cast<int>(source.provider()->asID()) forWebFrame:webFrame];
- [[webView _scriptDebugDelegateForwarder] webView:webView didParseSource:nsSource fromURL:[nsURL absoluteString] sourceId:static_cast<int>(source.provider()->asID()) forWebFrame:webFrame]; // deprecated delegate method
- } else {
- NSString* nsErrorMessage = toNSString(errorMsg);
- NSDictionary *info = [[NSDictionary alloc] initWithObjectsAndKeys:nsErrorMessage, WebScriptErrorDescriptionKey, [NSNumber numberWithUnsignedInt:errorLine], WebScriptErrorLineNumberKey, nil];
- NSError *error = [[NSError alloc] initWithDomain:WebScriptErrorDomain code:WebScriptGeneralErrorCode userInfo:info];
- [[webView _scriptDebugDelegateForwarder] webView:webView failedToParseSource:nsSource baseLineNumber:source.firstLine() fromURL:nsURL withError:error forWebFrame:webFrame];
- [error release];
- [info release];
- }
-
- m_callingDelegate = false;
-}
-
-void WebScriptDebugger::callEvent(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
-{
- if (m_callingDelegate)
- return;
-
- m_callingDelegate = true;
-
- WebFrame *webFrame = toWebFrame(debuggerCallFrame.dynamicGlobalObject());
-
- m_topCallFrame.adoptNS([[WebScriptCallFrame alloc] _initWithGlobalObject:core(webFrame)->script()->windowScriptObject() caller:m_topCallFrame.get() debuggerCallFrame:debuggerCallFrame]);
-
- WebView *webView = [webFrame webView];
- [[webView _scriptDebugDelegateForwarder] webView:webView didEnterCallFrame:m_topCallFrame.get() sourceId:static_cast<int>(sourceID) line:lineNumber forWebFrame:webFrame];
-
- m_callingDelegate = false;
-}
-
-void WebScriptDebugger::atStatement(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
-{
- if (m_callingDelegate)
- return;
-
- m_callingDelegate = true;
-
- WebFrame *webFrame = toWebFrame(debuggerCallFrame.dynamicGlobalObject());
- WebView *webView = [webFrame webView];
-
- [m_topCallFrame.get() _setDebuggerCallFrame:debuggerCallFrame];
- [[webView _scriptDebugDelegateForwarder] webView:webView willExecuteStatement:m_topCallFrame.get() sourceId:static_cast<int>(sourceID) line:lineNumber forWebFrame:webFrame];
-
- m_callingDelegate = false;
-}
-
-void WebScriptDebugger::returnEvent(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
-{
- if (m_callingDelegate)
- return;
-
- m_callingDelegate = true;
-
- WebFrame *webFrame = toWebFrame(debuggerCallFrame.dynamicGlobalObject());
- WebView *webView = [webFrame webView];
-
- [m_topCallFrame.get() _setDebuggerCallFrame:debuggerCallFrame];
- [[webView _scriptDebugDelegateForwarder] webView:webView willLeaveCallFrame:m_topCallFrame.get() sourceId:static_cast<int>(sourceID) line:lineNumber forWebFrame:webFrame];
-
- [m_topCallFrame.get() _clearDebuggerCallFrame];
- m_topCallFrame = [m_topCallFrame.get() caller];
-
- m_callingDelegate = false;
-}
-
-void WebScriptDebugger::exception(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
-{
- if (m_callingDelegate)
- return;
-
- m_callingDelegate = true;
-
- WebFrame *webFrame = toWebFrame(debuggerCallFrame.dynamicGlobalObject());
- WebView *webView = [webFrame webView];
- [m_topCallFrame.get() _setDebuggerCallFrame:debuggerCallFrame];
-
- [[webView _scriptDebugDelegateForwarder] webView:webView exceptionWasRaised:m_topCallFrame.get() sourceId:static_cast<int>(sourceID) line:lineNumber forWebFrame:webFrame];
-
- m_callingDelegate = false;
-}
-
-void WebScriptDebugger::willExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineno)
-{
-}
-
-void WebScriptDebugger::didExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineno)
-{
-}
-
-void WebScriptDebugger::didReachBreakpoint(const DebuggerCallFrame&, intptr_t, int)
-{
- return;
-}
diff --git a/WebKit/mac/WebView/WebTextIterator.h b/WebKit/mac/WebView/WebTextIterator.h
deleted file mode 100644
index e6f77ac..0000000
--- a/WebKit/mac/WebView/WebTextIterator.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-
-@class DOMRange;
-@class DOMNode;
-@class WebTextIteratorPrivate;
-
-@interface WebTextIterator : NSObject
-{
-@private
- WebTextIteratorPrivate *_private;
-}
-
-- (id)initWithRange:(DOMRange *)range;
-
-/*!
- @method advance:
- @abstract Makes the WebTextIterator iterate to the next visible text element.
- */
-- (void)advance;
-
-/*!
- @method currentNode:
- @result The current DOMNode in the WebTextIterator.
- */
-- (DOMNode *)currentNode;
-
-/*!
- @method currentText:
- @result The current text in the WebTextIterator.
- */
-- (NSString *)currentText;
-
-/*!
- @method atEnd:
- @result YES if the WebTextIterator has reached the end of the DOMRange.
- */
-- (BOOL)atEnd;
-
-
-@end
diff --git a/WebKit/mac/WebView/WebTextIterator.mm b/WebKit/mac/WebView/WebTextIterator.mm
deleted file mode 100644
index 86db6d3..0000000
--- a/WebKit/mac/WebView/WebTextIterator.mm
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebTextIterator.h"
-
-#import "DOMNodeInternal.h"
-#import "DOMRangeInternal.h"
-#import <WebCore/TextIterator.h>
-#import <wtf/Vector.h>
-
-using namespace WebCore;
-
-@interface WebTextIteratorPrivate : NSObject
-{
-@public
- TextIterator* m_textIterator;
-}
-@end
-
-@implementation WebTextIteratorPrivate
-
-- (void)dealloc
-{
- delete m_textIterator;
- [super dealloc];
-}
-
-- (void)finalize
-{
- delete m_textIterator;
- [super finalize];
-}
-
-@end
-
-@implementation WebTextIterator
-
-- (void)dealloc
-{
- [_private release];
- [super dealloc];
-}
-
-- (id)initWithRange:(DOMRange *)range
-{
- self = [super init];
- if (!self)
- return self;
-
- _private = [[WebTextIteratorPrivate alloc] init];
- _private->m_textIterator = new TextIterator([range _range], true, false);
- return self;
-}
-
-- (void)advance
-{
- ASSERT(_private->m_textIterator);
-
- if (_private->m_textIterator->atEnd())
- return;
-
- _private->m_textIterator->advance();
-}
-
-- (DOMNode *)currentNode
-{
- ASSERT(_private->m_textIterator);
-
- return [DOMNode _wrapNode:_private->m_textIterator->node()];
-}
-
-- (NSString *)currentText
-{
- ASSERT(_private->m_textIterator);
-
- return [NSString stringWithCharacters:_private->m_textIterator->characters() length:_private->m_textIterator->length()];
-}
-
-- (BOOL)atEnd
-{
- ASSERT(_private->m_textIterator);
-
- return _private->m_textIterator->atEnd();
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebUIDelegate.h b/WebKit/mac/WebView/WebUIDelegate.h
deleted file mode 100644
index 8440bcb..0000000
--- a/WebKit/mac/WebView/WebUIDelegate.h
+++ /dev/null
@@ -1,575 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-#import <Foundation/NSURLRequest.h>
-#import <JavaScriptCore/WebKitAvailability.h>
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSUInteger unsigned int
-#else
-#define WebNSUInteger NSUInteger
-#endif
-
-/*!
- @enum WebMenuItemTag
- @discussion Each menu item in the default menu items array passed in
- contextMenuItemsForElement:defaultMenuItems: has its tag set to one of the WebMenuItemTags.
- When iterating through the default menu items array, use the tag to differentiate between them.
-*/
-
-enum {
- WebMenuItemTagOpenLinkInNewWindow=1,
- WebMenuItemTagDownloadLinkToDisk,
- WebMenuItemTagCopyLinkToClipboard,
- WebMenuItemTagOpenImageInNewWindow,
- WebMenuItemTagDownloadImageToDisk,
- WebMenuItemTagCopyImageToClipboard,
- WebMenuItemTagOpenFrameInNewWindow,
- WebMenuItemTagCopy,
- WebMenuItemTagGoBack,
- WebMenuItemTagGoForward,
- WebMenuItemTagStop,
- WebMenuItemTagReload,
- WebMenuItemTagCut,
- WebMenuItemTagPaste,
- WebMenuItemTagSpellingGuess,
- WebMenuItemTagNoGuessesFound,
- WebMenuItemTagIgnoreSpelling,
- WebMenuItemTagLearnSpelling,
- WebMenuItemTagOther,
- WebMenuItemTagSearchInSpotlight,
- WebMenuItemTagSearchWeb,
- WebMenuItemTagLookUpInDictionary,
- WebMenuItemTagOpenWithDefaultApplication,
- WebMenuItemPDFActualSize,
- WebMenuItemPDFZoomIn,
- WebMenuItemPDFZoomOut,
- WebMenuItemPDFAutoSize,
- WebMenuItemPDFSinglePage,
- WebMenuItemPDFFacingPages,
- WebMenuItemPDFContinuous,
- WebMenuItemPDFNextPage,
- WebMenuItemPDFPreviousPage,
-};
-
-/*!
- @enum WebDragDestinationAction
- @abstract Actions that the destination of a drag can perform.
- @constant WebDragDestinationActionNone No action
- @constant WebDragDestinationActionDHTML Allows DHTML (such as JavaScript) to handle the drag
- @constant WebDragDestinationActionEdit Allows editable documents to be edited from the drag
- @constant WebDragDestinationActionLoad Allows a location change from the drag
- @constant WebDragDestinationActionAny Allows any of the above to occur
-*/
-typedef enum {
- WebDragDestinationActionNone = 0,
- WebDragDestinationActionDHTML = 1,
- WebDragDestinationActionEdit = 2,
- WebDragDestinationActionLoad = 4,
- WebDragDestinationActionAny = UINT_MAX
-} WebDragDestinationAction;
-
-/*!
- @enum WebDragSourceAction
- @abstract Actions that the source of a drag can perform.
- @constant WebDragSourceActionNone No action
- @constant WebDragSourceActionDHTML Allows DHTML (such as JavaScript) to start a drag
- @constant WebDragSourceActionImage Allows an image drag to occur
- @constant WebDragSourceActionLink Allows a link drag to occur
- @constant WebDragSourceActionSelection Allows a selection drag to occur
- @constant WebDragSourceActionAny Allows any of the above to occur
-*/
-typedef enum {
- WebDragSourceActionNone = 0,
- WebDragSourceActionDHTML = 1,
- WebDragSourceActionImage = 2,
- WebDragSourceActionLink = 4,
- WebDragSourceActionSelection = 8,
- WebDragSourceActionAny = UINT_MAX
-} WebDragSourceAction;
-
-/*!
- @protocol WebOpenPanelResultListener
- @discussion This protocol is used to call back with the results of
- the file open panel requested by runOpenPanelForFileButtonWithResultListener:
-*/
-@protocol WebOpenPanelResultListener <NSObject>
-
-/*!
- @method chooseFilename:
- @abstract Call this method to return a filename from the file open panel.
- @param fileName
-*/
-- (void)chooseFilename:(NSString *)fileName;
-
-/*!
- @method chooseFilenames:
- @abstract Call this method to return an array of filenames from the file open panel.
- @param fileNames
-*/
-- (void)chooseFilenames:(NSArray *)fileNames WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_AFTER_WEBKIT_VERSION_3_1);
-
-/*!
- @method cancel
- @abstract Call this method to indicate that the file open panel was cancelled.
-*/
-- (void)cancel;
-
-@end
-
-@class WebView;
-
-/*!
- @category WebUIDelegate
- @discussion A class that implements WebUIDelegate provides
- window-related methods that may be used by Javascript, plugins and
- other aspects of web pages. These methods are used to open new
- windows and control aspects of existing windows.
-*/
-@interface NSObject (WebUIDelegate)
-
-/*!
- @method webView:createWebViewWithRequest:
- @abstract Create a new window and begin to load the specified request.
- @discussion The newly created window is hidden, and the window operations delegate on the
- new WebViews will get a webViewShow: call.
- @param sender The WebView sending the delegate method.
- @param request The request to load.
- @result The WebView for the new window.
-*/
-- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request;
-
-/*!
- @method webViewShow:
- @param sender The WebView sending the delegate method.
- @abstract Show the window that contains the top level view of the WebView,
- ordering it frontmost.
- @discussion This will only be called just after createWindowWithRequest:
- is used to create a new window.
-*/
-- (void)webViewShow:(WebView *)sender;
-
-/*!
- @method webView:createWebViewModalDialogWithRequest:
- @abstract Create a new window and begin to load the specified request.
- @discussion The newly created window is hidden, and the window operations delegate on the
- new WebViews will get a webViewShow: call.
- @param sender The WebView sending the delegate method.
- @param request The request to load.
- @result The WebView for the new window.
-*/
-- (WebView *)webView:(WebView *)sender createWebViewModalDialogWithRequest:(NSURLRequest *)request;
-
-/*!
- @method webViewRunModal:
- @param sender The WebView sending the delegate method.
- @abstract Show the window that contains the top level view of the WebView,
- ordering it frontmost. The window should be run modal in the application.
- @discussion This will only be called just after createWebViewModalDialogWithRequest:
- is used to create a new window.
-*/
-- (void)webViewRunModal:(WebView *)sender;
-
-/*!
- @method webViewClose:
- @abstract Close the current window.
- @param sender The WebView sending the delegate method.
- @discussion Clients showing multiple views in one window may
- choose to close only the one corresponding to this
- WebView. Other clients may choose to ignore this method
- entirely.
-*/
-- (void)webViewClose:(WebView *)sender;
-
-/*!
- @method webViewFocus:
- @abstract Focus the current window (i.e. makeKeyAndOrderFront:).
- @param The WebView sending the delegate method.
- @discussion Clients showing multiple views in one window may want to
- also do something to focus the one corresponding to this WebView.
-*/
-- (void)webViewFocus:(WebView *)sender;
-
-/*!
- @method webViewUnfocus:
- @abstract Unfocus the current window.
- @param sender The WebView sending the delegate method.
- @discussion Clients showing multiple views in one window may want to
- also do something to unfocus the one corresponding to this WebView.
-*/
-- (void)webViewUnfocus:(WebView *)sender;
-
-/*!
- @method webViewFirstResponder:
- @abstract Get the first responder for this window.
- @param sender The WebView sending the delegate method.
- @discussion This method should return the focused control in the
- WebView's view, if any. If the view is out of the window
- hierarchy, this might return something than calling firstResponder
- on the real NSWindow would. It's OK to return either nil or the
- real first responder if some control not in the window has focus.
-*/
-- (NSResponder *)webViewFirstResponder:(WebView *)sender;
-
-/*!
- @method webView:makeFirstResponder:
- @abstract Set the first responder for this window.
- @param sender The WebView sending the delegate method.
- @param responder The responder to make first (will always be a view)
- @discussion responder will always be a view that is in the view
- subhierarchy of the top-level web view for this WebView. If the
- WebView's top level view is currently out of the view
- hierarchy, it may be desirable to save the first responder
- elsewhere, or possibly ignore this call.
-*/
-- (void)webView:(WebView *)sender makeFirstResponder:(NSResponder *)responder;
-
-/*!
- @method webView:setStatusText:
- @abstract Set the window's status display, if any, to the specified string.
- @param sender The WebView sending the delegate method.
- @param text The status text to set
-*/
-- (void)webView:(WebView *)sender setStatusText:(NSString *)text;
-
-/*!
- @method webViewStatusText:
- @abstract Get the currently displayed status text.
- @param sender The WebView sending the delegate method.
- @result The status text
-*/
-- (NSString *)webViewStatusText:(WebView *)sender;
-
-/*!
- @method webViewAreToolbarsVisible:
- @abstract Determine whether the window's toolbars are currently visible
- @param sender The WebView sending the delegate method.
- @discussion This method should return YES if the window has any
- toolbars that are currently on, besides the status bar. If the app
- has more than one toolbar per window, for example a regular
- command toolbar and a favorites bar, it should return YES from
- this method if at least one is on.
- @result YES if at least one toolbar is visible, otherwise NO.
-*/
-- (BOOL)webViewAreToolbarsVisible:(WebView *)sender;
-
-/*!
- @method webView:setToolbarsVisible:
- @param sender The WebView sending the delegate method.
- @abstract Set whether the window's toolbars are currently visible.
- @param visible New value for toolbar visibility
- @discussion Setting this to YES should turn on all toolbars
- (except for a possible status bar). Setting it to NO should turn
- off all toolbars (with the same exception).
-*/
-- (void)webView:(WebView *)sender setToolbarsVisible:(BOOL)visible;
-
-/*!
- @method webViewIsStatusBarVisible:
- @abstract Determine whether the status bar is visible.
- @param sender The WebView sending the delegate method.
- @result YES if the status bar is visible, otherwise NO.
-*/
-- (BOOL)webViewIsStatusBarVisible:(WebView *)sender;
-
-/*!
- @method webView:setStatusBarVisible:
- @abstract Set whether the status bar is currently visible.
- @param visible The new visibility value
- @discussion Setting this to YES should show the status bar,
- setting it to NO should hide it.
-*/
-- (void)webView:(WebView *)sender setStatusBarVisible:(BOOL)visible;
-
-/*!
- @method webViewIsResizable:
- @abstract Determine whether the window is resizable or not.
- @param sender The WebView sending the delegate method.
- @result YES if resizable, NO if not.
- @discussion If there are multiple views in the same window, they
- have have their own separate resize controls and this may need to
- be handled specially.
-*/
-- (BOOL)webViewIsResizable:(WebView *)sender;
-
-/*!
- @method webView:setResizable:
- @abstract Set the window to resizable or not
- @param sender The WebView sending the delegate method.
- @param resizable YES if the window should be made resizable, NO if not.
- @discussion If there are multiple views in the same window, they
- have have their own separate resize controls and this may need to
- be handled specially.
-*/
-- (void)webView:(WebView *)sender setResizable:(BOOL)resizable;
-
-/*!
- @method webView:setFrame:
- @abstract Set the window's frame rect
- @param sender The WebView sending the delegate method.
- @param frame The new window frame size
- @discussion Even though a caller could set the frame directly using the NSWindow,
- this method is provided so implementors of this protocol can do special
- things on programmatic move/resize, like avoiding autosaving of the size.
-*/
-- (void)webView:(WebView *)sender setFrame:(NSRect)frame;
-
-/*!
- @method webViewFrame:
- @param sender The WebView sending the delegate method.
- @abstract REturn the window's frame rect
- @discussion
-*/
-- (NSRect)webViewFrame:(WebView *)sender;
-
-/*!
- @method webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:
- @abstract Display a JavaScript alert panel.
- @param sender The WebView sending the delegate method.
- @param message The message to display.
- @param frame The WebFrame whose JavaScript initiated this call.
- @discussion Clients should visually indicate that this panel comes
- from JavaScript initiated by the specified frame. The panel should have
- a single OK button.
-*/
-- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
-
-/*!
- @method webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:
- @abstract Display a JavaScript confirm panel.
- @param sender The WebView sending the delegate method.
- @param message The message to display.
- @param frame The WebFrame whose JavaScript initiated this call.
- @result YES if the user hit OK, NO if the user chose Cancel.
- @discussion Clients should visually indicate that this panel comes
- from JavaScript initiated by the specified frame. The panel should have
- two buttons, e.g. "OK" and "Cancel".
-*/
-- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
-
-/*!
- @method webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:
- @abstract Display a JavaScript text input panel.
- @param sender The WebView sending the delegate method.
- @param message The message to display.
- @param defaultText The initial text for the text entry area.
- @param frame The WebFrame whose JavaScript initiated this call.
- @result The typed text if the user hit OK, otherwise nil.
- @discussion Clients should visually indicate that this panel comes
- from JavaScript initiated by the specified frame. The panel should have
- two buttons, e.g. "OK" and "Cancel", and an area to type text.
-*/
-- (NSString *)webView:(WebView *)sender runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WebFrame *)frame;
-
-/*!
- @method webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:
- @abstract Display a confirm panel by an "before unload" event handler.
- @param sender The WebView sending the delegate method.
- @param message The message to display.
- @param frame The WebFrame whose JavaScript initiated this call.
- @result YES if the user hit OK, NO if the user chose Cancel.
- @discussion Clients should include a message in addition to the one
- supplied by the web page that indicates. The panel should have
- two buttons, e.g. "OK" and "Cancel".
-*/
-- (BOOL)webView:(WebView *)sender runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
-
-/*!
- @method webView:runOpenPanelForFileButtonWithResultListener:
- @abstract Display a file open panel for a file input control.
- @param sender The WebView sending the delegate method.
- @param resultListener The object to call back with the results.
- @discussion This method is passed a callback object instead of giving a return
- value so that it can be handled with a sheet.
-*/
-- (void)webView:(WebView *)sender runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener;
-
-/*!
- @method webView:runOpenPanelForFileButtonWithResultListener:allowMultipleFiles
- @abstract Display a file open panel for a file input control that may allow multiple files to be selected.
- @param sender The WebView sending the delegate method.
- @param resultListener The object to call back with the results.
- @param allowMultipleFiles YES if the open panel should allow myltiple files to be selected, NO if not.
- @discussion This method is passed a callback object instead of giving a return
- value so that it can be handled with a sheet.
-*/
-- (void)webView:(WebView *)sender runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener allowMultipleFiles:(BOOL)allowMultipleFiles WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_AFTER_WEBKIT_VERSION_3_1);
-
-/*!
- @method webView:mouseDidMoveOverElement:modifierFlags:
- @abstract Update the window's feedback for mousing over links to reflect a new item the mouse is over
- or new modifier flags.
- @param sender The WebView sending the delegate method.
- @param elementInformation Dictionary that describes the element that the mouse is over, or nil.
- @param modifierFlags The modifier flags as in NSEvent.
-*/
-- (void)webView:(WebView *)sender mouseDidMoveOverElement:(NSDictionary *)elementInformation modifierFlags:(WebNSUInteger)modifierFlags;
-
-/*!
- @method webView:contextMenuItemsForElement:defaultMenuItems:
- @abstract Returns the menu items to display in an element's contextual menu.
- @param sender The WebView sending the delegate method.
- @param element A dictionary representation of the clicked element.
- @param defaultMenuItems An array of default NSMenuItems to include in all contextual menus.
- @result An array of NSMenuItems to include in the contextual menu.
-*/
-- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems;
-
-/*!
- @method webView:validateUserInterfaceItem:defaultValidation:
- @abstract Controls UI validation
- @param webView The WebView sending the delegate method
- @param item The user interface item being validated
- @pararm defaultValidation Whether or not the WebView thinks the item is valid
- @discussion This method allows the UI delegate to control WebView's validation of user interface items.
- See WebView.h to see the methods to that WebView can currently validate. See NSUserInterfaceValidations and
- NSValidatedUserInterfaceItem for information about UI validation.
-*/
-- (BOOL)webView:(WebView *)webView validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item defaultValidation:(BOOL)defaultValidation;
-
-/*!
- @method webView:shouldPerformAction:fromSender:
- @abstract Controls actions
- @param webView The WebView sending the delegate method
- @param action The action being sent
- @param sender The sender of the action
- @discussion This method allows the UI delegate to control WebView's behavior when an action is being sent.
- For example, if the action is copy:, the delegate can return YES to allow WebView to perform its default
- copy behavior or return NO and perform copy: in some other way. See WebView.h to see the actions that
- WebView can perform.
-*/
-- (BOOL)webView:(WebView *)webView shouldPerformAction:(SEL)action fromSender:(id)sender;
-
-/*!
- @method webView:dragDestinationActionMaskForDraggingInfo:
- @abstract Controls behavior when dragging to a WebView
- @param webView The WebView sending the delegate method
- @param draggingInfo The dragging info of the drag
- @discussion This method is called periodically as something is dragged over a WebView. The UI delegate can return a mask
- indicating which drag destination actions can occur, WebDragDestinationActionAny to allow any kind of action or
- WebDragDestinationActionNone to not accept the drag.
-*/
-- (WebNSUInteger)webView:(WebView *)webView dragDestinationActionMaskForDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
-
-/*!
- @method webView:willPerformDragDestinationAction:forDraggingInfo:
- @abstract Informs that WebView will perform a drag destination action
- @param webView The WebView sending the delegate method
- @param action The drag destination action
- @param draggingInfo The dragging info of the drag
- @discussion This method is called after the last call to webView:dragDestinationActionMaskForDraggingInfo: after something is dropped on a WebView.
- This method informs the UI delegate of the drag destination action that WebView will perform.
-*/
-- (void)webView:(WebView *)webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
-
-/*!
- @method webView:dragSourceActionMaskForPoint:
- @abstract Controls behavior when dragging from a WebView
- @param webView The WebView sending the delegate method
- @param point The point where the drag started in the coordinates of the WebView
- @discussion This method is called after the user has begun a drag from a WebView. The UI delegate can return a mask indicating
- which drag source actions can occur, WebDragSourceActionAny to allow any kind of action or WebDragSourceActionNone to not begin a drag.
-*/
-- (WebNSUInteger)webView:(WebView *)webView dragSourceActionMaskForPoint:(NSPoint)point;
-
-/*!
- @method webView:willPerformDragSourceAction:fromPoint:withPasteboard:
- @abstract Informs that a drag a has begun from a WebView
- @param webView The WebView sending the delegate method
- @param action The drag source action
- @param point The point where the drag started in the coordinates of the WebView
- @param pasteboard The drag pasteboard
- @discussion This method is called after webView:dragSourceActionMaskForPoint: is called after the user has begun a drag from a WebView.
- This method informs the UI delegate of the drag source action that will be performed and gives the delegate an opportunity to modify
- the contents of the dragging pasteboard.
-*/
-- (void)webView:(WebView *)webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:(NSPoint)point withPasteboard:(NSPasteboard *)pasteboard;
-
-/*!
- @method webView:printFrameView:
- @abstract Informs that a WebFrameView needs to be printed
- @param webView The WebView sending the delegate method
- @param frameView The WebFrameView needing to be printed
- @discussion This method is called when a script or user requests the page to be printed.
- In this method the delegate can prepare the WebFrameView to be printed. Some content that WebKit
- displays can be printed directly by the WebFrameView, other content will need to be handled by
- the delegate. To determine if the WebFrameView can handle printing the delegate should check
- WebFrameView's documentViewShouldHandlePrint, if YES then the delegate can call printDocumentView
- on the WebFrameView. Otherwise the delegate will need to request a NSPrintOperation from
- the WebFrameView's printOperationWithPrintInfo to handle the printing.
-*/
-- (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView;
-
-/*!
- @method webViewHeaderHeight:
- @param webView The WebView sending the delegate method
- @abstract Reserve a height for the printed page header.
- @result The height to reserve for the printed page header, return 0.0 to not reserve any space for a header.
- @discussion The height returned will be used to calculate the rect passed to webView:drawHeaderInRect:.
-*/
-- (float)webViewHeaderHeight:(WebView *)sender;
-
-/*!
- @method webViewFooterHeight:
- @param webView The WebView sending the delegate method
- @abstract Reserve a height for the printed page footer.
- @result The height to reserve for the printed page footer, return 0.0 to not reserve any space for a footer.
- @discussion The height returned will be used to calculate the rect passed to webView:drawFooterInRect:.
-*/
-- (float)webViewFooterHeight:(WebView *)sender;
-
-/*!
- @method webView:drawHeaderInRect:
- @param webView The WebView sending the delegate method
- @param rect The NSRect reserved for the header of the page
- @abstract The delegate should draw a header for the sender in the supplied rect.
-*/
-- (void)webView:(WebView *)sender drawHeaderInRect:(NSRect)rect;
-
-/*!
- @method webView:drawFooterInRect:
- @param webView The WebView sending the delegate method
- @param rect The NSRect reserved for the footer of the page
- @abstract The delegate should draw a footer for the sender in the supplied rect.
-*/
-- (void)webView:(WebView *)sender drawFooterInRect:(NSRect)rect;
-
-// The following delegate methods are deprecated in favor of the ones above that specify
-// the WebFrame whose JavaScript initiated this call.
-- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0);
-- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0);
-- (NSString *)webView:(WebView *)sender runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0);
-
-// The following delegate methods are deprecated. Content rect calculations are now done automatically.
-- (void)webView:(WebView *)sender setContentRect:(NSRect)frame WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0);
-- (NSRect)webViewContentRect:(WebView *)sender WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0);
-
-@end
-
-#undef WebNSUInteger
diff --git a/WebKit/mac/WebView/WebUIDelegatePrivate.h b/WebKit/mac/WebView/WebUIDelegatePrivate.h
deleted file mode 100644
index 6a3c32f..0000000
--- a/WebKit/mac/WebView/WebUIDelegatePrivate.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebUIDelegate.h>
-
-#if !defined(ENABLE_DASHBOARD_SUPPORT)
-#define ENABLE_DASHBOARD_SUPPORT 1
-#endif
-
-// Mail on Tiger expects the old value for WebMenuItemTagSearchInGoogle
-#define WebMenuItemTagSearchInGoogle OldWebMenuItemTagSearchWeb
-
-#define WEBMENUITEMTAG_WEBKIT_3_0_SPI_START 2000
-enum {
- // The next three values were used in WebKit 2.0 for SPI. In WebKit 3.0 these are API, with different values.
- OldWebMenuItemTagSearchInSpotlight = 1000,
- OldWebMenuItemTagSearchWeb,
- OldWebMenuItemTagLookUpInDictionary,
- // FIXME: These should move to WebUIDelegate.h as part of the WebMenuItemTag enum there, when we're not in API freeze
- // Note that these values must be kept aligned with values in WebCore/ContextMenuItem.h
- WebMenuItemTagOpenLink = WEBMENUITEMTAG_WEBKIT_3_0_SPI_START,
- WebMenuItemTagIgnoreGrammar,
- WebMenuItemTagSpellingMenu,
- WebMenuItemTagShowSpellingPanel,
- WebMenuItemTagCheckSpelling,
- WebMenuItemTagCheckSpellingWhileTyping,
- WebMenuItemTagCheckGrammarWithSpelling,
- WebMenuItemTagFontMenu,
- WebMenuItemTagShowFonts,
- WebMenuItemTagBold,
- WebMenuItemTagItalic,
- WebMenuItemTagUnderline,
- WebMenuItemTagOutline,
- WebMenuItemTagStyles,
- WebMenuItemTagShowColors,
- WebMenuItemTagSpeechMenu,
- WebMenuItemTagStartSpeaking,
- WebMenuItemTagStopSpeaking,
- WebMenuItemTagWritingDirectionMenu,
- WebMenuItemTagDefaultDirection,
- WebMenuItemTagLeftToRight,
- WebMenuItemTagRightToLeft,
- WebMenuItemPDFSinglePageScrolling,
- WebMenuItemPDFFacingPagesScrolling,
- WebMenuItemTagInspectElement,
- WebMenuItemTagBaseApplication = 10000
-};
-@class WebSecurityOrigin;
-
-@interface NSObject (WebUIDelegatePrivate)
-
-- (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message;
-
-- (NSView *)webView:(WebView *)webView plugInViewWithArguments:(NSDictionary *)arguments;
-
-#if ENABLE_DASHBOARD_SUPPORT
-// regions is an dictionary whose keys are regions label and values are arrays of WebDashboardRegions.
-- (void)webView:(WebView *)webView dashboardRegionsChanged:(NSDictionary *)regions;
-#endif
-
-- (void)webView:(WebView *)sender dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag forView:(NSView *)view;
-- (void)webView:(WebView *)sender didDrawRect:(NSRect)rect;
-- (void)webView:(WebView *)sender didScrollDocumentInFrameView:(WebFrameView *)frameView;
-// FIXME: If we ever make this method public, it should include a WebFrame parameter.
-- (BOOL)webViewShouldInterruptJavaScript:(WebView *)sender;
-- (void)webView:(WebView *)sender willPopupMenu:(NSMenu *)menu;
-- (void)webView:(WebView *)sender contextMenuItemSelected:(NSMenuItem *)item forElement:(NSDictionary *)element;
-- (void)webView:(WebView *)sender saveFrameView:(WebFrameView *)frameView showingPanel:(BOOL)showingPanel;
-
-/*!
- @method webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:
- @param sender The WebView sending the delegate method.
- @param frame The WebFrame whose JavaScript initiated this call.
- @param origin The security origin that needs a larger quota.
- @param databaseIdentifier The identifier of the database involved.
-*/
-- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)databaseIdentifier;
-
-- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request windowFeatures:(NSDictionary *)features;
-
-- (BOOL)webView:(WebView *)sender shouldReplaceUploadFile:(NSString *)path usingGeneratedFilename:(NSString **)filename;
-- (NSString *)webView:(WebView *)sender generateReplacementFile:(NSString *)path;
-
-@end
diff --git a/WebKit/mac/WebView/WebView.h b/WebKit/mac/WebView/WebView.h
deleted file mode 100644
index 30aa7bd..0000000
--- a/WebKit/mac/WebView/WebView.h
+++ /dev/null
@@ -1,835 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSInteger int
-#else
-#define WebNSInteger NSInteger
-#endif
-
-@class DOMCSSStyleDeclaration;
-@class DOMDocument;
-@class DOMElement;
-@class DOMNode;
-@class DOMRange;
-
-@class WebArchive;
-@class WebBackForwardList;
-@class WebDataSource;
-@class WebFrame;
-@class WebFrameView;
-@class WebHistoryItem;
-@class WebPreferences;
-@class WebScriptObject;
-@class WebViewPrivate;
-
-// Element dictionary keys
-extern NSString *WebElementDOMNodeKey; // DOMNode of the element
-extern NSString *WebElementFrameKey; // WebFrame of the element
-extern NSString *WebElementImageAltStringKey; // NSString of the ALT attribute of the image element
-extern NSString *WebElementImageKey; // NSImage of the image element
-extern NSString *WebElementImageRectKey; // NSValue of an NSRect, the rect of the image element
-extern NSString *WebElementImageURLKey; // NSURL of the image element
-extern NSString *WebElementIsSelectedKey; // NSNumber of BOOL indicating whether the element is selected or not
-extern NSString *WebElementLinkURLKey; // NSURL of the link if the element is within an anchor
-extern NSString *WebElementLinkTargetFrameKey; // WebFrame of the target of the anchor
-extern NSString *WebElementLinkTitleKey; // NSString of the title of the anchor
-extern NSString *WebElementLinkLabelKey; // NSString of the text within the anchor
-
-/*
- @discussion Notifications sent by WebView to mark the progress of loads.
- @constant WebViewProgressStartedNotification Posted whenever a load begins in the WebView, including
- a load that is initiated in a subframe. After receiving this notification zero or more
- WebViewProgressEstimateChangedNotifications will be sent. The userInfo will be nil.
- @constant WebViewProgressEstimateChangedNotification Posted whenever the value of
- estimatedProgress changes. The userInfo will be nil.
- @constant WebViewProgressFinishedNotification Posted when the load for a WebView has finished.
- The userInfo will be nil.
-*/
-extern NSString *WebViewProgressStartedNotification;
-extern NSString *WebViewProgressEstimateChangedNotification;
-extern NSString *WebViewProgressFinishedNotification;
-
-/*!
- @class WebView
- WebView manages the interaction between WebFrameViews and WebDataSources. Modification
- of the policies and behavior of the WebKit is largely managed by WebViews and their
- delegates.
-
- <p>
- Typical usage:
- </p>
- <pre>
- WebView *webView;
- WebFrame *mainFrame;
-
- webView = [[WebView alloc] initWithFrame: NSMakeRect (0,0,640,480)];
- mainFrame = [webView mainFrame];
- [mainFrame loadRequest:request];
- </pre>
-
- WebViews have the following delegates: WebUIDelegate, WebResourceLoadDelegate,
- WebFrameLoadDelegate, and WebPolicyDelegate.
-
- WebKit depends on the WebView's WebUIDelegate for all window
- related management, including opening new windows and controlling the user interface
- elements in those windows.
-
- WebResourceLoadDelegate is used to monitor the progress of resources as they are
- loaded. This delegate may be used to present users with a progress monitor.
-
- The WebFrameLoadDelegate receives messages when the URL in a WebFrame is
- changed.
-
- WebView's WebPolicyDelegate can make determinations about how
- content should be handled, based on the resource's URL and MIME type.
-*/
-@interface WebView : NSView
-{
-@private
- WebViewPrivate *_private;
-}
-
-/*!
- @method canShowMIMEType:
- @abstract Checks if the WebKit can show content of a certain MIME type.
- @param MIMEType The MIME type to check.
- @result YES if the WebKit can show content with MIMEtype.
-*/
-+ (BOOL)canShowMIMEType:(NSString *)MIMEType;
-
-
-/*!
- @method canShowMIMETypeAsHTML:
- @abstract Checks if the the MIME type is a type that the WebKit will interpret as HTML.
- @param MIMEType The MIME type to check.
- @result YES if the MIMEtype in an HTML type.
-*/
-+ (BOOL)canShowMIMETypeAsHTML:(NSString *)MIMEType;
-
-/*!
- @method MIMETypesShownAsHTML
- @result Returns an array of NSStrings that describe the MIME types
- WebKit will attempt to render as HTML.
-*/
-+ (NSArray *)MIMETypesShownAsHTML;
-
-/*!
- @method setMIMETypesShownAsHTML:
- @discussion Sets the array of NSString MIME types that WebKit will
- attempt to render as HTML. Typically you will retrieve the built-in
- array using MIMETypesShownAsHTML and add additional MIME types to that
- array.
-*/
-+ (void)setMIMETypesShownAsHTML:(NSArray *)MIMETypes;
-
-/*!
- @method URLFromPasteboard:
- @abstract Returns a URL from a pasteboard
- @param pasteboard The pasteboard with a URL
- @result A URL if the pasteboard has one. Nil if it does not.
- @discussion This method differs than NSURL's URLFromPasteboard method in that it tries multiple pasteboard types
- including NSURLPboardType to find a URL on the pasteboard.
-*/
-+ (NSURL *)URLFromPasteboard:(NSPasteboard *)pasteboard;
-
-/*!
- @method URLTitleFromPasteboard:
- @abstract Returns a URL title from a pasteboard
- @param pasteboard The pasteboard with a URL title
- @result A URL title if the pasteboard has one. Nil if it does not.
- @discussion This method returns a title that refers a URL on the pasteboard. An example of this is the link label
- which is the text inside the anchor tag.
-*/
-+ (NSString *)URLTitleFromPasteboard:(NSPasteboard *)pasteboard;
-
-/*!
- @method registerURLSchemeAsLocal:
- @abstract Adds the scheme to the list of schemes to be treated as local.
- @param scheme The scheme to register
-*/
-+ (void)registerURLSchemeAsLocal:(NSString *)scheme;
-
-/*!
- @method initWithFrame:frameName:groupName:
- @abstract The designated initializer for WebView.
- @discussion Initialize a WebView with the supplied parameters. This method will
- create a main WebFrame with the view. Passing a top level frame name is useful if you
- handle a targetted frame navigation that would normally open a window in some other
- way that still ends up creating a new WebView.
- @param frame The frame used to create the view.
- @param frameName The name to use for the top level frame. May be nil.
- @param groupName The name of the webView set to which this webView will be added. May be nil.
- @result Returns an initialized WebView.
-*/
-- (id)initWithFrame:(NSRect)frame frameName:(NSString *)frameName groupName:(NSString *)groupName;
-
-/*!
- @method close
- @abstract Closes the receiver, unloading its web page and canceling any pending loads.
- Once the receiver has closed, it will no longer respond to requests or fire delegate methods.
- (However, the -close method itself may fire delegate methods.)
- @discussion A garbage collected application is required to call close when the receiver is no longer needed.
- The close method will be called automatically when the window or hostWindow closes and shouldCloseWithWindow returns YES.
- A non-garbage collected application can still call close, providing a convenient way to prevent receiver
- from doing any more loading and firing any future delegate methods.
-*/
-- (void)close;
-
-/*!
- @method setShouldCloseWithWindow:
- @abstract Set whether the receiver closes when either it's window or hostWindow closes.
- @param close YES if the receiver should close when either it's window or hostWindow closes, otherwise NO.
-*/
-- (void)setShouldCloseWithWindow:(BOOL)close;
-
-/*!
- @method shouldCloseWithWindow
- @abstract Returns whether the receiver closes when either it's window or hostWindow closes.
- @discussion Defaults to YES in garbage collected applications, otherwise NO to maintain backwards compatibility.
- @result YES if the receiver closes when either it's window or hostWindow closes, otherwise NO.
-*/
-- (BOOL)shouldCloseWithWindow;
-
-/*!
- @method setUIDelegate:
- @abstract Set the WebView's WebUIDelegate.
- @param delegate The WebUIDelegate to set as the delegate.
-*/
-- (void)setUIDelegate:(id)delegate;
-
-/*!
- @method UIDelegate
- @abstract Return the WebView's WebUIDelegate.
- @result The WebView's WebUIDelegate.
-*/
-- (id)UIDelegate;
-
-/*!
- @method setResourceLoadDelegate:
- @abstract Set the WebView's WebResourceLoadDelegate load delegate.
- @param delegate The WebResourceLoadDelegate to set as the load delegate.
-*/
-- (void)setResourceLoadDelegate:(id)delegate;
-
-/*!
- @method resourceLoadDelegate
- @result Return the WebView's WebResourceLoadDelegate.
-*/
-- (id)resourceLoadDelegate;
-
-/*!
- @method setDownloadDelegate:
- @abstract Set the WebView's WebDownloadDelegate.
- @discussion The download delegate is retained by WebDownload when any downloads are in progress.
- @param delegate The WebDownloadDelegate to set as the download delegate.
-*/
-- (void)setDownloadDelegate:(id)delegate;
-
-/*!
- @method downloadDelegate
- @abstract Return the WebView's WebDownloadDelegate.
- @result The WebView's WebDownloadDelegate.
-*/
-- (id)downloadDelegate;
-
-/*!
- @method setFrameLoadDelegate:
- @abstract Set the WebView's WebFrameLoadDelegate delegate.
- @param delegate The WebFrameLoadDelegate to set as the delegate.
-*/
-- (void)setFrameLoadDelegate:(id)delegate;
-
-/*!
- @method frameLoadDelegate
- @abstract Return the WebView's WebFrameLoadDelegate delegate.
- @result The WebView's WebFrameLoadDelegate delegate.
-*/
-- (id)frameLoadDelegate;
-
-/*!
- @method setPolicyDelegate:
- @abstract Set the WebView's WebPolicyDelegate delegate.
- @param delegate The WebPolicyDelegate to set as the delegate.
-*/
-- (void)setPolicyDelegate:(id)delegate;
-
-/*!
- @method policyDelegate
- @abstract Return the WebView's WebPolicyDelegate.
- @result The WebView's WebPolicyDelegate.
-*/
-- (id)policyDelegate;
-
-/*!
- @method mainFrame
- @abstract Return the top level frame.
- @discussion Note that even document that are not framesets will have a
- mainFrame.
- @result The main frame.
-*/
-- (WebFrame *)mainFrame;
-
-/*!
- @method selectedFrame
- @abstract Return the frame that has the active selection.
- @discussion Returns the frame that contains the first responder, if any. Otherwise returns the
- frame that contains a non-zero-length selection, if any. Returns nil if no frame meets these criteria.
- @result The selected frame.
-*/
-- (WebFrame *)selectedFrame;
-
-/*!
- @method backForwardList
- @result The backforward list for this webView.
-*/
-- (WebBackForwardList *)backForwardList;
-
-/*!
- @method setMaintainsBackForwardList:
- @abstract Enable or disable the use of a backforward list for this webView.
- @param flag Turns use of the back forward list on or off
-*/
-- (void)setMaintainsBackForwardList:(BOOL)flag;
-
-/*!
- @method goBack
- @abstract Go back to the previous URL in the backforward list.
- @result YES if able to go back in the backforward list, NO otherwise.
-*/
-- (BOOL)goBack;
-
-/*!
- @method goForward
- @abstract Go forward to the next URL in the backforward list.
- @result YES if able to go forward in the backforward list, NO otherwise.
-*/
-- (BOOL)goForward;
-
-/*!
- @method goToBackForwardItem:
- @abstract Go back or forward to an item in the backforward list.
- @result YES if able to go to the item, NO otherwise.
-*/
-- (BOOL)goToBackForwardItem:(WebHistoryItem *)item;
-
-/*!
- @method setTextSizeMultiplier:
- @abstract Change the size of the text rendering in views managed by this webView.
- @param multiplier A fractional percentage value, 1.0 is 100%.
-*/
-- (void)setTextSizeMultiplier:(float)multiplier;
-
-/*!
- @method textSizeMultiplier
- @result The text size multipler.
-*/
-- (float)textSizeMultiplier;
-
-/*!
- @method setApplicationNameForUserAgent:
- @abstract Set the application name.
- @discussion This name will be used in user-agent strings
- that are chosen for best results in rendering web pages.
- @param applicationName The application name
-*/
-- (void)setApplicationNameForUserAgent:(NSString *)applicationName;
-
-/*!
- @method applicationNameForUserAgent
- @result The name of the application as used in the user-agent string.
-*/
-- (NSString *)applicationNameForUserAgent;
-
-/*!
- @method setCustomUserAgent:
- @abstract Set the user agent.
- @discussion Setting this means that the webView should use this user-agent string
- instead of constructing a user-agent string for each URL. Setting it to nil
- causes the webView to construct the user-agent string for each URL
- for best results rendering web pages.
- @param userAgentString The user agent description
-*/
-- (void)setCustomUserAgent:(NSString *)userAgentString;
-
-/*!
- @method customUserAgent
- @result The custom user-agent string or nil if no custom user-agent string has been set.
-*/
-- (NSString *)customUserAgent;
-
-/*!
- @method userAgentForURL:
- @abstract Get the appropriate user-agent string for a particular URL.
- @param URL The URL.
- @result The user-agent string for the supplied URL.
-*/
-- (NSString *)userAgentForURL:(NSURL *)URL;
-
-
-/*!
- @method supportsTextEncoding
- @abstract Find out if the current web page supports text encodings.
- @result YES if the document view of the current web page can
- support different text encodings.
-*/
-- (BOOL)supportsTextEncoding;
-
-/*!
- @method setCustomTextEncodingName:
- @discussion Make the page display with a different text encoding; stops any load in progress.
- The text encoding passed in overrides the normal text encoding smarts including
- what's specified in a web page's header or HTTP response.
- The text encoding automatically goes back to the default when the top level frame
- changes to a new location.
- Setting the text encoding name to nil makes the webView use default encoding rules.
- @param encoding The text encoding name to use to display a page or nil.
-*/
-- (void)setCustomTextEncodingName:(NSString *)encodingName;
-
-/*!
- @method customTextEncodingName
- @result The custom text encoding name or nil if no custom text encoding name has been set.
-*/
-- (NSString *)customTextEncodingName;
-
-/*!
- @method setMediaStyle:
- @discussion Set the media style for the WebView. The mediaStyle will override the normal value
- of the CSS media property. Setting the value to nil will restore the normal value.
- @param mediaStyle The value to use for the CSS media property.
-*/
-- (void)setMediaStyle:(NSString *)mediaStyle;
-
-/*!
- @method mediaStyle
- @result mediaStyle The value to use for the CSS media property, as set by setMediaStyle:. It
- will be nil unless set by that method.
-*/
-- (NSString *)mediaStyle;
-
-/*!
- @method stringByEvaluatingJavaScriptFromString:
- @param script The text of the JavaScript.
- @result The result of the script, converted to a string, or nil for failure.
-*/
-- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script;
-
-/*!
- @method windowScriptObject
- @discussion windowScriptObject return a WebScriptObject that represents the
- window object from the script environment.
- @result Returns the window object from the script environment.
-*/
-- (WebScriptObject *)windowScriptObject;
-
-/*!
- @method setPreferences:
- @param preferences The preferences to use for the webView.
- @abstract Override the standard setting for the webView.
-*/
-- (void)setPreferences: (WebPreferences *)prefs;
-
-/*!
- @method preferences
- @result Returns the preferences used by this webView.
- @discussion This method will return [WebPreferences standardPreferences] if no
- other instance of WebPreferences has been set.
-*/
-- (WebPreferences *)preferences;
-
-/*!
- @method setPreferencesIdentifier:
- @param anIdentifier The string to use a prefix for storing values for this WebView in the user
- defaults database.
- @discussion If the WebPreferences for this WebView are stored in the user defaults database, the
- string set in this method will be used a key prefix.
-*/
-- (void)setPreferencesIdentifier:(NSString *)anIdentifier;
-
-/*!
- @method preferencesIdentifier
- @result Returns the WebPreferences key prefix.
-*/
-- (NSString *)preferencesIdentifier;
-
-
-/*!
- @method setHostWindow:
- @param hostWindow The host window for the web view.
- @discussion Parts of WebKit (such as plug-ins and JavaScript) depend on a window to function
- properly. Set a host window so these parts continue to function even when the web view is
- not in an actual window.
-*/
-- (void)setHostWindow:(NSWindow *)hostWindow;
-
-/*!
- @method hostWindow
- @result The host window for the web view.
-*/
-- (NSWindow *)hostWindow;
-
-/*!
- @method searchFor:direction:caseSensitive:
- @abstract Searches a document view for a string and highlights the string if it is found.
- Starts the search from the current selection. Will search across all frames.
- @param string The string to search for.
- @param forward YES to search forward, NO to seach backwards.
- @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
- @result YES if found, NO if not found.
-*/
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag;
-
-/*!
- @method registerViewClass:representationClass:forMIMEType:
- @discussion Register classes that implement WebDocumentView and WebDocumentRepresentation respectively.
- A document class may register for a primary MIME type by excluding
- a subtype, i.e. "video/" will match the document class with
- all video types. More specific matching takes precedence
- over general matching.
- @param viewClass The WebDocumentView class to use to render data for a given MIME type.
- @param representationClass The WebDocumentRepresentation class to use to represent data of the given MIME type.
- @param MIMEType The MIME type to represent with an object of the given class.
-*/
-+ (void)registerViewClass:(Class)viewClass representationClass:(Class)representationClass forMIMEType:(NSString *)MIMEType;
-
-
-/*!
- @method setGroupName:
- @param groupName The name of the group for this WebView.
- @discussion JavaScript may access named frames within the same group.
-*/
-- (void)setGroupName:(NSString *)groupName;
-
-/*!
- @method groupName
- @discussion The group name for this WebView.
-*/
-- (NSString *)groupName;
-
-/*!
- @method estimatedProgress
- @discussion An estimate of the percent complete for a document load. This
- value will range from 0 to 1.0 and, once a load completes, will remain at 1.0
- until a new load starts, at which point it will be reset to 0. The value is an
- estimate based on the total number of bytes expected to be received
- for a document, including all it's possible subresources. For more accurate progress
- indication it is recommended that you implement a WebFrameLoadDelegate and a
- WebResourceLoadDelegate.
-*/
-- (double)estimatedProgress;
-
-/*!
- @method isLoading
- @discussion Returns YES if there are any pending loads.
-*/
-- (BOOL)isLoading;
-
-/*!
- @method elementAtPoint:
- @param point A point in the coordinates of the WebView
- @result An element dictionary describing the point
-*/
-- (NSDictionary *)elementAtPoint:(NSPoint)point;
-
-/*!
- @method pasteboardTypesForSelection
- @abstract Returns the pasteboard types that WebView can use for the current selection
-*/
-- (NSArray *)pasteboardTypesForSelection;
-
-/*!
- @method writeSelectionWithPasteboardTypes:toPasteboard:
- @abstract Writes the current selection to the pasteboard
- @param types The types that WebView will write to the pasteboard
- @param pasteboard The pasteboard to write to
-*/
-- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
-
-/*!
- @method pasteboardTypesForElement:
- @abstract Returns the pasteboard types that WebView can use for an element
- @param element The element
-*/
-- (NSArray *)pasteboardTypesForElement:(NSDictionary *)element;
-
-/*!
- @method writeElement:withPasteboardTypes:toPasteboard:
- @abstract Writes an element to the pasteboard
- @param element The element to write to the pasteboard
- @param types The types that WebView will write to the pasteboard
- @param pasteboard The pasteboard to write to
-*/
-- (void)writeElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
-
-/*!
- @method moveDragCaretToPoint:
- @param point A point in the coordinates of the WebView
- @discussion This method moves the caret that shows where something being dragged will be dropped. It may cause the WebView to scroll
- to make the new position of the drag caret visible.
-*/
-- (void)moveDragCaretToPoint:(NSPoint)point;
-
-/*!
- @method removeDragCaret
- @abstract Removes the drag caret from the WebView
-*/
-- (void)removeDragCaret;
-
-/*!
- @method setDrawsBackground:
- @param drawsBackround YES to cause the receiver to draw a default white background, NO otherwise.
- @abstract Sets whether the receiver draws a default white background when the loaded page has no background specified.
-*/
-- (void)setDrawsBackground:(BOOL)drawsBackround;
-
-/*!
- @method drawsBackground
- @result Returns YES if the receiver draws a default white background, NO otherwise.
-*/
-- (BOOL)drawsBackground;
-
-/*!
- @method setShouldUpdateWhileOffscreen:
- @abstract Sets whether the receiver must update even when it is not in a window that is currently visible.
- @param updateWhileOffscreen whether the receiver is required to render updates to the web page when it is not in a visible window.
- @abstract If set to NO, then whenever the web view is not in a visible window, updates to the web page will not necessarily be rendered in the view.
- However, when the window is made visible, the view will be updated automatically. Not updating while hidden can improve performance. If set to is YES,
- hidden web views are always updated. This is the default.
-*/
-- (void)setShouldUpdateWhileOffscreen:(BOOL)updateWhileOffscreen;
-
-/*!
- @method shouldUpdateWhileOffscreen
- @result Returns whether the web view is always updated even when it is not in a window that is currently visible.
-*/
-- (BOOL)shouldUpdateWhileOffscreen;
-
-/*!
- @method setMainFrameURL:
- @param URLString The URL to load in the mainFrame.
-*/
-- (void)setMainFrameURL:(NSString *)URLString;
-
-/*!
- @method mainFrameURL
- @result Returns the main frame's current URL.
-*/
-- (NSString *)mainFrameURL;
-
-/*!
- @method mainFrameDocument
- @result Returns the main frame's DOMDocument.
-*/
-- (DOMDocument *)mainFrameDocument;
-
-/*!
- @method mainFrameTitle
- @result Returns the main frame's title if any, otherwise an empty string.
-*/
-- (NSString *)mainFrameTitle;
-
-/*!
- @method mainFrameIcon
- @discussion The methods returns the site icon for the current page loaded in the mainFrame.
- @result Returns the main frame's icon if any, otherwise nil.
-*/
-- (NSImage *)mainFrameIcon;
-
-@end
-
-
-@interface WebView (WebIBActions) <NSUserInterfaceValidations>
-- (IBAction)takeStringURLFrom:(id)sender;
-- (IBAction)stopLoading:(id)sender;
-- (IBAction)reload:(id)sender;
-- (BOOL)canGoBack;
-- (IBAction)goBack:(id)sender;
-- (BOOL)canGoForward;
-- (IBAction)goForward:(id)sender;
-- (BOOL)canMakeTextLarger;
-- (IBAction)makeTextLarger:(id)sender;
-- (BOOL)canMakeTextSmaller;
-- (IBAction)makeTextSmaller:(id)sender;
-- (BOOL)canMakeTextStandardSize;
-- (IBAction)makeTextStandardSize:(id)sender;
-- (IBAction)toggleContinuousSpellChecking:(id)sender;
-- (IBAction)toggleSmartInsertDelete:(id)sender;
-@end
-
-
-// WebView editing support
-
-extern NSString * const WebViewDidBeginEditingNotification;
-extern NSString * const WebViewDidChangeNotification;
-extern NSString * const WebViewDidEndEditingNotification;
-extern NSString * const WebViewDidChangeTypingStyleNotification;
-extern NSString * const WebViewDidChangeSelectionNotification;
-
-@interface WebView (WebViewCSS)
-- (DOMCSSStyleDeclaration *)computedStyleForElement:(DOMElement *)element pseudoElement:(NSString *)pseudoElement;
-@end
-
-@interface WebView (WebViewEditing)
-- (DOMRange *)editableDOMRangeForPoint:(NSPoint)point;
-- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)selectionAffinity;
-- (DOMRange *)selectedDOMRange;
-- (NSSelectionAffinity)selectionAffinity;
-- (BOOL)maintainsInactiveSelection;
-- (void)setEditable:(BOOL)flag;
-- (BOOL)isEditable;
-- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style;
-- (DOMCSSStyleDeclaration *)typingStyle;
-- (void)setSmartInsertDeleteEnabled:(BOOL)flag;
-- (BOOL)smartInsertDeleteEnabled;
-- (void)setContinuousSpellCheckingEnabled:(BOOL)flag;
-- (BOOL)isContinuousSpellCheckingEnabled;
-- (WebNSInteger)spellCheckerDocumentTag;
-- (NSUndoManager *)undoManager;
-- (void)setEditingDelegate:(id)delegate;
-- (id)editingDelegate;
-- (DOMCSSStyleDeclaration *)styleDeclarationWithText:(NSString *)text;
-@end
-
-@interface WebView (WebViewUndoableEditing)
-- (void)replaceSelectionWithNode:(DOMNode *)node;
-- (void)replaceSelectionWithText:(NSString *)text;
-- (void)replaceSelectionWithMarkupString:(NSString *)markupString;
-- (void)replaceSelectionWithArchive:(WebArchive *)archive;
-- (void)deleteSelection;
-- (void)applyStyle:(DOMCSSStyleDeclaration *)style;
-@end
-
-@interface WebView (WebViewEditingActions)
-
-- (void)copy:(id)sender;
-- (void)cut:(id)sender;
-- (void)paste:(id)sender;
-- (void)copyFont:(id)sender;
-- (void)pasteFont:(id)sender;
-- (void)delete:(id)sender;
-- (void)pasteAsPlainText:(id)sender;
-- (void)pasteAsRichText:(id)sender;
-
-- (void)changeFont:(id)sender;
-- (void)changeAttributes:(id)sender;
-- (void)changeDocumentBackgroundColor:(id)sender;
-- (void)changeColor:(id)sender;
-
-- (void)alignCenter:(id)sender;
-- (void)alignJustified:(id)sender;
-- (void)alignLeft:(id)sender;
-- (void)alignRight:(id)sender;
-
-- (void)checkSpelling:(id)sender;
-- (void)showGuessPanel:(id)sender;
-- (void)performFindPanelAction:(id)sender;
-
-- (void)startSpeaking:(id)sender;
-- (void)stopSpeaking:(id)sender;
-
-- (void)moveToBeginningOfSentence:(id)sender;
-- (void)moveToBeginningOfSentenceAndModifySelection:(id)sender;
-- (void)moveToEndOfSentence:(id)sender;
-- (void)moveToEndOfSentenceAndModifySelection:(id)sender;
-- (void)selectSentence:(id)sender;
-
-/*
-The following methods are declared in NSResponder.h.
-WebView overrides each method in this list, providing
-a custom implementation for each.
-
-- (void)capitalizeWord:(id)sender;
-- (void)centerSelectionInVisibleArea:(id)sender;
-- (void)changeCaseOfLetter:(id)sender;
-- (void)complete:(id)sender;
-- (void)deleteBackward:(id)sender;
-- (void)deleteBackwardByDecomposingPreviousCharacter:(id)sender;
-- (void)deleteForward:(id)sender;
-- (void)deleteToBeginningOfLine:(id)sender;
-- (void)deleteToBeginningOfParagraph:(id)sender;
-- (void)deleteToEndOfLine:(id)sender;
-- (void)deleteToEndOfParagraph:(id)sender;
-- (void)deleteWordBackward:(id)sender;
-- (void)deleteWordForward:(id)sender;
-- (void)indent:(id)sender;
-- (void)insertBacktab:(id)sender;
-- (void)insertNewline:(id)sender;
-- (void)insertParagraphSeparator:(id)sender;
-- (void)insertTab:(id)sender;
-- (void)lowercaseWord:(id)sender;
-- (void)moveBackward:(id)sender;
-- (void)moveBackwardAndModifySelection:(id)sender;
-- (void)moveDown:(id)sender;
-- (void)moveDownAndModifySelection:(id)sender;
-- (void)moveForward:(id)sender;
-- (void)moveForwardAndModifySelection:(id)sender;
-- (void)moveLeft:(id)sender;
-- (void)moveLeftAndModifySelection:(id)sender;
-- (void)moveRight:(id)sender;
-- (void)moveRightAndModifySelection:(id)sender;
-- (void)moveToBeginningOfDocument:(id)sender;
-- (void)moveToBeginningOfDocumentAndModifySelection:(id)sender;
-- (void)moveToBeginningOfLine:(id)sender;
-- (void)moveToBeginningOfLineAndModifySelection:(id)sender;
-- (void)moveToBeginningOfParagraph:(id)sender;
-- (void)moveToBeginningOfParagraphAndModifySelection:(id)sender;
-- (void)moveToEndOfDocument:(id)sender;
-- (void)moveToEndOfDocumentAndModifySelection:(id)sender;
-- (void)moveToEndOfLine:(id)sender;
-- (void)moveToEndOfLineAndModifySelection:(id)sender;
-- (void)moveToEndOfParagraph:(id)sender;
-- (void)moveToEndOfParagraphAndModifySelection:(id)sender;
-- (void)moveUp:(id)sender;
-- (void)moveUpAndModifySelection:(id)sender;
-- (void)moveWordBackward:(id)sender;
-- (void)moveWordBackwardAndModifySelection:(id)sender;
-- (void)moveWordForward:(id)sender;
-- (void)moveWordForwardAndModifySelection:(id)sender;
-- (void)moveWordLeft:(id)sender;
-- (void)moveWordLeftAndModifySelection:(id)sender;
-- (void)moveWordRight:(id)sender;
-- (void)moveWordRightAndModifySelection:(id)sender;
-- (void)pageDown:(id)sender;
-- (void)pageUp:(id)sender;
-- (void)scrollLineDown:(id)sender;
-- (void)scrollLineUp:(id)sender;
-- (void)scrollPageDown:(id)sender;
-- (void)scrollPageUp:(id)sender;
-- (void)selectAll:(id)sender;
-- (void)selectLine:(id)sender;
-- (void)selectParagraph:(id)sender;
-- (void)selectWord:(id)sender;
-- (void)uppercaseWord:(id)sender;
-*/
-
-@end
-
-#undef WebNSInteger
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
deleted file mode 100644
index a52d3b5..0000000
--- a/WebKit/mac/WebView/WebView.mm
+++ /dev/null
@@ -1,5222 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 David Smith (catfish.man@gmail.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebViewInternal.h"
-
-#import "DOMRangeInternal.h"
-#import "WebBackForwardListInternal.h"
-#import "WebBaseNetscapePluginView.h"
-#import "WebChromeClient.h"
-#import "WebContextMenuClient.h"
-#import "WebDOMOperationsPrivate.h"
-#import "WebDataSourceInternal.h"
-#import "WebDatabaseManagerInternal.h"
-#import "WebDefaultEditingDelegate.h"
-#import "WebDefaultPolicyDelegate.h"
-#import "WebDefaultScriptDebugDelegate.h"
-#import "WebDefaultUIDelegate.h"
-#import "WebDocument.h"
-#import "WebDocumentInternal.h"
-#import "WebDownload.h"
-#import "WebDownloadInternal.h"
-#import "WebDragClient.h"
-#import "WebDynamicScrollBarsViewInternal.h"
-#import "WebEditingDelegate.h"
-#import "WebEditorClient.h"
-#import "WebFormDelegatePrivate.h"
-#import "WebFrameInternal.h"
-#import "WebFrameViewInternal.h"
-#import "WebHTMLRepresentation.h"
-#import "WebHTMLViewInternal.h"
-#import "WebHistoryItemInternal.h"
-#import "WebIconDatabaseInternal.h"
-#import "WebInspector.h"
-#import "WebInspectorClient.h"
-#import "WebKitErrors.h"
-#import "WebKitLogging.h"
-#import "WebKitNSStringExtras.h"
-#import "WebKitStatisticsPrivate.h"
-#import "WebKitSystemBits.h"
-#import "WebKitVersionChecks.h"
-#import "WebLocalizableStrings.h"
-#import "WebNodeHighlight.h"
-#import "WebNSDataExtras.h"
-#import "WebNSDataExtrasPrivate.h"
-#import "WebNSDictionaryExtras.h"
-#import "WebNSEventExtras.h"
-#import "WebNSObjectExtras.h"
-#import "WebNSPasteboardExtras.h"
-#import "WebNSPrintOperationExtras.h"
-#import "WebNSURLExtras.h"
-#import "WebNSURLRequestExtras.h"
-#import "WebNSUserDefaultsExtras.h"
-#import "WebNSViewExtras.h"
-#import "WebPDFView.h"
-#import "WebPanelAuthenticationHandler.h"
-#import "WebPasteboardHelper.h"
-#import "WebPluginDatabase.h"
-#import "WebPolicyDelegate.h"
-#import "WebPreferenceKeysPrivate.h"
-#import "WebPreferencesPrivate.h"
-#import "WebTextIterator.h"
-#import "WebUIDelegate.h"
-#import "WebUIDelegatePrivate.h"
-#import <CoreFoundation/CFSet.h>
-#import <Foundation/NSURLConnection.h>
-#import <WebCore/ApplicationCacheStorage.h>
-#import <WebCore/Cache.h>
-#import <WebCore/ColorMac.h>
-#import <WebCore/Document.h>
-#import <WebCore/DocumentLoader.h>
-#import <WebCore/DragController.h>
-#import <WebCore/DragData.h>
-#import <WebCore/Editor.h>
-#import <WebCore/EventHandler.h>
-#import <WebCore/ExceptionHandlers.h>
-#import <WebCore/FocusController.h>
-#import <WebCore/Frame.h>
-#import <WebCore/FrameLoader.h>
-#import <WebCore/FrameView.h>
-#import <WebCore/FrameTree.h>
-#import <WebCore/GCController.h>
-#import <WebCore/HTMLNames.h>
-#import <WebCore/HistoryItem.h>
-#import <WebCore/Logging.h>
-#import <WebCore/MIMETypeRegistry.h>
-#import <WebCore/Page.h>
-#import <WebCore/PageCache.h>
-#import <WebCore/PageGroup.h>
-#import <WebCore/PlatformMouseEvent.h>
-#import <WebCore/ProgressTracker.h>
-#import <WebCore/ScriptController.h>
-#import <WebCore/SelectionController.h>
-#import <WebCore/Settings.h>
-#import <WebCore/TextResourceDecoder.h>
-#import <WebCore/WebCoreObjCExtras.h>
-#import <WebCore/WebCoreTextRenderer.h>
-#import <WebCore/WebCoreView.h>
-#import <WebKit/DOM.h>
-#import <WebKit/DOMExtensions.h>
-#import <WebKit/DOMPrivate.h>
-#import <WebKitSystemInterface.h>
-#import <runtime/ArrayPrototype.h>
-#import <runtime/DateInstance.h>
-#import <runtime/InitializeThreading.h>
-#import <runtime/JSLock.h>
-#import <mach-o/dyld.h>
-#import <objc/objc-auto.h>
-#import <objc/objc-runtime.h>
-#import <wtf/Assertions.h>
-#import <wtf/HashTraits.h>
-#import <wtf/RefCountedLeakCounter.h>
-#import <wtf/RefPtr.h>
-
-#if ENABLE(DASHBOARD_SUPPORT)
-#import <WebKit/WebDashboardRegion.h>
-#endif
-
-using namespace WebCore;
-using namespace JSC;
-
-#if defined(__ppc__) || defined(__ppc64__)
-#define PROCESSOR "PPC"
-#elif defined(__i386__) || defined(__x86_64__)
-#define PROCESSOR "Intel"
-#else
-#error Unknown architecture
-#endif
-
-#define FOR_EACH_RESPONDER_SELECTOR(macro) \
-macro(alignCenter) \
-macro(alignJustified) \
-macro(alignLeft) \
-macro(alignRight) \
-macro(capitalizeWord) \
-macro(centerSelectionInVisibleArea) \
-macro(changeAttributes) \
-macro(changeBaseWritingDirection) \
-macro(changeBaseWritingDirectionToLTR) \
-macro(changeBaseWritingDirectionToRTL) \
-macro(changeColor) \
-macro(changeDocumentBackgroundColor) \
-macro(changeFont) \
-macro(changeSpelling) \
-macro(checkSpelling) \
-macro(complete) \
-macro(copy) \
-macro(copyFont) \
-macro(cut) \
-macro(delete) \
-macro(deleteBackward) \
-macro(deleteBackwardByDecomposingPreviousCharacter) \
-macro(deleteForward) \
-macro(deleteToBeginningOfLine) \
-macro(deleteToBeginningOfParagraph) \
-macro(deleteToEndOfLine) \
-macro(deleteToEndOfParagraph) \
-macro(deleteToMark) \
-macro(deleteWordBackward) \
-macro(deleteWordForward) \
-macro(ignoreSpelling) \
-macro(indent) \
-macro(insertBacktab) \
-macro(insertLineBreak) \
-macro(insertNewline) \
-macro(insertNewlineIgnoringFieldEditor) \
-macro(insertParagraphSeparator) \
-macro(insertTab) \
-macro(insertTabIgnoringFieldEditor) \
-macro(lowercaseWord) \
-macro(moveBackward) \
-macro(moveBackwardAndModifySelection) \
-macro(moveDown) \
-macro(moveDownAndModifySelection) \
-macro(moveForward) \
-macro(moveForwardAndModifySelection) \
-macro(moveLeft) \
-macro(moveLeftAndModifySelection) \
-macro(moveParagraphBackwardAndModifySelection) \
-macro(moveParagraphForwardAndModifySelection) \
-macro(moveRight) \
-macro(moveRightAndModifySelection) \
-macro(moveToBeginningOfDocument) \
-macro(moveToBeginningOfDocumentAndModifySelection) \
-macro(moveToBeginningOfLine) \
-macro(moveToBeginningOfLineAndModifySelection) \
-macro(moveToBeginningOfParagraph) \
-macro(moveToBeginningOfParagraphAndModifySelection) \
-macro(moveToBeginningOfSentence) \
-macro(moveToBeginningOfSentenceAndModifySelection) \
-macro(moveToEndOfDocument) \
-macro(moveToEndOfDocumentAndModifySelection) \
-macro(moveToEndOfLine) \
-macro(moveToEndOfLineAndModifySelection) \
-macro(moveToEndOfParagraph) \
-macro(moveToEndOfParagraphAndModifySelection) \
-macro(moveToEndOfSentence) \
-macro(moveToEndOfSentenceAndModifySelection) \
-macro(moveUp) \
-macro(moveUpAndModifySelection) \
-macro(moveWordBackward) \
-macro(moveWordBackwardAndModifySelection) \
-macro(moveWordForward) \
-macro(moveWordForwardAndModifySelection) \
-macro(moveWordLeft) \
-macro(moveWordLeftAndModifySelection) \
-macro(moveWordRight) \
-macro(moveWordRightAndModifySelection) \
-macro(outdent) \
-macro(pageDown) \
-macro(pageDownAndModifySelection) \
-macro(pageUp) \
-macro(pageUpAndModifySelection) \
-macro(paste) \
-macro(pasteAsPlainText) \
-macro(pasteAsRichText) \
-macro(pasteFont) \
-macro(performFindPanelAction) \
-macro(scrollLineDown) \
-macro(scrollLineUp) \
-macro(scrollPageDown) \
-macro(scrollPageUp) \
-macro(scrollToBeginningOfDocument) \
-macro(scrollToEndOfDocument) \
-macro(selectAll) \
-macro(selectLine) \
-macro(selectParagraph) \
-macro(selectSentence) \
-macro(selectToMark) \
-macro(selectWord) \
-macro(setMark) \
-macro(showGuessPanel) \
-macro(startSpeaking) \
-macro(stopSpeaking) \
-macro(subscript) \
-macro(superscript) \
-macro(swapWithMark) \
-macro(takeFindStringFromSelection) \
-macro(toggleBaseWritingDirection) \
-macro(transpose) \
-macro(underline) \
-macro(unscript) \
-macro(uppercaseWord) \
-macro(yank) \
-macro(yankAndSelect) \
-
-#define WebKitOriginalTopPrintingMarginKey @"WebKitOriginalTopMargin"
-#define WebKitOriginalBottomPrintingMarginKey @"WebKitOriginalBottomMargin"
-
-#define KeyboardUIModeDidChangeNotification @"com.apple.KeyboardUIModeDidChange"
-#define AppleKeyboardUIMode CFSTR("AppleKeyboardUIMode")
-#define UniversalAccessDomain CFSTR("com.apple.universalaccess")
-
-static BOOL s_didSetCacheModel;
-static WebCacheModel s_cacheModel = WebCacheModelDocumentViewer;
-
-static BOOL applicationIsTerminating;
-static int pluginDatabaseClientCount = 0;
-
-#ifndef NDEBUG
-static const char webViewIsOpen[] = "At least one WebView is still open.";
-#endif
-
-@interface NSSpellChecker (AppKitSecretsIKnow)
-- (void)_preflightChosenSpellServer;
-@end
-
-@interface NSView (AppKitSecretsIKnow)
-- (NSView *)_hitTest:(NSPoint *)aPoint dragTypes:(NSSet *)types;
-- (void)_autoscrollForDraggingInfo:(id)dragInfo timeDelta:(NSTimeInterval)repeatDelta;
-- (BOOL)_shouldAutoscrollForDraggingInfo:(id)dragInfo;
-@end
-
-@interface NSWindow (AppKitSecretsIKnow)
-- (id)_oldFirstResponderBeforeBecoming;
-@end
-
-@interface NSObject (ValidateWithoutDelegate)
-- (BOOL)validateUserInterfaceItemWithoutDelegate:(id <NSValidatedUserInterfaceItem>)item;
-@end
-
-@interface _WebSafeForwarder : NSObject
-{
- id target; // Non-retained. Don't retain delegates.
- id defaultTarget;
- BOOL catchExceptions;
-}
-- (id)initWithTarget:(id)target defaultTarget:(id)defaultTarget catchExceptions:(BOOL)catchExceptions;
-@end
-
-@interface WebViewPrivate : NSObject {
-@public
- Page* page;
-
- id UIDelegate;
- id UIDelegateForwarder;
- id resourceProgressDelegate;
- id downloadDelegate;
- id policyDelegate;
- id policyDelegateForwarder;
- id frameLoadDelegate;
- id frameLoadDelegateForwarder;
- id <WebFormDelegate> formDelegate;
- id editingDelegate;
- id editingDelegateForwarder;
- id scriptDebugDelegate;
- id scriptDebugDelegateForwarder;
-
- WebInspector *inspector;
- WebNodeHighlight *currentNodeHighlight;
-
- BOOL allowsUndo;
-
- float zoomMultiplier;
- BOOL zoomMultiplierIsTextOnly;
-
- NSString *applicationNameForUserAgent;
- String userAgent;
- BOOL userAgentOverridden;
-
- WebPreferences *preferences;
- BOOL useSiteSpecificSpoofing;
-
- NSWindow *hostWindow;
-
- int programmaticFocusCount;
-
- WebResourceDelegateImplementationCache resourceLoadDelegateImplementations;
- WebFrameLoadDelegateImplementationCache frameLoadDelegateImplementations;
-
- void *observationInfo;
-
- BOOL closed;
- BOOL shouldCloseWithWindow;
- BOOL mainFrameDocumentReady;
- BOOL drawsBackground;
- BOOL editable;
- BOOL tabKeyCyclesThroughElementsChanged;
- BOOL becomingFirstResponder;
- BOOL becomingFirstResponderFromOutside;
- BOOL hoverFeedbackSuspended;
- BOOL usesPageCache;
- BOOL catchesDelegateExceptions;
-
- NSColor *backgroundColor;
-
- NSString *mediaStyle;
-
- BOOL hasSpellCheckerDocumentTag;
- NSInteger spellCheckerDocumentTag;
-
- BOOL smartInsertDeleteEnabled;
-
-#if ENABLE(DASHBOARD_SUPPORT)
- BOOL dashboardBehaviorAlwaysSendMouseEventsToAllWindows;
- BOOL dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns;
- BOOL dashboardBehaviorAlwaysAcceptsFirstMouse;
- BOOL dashboardBehaviorAllowWheelScrolling;
-#endif
-
- // WebKit has both a global plug-in database and a separate, per WebView plug-in database. Dashboard uses the per WebView database.
- WebPluginDatabase *pluginDatabase;
-
- HashMap<unsigned long, RetainPtr<id> > identifierMap;
-
- BOOL _keyboardUIModeAccessed;
- KeyboardUIMode _keyboardUIMode;
-
- BOOL shouldUpdateWhileOffscreen;
-
- // When this flag is set, we will not make any subviews underneath this WebView. This means no WebFrameViews and no WebHTMLViews.
- BOOL useDocumentViews;
-}
-@end
-
-@interface WebView (WebFileInternal)
-- (WebFrame *)_selectedOrMainFrame;
-- (BOOL)_isLoading;
-- (WebFrameView *)_frameViewAtWindowPoint:(NSPoint)point;
-- (WebFrame *)_focusedFrame;
-+ (void)_preflightSpellChecker;
-- (BOOL)_continuousCheckingAllowed;
-- (NSResponder *)_responderForResponderOperations;
-@end
-
-@interface WebView (WebCallDelegateFunctions)
-@end
-
-NSString *WebElementDOMNodeKey = @"WebElementDOMNode";
-NSString *WebElementFrameKey = @"WebElementFrame";
-NSString *WebElementImageKey = @"WebElementImage";
-NSString *WebElementImageAltStringKey = @"WebElementImageAltString";
-NSString *WebElementImageRectKey = @"WebElementImageRect";
-NSString *WebElementImageURLKey = @"WebElementImageURL";
-NSString *WebElementIsSelectedKey = @"WebElementIsSelected";
-NSString *WebElementLinkLabelKey = @"WebElementLinkLabel";
-NSString *WebElementLinkTargetFrameKey = @"WebElementTargetFrame";
-NSString *WebElementLinkTitleKey = @"WebElementLinkTitle";
-NSString *WebElementLinkURLKey = @"WebElementLinkURL";
-NSString *WebElementSpellingToolTipKey = @"WebElementSpellingToolTip";
-NSString *WebElementTitleKey = @"WebElementTitle";
-NSString *WebElementLinkIsLiveKey = @"WebElementLinkIsLive";
-NSString *WebElementIsContentEditableKey = @"WebElementIsContentEditableKey";
-
-NSString *WebViewProgressStartedNotification = @"WebProgressStartedNotification";
-NSString *WebViewProgressEstimateChangedNotification = @"WebProgressEstimateChangedNotification";
-NSString *WebViewProgressFinishedNotification = @"WebProgressFinishedNotification";
-
-NSString * const WebViewDidBeginEditingNotification = @"WebViewDidBeginEditingNotification";
-NSString * const WebViewDidChangeNotification = @"WebViewDidChangeNotification";
-NSString * const WebViewDidEndEditingNotification = @"WebViewDidEndEditingNotification";
-NSString * const WebViewDidChangeTypingStyleNotification = @"WebViewDidChangeTypingStyleNotification";
-NSString * const WebViewDidChangeSelectionNotification = @"WebViewDidChangeSelectionNotification";
-
-enum { WebViewVersion = 4 };
-
-#define timedLayoutSize 4096
-
-static NSMutableSet *schemesWithRepresentationsSet;
-
-NSString *_WebCanGoBackKey = @"canGoBack";
-NSString *_WebCanGoForwardKey = @"canGoForward";
-NSString *_WebEstimatedProgressKey = @"estimatedProgress";
-NSString *_WebIsLoadingKey = @"isLoading";
-NSString *_WebMainFrameIconKey = @"mainFrameIcon";
-NSString *_WebMainFrameTitleKey = @"mainFrameTitle";
-NSString *_WebMainFrameURLKey = @"mainFrameURL";
-NSString *_WebMainFrameDocumentKey = @"mainFrameDocument";
-
-@interface WebProgressItem : NSObject
-{
-@public
- long long bytesReceived;
- long long estimatedLength;
-}
-@end
-
-@implementation WebProgressItem
-@end
-
-static BOOL continuousSpellCheckingEnabled;
-#ifndef BUILDING_ON_TIGER
-static BOOL grammarCheckingEnabled;
-#endif
-
-@implementation WebViewPrivate
-
-#ifndef BUILDING_ON_TIGER
-+ (void)initialize
-{
- WebCoreObjCFinalizeOnMainThread(self);
-}
-#endif
-
-- init
-{
- self = [super init];
- if (!self)
- return nil;
- JSC::initializeThreading();
- allowsUndo = YES;
- zoomMultiplier = 1;
- zoomMultiplierIsTextOnly = YES;
-#if ENABLE(DASHBOARD_SUPPORT)
- dashboardBehaviorAllowWheelScrolling = YES;
-#endif
- shouldCloseWithWindow = objc_collecting_enabled();
- continuousSpellCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebContinuousSpellCheckingEnabled];
-
-#ifndef BUILDING_ON_TIGER
- grammarCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebGrammarCheckingEnabled];
-#endif
-
- usesPageCache = YES;
-
- pluginDatabaseClientCount++;
-
- shouldUpdateWhileOffscreen = YES;
-
- return self;
-}
-
-- (void)dealloc
-{
- ASSERT(applicationIsTerminating || !page);
- ASSERT(applicationIsTerminating || !preferences);
-
- [applicationNameForUserAgent release];
- [backgroundColor release];
-
- [inspector release];
- [currentNodeHighlight release];
-
- [hostWindow release];
-
- [policyDelegateForwarder release];
- [UIDelegateForwarder release];
- [frameLoadDelegateForwarder release];
- [editingDelegateForwarder release];
- [scriptDebugDelegateForwarder release];
-
- [mediaStyle release];
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- ASSERT_MAIN_THREAD();
-
- [super finalize];
-}
-
-@end
-
-@implementation WebView (AllWebViews)
-
-static CFSetCallBacks NonRetainingSetCallbacks = {
- 0,
- NULL,
- NULL,
- CFCopyDescription,
- CFEqual,
- CFHash
-};
-
-static CFMutableSetRef allWebViewsSet;
-
-+ (void)_makeAllWebViewsPerformSelector:(SEL)selector
-{
- if (!allWebViewsSet)
- return;
-
- [(NSMutableSet *)allWebViewsSet makeObjectsPerformSelector:selector];
-}
-
-- (void)_removeFromAllWebViewsSet
-{
- if (allWebViewsSet)
- CFSetRemoveValue(allWebViewsSet, self);
-}
-
-- (void)_addToAllWebViewsSet
-{
- if (!allWebViewsSet)
- allWebViewsSet = CFSetCreateMutable(NULL, 0, &NonRetainingSetCallbacks);
-
- CFSetSetValue(allWebViewsSet, self);
-}
-
-@end
-
-@implementation WebView (WebPrivate)
-
-static inline int callGestalt(OSType selector)
-{
- SInt32 value = 0;
- Gestalt(selector, &value);
- return value;
-}
-
-// Uses underscores instead of dots because if "4." ever appears in a user agent string, old DHTML libraries treat it as Netscape 4.
-static NSString *createMacOSXVersionString()
-{
- // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want.
- int major = callGestalt(gestaltSystemVersionMajor);
- ASSERT(major);
-
- int minor = callGestalt(gestaltSystemVersionMinor);
- int bugFix = callGestalt(gestaltSystemVersionBugFix);
- if (bugFix)
- return [[NSString alloc] initWithFormat:@"%d_%d_%d", major, minor, bugFix];
- if (minor)
- return [[NSString alloc] initWithFormat:@"%d_%d", major, minor];
- return [[NSString alloc] initWithFormat:@"%d", major];
-}
-
-static NSString *createUserVisibleWebKitVersionString()
-{
- // If the version is 4 digits long or longer, then the first digit represents
- // the version of the OS. Our user agent string should not include this first digit,
- // so strip it off and report the rest as the version. <rdar://problem/4997547>
- NSString *fullVersion = [[NSBundle bundleForClass:[WebView class]] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
- NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
- if (nonDigitRange.location == NSNotFound && [fullVersion length] >= 4)
- return [[fullVersion substringFromIndex:1] copy];
- if (nonDigitRange.location != NSNotFound && nonDigitRange.location >= 4)
- return [[fullVersion substringFromIndex:1] copy];
- return [fullVersion copy];
-}
-
-+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName
-{
- // Note: Do *not* move the initialization of osVersion nor webKitVersion into the declaration.
- // Garbage collection won't correctly mark the global variable in that case <rdar://problem/5733674>.
- static NSString *osVersion;
- static NSString *webKitVersion;
- if (!osVersion)
- osVersion = createMacOSXVersionString();
- if (!webKitVersion)
- webKitVersion = createUserVisibleWebKitVersionString();
- NSString *language = [NSUserDefaults _webkit_preferredLanguageCode];
- if ([applicationName length])
- return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko) %@", osVersion, language, webKitVersion, applicationName];
- return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko)", osVersion, language, webKitVersion];
-}
-
-static void WebKitInitializeApplicationCachePathIfNecessary()
-{
- static BOOL initialized = NO;
- if (initialized)
- return;
-
- NSString *appName = [[NSBundle mainBundle] bundleIdentifier];
- if (!appName)
- appName = [[NSProcessInfo processInfo] processName];
-
- ASSERT(appName);
-
- NSString* cacheDir = [NSString _webkit_localCacheDirectoryWithBundleIdentifier:appName];
-
- cacheStorage().setCacheDirectory(cacheDir);
- initialized = YES;
-}
-
-- (void)_registerDraggedTypes
-{
- NSArray *editableTypes = [WebHTMLView _insertablePasteboardTypes];
- NSArray *URLTypes = [NSPasteboard _web_dragTypesForURL];
- NSMutableSet *types = [[NSMutableSet alloc] initWithArray:editableTypes];
- [types addObjectsFromArray:URLTypes];
- [self registerForDraggedTypes:[types allObjects]];
- [types release];
-}
-
-- (BOOL)_usesDocumentViews
-{
- return _private->useDocumentViews;
-}
-
-- (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSString *)groupName usesDocumentViews:(BOOL)usesDocumentViews
-{
-#ifndef NDEBUG
- WTF::RefCountedLeakCounter::suppressMessages(webViewIsOpen);
-#endif
-
- WebPreferences *standardPreferences = [WebPreferences standardPreferences];
- [standardPreferences willAddToWebView];
-
- _private->preferences = [standardPreferences retain];
- _private->catchesDelegateExceptions = YES;
- _private->mainFrameDocumentReady = NO;
- _private->drawsBackground = YES;
- _private->smartInsertDeleteEnabled = YES;
- _private->backgroundColor = [[NSColor whiteColor] retain];
- _private->useDocumentViews = usesDocumentViews;
-
- WebFrameView *frameView = nil;
- if (_private->useDocumentViews) {
- NSRect f = [self frame];
- frameView = [[WebFrameView alloc] initWithFrame: NSMakeRect(0,0,f.size.width,f.size.height)];
- [frameView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
- [self addSubview:frameView];
- [frameView release];
- }
-
- WebKitInitializeLoggingChannelsIfNecessary();
- WebCore::InitializeLoggingChannelsIfNecessary();
- [WebHistoryItem initWindowWatcherIfNecessary];
- WebKitInitializeDatabasesIfNecessary();
- WebKitInitializeApplicationCachePathIfNecessary();
-
- _private->page = new Page(new WebChromeClient(self), new WebContextMenuClient(self), new WebEditorClient(self), new WebDragClient(self), new WebInspectorClient(self));
-
- _private->page->settings()->setLocalStorageDatabasePath([[self preferences] _localStorageDatabasePath]);
-
- [WebFrame _createMainFrameWithPage:_private->page frameName:frameName frameView:frameView];
-
-#ifndef BUILDING_ON_TIGER
- if (WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_LOADING_DURING_COMMON_RUNLOOP_MODES))
- [self scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
- else
- [self scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
-#endif
-
- [self _addToAllWebViewsSet];
- [self setGroupName:groupName];
-
- // If there's already a next key view (e.g., from a nib), wire it up to our
- // contained frame view. In any case, wire our next key view up to the our
- // contained frame view. This works together with our becomeFirstResponder
- // and setNextKeyView overrides.
- NSView *nextKeyView = [self nextKeyView];
- if (nextKeyView && nextKeyView != frameView)
- [frameView setNextKeyView:nextKeyView];
- [super setNextKeyView:frameView];
-
- ++WebViewCount;
-
- [self _registerDraggedTypes];
-
- WebPreferences *prefs = [self preferences];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:)
- name:WebPreferencesChangedNotification object:prefs];
-
- // Post a notification so the WebCore settings update.
- [[self preferences] _postPreferencesChangesNotification];
-
- if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION)) {
- // Originally, we allowed all local loads.
- FrameLoader::setLocalLoadPolicy(FrameLoader::AllowLocalLoadsForAll);
- } else if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_MORE_STRICT_LOCAL_RESOURCE_SECURITY_RESTRICTION)) {
- // Later, we allowed local loads for local URLs and documents loaded
- // with substitute data.
- FrameLoader::setLocalLoadPolicy(FrameLoader::AllowLocalLoadsForLocalAndSubstituteData);
- }
-}
-
-- (id)_initWithFrame:(NSRect)f frameName:(NSString *)frameName groupName:(NSString *)groupName usesDocumentViews:(BOOL)usesDocumentViews
-{
- self = [super initWithFrame:f];
- if (!self)
- return nil;
-
-#ifdef ENABLE_WEBKIT_UNSET_DYLD_FRAMEWORK_PATH
- // DYLD_FRAMEWORK_PATH is used so Safari will load the development version of WebKit, which
- // may not work with other WebKit applications. Unsetting DYLD_FRAMEWORK_PATH removes the
- // need for Safari to unset it to prevent it from being passed to applications it launches.
- // Unsetting it when a WebView is first created is as good a place as any.
- // See <http://bugs.webkit.org/show_bug.cgi?id=4286> for more details.
- if (getenv("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH")) {
- unsetenv("DYLD_FRAMEWORK_PATH");
- unsetenv("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH");
- }
-#endif
-
- _private = [[WebViewPrivate alloc] init];
- [self _commonInitializationWithFrameName:frameName groupName:groupName usesDocumentViews:usesDocumentViews];
- [self setMaintainsBackForwardList: YES];
- return self;
-}
-
-- (void)_boundsChanged
-{
- Frame* frame = core([self mainFrame]);
- IntSize oldSize = frame->view()->frameRect().size();
- frame->view()->resize([self bounds].size.width, [self bounds].size.height);
- if (oldSize != frame->view()->frameRect().size())
- [self setNeedsDisplay: YES];
-}
-
-- (BOOL)_mustDrawUnionedRect:(NSRect)rect singleRects:(const NSRect *)rects count:(NSInteger)count
-{
- // If count == 0 here, use the rect passed in for drawing. This is a workaround for:
- // <rdar://problem/3908282> REGRESSION (Mail): No drag image dragging selected text in Blot and Mail
- // The reason for the workaround is that this method is called explicitly from the code
- // to generate a drag image, and at that time, getRectsBeingDrawn:count: will return a zero count.
- const int cRectThreshold = 10;
- const float cWastedSpaceThreshold = 0.75f;
- BOOL useUnionedRect = (count <= 1) || (count > cRectThreshold);
- if (!useUnionedRect) {
- // Attempt to guess whether or not we should use the unioned rect or the individual rects.
- // We do this by computing the percentage of "wasted space" in the union. If that wasted space
- // is too large, then we will do individual rect painting instead.
- float unionPixels = (rect.size.width * rect.size.height);
- float singlePixels = 0;
- for (int i = 0; i < count; ++i)
- singlePixels += rects[i].size.width * rects[i].size.height;
- float wastedSpace = 1 - (singlePixels / unionPixels);
- if (wastedSpace <= cWastedSpaceThreshold)
- useUnionedRect = YES;
- }
- return useUnionedRect;
-}
-
-- (void)drawSingleRect:(NSRect)rect
-{
- ASSERT(!_private->useDocumentViews);
-
- [NSGraphicsContext saveGraphicsState];
- NSRectClip(rect);
-
- @try {
- [[self mainFrame] _drawRect:rect contentsOnly:NO];
-
- WebView *webView = [self _webView];
- [[webView _UIDelegateForwarder] webView:webView didDrawRect:rect];
-
- if (WebNodeHighlight *currentHighlight = [webView currentNodeHighlight])
- [currentHighlight setNeedsUpdateInTargetViewRect:rect];
-
- [NSGraphicsContext restoreGraphicsState];
- } @catch (NSException *localException) {
- [NSGraphicsContext restoreGraphicsState];
- LOG_ERROR("Exception caught while drawing: %@", localException);
- [localException raise];
- }
-}
-
-- (BOOL)isFlipped
-{
- return _private && !_private->useDocumentViews;
-}
-
-#ifndef BUILDING_ON_TIGER
-
-- (void)viewWillDraw
-{
- if (!_private->useDocumentViews) {
- Frame* frame = core([self mainFrame]);
- if (frame && frame->view())
- frame->view()->layoutIfNeededRecursive();
- }
- [super viewWillDraw];
-}
-
-#endif
-
-
-- (void)drawRect:(NSRect)rect
-{
- if (_private->useDocumentViews)
- return [super drawRect:rect];
-
- ASSERT_MAIN_THREAD();
-
- const NSRect *rects;
- NSInteger count;
- [self getRectsBeingDrawn:&rects count:&count];
-
-
- if ([self _mustDrawUnionedRect:rect singleRects:rects count:count])
- [self drawSingleRect:rect];
- else
- for (int i = 0; i < count; ++i)
- [self drawSingleRect:rects[i]];
-}
-
-+ (NSArray *)_supportedMIMETypes
-{
- // Load the plug-in DB allowing plug-ins to install types.
- [WebPluginDatabase sharedDatabase];
- return [[WebFrameView _viewTypesAllowImageTypeOmission:NO] allKeys];
-}
-
-+ (NSArray *)_supportedFileExtensions
-{
- NSMutableSet *extensions = [[NSMutableSet alloc] init];
- NSArray *MIMETypes = [self _supportedMIMETypes];
- NSEnumerator *enumerator = [MIMETypes objectEnumerator];
- NSString *MIMEType;
- while ((MIMEType = [enumerator nextObject]) != nil) {
- NSArray *extensionsForType = WKGetExtensionsForMIMEType(MIMEType);
- if (extensionsForType) {
- [extensions addObjectsFromArray:extensionsForType];
- }
- }
- NSArray *uniqueExtensions = [extensions allObjects];
- [extensions release];
- return uniqueExtensions;
-}
-
-+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
-{
- MIMEType = [MIMEType lowercaseString];
- Class viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];
- Class repClass = [[WebDataSource _repTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];
-
- if (!viewClass || !repClass || [[WebPDFView supportedMIMETypes] containsObject:MIMEType]) {
- // 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 sharedDatabase];
-
- // 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 WebHTMLView for text types that shouldn't be shown.
- if (viewClass == [WebHTMLView class] &&
- repClass == [WebHTMLRepresentation class] &&
- [[WebHTMLView unsupportedTextMIMETypes] containsObject:MIMEType]) {
- return NO;
- }
- if (vClass)
- *vClass = viewClass;
- if (rClass)
- *rClass = repClass;
- return YES;
- }
-
- return NO;
-}
-
-- (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
-{
- if ([[self class] _viewClass:vClass andRepresentationClass:rClass forMIMEType:MIMEType])
- return YES;
-
- if (_private->pluginDatabase) {
- WebBasePluginPackage *pluginPackage = [_private->pluginDatabase pluginForMIMEType:MIMEType];
- if (pluginPackage) {
- if (vClass)
- *vClass = [WebHTMLView class];
- if (rClass)
- *rClass = [WebHTMLRepresentation class];
- return YES;
- }
- }
-
- return NO;
-}
-
-+ (void)_setAlwaysUseATSU:(BOOL)f
-{
- [self _setAlwaysUsesComplexTextCodePath:f];
-}
-
-+ (void)_setAlwaysUsesComplexTextCodePath:(BOOL)f
-{
- WebCoreSetAlwaysUsesComplexTextCodePath(f);
-}
-
-+ (BOOL)canShowFile:(NSString *)path
-{
- return [[self class] canShowMIMEType:[WebView _MIMETypeForFile:path]];
-}
-
-+ (NSString *)suggestedFileExtensionForMIMEType:(NSString *)type
-{
- return WKGetPreferredExtensionForMIMEType(type);
-}
-
-- (BOOL)_isClosed
-{
- return !_private || _private->closed;
-}
-
-- (void)_closePluginDatabases
-{
- pluginDatabaseClientCount--;
-
- // Close both sets of plug-in databases because plug-ins need an opportunity to clean up files, etc.
-
- // Unload the WebView local plug-in database.
- if (_private->pluginDatabase) {
- [_private->pluginDatabase destroyAllPluginInstanceViews];
- [_private->pluginDatabase close];
- [_private->pluginDatabase release];
- _private->pluginDatabase = nil;
- }
-
- // Keep the global plug-in database active until the app terminates to avoid having to reload plug-in bundles.
- if (!pluginDatabaseClientCount && applicationIsTerminating)
- [WebPluginDatabase closeSharedDatabase];
-}
-
-- (void)_closeWithFastTeardown
-{
-#ifndef NDEBUG
- WTF::RefCountedLeakCounter::suppressMessages("At least one WebView was closed with fast teardown.");
-#endif
-
- // Dispatch unload events.
- // FIXME: Shouldn't have to use a RefPtr here -- keeping the frame alive while stopping it
- // should be WebCore's responsibility -- but we do as of the time this comment was written.
- RefPtr<Frame> mainFrame = core([self mainFrame]);
- if (mainFrame && mainFrame->page() && mainFrame->page()->pendingUnloadEventCount())
- mainFrame->loader()->stopLoading(true);
-
- _private->closed = YES;
-
- [self _closePluginDatabases];
-}
-
-// _close is here only for backward compatibility; clients and subclasses should use
-// public method -close instead.
-- (void)_close
-{
- if (!_private || _private->closed)
- return;
-
-#ifndef NDEBUG
- WTF::RefCountedLeakCounter::cancelMessageSuppression(webViewIsOpen);
-#endif
-
- WebPreferences *preferences = _private->preferences;
- BOOL fullDocumentTeardown = [preferences fullDocumentTeardownEnabled];
-
- // To quit the apps fast we skip document teardown. Two exceptions:
- // 1) plugins need to be destroyed and unloaded
- // 2) unload events need to be called
- if (applicationIsTerminating && !fullDocumentTeardown) {
- [self _closeWithFastTeardown];
- return;
- }
-
- if (Frame* mainFrame = core([self mainFrame]))
- mainFrame->loader()->detachFromParent();
-
- [self _removeFromAllWebViewsSet];
- [self setHostWindow:nil];
-
- [self setDownloadDelegate:nil];
- [self setEditingDelegate:nil];
- [self setFrameLoadDelegate:nil];
- [self setPolicyDelegate:nil];
- [self setResourceLoadDelegate:nil];
- [self setScriptDebugDelegate:nil];
- [self setUIDelegate:nil];
-
- [_private->inspector webViewClosed];
-
- // setHostWindow:nil must be called before this value is set (see 5408186)
- _private->closed = YES;
-
- // To avoid leaks, call removeDragCaret in case it wasn't called after moveDragCaretToPoint.
- [self removeDragCaret];
-
- // Deleteing the WebCore::Page will clear the page cache so we call destroy on
- // all the plug-ins in the page cache to break any retain cycles.
- // See comment in HistoryItem::releaseAllPendingPageCaches() for more information.
- delete _private->page;
- _private->page = 0;
-
- if (_private->hasSpellCheckerDocumentTag) {
- [[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:_private->spellCheckerDocumentTag];
- _private->hasSpellCheckerDocumentTag = NO;
- }
-
- [[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-
- [WebPreferences _removeReferenceForIdentifier:[self preferencesIdentifier]];
-
- _private->preferences = nil;
- [preferences didRemoveFromWebView];
- [preferences release];
-
- [self _closePluginDatabases];
-
-#ifndef NDEBUG
- // Need this to make leak messages accurate.
- if (applicationIsTerminating)
- gcController().garbageCollectNow();
-#endif
-}
-
-+ (NSString *)_MIMETypeForFile:(NSString *)path
-{
- NSString *extension = [path pathExtension];
- NSString *MIMEType = nil;
-
- // Get the MIME type from the extension.
- if ([extension length] != 0) {
- MIMEType = WKGetMIMETypeForExtension(extension);
- }
-
- // If we can't get a known MIME type from the extension, sniff.
- if ([MIMEType length] == 0 || [MIMEType isEqualToString:@"application/octet-stream"]) {
- NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
- NSData *data = [handle readDataOfLength:WEB_GUESS_MIME_TYPE_PEEK_LENGTH];
- [handle closeFile];
- if ([data length] != 0) {
- MIMEType = [data _webkit_guessedMIMEType];
- }
- if ([MIMEType length] == 0) {
- MIMEType = @"application/octet-stream";
- }
- }
-
- return MIMEType;
-}
-
-- (WebDownload *)_downloadURL:(NSURL *)URL
-{
- ASSERT(URL);
-
- NSURLRequest *request = [[NSURLRequest alloc] initWithURL:URL];
- WebDownload *download = [WebDownload _downloadWithRequest:request
- delegate:_private->downloadDelegate
- directory:nil];
- [request release];
-
- return download;
-}
-
-- (WebView *)_openNewWindowWithRequest:(NSURLRequest *)request
-{
- NSDictionary *features = [[NSDictionary alloc] init];
- WebView *newWindowWebView = [[self _UIDelegateForwarder] webView:self
- createWebViewWithRequest:nil
- windowFeatures:features];
- [features release];
- if (!newWindowWebView)
- return nil;
-
- CallUIDelegate(newWindowWebView, @selector(webViewShow:));
- return newWindowWebView;
-}
-
-- (WebInspector *)inspector
-{
- if (!_private->inspector)
- _private->inspector = [[WebInspector alloc] initWithWebView:self];
- return _private->inspector;
-}
-
-- (WebCore::Page*)page
-{
- return _private->page;
-}
-
-- (NSMenu *)_menuForElement:(NSDictionary *)element defaultItems:(NSArray *)items
-{
- NSArray *defaultMenuItems = [[WebDefaultUIDelegate sharedUIDelegate] webView:self contextMenuItemsForElement:element defaultMenuItems:items];
-
- NSArray *menuItems = CallUIDelegate(self, @selector(webView:contextMenuItemsForElement:defaultMenuItems:), element, defaultMenuItems);
- if (!menuItems)
- return nil;
-
- unsigned count = [menuItems count];
- if (!count)
- return nil;
-
- NSMenu *menu = [[NSMenu alloc] init];
- for (unsigned i = 0; i < count; i++)
- [menu addItem:[menuItems objectAtIndex:i]];
-
- return [menu autorelease];
-}
-
-- (void)_mouseDidMoveOverElement:(NSDictionary *)dictionary modifierFlags:(NSUInteger)modifierFlags
-{
- // We originally intended to call this delegate method sometimes with a nil dictionary, but due to
- // a bug dating back to WebKit 1.0 this delegate was never called with nil! Unfortunately we can't
- // start calling this with nil since it will break Adobe Help Viewer, and possibly other clients.
- if (!dictionary)
- return;
- CallUIDelegate(self, @selector(webView:mouseDidMoveOverElement:modifierFlags:), dictionary, modifierFlags);
-}
-
-- (void)_loadBackForwardListFromOtherView:(WebView *)otherView
-{
- if (!_private->page)
- return;
-
- if (!otherView->_private->page)
- return;
-
- // It turns out the right combination of behavior is done with the back/forward load
- // type. (See behavior matrix at the top of WebFramePrivate.) So we copy all the items
- // in the back forward list, and go to the current one.
-
- BackForwardList* backForwardList = _private->page->backForwardList();
- ASSERT(!backForwardList->currentItem()); // destination list should be empty
-
- BackForwardList* otherBackForwardList = otherView->_private->page->backForwardList();
- if (!otherBackForwardList->currentItem())
- return; // empty back forward list, bail
-
- HistoryItem* newItemToGoTo = 0;
-
- int lastItemIndex = otherBackForwardList->forwardListCount();
- for (int i = -otherBackForwardList->backListCount(); i <= lastItemIndex; ++i) {
- if (i == 0) {
- // If this item is showing , save away its current scroll and form state,
- // since that might have changed since loading and it is normally not saved
- // until we leave that page.
- otherView->_private->page->mainFrame()->loader()->saveDocumentAndScrollState();
- }
- RefPtr<HistoryItem> newItem = otherBackForwardList->itemAtIndex(i)->copy();
- if (i == 0)
- newItemToGoTo = newItem.get();
- backForwardList->addItem(newItem.release());
- }
-
- ASSERT(newItemToGoTo);
- _private->page->goToItem(newItemToGoTo, FrameLoadTypeIndexedBackForward);
-}
-
-- (void)_setFormDelegate: (id<WebFormDelegate>)delegate
-{
- _private->formDelegate = delegate;
-}
-
-- (id<WebFormDelegate>)_formDelegate
-{
- return _private->formDelegate;
-}
-
-- (BOOL)_needsAdobeFrameReloadingQuirk
-{
- static BOOL checked = NO;
- static BOOL needsQuirk = NO;
-
- if (checked)
- return needsQuirk;
-
- needsQuirk = WKAppVersionCheckLessThan(@"com.adobe.Acrobat", -1, 9.0)
- || WKAppVersionCheckLessThan(@"com.adobe.Acrobat.Pro", -1, 9.0)
- || WKAppVersionCheckLessThan(@"com.adobe.Reader", -1, 9.0)
- || WKAppVersionCheckLessThan(@"com.adobe.distiller", -1, 9.0)
- || WKAppVersionCheckLessThan(@"com.adobe.Contribute", -1, 4.2)
- || WKAppVersionCheckLessThan(@"com.adobe.dreamweaver-9.0", -1, 9.1)
- || WKAppVersionCheckLessThan(@"com.macromedia.fireworks", -1, 9.1)
- || WKAppVersionCheckLessThan(@"com.adobe.InCopy", -1, 5.1)
- || WKAppVersionCheckLessThan(@"com.adobe.InDesign", -1, 5.1)
- || WKAppVersionCheckLessThan(@"com.adobe.Soundbooth", -1, 2);
- checked = YES;
-
- return needsQuirk;
-}
-
-- (BOOL)_needsKeyboardEventDisambiguationQuirks
-{
- static BOOL checked = NO;
- static BOOL needsQuirks = NO;
-
- if (checked)
- return needsQuirks;
-
- needsQuirks = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_IE_COMPATIBLE_KEYBOARD_EVENT_DISPATCH)
- && ![[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"];
- checked = YES;
-
- return needsQuirks;
-}
-
-- (void)_preferencesChangedNotification:(NSNotification *)notification
-{
- WebPreferences *preferences = (WebPreferences *)[notification object];
- ASSERT(preferences == [self preferences]);
-
- if (!_private->userAgentOverridden)
- _private->userAgent = String();
-
- // Cache this value so we don't have to read NSUserDefaults on each page load
- _private->useSiteSpecificSpoofing = [preferences _useSiteSpecificSpoofing];
-
- // Update corresponding WebCore Settings object.
- if (!_private->page)
- return;
-
- Settings* settings = _private->page->settings();
-
- settings->setCursiveFontFamily([preferences cursiveFontFamily]);
- settings->setDefaultFixedFontSize([preferences defaultFixedFontSize]);
- settings->setDefaultFontSize([preferences defaultFontSize]);
- settings->setDefaultTextEncodingName([preferences defaultTextEncodingName]);
- settings->setFantasyFontFamily([preferences fantasyFontFamily]);
- settings->setFixedFontFamily([preferences fixedFontFamily]);
- settings->setForceFTPDirectoryListings([preferences _forceFTPDirectoryListings]);
- settings->setFTPDirectoryTemplatePath([preferences _ftpDirectoryTemplatePath]);
- settings->setLocalStorageDatabasePath([preferences _localStorageDatabasePath]);
- settings->setJavaEnabled([preferences isJavaEnabled]);
- settings->setJavaScriptEnabled([preferences isJavaScriptEnabled]);
- settings->setJavaScriptCanOpenWindowsAutomatically([preferences javaScriptCanOpenWindowsAutomatically]);
- settings->setMinimumFontSize([preferences minimumFontSize]);
- settings->setMinimumLogicalFontSize([preferences minimumLogicalFontSize]);
- settings->setPluginsEnabled([preferences arePlugInsEnabled]);
- settings->setPrivateBrowsingEnabled([preferences privateBrowsingEnabled]);
- settings->setSansSerifFontFamily([preferences sansSerifFontFamily]);
- settings->setSerifFontFamily([preferences serifFontFamily]);
- settings->setStandardFontFamily([preferences standardFontFamily]);
- settings->setLoadsImagesAutomatically([preferences loadsImagesAutomatically]);
- settings->setShouldPrintBackgrounds([preferences shouldPrintBackgrounds]);
- settings->setTextAreasAreResizable([preferences textAreasAreResizable]);
- settings->setShrinksStandaloneImagesToFit([preferences shrinksStandaloneImagesToFit]);
- settings->setEditableLinkBehavior(core([preferences editableLinkBehavior]));
- settings->setDOMPasteAllowed([preferences isDOMPasteAllowed]);
- settings->setUsesPageCache([self usesPageCache]);
- settings->setShowsURLsInToolTips([preferences showsURLsInToolTips]);
- settings->setDeveloperExtrasEnabled([preferences developerExtrasEnabled]);
- settings->setAuthorAndUserStylesEnabled([preferences authorAndUserStylesEnabled]);
- settings->setApplicationChromeMode([preferences applicationChromeModeEnabled]);
- if ([preferences userStyleSheetEnabled]) {
- NSString* location = [[preferences userStyleSheetLocation] _web_originalDataAsString];
- settings->setUserStyleSheetLocation([NSURL URLWithString:(location ? location : @"")]);
- } else
- settings->setUserStyleSheetLocation([NSURL URLWithString:@""]);
- settings->setNeedsAdobeFrameReloadingQuirk([self _needsAdobeFrameReloadingQuirk]);
- settings->setNeedsKeyboardEventDisambiguationQuirks([self _needsKeyboardEventDisambiguationQuirks]);
- settings->setNeedsSiteSpecificQuirks(_private->useSiteSpecificSpoofing);
- settings->setWebArchiveDebugModeEnabled([preferences webArchiveDebugModeEnabled]);
- settings->disableRangeMutationForOldAppleMail(WKAppVersionCheckLessThan(@"com.apple.mail", -1, 4.0));
- settings->setOfflineWebApplicationCacheEnabled([preferences offlineWebApplicationCacheEnabled]);
- settings->setZoomsTextOnly([preferences zoomsTextOnly]);
- settings->setEnforceCSSMIMETypeInStrictMode(!WKAppVersionCheckLessThan(@"com.apple.iWeb", -1, 2.1));
-}
-
-static inline IMP getMethod(id o, SEL s)
-{
- return [o respondsToSelector:s] ? [o methodForSelector:s] : 0;
-}
-
-- (void)_cacheResourceLoadDelegateImplementations
-{
- WebResourceDelegateImplementationCache *cache = &_private->resourceLoadDelegateImplementations;
- id delegate = _private->resourceProgressDelegate;
-
- if (!delegate) {
- bzero(cache, sizeof(WebResourceDelegateImplementationCache));
- return;
- }
-
- cache->didCancelAuthenticationChallengeFunc = getMethod(delegate, @selector(webView:resource:didReceiveAuthenticationChallenge:fromDataSource:));
- cache->didFailLoadingWithErrorFromDataSourceFunc = getMethod(delegate, @selector(webView:resource:didFailLoadingWithError:fromDataSource:));
- cache->didFinishLoadingFromDataSourceFunc = getMethod(delegate, @selector(webView:resource:didFinishLoadingFromDataSource:));
- cache->didLoadResourceFromMemoryCacheFunc = getMethod(delegate, @selector(webView:didLoadResourceFromMemoryCache:response:length:fromDataSource:));
- cache->didReceiveAuthenticationChallengeFunc = getMethod(delegate, @selector(webView:resource:didReceiveAuthenticationChallenge:fromDataSource:));
- cache->didReceiveContentLengthFunc = getMethod(delegate, @selector(webView:resource:didReceiveContentLength:fromDataSource:));
- cache->didReceiveResponseFunc = getMethod(delegate, @selector(webView:resource:didReceiveResponse:fromDataSource:));
- cache->identifierForRequestFunc = getMethod(delegate, @selector(webView:identifierForInitialRequest:fromDataSource:));
- cache->plugInFailedWithErrorFunc = getMethod(delegate, @selector(webView:plugInFailedWithError:dataSource:));
- cache->willCacheResponseFunc = getMethod(delegate, @selector(webView:resource:willCacheResponse:fromDataSource:));
- cache->willSendRequestFunc = getMethod(delegate, @selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:));
-}
-
-WebResourceDelegateImplementationCache* WebViewGetResourceLoadDelegateImplementations(WebView *webView)
-{
- static WebResourceDelegateImplementationCache empty;
- if (!webView)
- return &empty;
- return &webView->_private->resourceLoadDelegateImplementations;
-}
-
-- (void)_cacheFrameLoadDelegateImplementations
-{
- WebFrameLoadDelegateImplementationCache *cache = &_private->frameLoadDelegateImplementations;
- id delegate = _private->frameLoadDelegate;
-
- if (!delegate) {
- bzero(cache, sizeof(WebFrameLoadDelegateImplementationCache));
- return;
- }
-
- cache->didCancelClientRedirectForFrameFunc = getMethod(delegate, @selector(webView:didCancelClientRedirectForFrame:));
- cache->didChangeLocationWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didChangeLocationWithinPageForFrame:));
- cache->didClearWindowObjectForFrameFunc = getMethod(delegate, @selector(webView:didClearWindowObject:forFrame:));
- cache->didCommitLoadForFrameFunc = getMethod(delegate, @selector(webView:didCommitLoadForFrame:));
- cache->didFailLoadWithErrorForFrameFunc = getMethod(delegate, @selector(webView:didFailLoadWithError:forFrame:));
- cache->didFailProvisionalLoadWithErrorForFrameFunc = getMethod(delegate, @selector(webView:didFailProvisionalLoadWithError:forFrame:));
- cache->didFinishDocumentLoadForFrameFunc = getMethod(delegate, @selector(webView:didFinishDocumentLoadForFrame:));
- cache->didFinishLoadForFrameFunc = getMethod(delegate, @selector(webView:didFinishLoadForFrame:));
- cache->didFirstLayoutInFrameFunc = getMethod(delegate, @selector(webView:didFirstLayoutInFrame:));
- cache->didHandleOnloadEventsForFrameFunc = getMethod(delegate, @selector(webView:didHandleOnloadEventsForFrame:));
- cache->didReceiveIconForFrameFunc = getMethod(delegate, @selector(webView:didReceiveIcon:forFrame:));
- cache->didReceiveServerRedirectForProvisionalLoadForFrameFunc = getMethod(delegate, @selector(webView:didReceiveServerRedirectForProvisionalLoadForFrame:));
- cache->didReceiveTitleForFrameFunc = getMethod(delegate, @selector(webView:didReceiveTitle:forFrame:));
- cache->didStartProvisionalLoadForFrameFunc = getMethod(delegate, @selector(webView:didStartProvisionalLoadForFrame:));
- cache->willCloseFrameFunc = getMethod(delegate, @selector(webView:willCloseFrame:));
- cache->willPerformClientRedirectToURLDelayFireDateForFrameFunc = getMethod(delegate, @selector(webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:));
- cache->windowScriptObjectAvailableFunc = getMethod(delegate, @selector(webView:windowScriptObjectAvailable:));
-}
-
-WebFrameLoadDelegateImplementationCache* WebViewGetFrameLoadDelegateImplementations(WebView *webView)
-{
- static WebFrameLoadDelegateImplementationCache empty;
- if (!webView)
- return &empty;
- return &webView->_private->frameLoadDelegateImplementations;
-}
-
-- (id)_policyDelegateForwarder
-{
- if (!_private->policyDelegateForwarder)
- _private->policyDelegateForwarder = [[_WebSafeForwarder alloc] initWithTarget:_private->policyDelegate defaultTarget:[WebDefaultPolicyDelegate sharedPolicyDelegate] catchExceptions:_private->catchesDelegateExceptions];
- return _private->policyDelegateForwarder;
-}
-
-- (id)_UIDelegateForwarder
-{
- if (!_private->UIDelegateForwarder)
- _private->UIDelegateForwarder = [[_WebSafeForwarder alloc] initWithTarget:_private->UIDelegate defaultTarget:[WebDefaultUIDelegate sharedUIDelegate] catchExceptions:_private->catchesDelegateExceptions];
- return _private->UIDelegateForwarder;
-}
-
-- (id)_editingDelegateForwarder
-{
- // This can be called during window deallocation by QTMovieView in the QuickTime Cocoa Plug-in.
- // Not sure if that is a bug or not.
- if (!_private)
- return nil;
-
- if (!_private->editingDelegateForwarder)
- _private->editingDelegateForwarder = [[_WebSafeForwarder alloc] initWithTarget:_private->editingDelegate defaultTarget:[WebDefaultEditingDelegate sharedEditingDelegate] catchExceptions:_private->catchesDelegateExceptions];
- return _private->editingDelegateForwarder;
-}
-
-- (id)_scriptDebugDelegateForwarder
-{
- if (!_private->scriptDebugDelegateForwarder)
- _private->scriptDebugDelegateForwarder = [[_WebSafeForwarder alloc] initWithTarget:_private->scriptDebugDelegate defaultTarget:[WebDefaultScriptDebugDelegate sharedScriptDebugDelegate] catchExceptions:_private->catchesDelegateExceptions];
- return _private->scriptDebugDelegateForwarder;
-}
-
-- (void)_closeWindow
-{
- [[self _UIDelegateForwarder] webViewClose:self];
-}
-
-+ (void)_unregisterViewClassAndRepresentationClassForMIMEType:(NSString *)MIMEType;
-{
- [[WebFrameView _viewTypesAllowImageTypeOmission:NO] removeObjectForKey:MIMEType];
- [[WebDataSource _repTypesAllowImageTypeOmission:NO] removeObjectForKey:MIMEType];
-
- // FIXME: We also need to maintain MIMEType registrations (which can be dynamically changed)
- // in the WebCore MIMEType registry. For now we're doing this in a safe, limited manner
- // to fix <rdar://problem/5372989> - a future revamping of the entire system is neccesary for future robustness
- MIMETypeRegistry::getSupportedNonImageMIMETypes().remove(MIMEType);
-}
-
-+ (void)_registerViewClass:(Class)viewClass representationClass:(Class)representationClass forURLScheme:(NSString *)URLScheme;
-{
- NSString *MIMEType = [self _generatedMIMETypeForURLScheme:URLScheme];
- [self registerViewClass:viewClass representationClass:representationClass forMIMEType:MIMEType];
-
- // FIXME: We also need to maintain MIMEType registrations (which can be dynamically changed)
- // in the WebCore MIMEType registry. For now we're doing this in a safe, limited manner
- // to fix <rdar://problem/5372989> - a future revamping of the entire system is neccesary for future robustness
- if ([viewClass class] == [WebHTMLView class])
- MIMETypeRegistry::getSupportedNonImageMIMETypes().add(MIMEType);
-
- // This is used to make _representationExistsForURLScheme faster.
- // Without this set, we'd have to create the MIME type each time.
- if (schemesWithRepresentationsSet == nil) {
- schemesWithRepresentationsSet = [[NSMutableSet alloc] init];
- }
- [schemesWithRepresentationsSet addObject:[[[URLScheme lowercaseString] copy] autorelease]];
-}
-
-+ (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme
-{
- return [@"x-apple-web-kit/" stringByAppendingString:[URLScheme lowercaseString]];
-}
-
-+ (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme
-{
- return [schemesWithRepresentationsSet containsObject:[URLScheme lowercaseString]];
-}
-
-+ (BOOL)_canHandleRequest:(NSURLRequest *)request forMainFrame:(BOOL)forMainFrame
-{
- // FIXME: If <rdar://problem/5217309> gets fixed, this check can be removed.
- if (!request)
- return NO;
-
- if ([NSURLConnection canHandleRequest:request])
- return YES;
-
- NSString *scheme = [[request URL] scheme];
-
- // Representations for URL schemes work at the top level.
- if (forMainFrame && [self _representationExistsForURLScheme:scheme])
- return YES;
-
- return [scheme _webkit_isCaseInsensitiveEqualToString:@"applewebdata"];
-}
-
-+ (BOOL)_canHandleRequest:(NSURLRequest *)request
-{
- return [self _canHandleRequest:request forMainFrame:YES];
-}
-
-+ (NSString *)_decodeData:(NSData *)data
-{
- HTMLNames::init(); // this method is used for importing bookmarks at startup, so HTMLNames are likely to be uninitialized yet
- RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("text/html"); // bookmark files are HTML
- String result = decoder->decode(static_cast<const char*>([data bytes]), [data length]);
- result += decoder->flush();
- return result;
-}
-
-- (void)_pushPerformingProgrammaticFocus
-{
- _private->programmaticFocusCount++;
-}
-
-- (void)_popPerformingProgrammaticFocus
-{
- _private->programmaticFocusCount--;
-}
-
-- (BOOL)_isPerformingProgrammaticFocus
-{
- return _private->programmaticFocusCount != 0;
-}
-
-- (void)_didChangeValueForKey: (NSString *)key
-{
- LOG (Bindings, "calling didChangeValueForKey: %@", key);
- [self didChangeValueForKey: key];
-}
-
-- (void)_willChangeValueForKey: (NSString *)key
-{
- LOG (Bindings, "calling willChangeValueForKey: %@", key);
- [self willChangeValueForKey: key];
-}
-
-+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key {
- static NSSet *manualNotifyKeys = nil;
- if (!manualNotifyKeys)
- manualNotifyKeys = [[NSSet alloc] initWithObjects:_WebMainFrameURLKey, _WebIsLoadingKey, _WebEstimatedProgressKey,
- _WebCanGoBackKey, _WebCanGoForwardKey, _WebMainFrameTitleKey, _WebMainFrameIconKey, _WebMainFrameDocumentKey, nil];
- if ([manualNotifyKeys containsObject:key])
- return NO;
- return YES;
-}
-
-- (NSArray *)_declaredKeys {
- static NSArray *declaredKeys = nil;
- if (!declaredKeys)
- declaredKeys = [[NSArray alloc] initWithObjects:_WebMainFrameURLKey, _WebIsLoadingKey, _WebEstimatedProgressKey,
- _WebCanGoBackKey, _WebCanGoForwardKey, _WebMainFrameTitleKey, _WebMainFrameIconKey, _WebMainFrameDocumentKey, nil];
- return declaredKeys;
-}
-
-- (void)setObservationInfo:(void *)info
-{
- _private->observationInfo = info;
-}
-
-- (void *)observationInfo
-{
- return _private->observationInfo;
-}
-
-- (void)_willChangeBackForwardKeys
-{
- [self _willChangeValueForKey: _WebCanGoBackKey];
- [self _willChangeValueForKey: _WebCanGoForwardKey];
-}
-
-- (void)_didChangeBackForwardKeys
-{
- [self _didChangeValueForKey: _WebCanGoBackKey];
- [self _didChangeValueForKey: _WebCanGoForwardKey];
-}
-
-- (void)_didStartProvisionalLoadForFrame:(WebFrame *)frame
-{
- [self _willChangeBackForwardKeys];
- if (frame == [self mainFrame]){
- // Force an observer update by sending a will/did.
- [self _willChangeValueForKey: _WebIsLoadingKey];
- [self _didChangeValueForKey: _WebIsLoadingKey];
-
- [self _willChangeValueForKey: _WebMainFrameURLKey];
- }
-
- [NSApp setWindowsNeedUpdate:YES];
-}
-
-- (void)_didCommitLoadForFrame:(WebFrame *)frame
-{
- if (frame == [self mainFrame])
- [self _didChangeValueForKey: _WebMainFrameURLKey];
- [NSApp setWindowsNeedUpdate:YES];
-}
-
-- (void)_didFinishLoadForFrame:(WebFrame *)frame
-{
- [self _didChangeBackForwardKeys];
- if (frame == [self mainFrame]){
- // Force an observer update by sending a will/did.
- [self _willChangeValueForKey: _WebIsLoadingKey];
- [self _didChangeValueForKey: _WebIsLoadingKey];
- }
- [NSApp setWindowsNeedUpdate:YES];
-}
-
-- (void)_didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
-{
- [self _didChangeBackForwardKeys];
- if (frame == [self mainFrame]){
- // Force an observer update by sending a will/did.
- [self _willChangeValueForKey: _WebIsLoadingKey];
- [self _didChangeValueForKey: _WebIsLoadingKey];
- }
- [NSApp setWindowsNeedUpdate:YES];
-}
-
-- (void)_didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
-{
- [self _didChangeBackForwardKeys];
- if (frame == [self mainFrame]){
- // Force an observer update by sending a will/did.
- [self _willChangeValueForKey: _WebIsLoadingKey];
- [self _didChangeValueForKey: _WebIsLoadingKey];
-
- [self _didChangeValueForKey: _WebMainFrameURLKey];
- }
- [NSApp setWindowsNeedUpdate:YES];
-}
-
-- (NSCachedURLResponse *)_cachedResponseForURL:(NSURL *)URL
-{
- NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL];
- [request _web_setHTTPUserAgent:[self userAgentForURL:URL]];
- NSCachedURLResponse *cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
- [request release];
- return cachedResponse;
-}
-
-- (void)_writeImageForElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
-{
- NSURL *linkURL = [element objectForKey:WebElementLinkURLKey];
- DOMElement *domElement = [element objectForKey:WebElementDOMNodeKey];
- [pasteboard _web_writeImage:(NSImage *)(domElement ? nil : [element objectForKey:WebElementImageKey])
- element:domElement
- URL:linkURL ? linkURL : (NSURL *)[element objectForKey:WebElementImageURLKey]
- title:[element objectForKey:WebElementImageAltStringKey]
- archive:[[element objectForKey:WebElementDOMNodeKey] webArchive]
- types:types
- source:nil];
-}
-
-- (void)_writeLinkElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
-{
- [pasteboard _web_writeURL:[element objectForKey:WebElementLinkURLKey]
- andTitle:[element objectForKey:WebElementLinkLabelKey]
- types:types];
-}
-
-- (void)_setInitiatedDrag:(BOOL)initiatedDrag
-{
- if (!_private->page)
- return;
- _private->page->dragController()->setDidInitiateDrag(initiatedDrag);
-}
-
-#if ENABLE(DASHBOARD_SUPPORT)
-
-#define DASHBOARD_CONTROL_LABEL @"control"
-
-- (void)_addScrollerDashboardRegions:(NSMutableDictionary *)regions from:(NSArray *)views
-{
- // Add scroller regions for NSScroller and KWQScrollBar
- int i, count = [views count];
-
- for (i = 0; i < count; i++) {
- NSView *aView = [views objectAtIndex:i];
-
- if ([aView isKindOfClass:[NSScroller class]] ||
- [aView isKindOfClass:NSClassFromString (@"KWQScrollBar")]) {
- NSRect bounds = [aView bounds];
- NSRect adjustedBounds;
- adjustedBounds.origin = [self convertPoint:bounds.origin fromView:aView];
- adjustedBounds.origin.y = [self bounds].size.height - adjustedBounds.origin.y;
-
- // AppKit has horrible hack of placing absent scrollers at -100,-100
- if (adjustedBounds.origin.y == -100)
- continue;
- adjustedBounds.size = bounds.size;
- NSRect clip = [aView visibleRect];
- NSRect adjustedClip;
- adjustedClip.origin = [self convertPoint:clip.origin fromView:aView];
- adjustedClip.origin.y = [self bounds].size.height - adjustedClip.origin.y;
- adjustedClip.size = clip.size;
- WebDashboardRegion *aRegion =
- [[[WebDashboardRegion alloc] initWithRect:adjustedBounds
- clip:adjustedClip type:WebDashboardRegionTypeScrollerRectangle] autorelease];
- NSMutableArray *scrollerRegions;
- scrollerRegions = [regions objectForKey:DASHBOARD_CONTROL_LABEL];
- if (!scrollerRegions) {
- scrollerRegions = [NSMutableArray array];
- [regions setObject:scrollerRegions forKey:DASHBOARD_CONTROL_LABEL];
- }
- [scrollerRegions addObject:aRegion];
- }
- [self _addScrollerDashboardRegions:regions from:[aView subviews]];
- }
-}
-
-- (void)_addScrollerDashboardRegions:(NSMutableDictionary *)regions
-{
- [self _addScrollerDashboardRegions:regions from:[self subviews]];
-}
-
-- (NSDictionary *)_dashboardRegions
-{
- // Only return regions from main frame.
- Frame* mainFrame = core([self mainFrame]);
- if (!mainFrame)
- return nil;
- NSMutableDictionary *regions = mainFrame->dashboardRegionsDictionary();
- [self _addScrollerDashboardRegions:regions];
- return regions;
-}
-
-- (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag
-{
- // FIXME: Remove this blanket assignment once Dashboard and Dashcode implement
- // specific support for the backward compatibility mode flag.
- if (behavior == WebDashboardBehaviorAllowWheelScrolling && flag == NO && _private->page)
- _private->page->settings()->setUsesDashboardBackwardCompatibilityMode(true);
-
- switch (behavior) {
- case WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows: {
- _private->dashboardBehaviorAlwaysSendMouseEventsToAllWindows = flag;
- break;
- }
- case WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns: {
- _private->dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns = flag;
- break;
- }
- case WebDashboardBehaviorAlwaysAcceptsFirstMouse: {
- _private->dashboardBehaviorAlwaysAcceptsFirstMouse = flag;
- break;
- }
- case WebDashboardBehaviorAllowWheelScrolling: {
- _private->dashboardBehaviorAllowWheelScrolling = flag;
- break;
- }
- case WebDashboardBehaviorUseBackwardCompatibilityMode: {
- if (_private->page)
- _private->page->settings()->setUsesDashboardBackwardCompatibilityMode(flag);
- break;
- }
- }
-}
-
-- (BOOL)_dashboardBehavior:(WebDashboardBehavior)behavior
-{
- switch (behavior) {
- case WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows: {
- return _private->dashboardBehaviorAlwaysSendMouseEventsToAllWindows;
- }
- case WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns: {
- return _private->dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns;
- }
- case WebDashboardBehaviorAlwaysAcceptsFirstMouse: {
- return _private->dashboardBehaviorAlwaysAcceptsFirstMouse;
- }
- case WebDashboardBehaviorAllowWheelScrolling: {
- return _private->dashboardBehaviorAllowWheelScrolling;
- }
- case WebDashboardBehaviorUseBackwardCompatibilityMode: {
- return _private->page && _private->page->settings()->usesDashboardBackwardCompatibilityMode();
- }
- }
- return NO;
-}
-
-#endif /* ENABLE(DASHBOARD_SUPPORT) */
-
-+ (void)_setShouldUseFontSmoothing:(BOOL)f
-{
- WebCoreSetShouldUseFontSmoothing(f);
-}
-
-+ (BOOL)_shouldUseFontSmoothing
-{
- return WebCoreShouldUseFontSmoothing();
-}
-
-+ (void)_setUsesTestModeFocusRingColor:(BOOL)f
-{
- setUsesTestModeFocusRingColor(f);
-}
-
-+ (BOOL)_usesTestModeFocusRingColor
-{
- return usesTestModeFocusRingColor();
-}
-
-// This is only used by versions of Safari up to and including 3.0 and should be removed in a future release.
-+ (NSString *)_minimumRequiredSafariBuildNumber
-{
- return @"420+";
-}
-
-- (void)setAlwaysShowVerticalScroller:(BOOL)flag
-{
- WebDynamicScrollBarsView *scrollview = [[[self mainFrame] frameView] _scrollView];
- if (flag) {
- [scrollview setVerticalScrollingMode:ScrollbarAlwaysOn andLock:YES];
- } else {
- [scrollview setVerticalScrollingModeLocked:NO];
- [scrollview setVerticalScrollingMode:ScrollbarAuto andLock:NO];
- }
-}
-
-- (BOOL)alwaysShowVerticalScroller
-{
- WebDynamicScrollBarsView *scrollview = [[[self mainFrame] frameView] _scrollView];
- return [scrollview verticalScrollingModeLocked] && [scrollview verticalScrollingMode] == ScrollbarAlwaysOn;
-}
-
-- (void)setAlwaysShowHorizontalScroller:(BOOL)flag
-{
- WebDynamicScrollBarsView *scrollview = [[[self mainFrame] frameView] _scrollView];
- if (flag) {
- [scrollview setHorizontalScrollingMode:ScrollbarAlwaysOn andLock:YES];
- } else {
- [scrollview setHorizontalScrollingModeLocked:NO];
- [scrollview setHorizontalScrollingMode:ScrollbarAuto andLock:NO];
- }
-}
-
-- (void)setProhibitsMainFrameScrolling:(BOOL)prohibits
-{
- Frame* mainFrame = core([self mainFrame]);
- if (mainFrame)
- mainFrame->view()->setProhibitsScrolling(prohibits);
-}
-
-- (BOOL)alwaysShowHorizontalScroller
-{
- WebDynamicScrollBarsView *scrollview = [[[self mainFrame] frameView] _scrollView];
- return [scrollview horizontalScrollingModeLocked] && [scrollview horizontalScrollingMode] == ScrollbarAlwaysOn;
-}
-
-- (void)_setInViewSourceMode:(BOOL)flag
-{
- Frame* mainFrame = core([self mainFrame]);
- if (mainFrame)
- mainFrame->setInViewSourceMode(flag);
-}
-
-- (BOOL)_inViewSourceMode
-{
- Frame* mainFrame = core([self mainFrame]);
- return mainFrame && mainFrame->inViewSourceMode();
-}
-
-- (void)_setUseFastImageScalingMode:(BOOL)flag
-{
- if (_private->page && _private->page->inLowQualityImageInterpolationMode() != flag) {
- _private->page->setInLowQualityImageInterpolationMode(flag);
- [self setNeedsDisplay:YES];
- }
-}
-
-- (BOOL)_inFastImageScalingMode
-{
- if (_private->page)
- return _private->page->inLowQualityImageInterpolationMode();
- return NO;
-}
-
-- (BOOL)_cookieEnabled
-{
- if (_private->page)
- return _private->page->cookieEnabled();
- return YES;
-}
-
-- (void)_setCookieEnabled:(BOOL)enable
-{
- if (_private->page)
- _private->page->setCookieEnabled(enable);
-}
-
-- (void)_setAdditionalWebPlugInPaths:(NSArray *)newPaths
-{
- if (!_private->pluginDatabase)
- _private->pluginDatabase = [[WebPluginDatabase alloc] init];
-
- [_private->pluginDatabase setPlugInPaths:newPaths];
- [_private->pluginDatabase refresh];
-}
-
-- (void)_attachScriptDebuggerToAllFrames
-{
- for (Frame* frame = core([self mainFrame]); frame; frame = frame->tree()->traverseNext())
- [kit(frame) _attachScriptDebugger];
-}
-
-- (void)_detachScriptDebuggerFromAllFrames
-{
- for (Frame* frame = core([self mainFrame]); frame; frame = frame->tree()->traverseNext())
- [kit(frame) _detachScriptDebugger];
-}
-
-- (void)setBackgroundColor:(NSColor *)backgroundColor
-{
- if ([_private->backgroundColor isEqual:backgroundColor])
- return;
-
- id old = _private->backgroundColor;
- _private->backgroundColor = [backgroundColor retain];
- [old release];
-
- [[self mainFrame] _updateBackgroundAndUpdatesWhileOffscreen];
-}
-
-- (NSColor *)backgroundColor
-{
- return _private->backgroundColor;
-}
-
-- (BOOL)defersCallbacks
-{
- if (!_private->page)
- return NO;
- return _private->page->defersLoading();
-}
-
-- (void)setDefersCallbacks:(BOOL)defer
-{
- if (!_private->page)
- return;
- return _private->page->setDefersLoading(defer);
-}
-
-// For backwards compatibility with the WebBackForwardList API, we honor both
-// a per-WebView and a per-preferences setting for whether to use the page cache.
-
-- (BOOL)usesPageCache
-{
- return _private->usesPageCache && [[self preferences] usesPageCache];
-}
-
-- (void)setUsesPageCache:(BOOL)usesPageCache
-{
- _private->usesPageCache = usesPageCache;
-
- // Post a notification so the WebCore settings update.
- [[self preferences] _postPreferencesChangesNotification];
-}
-
-- (WebTextIterator *)textIteratorForRect:(NSRect)rect
-{
- IntPoint rectStart(rect.origin.x, rect.origin.y);
- IntPoint rectEnd(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height);
-
- Frame* coreFrame = core([self mainFrame]);
- if (!coreFrame)
- return nil;
-
- Selection selectionInsideRect(coreFrame->visiblePositionForPoint(rectStart), coreFrame->visiblePositionForPoint(rectEnd));
-
- return [[[WebTextIterator alloc] initWithRange:[DOMRange _wrapRange:selectionInsideRect.toRange().get()]] autorelease];
-}
-
-- (void)handleAuthenticationForResource:(id)identifier challenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
-{
- NSWindow *window = [self hostWindow] ? [self hostWindow] : [self window];
- [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window];
-}
-
-- (void)_clearUndoRedoOperations
-{
- if (!_private->page)
- return;
- _private->page->clearUndoRedoOperations();
-}
-
-- (void)_setCatchesDelegateExceptions:(BOOL)f
-{
- _private->catchesDelegateExceptions = f;
-}
-
-- (BOOL)_catchesDelegateExceptions
-{
- return _private->catchesDelegateExceptions;
-}
-
-- (void)_executeCoreCommandByName:(NSString *)name value:(NSString *)value
-{
- Frame* coreFrame = core([self mainFrame]);
- if (!coreFrame)
- return;
- coreFrame->editor()->command(name).execute(value);
-}
-
-- (void)_setCustomHTMLTokenizerTimeDelay:(double)timeDelay
-{
- if (!_private->page)
- return;
- return _private->page->setCustomHTMLTokenizerTimeDelay(timeDelay);
-}
-
-- (void)_setCustomHTMLTokenizerChunkSize:(int)chunkSize
-{
- if (!_private->page)
- return;
- return _private->page->setCustomHTMLTokenizerChunkSize(chunkSize);
-}
-
-- (void)_clearMainFrameName
-{
- _private->page->mainFrame()->tree()->clearName();
-}
-
-@end
-
-@implementation _WebSafeForwarder
-
-// Used to send messages to delegates that implement informal protocols.
-
-- (id)initWithTarget:(id)t defaultTarget:(id)dt catchExceptions:(BOOL)c
-{
- self = [super init];
- if (!self)
- return nil;
- target = t; // Non retained.
- defaultTarget = dt;
- catchExceptions = c;
- return self;
-}
-
-- (void)forwardInvocation:(NSInvocation *)invocation
-{
- if ([target respondsToSelector:[invocation selector]]) {
- if (catchExceptions) {
- @try {
- [invocation invokeWithTarget:target];
- } @catch(id exception) {
- ReportDiscardedDelegateException([invocation selector], exception);
- }
- } else
- [invocation invokeWithTarget:target];
- return;
- }
-
- if ([defaultTarget respondsToSelector:[invocation selector]])
- [invocation invokeWithTarget:defaultTarget];
-
- // Do nothing quietly if method not implemented.
-}
-
-- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
-{
- return [defaultTarget methodSignatureForSelector:aSelector];
-}
-
-@end
-
-@implementation WebView
-
-+ (void)initialize
-{
- static BOOL initialized = NO;
- if (initialized)
- return;
- initialized = YES;
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:NSApp];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) name:WebPreferencesChangedNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesRemovedNotification:) name:WebPreferencesRemovedNotification object:nil];
-}
-
-+ (void)_applicationWillTerminate
-{
- applicationIsTerminating = YES;
- if (!pluginDatabaseClientCount)
- [WebPluginDatabase closeSharedDatabase];
-
- PageGroup::closeLocalStorage();
-}
-
-+ (BOOL)canShowMIMEType:(NSString *)MIMEType
-{
- return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType];
-}
-
-- (WebBasePluginPackage *)_pluginForMIMEType:(NSString *)MIMEType
-{
- WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForMIMEType:MIMEType];
- if (pluginPackage)
- return pluginPackage;
-
- if (_private->pluginDatabase)
- return [_private->pluginDatabase pluginForMIMEType:MIMEType];
-
- return nil;
-}
-
-- (WebBasePluginPackage *)_pluginForExtension:(NSString *)extension
-{
- WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForExtension:extension];
- if (pluginPackage)
- return pluginPackage;
-
- if (_private->pluginDatabase)
- return [_private->pluginDatabase pluginForExtension:extension];
-
- return nil;
-}
-
-- (void)addPluginInstanceView:(NSView *)view
-{
- if (!_private->pluginDatabase)
- _private->pluginDatabase = [[WebPluginDatabase alloc] init];
- [_private->pluginDatabase addPluginInstanceView:view];
-}
-
-- (void)removePluginInstanceView:(NSView *)view
-{
- if (_private->pluginDatabase)
- [_private->pluginDatabase removePluginInstanceView:view];
-}
-
-- (void)removePluginInstanceViewsFor:(WebFrame*)webFrame
-{
- if (_private->pluginDatabase)
- [_private->pluginDatabase removePluginInstanceViewsFor:webFrame];
-}
-
-- (BOOL)_isMIMETypeRegisteredAsPlugin:(NSString *)MIMEType
-{
- if ([[WebPluginDatabase sharedDatabase] isMIMETypeRegistered:MIMEType])
- return YES;
-
- if (_private->pluginDatabase && [_private->pluginDatabase isMIMETypeRegistered:MIMEType])
- return YES;
-
- return NO;
-}
-
-+ (BOOL)canShowMIMETypeAsHTML:(NSString *)MIMEType
-{
- return [WebFrameView _canShowMIMETypeAsHTML:MIMEType];
-}
-
-+ (NSArray *)MIMETypesShownAsHTML
-{
- NSMutableDictionary *viewTypes = [WebFrameView _viewTypesAllowImageTypeOmission:YES];
- NSEnumerator *enumerator = [viewTypes keyEnumerator];
- id key;
- NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease];
-
- while ((key = [enumerator nextObject])) {
- if ([viewTypes objectForKey:key] == [WebHTMLView class])
- [array addObject:key];
- }
-
- return array;
-}
-
-+ (void)setMIMETypesShownAsHTML:(NSArray *)MIMETypes
-{
- NSDictionary *viewTypes = [[WebFrameView _viewTypesAllowImageTypeOmission:YES] copy];
- NSEnumerator *enumerator = [viewTypes keyEnumerator];
- id key;
- while ((key = [enumerator nextObject])) {
- if ([viewTypes objectForKey:key] == [WebHTMLView class])
- [WebView _unregisterViewClassAndRepresentationClassForMIMEType:key];
- }
-
- int i, count = [MIMETypes count];
- for (i = 0; i < count; i++) {
- [WebView registerViewClass:[WebHTMLView class]
- representationClass:[WebHTMLRepresentation class]
- forMIMEType:[MIMETypes objectAtIndex:i]];
- }
- [viewTypes release];
-}
-
-+ (NSURL *)URLFromPasteboard:(NSPasteboard *)pasteboard
-{
- return [pasteboard _web_bestURL];
-}
-
-+ (NSString *)URLTitleFromPasteboard:(NSPasteboard *)pasteboard
-{
- return [pasteboard stringForType:WebURLNamePboardType];
-}
-
-+ (void)registerURLSchemeAsLocal:(NSString *)protocol
-{
- FrameLoader::registerURLSchemeAsLocal(protocol);
-}
-
-- (id)initWithFrame:(NSRect)f
-{
- return [self initWithFrame:f frameName:nil groupName:nil];
-}
-
-- (id)initWithFrame:(NSRect)f frameName:(NSString *)frameName groupName:(NSString *)groupName
-{
- return [self _initWithFrame:f frameName:frameName groupName:groupName usesDocumentViews:YES];
-}
-
-- (id)initWithCoder:(NSCoder *)decoder
-{
- WebView *result = nil;
-
- @try {
- NSString *frameName;
- NSString *groupName;
- WebPreferences *preferences;
- BOOL useBackForwardList = NO;
- BOOL allowsUndo = YES;
-
- result = [super initWithCoder:decoder];
- result->_private = [[WebViewPrivate alloc] init];
-
- // We don't want any of the archived subviews. The subviews will always
- // be created in _commonInitializationFrameName:groupName:.
- [[result subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
-
- if ([decoder allowsKeyedCoding]) {
- frameName = [decoder decodeObjectForKey:@"FrameName"];
- groupName = [decoder decodeObjectForKey:@"GroupName"];
- preferences = [decoder decodeObjectForKey:@"Preferences"];
- useBackForwardList = [decoder decodeBoolForKey:@"UseBackForwardList"];
- if ([decoder containsValueForKey:@"AllowsUndo"])
- allowsUndo = [decoder decodeBoolForKey:@"AllowsUndo"];
- } else {
- int version;
- [decoder decodeValueOfObjCType:@encode(int) at:&version];
- frameName = [decoder decodeObject];
- groupName = [decoder decodeObject];
- preferences = [decoder decodeObject];
- if (version > 1)
- [decoder decodeValuesOfObjCTypes:"c", &useBackForwardList];
- // The allowsUndo field is no longer written out in encodeWithCoder, but since there are
- // version 3 NIBs that have this field encoded, we still need to read it in.
- if (version == 3)
- [decoder decodeValuesOfObjCTypes:"c", &allowsUndo];
- }
-
- if (![frameName isKindOfClass:[NSString class]])
- frameName = nil;
- if (![groupName isKindOfClass:[NSString class]])
- groupName = nil;
- if (![preferences isKindOfClass:[WebPreferences class]])
- preferences = nil;
-
- LOG(Encoding, "FrameName = %@, GroupName = %@, useBackForwardList = %d\n", frameName, groupName, (int)useBackForwardList);
- [result _commonInitializationWithFrameName:frameName groupName:groupName usesDocumentViews:YES];
- [result page]->backForwardList()->setEnabled(useBackForwardList);
- result->_private->allowsUndo = allowsUndo;
- if (preferences)
- [result setPreferences:preferences];
- } @catch (NSException *localException) {
- result = nil;
- [self release];
- }
-
- return result;
-}
-
-- (void)encodeWithCoder:(NSCoder *)encoder
-{
- // Set asside the subviews before we archive. We don't want to archive any subviews.
- // The subviews will always be created in _commonInitializationFrameName:groupName:.
- id originalSubviews = _subviews;
- _subviews = nil;
-
- [super encodeWithCoder:encoder];
-
- // Restore the subviews we set aside.
- _subviews = originalSubviews;
-
- BOOL useBackForwardList = _private->page && _private->page->backForwardList()->enabled();
- if ([encoder allowsKeyedCoding]) {
- [encoder encodeObject:[[self mainFrame] name] forKey:@"FrameName"];
- [encoder encodeObject:[self groupName] forKey:@"GroupName"];
- [encoder encodeObject:[self preferences] forKey:@"Preferences"];
- [encoder encodeBool:useBackForwardList forKey:@"UseBackForwardList"];
- [encoder encodeBool:_private->allowsUndo forKey:@"AllowsUndo"];
- } else {
- int version = WebViewVersion;
- [encoder encodeValueOfObjCType:@encode(int) at:&version];
- [encoder encodeObject:[[self mainFrame] name]];
- [encoder encodeObject:[self groupName]];
- [encoder encodeObject:[self preferences]];
- [encoder encodeValuesOfObjCTypes:"c", &useBackForwardList];
- // DO NOT encode any new fields here, doing so will break older WebKit releases.
- }
-
- LOG(Encoding, "FrameName = %@, GroupName = %@, useBackForwardList = %d\n", [[self mainFrame] name], [self groupName], (int)useBackForwardList);
-}
-
-- (void)dealloc
-{
- if (WebCoreObjCScheduleDeallocateOnMainThread([WebView class], self))
- return;
-
- // call close to ensure we tear-down completely
- // this maintains our old behavior for existing applications
- [self close];
-
- --WebViewCount;
-
- [_private release];
- // [super dealloc] can end up dispatching against _private (3466082)
- _private = nil;
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- ASSERT(_private->closed);
-
- --WebViewCount;
-
- [super finalize];
-}
-
-- (void)close
-{
- // _close existed first, and some clients might be calling or overriding it, so call through.
- [self _close];
-}
-
-- (void)setShouldCloseWithWindow:(BOOL)close
-{
- _private->shouldCloseWithWindow = close;
-}
-
-- (BOOL)shouldCloseWithWindow
-{
- return _private->shouldCloseWithWindow;
-}
-
-- (void)removeSizeObservers
-{
- if (!_private->useDocumentViews && [self window]) {
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSViewFrameDidChangeNotification object:self];
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSViewBoundsDidChangeNotification object:self];
- }
-}
-
-- (void)addSizeObservers
-{
- if (!_private->useDocumentViews && [self window]) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_boundsChanged)
- name:NSViewFrameDidChangeNotification object:self];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_boundsChanged)
- name:NSViewBoundsDidChangeNotification object:self];
- [self _boundsChanged];
- }
-}
-
-- (void)addWindowObservers
-{
- NSWindow *window = [self window];
- if (!_private->useDocumentViews && window) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidBecomeKey:)
- name:NSWindowDidBecomeKeyNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidResignKey:)
- name:NSWindowDidResignKeyNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOnScreen:)
- name:WKWindowWillOrderOnScreenNotification() object:window];
- }
-}
-
-- (void)removeWindowObservers
-{
- NSWindow *window = [self window];
- if (!_private->useDocumentViews && window) {
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSWindowDidBecomeKeyNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSWindowDidResignKeyNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:WKWindowWillOrderOnScreenNotification() object:window];
- }
-}
-
-- (void)viewWillMoveToWindow:(NSWindow *)window
-{
- // Don't do anything if the WebView isn't initialized.
- // This happens when decoding a WebView in a nib.
- // FIXME: What sets up the observer of NSWindowWillCloseNotification in this case?
- if (!_private)
- return;
-
- if (_private->closed)
- return;
-
- if ([self window] && [self window] != [self hostWindow])
- [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:[self window]];
-
- if (window) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillClose:) name:NSWindowWillCloseNotification object:window];
-
- // Ensure that we will receive the events that WebHTMLView (at least) needs.
- // The following are expensive enough that we don't want to call them over
- // and over, so do them when we move into a window.
- [window setAcceptsMouseMovedEvents:YES];
- WKSetNSWindowShouldPostEventNotifications(window, YES);
-
- [self removeWindowObservers];
- [self removeSizeObservers];
- }
-}
-
-- (void)viewDidMoveToWindow
-{
- // Don't do anything if we aren't initialized. This happens
- // when decoding a WebView. When WebViews are decoded their subviews
- // are created by initWithCoder: and so won't be normally
- // initialized. The stub views are discarded by WebView.
- if (!_private || _private->closed)
- return;
-
- if ([self window]) {
- [self addWindowObservers];
- [self addSizeObservers];
- }
-}
-
-- (void)_updateFocusedAndActiveState
-{
- ASSERT(!_private->useDocumentViews);
- [self _updateFocusedAndActiveStateForFrame:[self mainFrame]];
-}
-
-- (void)_updateFocusedAndActiveStateForFrame:(WebFrame *)webFrame
-{
- Frame* frame = core(webFrame);
- if (!frame)
- return;
-
- Page* page = frame->page();
- if (!page)
- return;
-
- NSWindow *window = [self window];
- BOOL windowIsKey = [window isKeyWindow];
- BOOL windowOrSheetIsKey = windowIsKey || [[window attachedSheet] isKeyWindow];
-
- page->focusController()->setActive(windowIsKey);
-
- Frame* focusedFrame = page->focusController()->focusedOrMainFrame();
- frame->selection()->setFocused(frame == focusedFrame && windowOrSheetIsKey);
-}
-
-- (void)_windowDidBecomeKey:(NSNotification *)notification
-{
- ASSERT(!_private->useDocumentViews);
- NSWindow *keyWindow = [notification object];
- if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet])
- [self _updateFocusedAndActiveState];
-}
-
-- (void)_windowDidResignKey:(NSNotification *)notification
-{
- ASSERT(!_private->useDocumentViews);
- NSWindow *formerKeyWindow = [notification object];
- if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet])
- [self _updateFocusedAndActiveState];
-}
-
-- (void)_windowWillOrderOnScreen:(NSNotification *)notification
-{
- ASSERT(!_private->useDocumentViews);
- if (![self shouldUpdateWhileOffscreen])
- [self setNeedsDisplay:YES];
-}
-
-- (void)_windowWillClose:(NSNotification *)notification
-{
- if ([self shouldCloseWithWindow] && ([self window] == [self hostWindow] || ([self window] && ![self hostWindow]) || (![self window] && [self hostWindow])))
- [self close];
-}
-
-- (void)setPreferences:(WebPreferences *)prefs
-{
- if (!prefs)
- prefs = [WebPreferences standardPreferences];
-
- if (_private->preferences == prefs)
- return;
-
- [prefs willAddToWebView];
-
- WebPreferences *oldPrefs = _private->preferences;
-
- [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChangedNotification object:[self preferences]];
- [WebPreferences _removeReferenceForIdentifier:[oldPrefs identifier]];
-
- _private->preferences = [prefs retain];
-
- // After registering for the notification, post it so the WebCore settings update.
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:)
- name:WebPreferencesChangedNotification object:[self preferences]];
- [[self preferences] _postPreferencesChangesNotification];
-
- [oldPrefs didRemoveFromWebView];
- [oldPrefs release];
-}
-
-- (WebPreferences *)preferences
-{
- return _private->preferences;
-}
-
-- (void)setPreferencesIdentifier:(NSString *)anIdentifier
-{
- if (!_private->closed && ![anIdentifier isEqual:[[self preferences] identifier]]) {
- WebPreferences *prefs = [[WebPreferences alloc] initWithIdentifier:anIdentifier];
- [self setPreferences:prefs];
- [prefs release];
- }
-}
-
-- (NSString *)preferencesIdentifier
-{
- return [[self preferences] identifier];
-}
-
-
-- (void)setUIDelegate:delegate
-{
- _private->UIDelegate = delegate;
- [_private->UIDelegateForwarder release];
- _private->UIDelegateForwarder = nil;
-}
-
-- UIDelegate
-{
- return _private->UIDelegate;
-}
-
-- (void)setResourceLoadDelegate: delegate
-{
- _private->resourceProgressDelegate = delegate;
- [self _cacheResourceLoadDelegateImplementations];
-}
-
-- resourceLoadDelegate
-{
- return _private->resourceProgressDelegate;
-}
-
-- (void)setDownloadDelegate: delegate
-{
- _private->downloadDelegate = delegate;
-}
-
-
-- downloadDelegate
-{
- return _private->downloadDelegate;
-}
-
-- (void)setPolicyDelegate:delegate
-{
- _private->policyDelegate = delegate;
- [_private->policyDelegateForwarder release];
- _private->policyDelegateForwarder = nil;
-}
-
-- policyDelegate
-{
- return _private->policyDelegate;
-}
-
-- (void)setFrameLoadDelegate:delegate
-{
- _private->frameLoadDelegate = delegate;
- [self _cacheFrameLoadDelegateImplementations];
-
- // If this delegate wants callbacks for icons, fire up the icon database.
- if (_private->frameLoadDelegateImplementations.didReceiveIconForFrameFunc)
- [WebIconDatabase sharedIconDatabase];
-}
-
-- frameLoadDelegate
-{
- return _private->frameLoadDelegate;
-}
-
-- (WebFrame *)mainFrame
-{
- // This can be called in initialization, before _private has been set up (3465613)
- if (!_private)
- return nil;
- if (!_private->page)
- return nil;
- return kit(_private->page->mainFrame());
-}
-
-- (WebFrame *)selectedFrame
-{
- // If the first responder is a view in our tree, we get the frame containing the first responder.
- // This is faster than searching the frame hierarchy, and will give us a result even in the case
- // where the focused frame doesn't actually contain a selection.
- WebFrame *focusedFrame = [self _focusedFrame];
- if (focusedFrame)
- return focusedFrame;
-
- // If the first responder is outside of our view tree, we search for a frame containing a selection.
- // There should be at most only one of these.
- return [[self mainFrame] _findFrameWithSelection];
-}
-
-- (WebBackForwardList *)backForwardList
-{
- if (!_private->page)
- return nil;
- if (!_private->page->backForwardList()->enabled())
- return nil;
- return kit(_private->page->backForwardList());
-}
-
-- (void)setMaintainsBackForwardList: (BOOL)flag
-{
- if (!_private->page)
- return;
- _private->page->backForwardList()->setEnabled(flag);
-}
-
-- (BOOL)goBack
-{
- if (!_private->page)
- return NO;
-
- return _private->page->goBack();
-}
-
-- (BOOL)goForward
-{
- if (!_private->page)
- return NO;
-
- return _private->page->goForward();
-}
-
-- (BOOL)goToBackForwardItem:(WebHistoryItem *)item
-{
- if (!_private->page)
- return NO;
-
- _private->page->goToItem(core(item), FrameLoadTypeIndexedBackForward);
- return YES;
-}
-
-- (void)setTextSizeMultiplier:(float)m
-{
- [self _setZoomMultiplier:m isTextOnly:![[NSUserDefaults standardUserDefaults] boolForKey:WebKitDebugFullPageZoomPreferenceKey]];
-}
-
-- (float)textSizeMultiplier
-{
- return _private->zoomMultiplierIsTextOnly ? _private->zoomMultiplier : 1.0f;
-}
-
-- (void)_setZoomMultiplier:(float)m isTextOnly:(BOOL)isTextOnly
-{
- // NOTE: This has no visible effect when viewing a PDF (see <rdar://problem/4737380>)
- _private->zoomMultiplier = m;
- _private->zoomMultiplierIsTextOnly = isTextOnly;
- Frame* coreFrame = core([self mainFrame]);
- if (coreFrame)
- coreFrame->setZoomFactor(m, isTextOnly);
-}
-
-- (float)_zoomMultiplier:(BOOL)isTextOnly
-{
- if (isTextOnly != _private->zoomMultiplierIsTextOnly)
- return 1.0f;
- return _private->zoomMultiplier;
-}
-
-- (float)_realZoomMultiplier
-{
- return _private->zoomMultiplier;
-}
-
-- (BOOL)_realZoomMultiplierIsTextOnly
-{
- return _private->zoomMultiplierIsTextOnly;
-}
-
-#define MinimumZoomMultiplier 0.5f
-#define MaximumZoomMultiplier 3.0f
-#define ZoomMultiplierRatio 1.2f
-
-- (BOOL)_canZoomOut:(BOOL)isTextOnly
-{
- id docView = [[[self mainFrame] frameView] documentView];
- if ([docView conformsToProtocol:@protocol(_WebDocumentZooming)]) {
- id <_WebDocumentZooming> zoomingDocView = (id <_WebDocumentZooming>)docView;
- return [zoomingDocView _canZoomOut];
- }
- return [self _zoomMultiplier:isTextOnly] / ZoomMultiplierRatio > MinimumZoomMultiplier;
-}
-
-
-- (BOOL)_canZoomIn:(BOOL)isTextOnly
-{
- id docView = [[[self mainFrame] frameView] documentView];
- if ([docView conformsToProtocol:@protocol(_WebDocumentZooming)]) {
- id <_WebDocumentZooming> zoomingDocView = (id <_WebDocumentZooming>)docView;
- return [zoomingDocView _canZoomIn];
- }
- return [self _zoomMultiplier:isTextOnly] * ZoomMultiplierRatio < MaximumZoomMultiplier;
-}
-
-- (IBAction)_zoomOut:(id)sender isTextOnly:(BOOL)isTextOnly
-{
- id docView = [[[self mainFrame] frameView] documentView];
- if ([docView conformsToProtocol:@protocol(_WebDocumentZooming)]) {
- id <_WebDocumentZooming> zoomingDocView = (id <_WebDocumentZooming>)docView;
- return [zoomingDocView _zoomOut:sender];
- }
- float newScale = [self _zoomMultiplier:isTextOnly] / ZoomMultiplierRatio;
- if (newScale > MinimumZoomMultiplier)
- [self _setZoomMultiplier:newScale isTextOnly:isTextOnly];
-}
-
-- (IBAction)_zoomIn:(id)sender isTextOnly:(BOOL)isTextOnly
-{
- id docView = [[[self mainFrame] frameView] documentView];
- if ([docView conformsToProtocol:@protocol(_WebDocumentZooming)]) {
- id <_WebDocumentZooming> zoomingDocView = (id <_WebDocumentZooming>)docView;
- return [zoomingDocView _zoomIn:sender];
- }
- float newScale = [self _zoomMultiplier:isTextOnly] * ZoomMultiplierRatio;
- if (newScale < MaximumZoomMultiplier)
- [self _setZoomMultiplier:newScale isTextOnly:isTextOnly];
-}
-
-- (BOOL)_canResetZoom:(BOOL)isTextOnly
-{
- id docView = [[[self mainFrame] frameView] documentView];
- if ([docView conformsToProtocol:@protocol(_WebDocumentZooming)]) {
- id <_WebDocumentZooming> zoomingDocView = (id <_WebDocumentZooming>)docView;
- return [zoomingDocView _canResetZoom];
- }
- return [self _zoomMultiplier:isTextOnly] != 1.0f;
-}
-
-- (IBAction)_resetZoom:(id)sender isTextOnly:(BOOL)isTextOnly
-{
- id docView = [[[self mainFrame] frameView] documentView];
- if ([docView conformsToProtocol:@protocol(_WebDocumentZooming)]) {
- id <_WebDocumentZooming> zoomingDocView = (id <_WebDocumentZooming>)docView;
- return [zoomingDocView _resetZoom:sender];
- }
- if ([self _zoomMultiplier:isTextOnly] != 1.0f)
- [self _setZoomMultiplier:1.0f isTextOnly:isTextOnly];
-}
-
-- (void)viewWillMoveToSuperview:(NSView *)newSuperview
-{
- [self removeSizeObservers];
-}
-
-- (void)viewDidMoveToSuperview
-{
- if ([self superview] != nil)
- [self addSizeObservers];
-}
-
-- (void)setApplicationNameForUserAgent:(NSString *)applicationName
-{
- NSString *name = [applicationName copy];
- [_private->applicationNameForUserAgent release];
- _private->applicationNameForUserAgent = name;
- if (!_private->userAgentOverridden)
- _private->userAgent = String();
-}
-
-- (NSString *)applicationNameForUserAgent
-{
- return [[_private->applicationNameForUserAgent retain] autorelease];
-}
-
-- (void)setCustomUserAgent:(NSString *)userAgentString
-{
- _private->userAgent = userAgentString;
- _private->userAgentOverridden = userAgentString != nil;
-}
-
-- (NSString *)customUserAgent
-{
- if (!_private->userAgentOverridden)
- return nil;
- return _private->userAgent;
-}
-
-- (void)setMediaStyle:(NSString *)mediaStyle
-{
- if (_private->mediaStyle != mediaStyle) {
- [_private->mediaStyle release];
- _private->mediaStyle = [mediaStyle copy];
- }
-}
-
-- (NSString *)mediaStyle
-{
- return _private->mediaStyle;
-}
-
-- (BOOL)supportsTextEncoding
-{
- id documentView = [[[self mainFrame] frameView] documentView];
- return [documentView conformsToProtocol:@protocol(WebDocumentText)]
- && [documentView supportsTextEncoding];
-}
-
-- (void)setCustomTextEncodingName:(NSString *)encoding
-{
- NSString *oldEncoding = [self customTextEncodingName];
- if (encoding == oldEncoding || [encoding isEqualToString:oldEncoding])
- return;
- if (Frame* mainFrame = core([self mainFrame]))
- mainFrame->loader()->reloadAllowingStaleData(encoding);
-}
-
-- (NSString *)_mainFrameOverrideEncoding
-{
- WebDataSource *dataSource = [[self mainFrame] provisionalDataSource];
- if (dataSource == nil)
- dataSource = [[self mainFrame] _dataSource];
- if (dataSource == nil)
- return nil;
- return nsStringNilIfEmpty([dataSource _documentLoader]->overrideEncoding());
-}
-
-- (NSString *)customTextEncodingName
-{
- return [self _mainFrameOverrideEncoding];
-}
-
-- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
-{
- // Return statements are only valid in a function but some applications pass in scripts
- // prefixed with return (<rdar://problems/5103720&4616860>) since older WebKit versions
- // silently ignored the return. If the application is linked against an earlier version
- // of WebKit we will strip the return so the script wont fail.
- if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITHOUT_JAVASCRIPT_RETURN_QUIRK)) {
- NSRange returnStringRange = [script rangeOfString:@"return "];
- if (returnStringRange.length && !returnStringRange.location)
- script = [script substringFromIndex:returnStringRange.location + returnStringRange.length];
- }
-
- NSString *result = [[self mainFrame] _stringByEvaluatingJavaScriptFromString:script];
- // The only way stringByEvaluatingJavaScriptFromString can return nil is if the frame was removed by the script
- // Since there's no way to get rid of the main frame, result will never ever be nil here.
- ASSERT(result);
-
- return result;
-}
-
-- (WebScriptObject *)windowScriptObject
-{
- Frame* coreFrame = core([self mainFrame]);
- if (!coreFrame)
- return nil;
- return coreFrame->script()->windowScriptObject();
-}
-
-// Get the appropriate user-agent string for a particular URL.
-- (NSString *)userAgentForURL:(NSURL *)url
-{
- return [self _userAgentForURL:KURL([url absoluteURL])];
-}
-
-- (void)setHostWindow:(NSWindow *)hostWindow
-{
- if (_private->closed)
- return;
- if (hostWindow == _private->hostWindow)
- return;
-
- Frame* coreFrame = core([self mainFrame]);
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame))
- [[[kit(frame) frameView] documentView] viewWillMoveToHostWindow:hostWindow];
- if (_private->hostWindow && [self window] != _private->hostWindow)
- [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:_private->hostWindow];
- if (hostWindow)
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillClose:) name:NSWindowWillCloseNotification object:hostWindow];
- [_private->hostWindow release];
- _private->hostWindow = [hostWindow retain];
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame))
- [[[kit(frame) frameView] documentView] viewDidMoveToHostWindow];
-}
-
-- (NSWindow *)hostWindow
-{
- return _private->hostWindow;
-}
-
-- (NSView <WebDocumentView> *)documentViewAtWindowPoint:(NSPoint)point
-{
- return [[self _frameViewAtWindowPoint:point] documentView];
-}
-
-- (NSDictionary *)_elementAtWindowPoint:(NSPoint)windowPoint
-{
- WebFrameView *frameView = [self _frameViewAtWindowPoint:windowPoint];
- if (!frameView)
- return nil;
- NSView <WebDocumentView> *documentView = [frameView documentView];
- if ([documentView conformsToProtocol:@protocol(WebDocumentElement)]) {
- NSPoint point = [documentView convertPoint:windowPoint fromView:nil];
- return [(NSView <WebDocumentElement> *)documentView elementAtPoint:point];
- }
- return [NSDictionary dictionaryWithObject:[frameView webFrame] forKey:WebElementFrameKey];
-}
-
-- (NSDictionary *)elementAtPoint:(NSPoint)point
-{
- return [self _elementAtWindowPoint:[self convertPoint:point toView:nil]];
-}
-
-// The following 2 internal NSView methods are called on the drag destination by make scrolling while dragging work.
-// Scrolling while dragging will only work if the drag destination is in a scroll view. The WebView is the drag destination.
-// When dragging to a WebView, the document subview should scroll, but it doesn't because it is not the drag destination.
-// Forward these calls to the document subview to make its scroll view scroll.
-- (void)_autoscrollForDraggingInfo:(id)draggingInfo timeDelta:(NSTimeInterval)repeatDelta
-{
- NSView <WebDocumentView> *documentView = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
- [documentView _autoscrollForDraggingInfo:draggingInfo timeDelta:repeatDelta];
-}
-
-- (BOOL)_shouldAutoscrollForDraggingInfo:(id)draggingInfo
-{
- NSView <WebDocumentView> *documentView = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
- return [documentView _shouldAutoscrollForDraggingInfo:draggingInfo];
-}
-
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)draggingInfo
-{
- NSView <WebDocumentView>* view = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
- WebPasteboardHelper helper([view isKindOfClass:[WebHTMLView class]] ? (WebHTMLView*)view : nil);
- IntPoint client([draggingInfo draggingLocation]);
- IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
- DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask], &helper);
- return core(self)->dragController()->dragEntered(&dragData);
-}
-
-- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)draggingInfo
-{
- Page* page = core(self);
- if (!page)
- return NSDragOperationNone;
-
- NSView <WebDocumentView>* view = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
- WebPasteboardHelper helper([view isKindOfClass:[WebHTMLView class]] ? (WebHTMLView*)view : nil);
- IntPoint client([draggingInfo draggingLocation]);
- IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
- DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask], &helper);
- return page->dragController()->dragUpdated(&dragData);
-}
-
-- (void)draggingExited:(id <NSDraggingInfo>)draggingInfo
-{
- Page* page = core(self);
- if (!page)
- return;
-
- NSView <WebDocumentView>* view = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
- WebPasteboardHelper helper([view isKindOfClass:[WebHTMLView class]] ? (WebHTMLView*)view : nil);
- IntPoint client([draggingInfo draggingLocation]);
- IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
- DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask], &helper);
- page->dragController()->dragExited(&dragData);
-}
-
-- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)draggingInfo
-{
- return YES;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)draggingInfo
-{
- NSView <WebDocumentView>* view = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
- WebPasteboardHelper helper([view isKindOfClass:[WebHTMLView class]]? (WebHTMLView*)view : nil);
- IntPoint client([draggingInfo draggingLocation]);
- IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
- DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask], &helper);
- return core(self)->dragController()->performDrag(&dragData);
-}
-
-- (NSView *)_hitTest:(NSPoint *)aPoint dragTypes:(NSSet *)types
-{
- NSView *hitView = [super _hitTest:aPoint dragTypes:types];
- if (!hitView && [[self superview] mouse:*aPoint inRect:[self frame]]) {
- return self;
- } else {
- return hitView;
- }
-}
-
-- (BOOL)acceptsFirstResponder
-{
- return [[[self mainFrame] frameView] acceptsFirstResponder];
-}
-
-- (BOOL)becomeFirstResponder
-{
- if (_private->becomingFirstResponder) {
- // Fix for unrepro infinite recursion reported in radar 4448181. If we hit this assert on
- // a debug build, we should figure out what causes the problem and do a better fix.
- ASSERT_NOT_REACHED();
- return NO;
- }
-
- // This works together with setNextKeyView to splice the WebView into
- // the key loop similar to the way NSScrollView does this. Note that
- // WebFrameView has very similar code.
- NSWindow *window = [self window];
- WebFrameView *mainFrameView = [[self mainFrame] frameView];
-
- NSResponder *previousFirstResponder = [[self window] _oldFirstResponderBeforeBecoming];
- BOOL fromOutside = ![previousFirstResponder isKindOfClass:[NSView class]] || (![(NSView *)previousFirstResponder isDescendantOf:self] && previousFirstResponder != self);
-
- if ([window keyViewSelectionDirection] == NSSelectingPrevious) {
- NSView *previousValidKeyView = [self previousValidKeyView];
- if ((previousValidKeyView != self) && (previousValidKeyView != mainFrameView)) {
- _private->becomingFirstResponder = YES;
- _private->becomingFirstResponderFromOutside = fromOutside;
- [window makeFirstResponder:previousValidKeyView];
- _private->becomingFirstResponderFromOutside = NO;
- _private->becomingFirstResponder = NO;
- return YES;
- } else {
- return NO;
- }
- }
-
- if ([mainFrameView acceptsFirstResponder]) {
- _private->becomingFirstResponder = YES;
- _private->becomingFirstResponderFromOutside = fromOutside;
- [window makeFirstResponder:mainFrameView];
- _private->becomingFirstResponderFromOutside = NO;
- _private->becomingFirstResponder = NO;
- return YES;
- }
-
- return NO;
-}
-
-- (NSView *)_webcore_effectiveFirstResponder
-{
- WebFrameView *frameView = [[self mainFrame] frameView];
- return frameView ? [frameView _webcore_effectiveFirstResponder] : [super _webcore_effectiveFirstResponder];
-}
-
-- (void)setNextKeyView:(NSView *)aView
-{
- // This works together with becomeFirstResponder to splice the WebView into
- // the key loop similar to the way NSScrollView does this. Note that
- // WebFrameView has very similar code.
- WebFrameView *mainFrameView = [[self mainFrame] frameView];
- if (mainFrameView != nil) {
- [mainFrameView setNextKeyView:aView];
- } else {
- [super setNextKeyView:aView];
- }
-}
-
-static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
-{
- Frame* coreFrame = core(curr);
- return kit(forward
- ? coreFrame->tree()->traverseNextWithWrap(wrapFlag)
- : coreFrame->tree()->traversePreviousWithWrap(wrapFlag));
-}
-
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag
-{
- return [self searchFor:string direction:forward caseSensitive:caseFlag wrap:wrapFlag startInSelection:NO];
-}
-
-+ (void)registerViewClass:(Class)viewClass representationClass:(Class)representationClass forMIMEType:(NSString *)MIMEType
-{
- [[WebFrameView _viewTypesAllowImageTypeOmission:YES] setObject:viewClass forKey:MIMEType];
- [[WebDataSource _repTypesAllowImageTypeOmission:YES] setObject:representationClass forKey:MIMEType];
-
- // FIXME: We also need to maintain MIMEType registrations (which can be dynamically changed)
- // in the WebCore MIMEType registry. For now we're doing this in a safe, limited manner
- // to fix <rdar://problem/5372989> - a future revamping of the entire system is neccesary for future robustness
- if ([viewClass class] == [WebHTMLView class])
- MIMETypeRegistry::getSupportedNonImageMIMETypes().add(MIMEType);
-}
-
-- (void)setGroupName:(NSString *)groupName
-{
- if (!_private->page)
- return;
- _private->page->setGroupName(groupName);
-}
-
-- (NSString *)groupName
-{
- if (!_private->page)
- return nil;
- return _private->page->groupName();
-}
-
-- (double)estimatedProgress
-{
- if (!_private->page)
- return 0.0;
-
- return _private->page->progress()->estimatedProgress();
-}
-
-- (NSArray *)pasteboardTypesForSelection
-{
- NSView <WebDocumentView> *documentView = [[[self _selectedOrMainFrame] frameView] documentView];
- if ([documentView conformsToProtocol:@protocol(WebDocumentSelection)]) {
- return [(NSView <WebDocumentSelection> *)documentView pasteboardTypesForSelection];
- }
- return [NSArray array];
-}
-
-- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
-{
- WebFrame *frame = [self _selectedOrMainFrame];
- if (frame && [frame _hasSelection]) {
- NSView <WebDocumentView> *documentView = [[frame frameView] documentView];
- if ([documentView conformsToProtocol:@protocol(WebDocumentSelection)])
- [(NSView <WebDocumentSelection> *)documentView writeSelectionWithPasteboardTypes:types toPasteboard:pasteboard];
- }
-}
-
-- (NSArray *)pasteboardTypesForElement:(NSDictionary *)element
-{
- if ([element objectForKey:WebElementImageURLKey] != nil) {
- return [NSPasteboard _web_writableTypesForImageIncludingArchive:([element objectForKey:WebElementDOMNodeKey] != nil)];
- } else if ([element objectForKey:WebElementLinkURLKey] != nil) {
- return [NSPasteboard _web_writableTypesForURL];
- } else if ([[element objectForKey:WebElementIsSelectedKey] boolValue]) {
- return [self pasteboardTypesForSelection];
- }
- return [NSArray array];
-}
-
-- (void)writeElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
-{
- if ([element objectForKey:WebElementImageURLKey] != nil) {
- [self _writeImageForElement:element withPasteboardTypes:types toPasteboard:pasteboard];
- } else if ([element objectForKey:WebElementLinkURLKey] != nil) {
- [self _writeLinkElement:element withPasteboardTypes:types toPasteboard:pasteboard];
- } else if ([[element objectForKey:WebElementIsSelectedKey] boolValue]) {
- [self writeSelectionWithPasteboardTypes:types toPasteboard:pasteboard];
- }
-}
-
-- (void)moveDragCaretToPoint:(NSPoint)point
-{
- if (Page* page = core(self))
- page->dragController()->placeDragCaret(IntPoint([self convertPoint:point toView:nil]));
-}
-
-- (void)removeDragCaret
-{
- if (Page* page = core(self))
- page->dragController()->dragEnded();
-}
-
-- (void)setMainFrameURL:(NSString *)URLString
-{
- [[self mainFrame] loadRequest: [NSURLRequest requestWithURL: [NSURL _web_URLWithDataAsString: URLString]]];
-}
-
-- (NSString *)mainFrameURL
-{
- WebDataSource *ds;
- ds = [[self mainFrame] provisionalDataSource];
- if (!ds)
- ds = [[self mainFrame] _dataSource];
- return [[[ds request] URL] _web_originalDataAsString];
-}
-
-- (BOOL)isLoading
-{
- LOG (Bindings, "isLoading = %d", (int)[self _isLoading]);
- return [self _isLoading];
-}
-
-- (NSString *)mainFrameTitle
-{
- NSString *mainFrameTitle = [[[self mainFrame] _dataSource] pageTitle];
- return (mainFrameTitle != nil) ? mainFrameTitle : (NSString *)@"";
-}
-
-- (NSImage *)mainFrameIcon
-{
- return [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[self mainFrame] _dataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
-}
-
-- (DOMDocument *)mainFrameDocument
-{
- // only return the actual value if the state we're in gives NSTreeController
- // enough time to release its observers on the old model
- if (_private->mainFrameDocumentReady)
- return [[self mainFrame] DOMDocument];
- return nil;
-}
-
-- (void)setDrawsBackground:(BOOL)drawsBackground
-{
- if (_private->drawsBackground == drawsBackground)
- return;
- _private->drawsBackground = drawsBackground;
- [[self mainFrame] _updateBackgroundAndUpdatesWhileOffscreen];
-}
-
-- (BOOL)drawsBackground
-{
- return _private->drawsBackground;
-}
-
-- (void)setShouldUpdateWhileOffscreen:(BOOL)updateWhileOffscreen
-{
- if (_private->shouldUpdateWhileOffscreen == updateWhileOffscreen)
- return;
- _private->shouldUpdateWhileOffscreen = updateWhileOffscreen;
- [[self mainFrame] _updateBackgroundAndUpdatesWhileOffscreen];
-}
-
-- (BOOL)shouldUpdateWhileOffscreen
-{
- return _private->shouldUpdateWhileOffscreen;
-}
-
-- (void)setCurrentNodeHighlight:(WebNodeHighlight *)nodeHighlight
-{
- id old = _private->currentNodeHighlight;
- _private->currentNodeHighlight = [nodeHighlight retain];
- [old release];
-}
-
-- (WebNodeHighlight *)currentNodeHighlight
-{
- return _private->currentNodeHighlight;
-}
-
-@end
-
-@implementation WebView (WebIBActions)
-
-- (IBAction)takeStringURLFrom: sender
-{
- NSString *URLString = [sender stringValue];
-
- [[self mainFrame] loadRequest: [NSURLRequest requestWithURL: [NSURL _web_URLWithDataAsString: URLString]]];
-}
-
-- (BOOL)canGoBack
-{
- if (!_private->page)
- return NO;
-
- return !!_private->page->backForwardList()->backItem();
-}
-
-- (BOOL)canGoForward
-{
- if (!_private->page)
- return NO;
-
- return !!_private->page->backForwardList()->forwardItem();
-}
-
-- (IBAction)goBack:(id)sender
-{
- [self goBack];
-}
-
-- (IBAction)goForward:(id)sender
-{
- [self goForward];
-}
-
-- (IBAction)stopLoading:(id)sender
-{
- [[self mainFrame] stopLoading];
-}
-
-- (IBAction)reload:(id)sender
-{
- [[self mainFrame] reload];
-}
-
-// FIXME: This code should move into WebCore so that it is not duplicated in each WebKit.
-// (This includes canMakeTextSmaller/Larger, makeTextSmaller/Larger, and canMakeTextStandardSize/makeTextStandardSize)
-- (BOOL)canMakeTextSmaller
-{
- return [self _canZoomOut:![[NSUserDefaults standardUserDefaults] boolForKey:WebKitDebugFullPageZoomPreferenceKey]];
-}
-
-- (IBAction)makeTextSmaller:(id)sender
-{
- return [self _zoomOut:sender isTextOnly:![[NSUserDefaults standardUserDefaults] boolForKey:WebKitDebugFullPageZoomPreferenceKey]];
-}
-
-- (BOOL)canMakeTextLarger
-{
- return [self _canZoomIn:![[NSUserDefaults standardUserDefaults] boolForKey:WebKitDebugFullPageZoomPreferenceKey]];
-}
-
-- (IBAction)makeTextLarger:(id)sender
-{
- return [self _zoomIn:sender isTextOnly:![[NSUserDefaults standardUserDefaults] boolForKey:WebKitDebugFullPageZoomPreferenceKey]];
-}
-
-- (BOOL)canMakeTextStandardSize
-{
- return [self _canResetZoom:![[NSUserDefaults standardUserDefaults] boolForKey:WebKitDebugFullPageZoomPreferenceKey]];
-}
-
-- (IBAction)makeTextStandardSize:(id)sender
-{
- return [self _resetZoom:sender isTextOnly:![[NSUserDefaults standardUserDefaults] boolForKey:WebKitDebugFullPageZoomPreferenceKey]];
-}
-
-- (IBAction)toggleSmartInsertDelete:(id)sender
-{
- [self setSmartInsertDeleteEnabled:![self smartInsertDeleteEnabled]];
-}
-
-- (IBAction)toggleContinuousSpellChecking:(id)sender
-{
- [self setContinuousSpellCheckingEnabled:![self isContinuousSpellCheckingEnabled]];
-}
-
-- (BOOL)_responderValidateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
-{
- id responder = [self _responderForResponderOperations];
- if (responder != self && [responder respondsToSelector:[item action]]) {
- if ([responder respondsToSelector:@selector(validateUserInterfaceItemWithoutDelegate:)])
- return [responder validateUserInterfaceItemWithoutDelegate:item];
- if ([responder respondsToSelector:@selector(validateUserInterfaceItem:)])
- return [responder validateUserInterfaceItem:item];
- return YES;
- }
- return NO;
-}
-
-#define VALIDATE(name) \
- else if (action == @selector(name:)) { return [self _responderValidateUserInterfaceItem:item]; }
-
-- (BOOL)validateUserInterfaceItemWithoutDelegate:(id <NSValidatedUserInterfaceItem>)item
-{
- SEL action = [item action];
-
- if (action == @selector(goBack:)) {
- return [self canGoBack];
- } else if (action == @selector(goForward:)) {
- return [self canGoForward];
- } else if (action == @selector(makeTextLarger:)) {
- return [self canMakeTextLarger];
- } else if (action == @selector(makeTextSmaller:)) {
- return [self canMakeTextSmaller];
- } else if (action == @selector(makeTextStandardSize:)) {
- return [self canMakeTextStandardSize];
- } else if (action == @selector(reload:)) {
- return [[self mainFrame] _dataSource] != nil;
- } else if (action == @selector(stopLoading:)) {
- return [self _isLoading];
- } else if (action == @selector(toggleContinuousSpellChecking:)) {
- BOOL checkMark = NO;
- BOOL retVal = NO;
- if ([self _continuousCheckingAllowed]) {
- checkMark = [self isContinuousSpellCheckingEnabled];
- retVal = YES;
- }
- if ([(NSObject *)item isKindOfClass:[NSMenuItem class]]) {
- NSMenuItem *menuItem = (NSMenuItem *)item;
- [menuItem setState:checkMark ? NSOnState : NSOffState];
- }
- return retVal;
-#ifndef BUILDING_ON_TIGER
- } else if (action == @selector(toggleGrammarChecking:)) {
- BOOL checkMark = [self isGrammarCheckingEnabled];
- if ([(NSObject *)item isKindOfClass:[NSMenuItem class]]) {
- NSMenuItem *menuItem = (NSMenuItem *)item;
- [menuItem setState:checkMark ? NSOnState : NSOffState];
- }
- return YES;
-#endif
- }
- FOR_EACH_RESPONDER_SELECTOR(VALIDATE)
-
- return YES;
-}
-
-- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
-{
- BOOL result = [self validateUserInterfaceItemWithoutDelegate:item];
- return CallUIDelegateReturningBoolean(result, self, @selector(webView:validateUserInterfaceItem:defaultValidation:), item, result);
-}
-
-@end
-
-@implementation WebView (WebPendingPublic)
-
-- (void)scheduleInRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode
-{
-#ifndef BUILDING_ON_TIGER
- if (runLoop && mode)
- core(self)->addSchedulePair(SchedulePair::create(runLoop, (CFStringRef)mode));
-#endif
-}
-
-- (void)unscheduleFromRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode
-{
-#ifndef BUILDING_ON_TIGER
- if (runLoop && mode)
- core(self)->removeSchedulePair(SchedulePair::create(runLoop, (CFStringRef)mode));
-#endif
-}
-
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection
-{
- if (_private->closed)
- return NO;
-
- // Get the frame holding the selection, or start with the main frame
- WebFrame *startFrame = [self _selectedOrMainFrame];
-
- // Search the first frame, then all the other frames, in order
- NSView <WebDocumentSearching> *startSearchView = nil;
- WebFrame *frame = startFrame;
- do {
- WebFrame *nextFrame = incrementFrame(frame, forward, wrapFlag);
-
- BOOL onlyOneFrame = (frame == nextFrame);
- ASSERT(!onlyOneFrame || frame == startFrame);
-
- id <WebDocumentView> view = [[frame frameView] documentView];
- if ([view conformsToProtocol:@protocol(WebDocumentSearching)]) {
- NSView <WebDocumentSearching> *searchView = (NSView <WebDocumentSearching> *)view;
-
- if (frame == startFrame)
- startSearchView = searchView;
-
- BOOL foundString;
- // In some cases we have to search some content twice; see comment later in this method.
- // We can avoid ever doing this in the common one-frame case by passing YES for wrapFlag
- // here, and then bailing out before we get to the code that would search again in the
- // same content.
- BOOL wrapOnThisPass = wrapFlag && onlyOneFrame;
- if ([searchView conformsToProtocol:@protocol(WebDocumentIncrementalSearching)])
- foundString = [(NSView <WebDocumentIncrementalSearching> *)searchView searchFor:string direction:forward caseSensitive:caseFlag wrap:wrapOnThisPass startInSelection:startInSelection];
- else
- foundString = [searchView searchFor:string direction:forward caseSensitive:caseFlag wrap:wrapOnThisPass];
-
- if (foundString) {
- if (frame != startFrame)
- [startFrame _clearSelection];
- [[self window] makeFirstResponder:searchView];
- return YES;
- }
-
- if (onlyOneFrame)
- return NO;
- }
- frame = nextFrame;
- } while (frame && frame != startFrame);
-
- // If there are multiple frames and wrapFlag is true and we've visited each one without finding a result, we still need to search in the
- // first-searched frame up to the selection. However, the API doesn't provide a way to search only up to a particular point. The only
- // way to make sure the entire frame is searched is to pass YES for the wrapFlag. When there are no matches, this will search again
- // some content that we already searched on the first pass. In the worst case, we could search the entire contents of this frame twice.
- // To fix this, we'd need to add a mechanism to specify a range in which to search.
- if (wrapFlag && startSearchView) {
- BOOL foundString;
- if ([startSearchView conformsToProtocol:@protocol(WebDocumentIncrementalSearching)])
- foundString = [(NSView <WebDocumentIncrementalSearching> *)startSearchView searchFor:string direction:forward caseSensitive:caseFlag wrap:YES startInSelection:startInSelection];
- else
- foundString = [startSearchView searchFor:string direction:forward caseSensitive:caseFlag wrap:YES];
- if (foundString) {
- [[self window] makeFirstResponder:startSearchView];
- return YES;
- }
- }
- return NO;
-}
-
-- (void)setHoverFeedbackSuspended:(BOOL)newValue
-{
- if (_private->hoverFeedbackSuspended == newValue)
- return;
-
- _private->hoverFeedbackSuspended = newValue;
- id <WebDocumentView> documentView = [[[self mainFrame] frameView] documentView];
- // FIXME: in a perfect world we'd do this in a general way that worked with any document view,
- // such as by calling a protocol method or using respondsToSelector or sending a notification.
- // But until there is any need for these more general solutions, we'll just hardwire it to work
- // with WebHTMLView.
- // Note that _hoverFeedbackSuspendedChanged needs to be called only on the main WebHTMLView, not
- // on each subframe separately.
- if ([documentView isKindOfClass:[WebHTMLView class]])
- [(WebHTMLView *)documentView _hoverFeedbackSuspendedChanged];
-}
-
-- (BOOL)isHoverFeedbackSuspended
-{
- return _private->hoverFeedbackSuspended;
-}
-
-- (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady
-{
- // by setting this to NO, calls to mainFrameDocument are forced to return nil
- // setting this to YES lets it return the actual DOMDocument value
- // we use this to tell NSTreeController to reset its observers and clear its state
- if (_private->mainFrameDocumentReady == mainFrameDocumentReady)
- return;
- [self _willChangeValueForKey:_WebMainFrameDocumentKey];
- _private->mainFrameDocumentReady = mainFrameDocumentReady;
- [self _didChangeValueForKey:_WebMainFrameDocumentKey];
- // this will cause observers to call mainFrameDocument where this flag will be checked
-}
-
-// This method name is used by Mail on Tiger (but not post-Tiger), so we shouldn't delete it
-// until the day comes when we're no longer supporting Mail on Tiger.
-- (WebFrame *)_frameForCurrentSelection
-{
- return [self _selectedOrMainFrame];
-}
-
-- (void)setTabKeyCyclesThroughElements:(BOOL)cyclesElements
-{
- _private->tabKeyCyclesThroughElementsChanged = YES;
- if (_private->page)
- _private->page->setTabKeyCyclesThroughElements(cyclesElements);
-}
-
-- (BOOL)tabKeyCyclesThroughElements
-{
- return _private->page && _private->page->tabKeyCyclesThroughElements();
-}
-
-- (void)setScriptDebugDelegate:(id)delegate
-{
- _private->scriptDebugDelegate = delegate;
- [_private->scriptDebugDelegateForwarder release];
- _private->scriptDebugDelegateForwarder = nil;
- if (delegate)
- [self _attachScriptDebuggerToAllFrames];
- else
- [self _detachScriptDebuggerFromAllFrames];
-}
-
-- (id)scriptDebugDelegate
-{
- return _private->scriptDebugDelegate;
-}
-
-- (BOOL)shouldClose
-{
- Frame* coreFrame = core([self mainFrame]);
- if (!coreFrame)
- return YES;
- return coreFrame->shouldClose();
-}
-
-static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue* jsValue)
-{
- NSAppleEventDescriptor* aeDesc = 0;
- if (jsValue->isBoolean())
- return [NSAppleEventDescriptor descriptorWithBoolean:jsValue->getBoolean()];
- if (jsValue->isString())
- return [NSAppleEventDescriptor descriptorWithString:String(jsValue->getString())];
- if (jsValue->isNumber()) {
- double value = jsValue->getNumber();
- int intValue = value;
- if (value == intValue)
- return [NSAppleEventDescriptor descriptorWithDescriptorType:typeSInt32 bytes:&intValue length:sizeof(intValue)];
- return [NSAppleEventDescriptor descriptorWithDescriptorType:typeIEEE64BitFloatingPoint bytes:&value length:sizeof(value)];
- }
- if (jsValue->isObject()) {
- JSObject* object = jsValue->getObject();
- if (object->inherits(&DateInstance::info)) {
- DateInstance* date = static_cast<DateInstance*>(object);
- double ms = 0;
- int tzOffset = 0;
- if (date->getTime(ms, tzOffset)) {
- CFAbsoluteTime utcSeconds = ms / 1000 - kCFAbsoluteTimeIntervalSince1970;
- LongDateTime ldt;
- if (noErr == UCConvertCFAbsoluteTimeToLongDateTime(utcSeconds, &ldt))
- return [NSAppleEventDescriptor descriptorWithDescriptorType:typeLongDateTime bytes:&ldt length:sizeof(ldt)];
- }
- }
- else if (object->inherits(&JSArray::info)) {
- static HashSet<JSObject*> visitedElems;
- if (!visitedElems.contains(object)) {
- visitedElems.add(object);
-
- JSArray* array = static_cast<JSArray*>(object);
- aeDesc = [NSAppleEventDescriptor listDescriptor];
- unsigned numItems = array->length();
- for (unsigned i = 0; i < numItems; ++i)
- [aeDesc insertDescriptor:aeDescFromJSValue(exec, array->get(exec, i)) atIndex:0];
-
- visitedElems.remove(object);
- return aeDesc;
- }
- }
- JSValue* primitive = object->toPrimitive(exec);
- if (exec->hadException()) {
- exec->clearException();
- return [NSAppleEventDescriptor nullDescriptor];
- }
- return aeDescFromJSValue(exec, primitive);
- }
- if (jsValue->isUndefined())
- return [NSAppleEventDescriptor descriptorWithTypeCode:cMissingValue];
- ASSERT(jsValue->isNull());
- return [NSAppleEventDescriptor nullDescriptor];
-}
-
-- (NSAppleEventDescriptor *)aeDescByEvaluatingJavaScriptFromString:(NSString *)script
-{
- Frame* coreFrame = core([self mainFrame]);
- if (!coreFrame)
- return nil;
- if (!coreFrame->document())
- return nil;
- JSValue* result = coreFrame->loader()->executeScript(script, true);
- if (!result) // FIXME: pass errors
- return 0;
- JSLock lock(false);
- return aeDescFromJSValue(coreFrame->script()->globalObject()->globalExec(), result);
-}
-
-- (BOOL)canMarkAllTextMatches
-{
- WebFrame *frame = [self mainFrame];
- do {
- id <WebDocumentView> view = [[frame frameView] documentView];
- if (view && ![view conformsToProtocol:@protocol(WebMultipleTextMatches)])
- return NO;
-
- frame = incrementFrame(frame, YES, NO);
- } while (frame);
-
- return YES;
-}
-
-- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit
-{
- WebFrame *frame = [self mainFrame];
- unsigned matchCount = 0;
- do {
- id <WebDocumentView> view = [[frame frameView] documentView];
- if ([view conformsToProtocol:@protocol(WebMultipleTextMatches)]) {
- [(NSView <WebMultipleTextMatches>*)view setMarkedTextMatchesAreHighlighted:highlight];
-
- ASSERT(limit == 0 || matchCount < limit);
- matchCount += [(NSView <WebMultipleTextMatches>*)view markAllMatchesForText:string caseSensitive:caseFlag limit:limit == 0 ? 0 : limit - matchCount];
-
- // Stop looking if we've reached the limit. A limit of 0 means no limit.
- if (limit > 0 && matchCount >= limit)
- break;
- }
-
- frame = incrementFrame(frame, YES, NO);
- } while (frame);
-
- return matchCount;
-}
-
-- (void)unmarkAllTextMatches
-{
- WebFrame *frame = [self mainFrame];
- do {
- id <WebDocumentView> view = [[frame frameView] documentView];
- if ([view conformsToProtocol:@protocol(WebMultipleTextMatches)])
- [(NSView <WebMultipleTextMatches>*)view unmarkAllTextMatches];
-
- frame = incrementFrame(frame, YES, NO);
- } while (frame);
-}
-
-- (NSArray *)rectsForTextMatches
-{
- NSMutableArray *result = [NSMutableArray array];
- WebFrame *frame = [self mainFrame];
- do {
- id <WebDocumentView> view = [[frame frameView] documentView];
- if ([view conformsToProtocol:@protocol(WebMultipleTextMatches)]) {
- NSView <WebMultipleTextMatches> *documentView = (NSView <WebMultipleTextMatches> *)view;
- NSRect documentViewVisibleRect = [documentView visibleRect];
- NSArray *originalRects = [documentView rectsForTextMatches];
- unsigned rectCount = [originalRects count];
- unsigned rectIndex;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- for (rectIndex = 0; rectIndex < rectCount; ++rectIndex) {
- NSRect r = [[originalRects objectAtIndex:rectIndex] rectValue];
- // Clip rect to document view's visible rect so rect is confined to subframe
- r = NSIntersectionRect(r, documentViewVisibleRect);
- if (NSIsEmptyRect(r))
- continue;
-
- // Convert rect to our coordinate system
- r = [documentView convertRect:r toView:self];
- [result addObject:[NSValue valueWithRect:r]];
- if (rectIndex % 10 == 0) {
- [pool drain];
- pool = [[NSAutoreleasePool alloc] init];
- }
- }
- [pool drain];
- }
-
- frame = incrementFrame(frame, YES, NO);
- } while (frame);
-
- return result;
-}
-
-- (void)scrollDOMRangeToVisible:(DOMRange *)range
-{
- [[[[range startContainer] ownerDocument] webFrame] _scrollDOMRangeToVisible:range];
-}
-
-- (BOOL)allowsUndo
-{
- return _private->allowsUndo;
-}
-
-- (void)setAllowsUndo:(BOOL)flag
-{
- _private->allowsUndo = flag;
-}
-
-- (void)setPageSizeMultiplier:(float)m
-{
- [self _setZoomMultiplier:m isTextOnly:NO];
-}
-
-- (float)pageSizeMultiplier
-{
- return !_private->zoomMultiplierIsTextOnly ? _private->zoomMultiplier : 1.0f;
-}
-
-- (BOOL)canZoomPageIn
-{
- return [self _canZoomIn:NO];
-}
-
-- (IBAction)zoomPageIn:(id)sender
-{
- return [self _zoomIn:sender isTextOnly:NO];
-}
-
-- (BOOL)canZoomPageOut
-{
- return [self _canZoomOut:NO];
-}
-
-- (IBAction)zoomPageOut:(id)sender
-{
- return [self _zoomOut:sender isTextOnly:NO];
-}
-
-- (BOOL)canResetPageZoom
-{
- return [self _canResetZoom:NO];
-}
-
-- (IBAction)resetPageZoom:(id)sender
-{
- return [self _resetZoom:sender isTextOnly:NO];
-}
-
-@end
-
-@implementation WebView (WebViewPrintingPrivate)
-
-- (float)_headerHeight
-{
- return CallUIDelegateReturningFloat(self, @selector(webViewHeaderHeight:));
-}
-
-- (float)_footerHeight
-{
- return CallUIDelegateReturningFloat(self, @selector(webViewFooterHeight:));
-}
-
-- (void)_drawHeaderInRect:(NSRect)rect
-{
-#ifdef DEBUG_HEADER_AND_FOOTER
- NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
- [currentContext saveGraphicsState];
- [[NSColor yellowColor] set];
- NSRectFill(rect);
- [currentContext restoreGraphicsState];
-#endif
-
- SEL selector = @selector(webView:drawHeaderInRect:);
- if (![_private->UIDelegate respondsToSelector:selector])
- return;
-
- NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
- [currentContext saveGraphicsState];
-
- NSRectClip(rect);
- CallUIDelegate(self, selector, rect);
-
- [currentContext restoreGraphicsState];
-}
-
-- (void)_drawFooterInRect:(NSRect)rect
-{
-#ifdef DEBUG_HEADER_AND_FOOTER
- NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
- [currentContext saveGraphicsState];
- [[NSColor cyanColor] set];
- NSRectFill(rect);
- [currentContext restoreGraphicsState];
-#endif
-
- SEL selector = @selector(webView:drawFooterInRect:);
- if (![_private->UIDelegate respondsToSelector:selector])
- return;
-
- NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
- [currentContext saveGraphicsState];
-
- NSRectClip(rect);
- CallUIDelegate(self, selector, rect);
-
- [currentContext restoreGraphicsState];
-}
-
-- (void)_adjustPrintingMarginsForHeaderAndFooter
-{
- NSPrintOperation *op = [NSPrintOperation currentOperation];
- NSPrintInfo *info = [op printInfo];
- NSMutableDictionary *infoDictionary = [info dictionary];
-
- // We need to modify the top and bottom margins in the NSPrintInfo to account for the space needed by the
- // header and footer. Because this method can be called more than once on the same NSPrintInfo (see 5038087),
- // we stash away the unmodified top and bottom margins the first time this method is called, and we read from
- // those stashed-away values on subsequent calls.
- float originalTopMargin;
- float originalBottomMargin;
- NSNumber *originalTopMarginNumber = [infoDictionary objectForKey:WebKitOriginalTopPrintingMarginKey];
- if (!originalTopMarginNumber) {
- ASSERT(![infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey]);
- originalTopMargin = [info topMargin];
- originalBottomMargin = [info bottomMargin];
- [infoDictionary setObject:[NSNumber numberWithFloat:originalTopMargin] forKey:WebKitOriginalTopPrintingMarginKey];
- [infoDictionary setObject:[NSNumber numberWithFloat:originalBottomMargin] forKey:WebKitOriginalBottomPrintingMarginKey];
- } else {
- ASSERT([originalTopMarginNumber isKindOfClass:[NSNumber class]]);
- ASSERT([[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] isKindOfClass:[NSNumber class]]);
- originalTopMargin = [originalTopMarginNumber floatValue];
- originalBottomMargin = [[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] floatValue];
- }
-
- float scale = [op _web_pageSetupScaleFactor];
- [info setTopMargin:originalTopMargin + [self _headerHeight] * scale];
- [info setBottomMargin:originalBottomMargin + [self _footerHeight] * scale];
-}
-
-- (void)_drawHeaderAndFooter
-{
- // The header and footer rect height scales with the page, but the width is always
- // all the way across the printed page (inset by printing margins).
- NSPrintOperation *op = [NSPrintOperation currentOperation];
- float scale = [op _web_pageSetupScaleFactor];
- NSPrintInfo *printInfo = [op printInfo];
- NSSize paperSize = [printInfo paperSize];
- float headerFooterLeft = [printInfo leftMargin]/scale;
- float headerFooterWidth = (paperSize.width - ([printInfo leftMargin] + [printInfo rightMargin]))/scale;
- NSRect footerRect = NSMakeRect(headerFooterLeft, [printInfo bottomMargin]/scale - [self _footerHeight] ,
- headerFooterWidth, [self _footerHeight]);
- NSRect headerRect = NSMakeRect(headerFooterLeft, (paperSize.height - [printInfo topMargin])/scale,
- headerFooterWidth, [self _headerHeight]);
-
- [self _drawHeaderInRect:headerRect];
- [self _drawFooterInRect:footerRect];
-}
-@end
-
-@implementation WebView (WebDebugBinding)
-
-- (void)addObserver:(NSObject *)anObserver forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(void *)context
-{
- LOG (Bindings, "addObserver:%p forKeyPath:%@ options:%x context:%p", anObserver, keyPath, options, context);
- [super addObserver:anObserver forKeyPath:keyPath options:options context:context];
-}
-
-- (void)removeObserver:(NSObject *)anObserver forKeyPath:(NSString *)keyPath
-{
- LOG (Bindings, "removeObserver:%p forKeyPath:%@", anObserver, keyPath);
- [super removeObserver:anObserver forKeyPath:keyPath];
-}
-
-@end
-
-//==========================================================================================
-// Editing
-
-@implementation WebView (WebViewCSS)
-
-- (DOMCSSStyleDeclaration *)computedStyleForElement:(DOMElement *)element pseudoElement:(NSString *)pseudoElement
-{
- // FIXME: is this the best level for this conversion?
- if (pseudoElement == nil)
- pseudoElement = @"";
-
- return [[element ownerDocument] getComputedStyle:element pseudoElement:pseudoElement];
-}
-
-@end
-
-@implementation WebView (WebViewEditing)
-
-- (DOMRange *)editableDOMRangeForPoint:(NSPoint)point
-{
- Page* page = core(self);
- if (!page)
- return nil;
- return kit(page->mainFrame()->editor()->rangeForPoint(IntPoint([self convertPoint:point toView:nil])).get());
-}
-
-- (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
-{
- // FIXME: This quirk is needed due to <rdar://problem/4985321> - We can phase it out once Aperture can adopt the new behavior on their end
- if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITHOUT_APERTURE_QUIRK) && [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Aperture"])
- return YES;
- return [[self _editingDelegateForwarder] webView:self shouldChangeSelectedDOMRange:currentRange toDOMRange:proposedRange affinity:selectionAffinity stillSelecting:flag];
-}
-
-- (BOOL)maintainsInactiveSelection
-{
- return NO;
-}
-
-- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)selectionAffinity
-{
- Frame* coreFrame = core([self _selectedOrMainFrame]);
- if (!coreFrame)
- return;
-
- if (range == nil)
- coreFrame->selection()->clear();
- else {
- // Derive the frame to use from the range passed in.
- // Using _selectedOrMainFrame could give us a different document than
- // the one the range uses.
- coreFrame = core([range startContainer])->document()->frame();
- if (!coreFrame)
- return;
-
- coreFrame->selection()->setSelectedRange([range _range], core(selectionAffinity), true);
- }
-}
-
-- (DOMRange *)selectedDOMRange
-{
- Frame* coreFrame = core([self _selectedOrMainFrame]);
- if (!coreFrame)
- return nil;
- return kit(coreFrame->selection()->toRange().get());
-}
-
-- (NSSelectionAffinity)selectionAffinity
-{
- Frame* coreFrame = core([self _selectedOrMainFrame]);
- if (!coreFrame)
- return NSSelectionAffinityDownstream;
- return kit(coreFrame->selection()->affinity());
-}
-
-- (void)setEditable:(BOOL)flag
-{
- if (_private->editable != flag) {
- _private->editable = flag;
- if (!_private->tabKeyCyclesThroughElementsChanged && _private->page)
- _private->page->setTabKeyCyclesThroughElements(!flag);
- Frame* mainFrame = core([self mainFrame]);
- if (mainFrame) {
- if (flag) {
- mainFrame->applyEditingStyleToBodyElement();
- // If the WebView is made editable and the selection is empty, set it to something.
- if (![self selectedDOMRange])
- mainFrame->setSelectionFromNone();
- } else
- mainFrame->removeEditingStyleFromBodyElement();
- }
- }
-}
-
-- (BOOL)isEditable
-{
- return _private->editable;
-}
-
-- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style
-{
- // We don't know enough at thls level to pass in a relevant WebUndoAction; we'd have to
- // change the API to allow this.
- [[self _selectedOrMainFrame] _setTypingStyle:style withUndoAction:EditActionUnspecified];
-}
-
-- (DOMCSSStyleDeclaration *)typingStyle
-{
- return [[self _selectedOrMainFrame] _typingStyle];
-}
-
-- (void)setSmartInsertDeleteEnabled:(BOOL)flag
-{
- _private->smartInsertDeleteEnabled = flag;
-}
-
-- (BOOL)smartInsertDeleteEnabled
-{
- return _private->smartInsertDeleteEnabled;
-}
-
-- (void)setContinuousSpellCheckingEnabled:(BOOL)flag
-{
- if (continuousSpellCheckingEnabled != flag) {
- continuousSpellCheckingEnabled = flag;
- [[NSUserDefaults standardUserDefaults] setBool:continuousSpellCheckingEnabled forKey:WebContinuousSpellCheckingEnabled];
- }
-
- if ([self isContinuousSpellCheckingEnabled]) {
- [[self class] _preflightSpellChecker];
- } else {
- [[self mainFrame] _unmarkAllMisspellings];
- }
-}
-
-- (BOOL)isContinuousSpellCheckingEnabled
-{
- return (continuousSpellCheckingEnabled && [self _continuousCheckingAllowed]);
-}
-
-- (NSInteger)spellCheckerDocumentTag
-{
- if (!_private->hasSpellCheckerDocumentTag) {
- _private->spellCheckerDocumentTag = [NSSpellChecker uniqueSpellDocumentTag];
- _private->hasSpellCheckerDocumentTag = YES;
- }
- return _private->spellCheckerDocumentTag;
-}
-
-- (NSUndoManager *)undoManager
-{
- if (!_private->allowsUndo)
- return nil;
-
- NSUndoManager *undoManager = [[self _editingDelegateForwarder] undoManagerForWebView:self];
- if (undoManager)
- return undoManager;
-
- return [super undoManager];
-}
-
-- (void)registerForEditingDelegateNotification:(NSString *)name selector:(SEL)selector
-{
- NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
- if ([_private->editingDelegate respondsToSelector:selector])
- [defaultCenter addObserver:_private->editingDelegate selector:selector name:name object:self];
-}
-
-- (void)setEditingDelegate:(id)delegate
-{
- if (_private->editingDelegate == delegate)
- return;
-
- NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
-
- // remove notifications from current delegate
- [defaultCenter removeObserver:_private->editingDelegate name:WebViewDidBeginEditingNotification object:self];
- [defaultCenter removeObserver:_private->editingDelegate name:WebViewDidChangeNotification object:self];
- [defaultCenter removeObserver:_private->editingDelegate name:WebViewDidEndEditingNotification object:self];
- [defaultCenter removeObserver:_private->editingDelegate name:WebViewDidChangeTypingStyleNotification object:self];
- [defaultCenter removeObserver:_private->editingDelegate name:WebViewDidChangeSelectionNotification object:self];
-
- _private->editingDelegate = delegate;
- [_private->editingDelegateForwarder release];
- _private->editingDelegateForwarder = nil;
-
- // add notifications for new delegate
- [self registerForEditingDelegateNotification:WebViewDidBeginEditingNotification selector:@selector(webViewDidBeginEditing:)];
- [self registerForEditingDelegateNotification:WebViewDidChangeNotification selector:@selector(webViewDidChange:)];
- [self registerForEditingDelegateNotification:WebViewDidEndEditingNotification selector:@selector(webViewDidEndEditing:)];
- [self registerForEditingDelegateNotification:WebViewDidChangeTypingStyleNotification selector:@selector(webViewDidChangeTypingStyle:)];
- [self registerForEditingDelegateNotification:WebViewDidChangeSelectionNotification selector:@selector(webViewDidChangeSelection:)];
-}
-
-- (id)editingDelegate
-{
- return _private->editingDelegate;
-}
-
-- (DOMCSSStyleDeclaration *)styleDeclarationWithText:(NSString *)text
-{
- // FIXME: Should this really be attached to the document with the current selection?
- DOMCSSStyleDeclaration *decl = [[[self _selectedOrMainFrame] DOMDocument] createCSSStyleDeclaration];
- [decl setCssText:text];
- return decl;
-}
-
-@end
-
-@implementation WebView (WebViewGrammarChecking)
-
-// FIXME: This method should be merged into WebViewEditing when we're not in API freeze
-- (BOOL)isGrammarCheckingEnabled
-{
-#ifdef BUILDING_ON_TIGER
- return NO;
-#else
- return grammarCheckingEnabled;
-#endif
-}
-
-#ifndef BUILDING_ON_TIGER
-// FIXME: This method should be merged into WebViewEditing when we're not in API freeze
-- (void)setGrammarCheckingEnabled:(BOOL)flag
-{
- if (grammarCheckingEnabled == flag)
- return;
-
- grammarCheckingEnabled = flag;
- [[NSUserDefaults standardUserDefaults] setBool:grammarCheckingEnabled forKey:WebGrammarCheckingEnabled];
-
- // FIXME 4811447: workaround for lack of API
- NSSpellChecker *spellChecker = [NSSpellChecker sharedSpellChecker];
- if ([spellChecker respondsToSelector:@selector(_updateGrammar)])
- [spellChecker performSelector:@selector(_updateGrammar)];
-
- // We call _preflightSpellChecker when turning continuous spell checking on, but we don't need to do that here
- // because grammar checking only occurs on code paths that already preflight spell checking appropriately.
-
- if (![self isGrammarCheckingEnabled])
- [[self mainFrame] _unmarkAllBadGrammar];
-}
-
-// FIXME: This method should be merged into WebIBActions when we're not in API freeze
-- (void)toggleGrammarChecking:(id)sender
-{
- [self setGrammarCheckingEnabled:![self isGrammarCheckingEnabled]];
-}
-#endif
-
-@end
-
-@implementation WebView (WebViewUndoableEditing)
-
-- (void)replaceSelectionWithNode:(DOMNode *)node
-{
- [[self _selectedOrMainFrame] _replaceSelectionWithNode:node selectReplacement:YES smartReplace:NO matchStyle:NO];
-}
-
-- (void)replaceSelectionWithText:(NSString *)text
-{
- [[self _selectedOrMainFrame] _replaceSelectionWithText:text selectReplacement:YES smartReplace:NO];
-}
-
-- (void)replaceSelectionWithMarkupString:(NSString *)markupString
-{
- [[self _selectedOrMainFrame] _replaceSelectionWithMarkupString:markupString baseURLString:nil selectReplacement:YES smartReplace:NO];
-}
-
-- (void)replaceSelectionWithArchive:(WebArchive *)archive
-{
- [[[self _selectedOrMainFrame] _dataSource] _replaceSelectionWithArchive:archive selectReplacement:YES];
-}
-
-- (void)deleteSelection
-{
- WebFrame *webFrame = [self _selectedOrMainFrame];
- Frame* coreFrame = core(webFrame);
- if (coreFrame)
- coreFrame->editor()->deleteSelectionWithSmartDelete([(WebHTMLView *)[[webFrame frameView] documentView] _canSmartCopyOrDelete]);
-}
-
-- (void)applyStyle:(DOMCSSStyleDeclaration *)style
-{
- // We don't know enough at thls level to pass in a relevant WebUndoAction; we'd have to
- // change the API to allow this.
- WebFrame *webFrame = [self _selectedOrMainFrame];
- Frame* coreFrame = core(webFrame);
- if (coreFrame)
- coreFrame->editor()->applyStyle(core(style));
-}
-
-@end
-
-@implementation WebView (WebViewEditingActions)
-
-- (void)_performResponderOperation:(SEL)selector with:(id)parameter
-{
- static BOOL reentered = NO;
- if (reentered) {
- [[self nextResponder] tryToPerform:selector with:parameter];
- return;
- }
-
- // There are two possibilities here.
- //
- // One is that WebView has been called in its role as part of the responder chain.
- // In that case, it's fine to call the first responder and end up calling down the
- // responder chain again. Later we will return here with reentered = YES and continue
- // past the WebView.
- //
- // The other is that we are being called directly, in which case we want to pass the
- // selector down to the view inside us that can handle it, and continue down the
- // responder chain as usual.
-
- // Pass this selector down to the first responder.
- NSResponder *responder = [self _responderForResponderOperations];
- reentered = YES;
- [responder tryToPerform:selector with:parameter];
- reentered = NO;
-}
-
-#define FORWARD(name) \
- - (void)name:(id)sender { [self _performResponderOperation:_cmd with:sender]; }
-
-FOR_EACH_RESPONDER_SELECTOR(FORWARD)
-
-- (void)insertText:(NSString *)text
-{
- [self _performResponderOperation:_cmd with:text];
-}
-
-@end
-
-@implementation WebView (WebViewEditingInMail)
-
-- (void)_insertNewlineInQuotedContent;
-{
- [[self _selectedOrMainFrame] _insertParagraphSeparatorInQuotedContent];
-}
-
-- (void)_replaceSelectionWithNode:(DOMNode *)node matchStyle:(BOOL)matchStyle
-{
- [[self _selectedOrMainFrame] _replaceSelectionWithNode:node selectReplacement:YES smartReplace:NO matchStyle:matchStyle];
-}
-
-@end
-
-static WebFrameView *containingFrameView(NSView *view)
-{
- while (view && ![view isKindOfClass:[WebFrameView class]])
- view = [view superview];
- return (WebFrameView *)view;
-}
-
-@implementation WebView (WebFileInternal)
-
-+ (void)_setCacheModel:(WebCacheModel)cacheModel
-{
- if (s_didSetCacheModel && cacheModel == s_cacheModel)
- return;
-
- NSString *nsurlCacheDirectory = [(NSString *)WKCopyFoundationCacheDirectory() autorelease];
- if (!nsurlCacheDirectory)
- nsurlCacheDirectory = NSHomeDirectory();
-
- // As a fudge factor, use 1000 instead of 1024, in case the reported byte
- // count doesn't align exactly to a megabyte boundary.
- uint64_t memSize = WebMemorySize() / 1024 / 1000;
- unsigned long long diskFreeSize = WebVolumeFreeSize(nsurlCacheDirectory) / 1024 / 1000;
- NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
-
- unsigned cacheTotalCapacity = 0;
- unsigned cacheMinDeadCapacity = 0;
- unsigned cacheMaxDeadCapacity = 0;
- double deadDecodedDataDeletionInterval = 0;
-
- unsigned pageCacheCapacity = 0;
-
- NSUInteger nsurlCacheMemoryCapacity = 0;
- NSUInteger nsurlCacheDiskCapacity = 0;
-
- switch (cacheModel) {
- case WebCacheModelDocumentViewer: {
- // Page cache capacity (in pages)
- pageCacheCapacity = 0;
-
- // Object cache capacities (in bytes)
- if (memSize >= 2048)
- cacheTotalCapacity = 128 * 1024 * 1024;
- else if (memSize >= 1536)
- cacheTotalCapacity = 86 * 1024 * 1024;
- else if (memSize >= 1024)
- cacheTotalCapacity = 64 * 1024 * 1024;
- else if (memSize >= 512)
- cacheTotalCapacity = 32 * 1024 * 1024;
- else if (memSize >= 256)
- cacheTotalCapacity = 16 * 1024 * 1024;
-
- cacheMinDeadCapacity = 0;
- cacheMaxDeadCapacity = 0;
-
- // Foundation memory cache capacity (in bytes)
- nsurlCacheMemoryCapacity = 0;
-
- // Foundation disk cache capacity (in bytes)
- nsurlCacheDiskCapacity = [nsurlCache diskCapacity];
-
- break;
- }
- case WebCacheModelDocumentBrowser: {
- // Page cache capacity (in pages)
- if (memSize >= 1024)
- pageCacheCapacity = 3;
- else if (memSize >= 512)
- pageCacheCapacity = 2;
- else if (memSize >= 256)
- pageCacheCapacity = 1;
- else
- pageCacheCapacity = 0;
-
- // Object cache capacities (in bytes)
- if (memSize >= 2048)
- cacheTotalCapacity = 128 * 1024 * 1024;
- else if (memSize >= 1536)
- cacheTotalCapacity = 86 * 1024 * 1024;
- else if (memSize >= 1024)
- cacheTotalCapacity = 64 * 1024 * 1024;
- else if (memSize >= 512)
- cacheTotalCapacity = 32 * 1024 * 1024;
- else if (memSize >= 256)
- cacheTotalCapacity = 16 * 1024 * 1024;
-
- cacheMinDeadCapacity = cacheTotalCapacity / 8;
- cacheMaxDeadCapacity = cacheTotalCapacity / 4;
-
- // Foundation memory cache capacity (in bytes)
- if (memSize >= 2048)
- nsurlCacheMemoryCapacity = 4 * 1024 * 1024;
- else if (memSize >= 1024)
- nsurlCacheMemoryCapacity = 2 * 1024 * 1024;
- else if (memSize >= 512)
- nsurlCacheMemoryCapacity = 1 * 1024 * 1024;
- else
- nsurlCacheMemoryCapacity = 512 * 1024;
-
- // Foundation disk cache capacity (in bytes)
- if (diskFreeSize >= 16384)
- nsurlCacheDiskCapacity = 50 * 1024 * 1024;
- else if (diskFreeSize >= 8192)
- nsurlCacheDiskCapacity = 40 * 1024 * 1024;
- else if (diskFreeSize >= 4096)
- nsurlCacheDiskCapacity = 30 * 1024 * 1024;
- else
- nsurlCacheDiskCapacity = 20 * 1024 * 1024;
-
- break;
- }
- case WebCacheModelPrimaryWebBrowser: {
- // Page cache capacity (in pages)
- // (Research indicates that value / page drops substantially after 3 pages.)
- if (memSize >= 2048)
- pageCacheCapacity = 5;
- else if (memSize >= 1024)
- pageCacheCapacity = 4;
- else if (memSize >= 512)
- pageCacheCapacity = 3;
- else if (memSize >= 256)
- pageCacheCapacity = 2;
- else
- pageCacheCapacity = 1;
-
- // Object cache capacities (in bytes)
- // (Testing indicates that value / MB depends heavily on content and
- // browsing pattern. Even growth above 128MB can have substantial
- // value / MB for some content / browsing patterns.)
- if (memSize >= 2048)
- cacheTotalCapacity = 256 * 1024 * 1024;
- else if (memSize >= 1536)
- cacheTotalCapacity = 172 * 1024 * 1024;
- else if (memSize >= 1024)
- cacheTotalCapacity = 128 * 1024 * 1024;
- else if (memSize >= 512)
- cacheTotalCapacity = 64 * 1024 * 1024;
- else if (memSize >= 256)
- cacheTotalCapacity = 32 * 1024 * 1024;
-
- cacheMinDeadCapacity = cacheTotalCapacity / 4;
- cacheMaxDeadCapacity = cacheTotalCapacity / 2;
-
- // This code is here to avoid a PLT regression. We can remove it if we
- // can prove that the overall system gain would justify the regression.
- cacheMaxDeadCapacity = max(24u, cacheMaxDeadCapacity);
-
- deadDecodedDataDeletionInterval = 60;
-
- // Foundation memory cache capacity (in bytes)
- // (These values are small because WebCore does most caching itself.)
- if (memSize >= 1024)
- nsurlCacheMemoryCapacity = 4 * 1024 * 1024;
- else if (memSize >= 512)
- nsurlCacheMemoryCapacity = 2 * 1024 * 1024;
- else if (memSize >= 256)
- nsurlCacheMemoryCapacity = 1 * 1024 * 1024;
- else
- nsurlCacheMemoryCapacity = 512 * 1024;
-
- // Foundation disk cache capacity (in bytes)
- if (diskFreeSize >= 16384)
- nsurlCacheDiskCapacity = 175 * 1024 * 1024;
- else if (diskFreeSize >= 8192)
- nsurlCacheDiskCapacity = 150 * 1024 * 1024;
- else if (diskFreeSize >= 4096)
- nsurlCacheDiskCapacity = 125 * 1024 * 1024;
- else if (diskFreeSize >= 2048)
- nsurlCacheDiskCapacity = 100 * 1024 * 1024;
- else if (diskFreeSize >= 1024)
- nsurlCacheDiskCapacity = 75 * 1024 * 1024;
- else
- nsurlCacheDiskCapacity = 50 * 1024 * 1024;
-
- break;
- }
- default:
- ASSERT_NOT_REACHED();
- };
-
-#ifdef BUILDING_ON_TIGER
- // Don't use a big Foundation disk cache on Tiger because, according to the
- // PLT, the Foundation disk cache on Tiger is slower than the network.
- nsurlCacheDiskCapacity = [nsurlCache diskCapacity];
-#endif
-
- // Don't shrink a big disk cache, since that would cause churn.
- nsurlCacheDiskCapacity = max(nsurlCacheDiskCapacity, [nsurlCache diskCapacity]);
-
- cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
- cache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
- pageCache()->setCapacity(pageCacheCapacity);
- [nsurlCache setMemoryCapacity:nsurlCacheMemoryCapacity];
- [nsurlCache setDiskCapacity:nsurlCacheDiskCapacity];
-
- s_cacheModel = cacheModel;
- s_didSetCacheModel = YES;
-}
-
-+ (WebCacheModel)_cacheModel
-{
- return s_cacheModel;
-}
-
-+ (WebCacheModel)_didSetCacheModel
-{
- return s_didSetCacheModel;
-}
-
-+ (WebCacheModel)_maxCacheModelInAnyInstance
-{
- WebCacheModel cacheModel = WebCacheModelDocumentViewer;
- NSEnumerator *enumerator = [(NSMutableSet *)allWebViewsSet objectEnumerator];
- while (WebPreferences *preferences = [[enumerator nextObject] preferences])
- cacheModel = max(cacheModel, [preferences cacheModel]);
- return cacheModel;
-}
-
-+ (void)_preferencesChangedNotification:(NSNotification *)notification
-{
- WebPreferences *preferences = (WebPreferences *)[notification object];
- ASSERT([preferences isKindOfClass:[WebPreferences class]]);
-
- WebCacheModel cacheModel = [preferences cacheModel];
- if (![self _didSetCacheModel] || cacheModel > [self _cacheModel])
- [self _setCacheModel:cacheModel];
- else if (cacheModel < [self _cacheModel])
- [self _setCacheModel:max([[WebPreferences standardPreferences] cacheModel], [self _maxCacheModelInAnyInstance])];
-}
-
-+ (void)_preferencesRemovedNotification:(NSNotification *)notification
-{
- WebPreferences *preferences = (WebPreferences *)[notification object];
- ASSERT([preferences isKindOfClass:[WebPreferences class]]);
-
- if ([preferences cacheModel] == [self _cacheModel])
- [self _setCacheModel:max([[WebPreferences standardPreferences] cacheModel], [self _maxCacheModelInAnyInstance])];
-}
-
-- (WebFrame *)_focusedFrame
-{
- NSResponder *resp = [[self window] firstResponder];
- if (resp && [resp isKindOfClass:[NSView class]] && [(NSView *)resp isDescendantOf:[[self mainFrame] frameView]]) {
- WebFrameView *frameView = containingFrameView((NSView *)resp);
- ASSERT(frameView != nil);
- return [frameView webFrame];
- }
-
- return nil;
-}
-
-- (WebFrame *)_selectedOrMainFrame
-{
- WebFrame *result = [self selectedFrame];
- if (result == nil)
- result = [self mainFrame];
- return result;
-}
-
-- (BOOL)_isLoading
-{
- WebFrame *mainFrame = [self mainFrame];
- return [[mainFrame _dataSource] isLoading]
- || [[mainFrame provisionalDataSource] isLoading];
-}
-
-- (WebFrameView *)_frameViewAtWindowPoint:(NSPoint)point
-{
- if (_private->closed)
- return nil;
- NSView *view = [self hitTest:[[self superview] convertPoint:point fromView:nil]];
- if (![view isDescendantOf:[[self mainFrame] frameView]])
- return nil;
- WebFrameView *frameView = containingFrameView(view);
- ASSERT(frameView);
- return frameView;
-}
-
-+ (void)_preflightSpellCheckerNow:(id)sender
-{
- [[NSSpellChecker sharedSpellChecker] _preflightChosenSpellServer];
-}
-
-+ (void)_preflightSpellChecker
-{
- // As AppKit does, we wish to delay tickling the shared spellchecker into existence on application launch.
- if ([NSSpellChecker sharedSpellCheckerExists]) {
- [self _preflightSpellCheckerNow:self];
- } else {
- [self performSelector:@selector(_preflightSpellCheckerNow:) withObject:self afterDelay:2.0];
- }
-}
-
-- (BOOL)_continuousCheckingAllowed
-{
- static BOOL allowContinuousSpellChecking = YES;
- static BOOL readAllowContinuousSpellCheckingDefault = NO;
- if (!readAllowContinuousSpellCheckingDefault) {
- if ([[NSUserDefaults standardUserDefaults] objectForKey:@"NSAllowContinuousSpellChecking"]) {
- allowContinuousSpellChecking = [[NSUserDefaults standardUserDefaults] boolForKey:@"NSAllowContinuousSpellChecking"];
- }
- readAllowContinuousSpellCheckingDefault = YES;
- }
- return allowContinuousSpellChecking;
-}
-
-- (NSResponder *)_responderForResponderOperations
-{
- NSResponder *responder = [[self window] firstResponder];
- WebFrameView *mainFrameView = [[self mainFrame] frameView];
-
- // If the current responder is outside of the webview, use our main frameView or its
- // document view. We also do this for subviews of self that are siblings of the main
- // frameView since clients might insert non-webview-related views there (see 4552713).
- if (responder != self && ![mainFrameView _web_firstResponderIsSelfOrDescendantView]) {
- responder = [mainFrameView documentView];
- if (!responder)
- responder = mainFrameView;
- }
- return responder;
-}
-
-- (void)_openFrameInNewWindowFromMenu:(NSMenuItem *)sender
-{
- ASSERT_ARG(sender, [sender isKindOfClass:[NSMenuItem class]]);
-
- NSDictionary *element = [sender representedObject];
- ASSERT([element isKindOfClass:[NSDictionary class]]);
-
- WebDataSource *dataSource = [[element objectForKey:WebElementFrameKey] dataSource];
- NSURLRequest *request = [[dataSource request] copy];
- ASSERT(request);
-
- [self _openNewWindowWithRequest:request];
- [request release];
-}
-
-- (void)_searchWithGoogleFromMenu:(id)sender
-{
- id documentView = [[[self selectedFrame] frameView] documentView];
- if (![documentView conformsToProtocol:@protocol(WebDocumentText)]) {
- return;
- }
-
- NSString *selectedString = [(id <WebDocumentText>)documentView selectedString];
- if ([selectedString length] == 0) {
- return;
- }
-
- NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
- [pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
- NSMutableString *s = [selectedString mutableCopy];
- const unichar nonBreakingSpaceCharacter = 0xA0;
- NSString *nonBreakingSpaceString = [NSString stringWithCharacters:&nonBreakingSpaceCharacter length:1];
- [s replaceOccurrencesOfString:nonBreakingSpaceString withString:@" " options:0 range:NSMakeRange(0, [s length])];
- [pasteboard setString:s forType:NSStringPboardType];
- [s release];
-
- // FIXME: seems fragile to use the service by name, but this is what AppKit does
- NSPerformService(@"Search With Google", pasteboard);
-}
-
-- (void)_searchWithSpotlightFromMenu:(id)sender
-{
- id documentView = [[[self selectedFrame] frameView] documentView];
- if (![documentView conformsToProtocol:@protocol(WebDocumentText)])
- return;
-
- NSString *selectedString = [(id <WebDocumentText>)documentView selectedString];
- if ([selectedString length] == 0) {
- return;
- }
-
- (void)HISearchWindowShow((CFStringRef)selectedString, kNilOptions);
-}
-@end
-
-@implementation WebView (WebViewInternal)
-
-- (BOOL)_becomingFirstResponderFromOutside
-{
- return _private->becomingFirstResponderFromOutside;
-}
-
-- (void)_receivedIconChangedNotification:(NSNotification *)notification
-{
- // Get the URL for this notification
- NSDictionary *userInfo = [notification userInfo];
- ASSERT([userInfo isKindOfClass:[NSDictionary class]]);
- NSString *urlString = [userInfo objectForKey:WebIconNotificationUserInfoURLKey];
- ASSERT([urlString isKindOfClass:[NSString class]]);
-
- // If that URL matches the current main frame, dispatch the delegate call, which will also unregister
- // us for this notification
- if ([[self mainFrameURL] isEqualTo:urlString])
- [self _dispatchDidReceiveIconFromWebFrame:[self mainFrame]];
-}
-
-- (void)_registerForIconNotification:(BOOL)listen
-{
- if (listen)
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_receivedIconChangedNotification:) name:WebIconDatabaseDidAddIconNotification object:nil];
- else
- [[NSNotificationCenter defaultCenter] removeObserver:self name:WebIconDatabaseDidAddIconNotification object:nil];
-}
-
-- (void)_dispatchDidReceiveIconFromWebFrame:(WebFrame *)webFrame
-{
- // FIXME: This willChangeValueForKey call is too late, because the icon has already changed by now.
- [self _willChangeValueForKey:_WebMainFrameIconKey];
-
- // Since we definitely have an icon and are about to send out the delegate call for that, this WebView doesn't need to listen for the general
- // notification any longer
- [self _registerForIconNotification:NO];
-
- WebFrameLoadDelegateImplementationCache* cache = &_private->frameLoadDelegateImplementations;
- if (cache->didReceiveIconForFrameFunc) {
- Image* image = iconDatabase()->iconForPageURL(core(webFrame)->loader()->url().string(), IntSize(16, 16));
- if (NSImage *icon = webGetNSImage(image, NSMakeSize(16, 16)))
- CallFrameLoadDelegate(cache->didReceiveIconForFrameFunc, self, @selector(webView:didReceiveIcon:forFrame:), icon, webFrame);
- }
-
- [self _didChangeValueForKey:_WebMainFrameIconKey];
-}
-
-// Get the appropriate user-agent string for a particular URL.
-- (WebCore::String)_userAgentForURL:(const WebCore::KURL&)url
-{
- if (_private->useSiteSpecificSpoofing) {
- // No current site-specific spoofs.
- }
-
- if (_private->userAgent.isNull())
- _private->userAgent = [[self class] _standardUserAgentWithApplicationName:_private->applicationNameForUserAgent];
-
- return _private->userAgent;
-}
-
-- (void)_addObject:(id)object forIdentifier:(unsigned long)identifier
-{
- ASSERT(!_private->identifierMap.contains(identifier));
-
- // If the identifier map is initially empty it means we're starting a load
- // of something. The semantic is that the web view should be around as long
- // as something is loading. Because of that we retain the web view.
- if (_private->identifierMap.isEmpty())
- CFRetain(self);
-
- _private->identifierMap.set(identifier, object);
-}
-
-- (id)_objectForIdentifier:(unsigned long)identifier
-{
- return _private->identifierMap.get(identifier).get();
-}
-
-- (void)_removeObjectForIdentifier:(unsigned long)identifier
-{
- ASSERT(_private->identifierMap.contains(identifier));
- _private->identifierMap.remove(identifier);
-
- // If the identifier map is now empty it means we're no longer loading anything
- // and we should release the web view.
- if (_private->identifierMap.isEmpty())
- CFRelease(self);
-}
-
-- (void)_retrieveKeyboardUIModeFromPreferences:(NSNotification *)notification
-{
- CFPreferencesAppSynchronize(UniversalAccessDomain);
-
- Boolean keyExistsAndHasValidFormat;
- int mode = CFPreferencesGetAppIntegerValue(AppleKeyboardUIMode, UniversalAccessDomain, &keyExistsAndHasValidFormat);
-
- // The keyboard access mode is reported by two bits:
- // Bit 0 is set if feature is on
- // Bit 1 is set if full keyboard access works for any control, not just text boxes and lists
- // We require both bits to be on.
- // I do not know that we would ever get one bit on and the other off since
- // checking the checkbox in system preferences which is marked as "Turn on full keyboard access"
- // turns on both bits.
- _private->_keyboardUIMode = (mode & 0x2) ? KeyboardAccessFull : KeyboardAccessDefault;
-
- // check for tabbing to links
- if ([_private->preferences tabsToLinks])
- _private->_keyboardUIMode = (KeyboardUIMode)(_private->_keyboardUIMode | KeyboardAccessTabsToLinks);
-}
-
-- (KeyboardUIMode)_keyboardUIMode
-{
- if (!_private->_keyboardUIModeAccessed) {
- _private->_keyboardUIModeAccessed = YES;
-
- [self _retrieveKeyboardUIModeFromPreferences:nil];
-
- [[NSDistributedNotificationCenter defaultCenter]
- addObserver:self selector:@selector(_retrieveKeyboardUIModeFromPreferences:)
- name:KeyboardUIModeDidChangeNotification object:nil];
-
- [[NSNotificationCenter defaultCenter]
- addObserver:self selector:@selector(_retrieveKeyboardUIModeFromPreferences:)
- name:WebPreferencesChangedNotification object:nil];
- }
- return _private->_keyboardUIMode;
-}
-
-@end
-
-// We use these functions to call the delegates and block exceptions. These functions are
-// declared inside a WebView category to get direct access to the delegate data memebers,
-// preventing more ObjC message dispatch and compensating for the expense of the @try/@catch.
-
-@implementation WebView (WebCallDelegateFunctions)
-
-typedef float (*ObjCMsgSendFPRet)(id, SEL, ...);
-#if defined(__i386__)
-static const ObjCMsgSendFPRet objc_msgSend_float_return = reinterpret_cast<ObjCMsgSendFPRet>(objc_msgSend_fpret);
-#else
-static const ObjCMsgSendFPRet objc_msgSend_float_return = reinterpret_cast<ObjCMsgSendFPRet>(objc_msgSend);
-#endif
-
-static inline id CallDelegate(WebView *self, id delegate, SEL selector)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend(delegate, selector, self);
- @try {
- return objc_msgSend(delegate, selector, self);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend(delegate, selector, self, object);
- @try {
- return objc_msgSend(delegate, selector, self, object);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(WebView *self, id delegate, SEL selector, NSRect rect)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return reinterpret_cast<id (*)(id, SEL, WebView *, NSRect)>(objc_msgSend)(delegate, selector, self, rect);
- @try {
- return reinterpret_cast<id (*)(id, SEL, WebView *, NSRect)>(objc_msgSend)(delegate, selector, self, rect);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object1, id object2)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend(delegate, selector, self, object1, object2);
- @try {
- return objc_msgSend(delegate, selector, self, object1, object2);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object, BOOL boolean)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend(delegate, selector, self, object, boolean);
- @try {
- return objc_msgSend(delegate, selector, self, object, boolean);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object1, id object2, id object3)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend(delegate, selector, self, object1, object2, object3);
- @try {
- return objc_msgSend(delegate, selector, self, object1, object2, object3);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object, NSUInteger integer)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend(delegate, selector, self, object, integer);
- @try {
- return objc_msgSend(delegate, selector, self, object, integer);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline float CallDelegateReturningFloat(WebView *self, id delegate, SEL selector)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return 0.0f;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend_float_return(delegate, selector, self);
- @try {
- return objc_msgSend_float_return(delegate, selector, self);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return 0.0f;
-}
-
-static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return result;
- if (!self->_private->catchesDelegateExceptions)
- return reinterpret_cast<BOOL (*)(id, SEL, WebView *)>(objc_msgSend)(delegate, selector, self);
- @try {
- return reinterpret_cast<BOOL (*)(id, SEL, WebView *)>(objc_msgSend)(delegate, selector, self);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return result;
-}
-
-static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return result;
- if (!self->_private->catchesDelegateExceptions)
- return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id)>(objc_msgSend)(delegate, selector, self, object);
- @try {
- return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id)>(objc_msgSend)(delegate, selector, self, object);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return result;
-}
-
-static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object, BOOL boolean)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return result;
- if (!self->_private->catchesDelegateExceptions)
- return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id, BOOL)>(objc_msgSend)(delegate, selector, self, object, boolean);
- @try {
- return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id, BOOL)>(objc_msgSend)(delegate, selector, self, object, boolean);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return result;
-}
-
-static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object1, id object2)
-{
- if (!delegate || ![delegate respondsToSelector:selector])
- return result;
- if (!self->_private->catchesDelegateExceptions)
- return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id, id)>(objc_msgSend)(delegate, selector, self, object1, object2);
- @try {
- return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id, id)>(objc_msgSend)(delegate, selector, self, object1, object2);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return result;
-}
-
-static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector)
-{
- if (!delegate)
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return implementation(delegate, selector, self);
- @try {
- return implementation(delegate, selector, self);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object)
-{
- if (!delegate)
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return implementation(delegate, selector, self, object);
- @try {
- return implementation(delegate, selector, self, object);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2)
-{
- if (!delegate)
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return implementation(delegate, selector, self, object1, object2);
- @try {
- return implementation(delegate, selector, self, object1, object2);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, id object3)
-{
- if (!delegate)
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return implementation(delegate, selector, self, object1, object2, object3);
- @try {
- return implementation(delegate, selector, self, object1, object2, object3);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, id object3, id object4)
-{
- if (!delegate)
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return implementation(delegate, selector, self, object1, object2, object3, object4);
- @try {
- return implementation(delegate, selector, self, object1, object2, object3, object4);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer, id object2)
-{
- if (!delegate)
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return implementation(delegate, selector, self, object1, integer, object2);
- @try {
- return implementation(delegate, selector, self, object1, integer, object2);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, NSInteger integer, id object3)
-{
- if (!delegate)
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return implementation(delegate, selector, self, object1, object2, integer, object3);
- @try {
- return implementation(delegate, selector, self, object1, object2, integer, object3);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSTimeInterval interval, id object2, id object3)
-{
- if (!delegate)
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return implementation(delegate, selector, self, object1, interval, object2, object3);
- @try {
- return implementation(delegate, selector, self, object1, interval, object2, object3);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-id CallUIDelegate(WebView *self, SEL selector)
-{
- return CallDelegate(self, self->_private->UIDelegate, selector);
-}
-
-id CallUIDelegate(WebView *self, SEL selector, id object)
-{
- return CallDelegate(self, self->_private->UIDelegate, selector, object);
-}
-
-id CallUIDelegate(WebView *self, SEL selector, id object, BOOL boolean)
-{
- return CallDelegate(self, self->_private->UIDelegate, selector, object, boolean);
-}
-
-id CallUIDelegate(WebView *self, SEL selector, NSRect rect)
-{
- return CallDelegate(self, self->_private->UIDelegate, selector, rect);
-}
-
-id CallUIDelegate(WebView *self, SEL selector, id object1, id object2)
-{
- return CallDelegate(self, self->_private->UIDelegate, selector, object1, object2);
-}
-
-id CallUIDelegate(WebView *self, SEL selector, id object1, id object2, id object3)
-{
- return CallDelegate(self, self->_private->UIDelegate, selector, object1, object2, object3);
-}
-
-id CallUIDelegate(WebView *self, SEL selector, id object, NSUInteger integer)
-{
- return CallDelegate(self, self->_private->UIDelegate, selector, object, integer);
-}
-
-float CallUIDelegateReturningFloat(WebView *self, SEL selector)
-{
- return CallDelegateReturningFloat(self, self->_private->UIDelegate, selector);
-}
-
-BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector)
-{
- return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector);
-}
-
-BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object)
-{
- return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object);
-}
-
-BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object, BOOL boolean)
-{
- return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object, boolean);
-}
-
-BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object1, id object2)
-{
- return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object1, object2);
-}
-
-id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector)
-{
- return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector);
-}
-
-id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object)
-{
- return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object);
-}
-
-id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2)
-{
- return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object1, object2);
-}
-
-id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3)
-{
- return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object1, object2, object3);
-}
-
-id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3, id object4)
-{
- return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object1, object2, object3, object4);
-}
-
-id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSTimeInterval interval, id object2, id object3)
-{
- return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object1, interval, object2, object3);
-}
-
-id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2)
-{
- return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2);
-}
-
-id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3)
-{
- return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, object3);
-}
-
-id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3, id object4)
-{
- return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, object3, object4);
-}
-
-id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSInteger integer, id object2)
-{
- return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, integer, object2);
-}
-
-id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, NSInteger integer, id object3)
-{
- return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, integer, object3);
-}
-
-// The form delegate needs to have it's own implementation, because the first argument is never the WebView
-
-id CallFormDelegate(WebView *self, SEL selector, id object1, id object2)
-{
- id delegate = self->_private->formDelegate;
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend(delegate, selector, object1, object2);
- @try {
- return objc_msgSend(delegate, selector, object1, object2);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id object3, id object4, id object5)
-{
- id delegate = self->_private->formDelegate;
- if (!delegate || ![delegate respondsToSelector:selector])
- return nil;
- if (!self->_private->catchesDelegateExceptions)
- return objc_msgSend(delegate, selector, object1, object2, object3, object4, object5);
- @try {
- return objc_msgSend(delegate, selector, object1, object2, object3, object4, object5);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return nil;
-}
-
-BOOL CallFormDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object1, SEL selectorArg, id object2)
-{
- id delegate = self->_private->formDelegate;
- if (!delegate || ![delegate respondsToSelector:selector])
- return result;
- if (!self->_private->catchesDelegateExceptions)
- return reinterpret_cast<BOOL (*)(id, SEL, id, SEL, id)>(objc_msgSend)(delegate, selector, object1, selectorArg, object2);
- @try {
- return reinterpret_cast<BOOL (*)(id, SEL, id, SEL, id)>(objc_msgSend)(delegate, selector, object1, selectorArg, object2);
- } @catch(id exception) {
- ReportDiscardedDelegateException(selector, exception);
- }
- return result;
-}
-
-@end
diff --git a/WebKit/mac/WebView/WebViewInternal.h b/WebKit/mac/WebView/WebViewInternal.h
deleted file mode 100644
index 39b3ef5..0000000
--- a/WebKit/mac/WebView/WebViewInternal.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// This header contains WebView declarations that can be used anywhere in WebKit, but are neither SPI nor API.
-
-#import "WebPreferences.h"
-#import "WebViewPrivate.h"
-#import "WebTypesInternal.h"
-
-#ifdef __cplusplus
-#import <WebCore/WebCoreKeyboardUIMode.h>
-#endif
-
-#ifdef __cplusplus
-namespace WebCore {
- class KeyboardEvent;
- class KURL;
- class Page;
- class String;
-}
-typedef WebCore::KeyboardEvent WebCoreKeyboardEvent;
-typedef WebCore::Page WebCorePage;
-#else
-@class WebCoreKeyboardEvent;
-@class WebCorePage;
-#endif
-
-@class WebBasePluginPackage;
-@class WebDownload;
-@class WebNodeHighlight;
-
-@interface WebView (WebViewEditingExtras)
-- (BOOL)_interceptEditingKeyEvent:(WebCoreKeyboardEvent *)event shouldSaveCommand:(BOOL)shouldSave;
-- (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
-@end
-
-@interface WebView (AllWebViews)
-+ (void)_makeAllWebViewsPerformSelector:(SEL)selector;
-- (void)_removeFromAllWebViewsSet;
-- (void)_addToAllWebViewsSet;
-@end
-
-@interface WebView (WebViewInternal)
-#ifdef __cplusplus
-- (WebCore::String)_userAgentForURL:(const WebCore::KURL&)url;
-- (WebCore::KeyboardUIMode)_keyboardUIMode;
-#endif
-@end
-
-@interface WebView (WebViewMiscInternal)
-
-+ (void)_setCacheModel:(WebCacheModel)cacheModel;
-+ (WebCacheModel)_cacheModel;
-- (WebCorePage*)page;
-- (NSMenu *)_menuForElement:(NSDictionary *)element defaultItems:(NSArray *)items;
-- (id)_UIDelegateForwarder;
-- (id)_editingDelegateForwarder;
-- (id)_policyDelegateForwarder;
-- (id)_scriptDebugDelegateForwarder;
-- (void)_pushPerformingProgrammaticFocus;
-- (void)_popPerformingProgrammaticFocus;
-- (void)_incrementProgressForIdentifier:(id)identifier response:(NSURLResponse *)response;
-- (void)_incrementProgressForIdentifier:(id)identifier length:(int)length;
-- (void)_completeProgressForIdentifier:(id)identifer;
-- (void)_progressStarted:(WebFrame *)frame;
-- (void)_didStartProvisionalLoadForFrame:(WebFrame *)frame;
-+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
-- (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
-+ (NSString *)_MIMETypeForFile:(NSString *)path;
-- (WebDownload *)_downloadURL:(NSURL *)URL;
-+ (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme;
-+ (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme;
-- (BOOL)_isPerformingProgrammaticFocus;
-- (void)_mouseDidMoveOverElement:(NSDictionary *)dictionary modifierFlags:(NSUInteger)modifierFlags;
-- (WebView *)_openNewWindowWithRequest:(NSURLRequest *)request;
-- (void)_writeImageForElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
-- (void)_writeLinkElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
-- (void)_openFrameInNewWindowFromMenu:(NSMenuItem *)sender;
-- (void)_searchWithGoogleFromMenu:(id)sender;
-- (void)_searchWithSpotlightFromMenu:(id)sender;
-- (void)_progressCompleted:(WebFrame *)frame;
-- (void)_didCommitLoadForFrame:(WebFrame *)frame;
-- (void)_didFinishLoadForFrame:(WebFrame *)frame;
-- (void)_didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
-- (void)_didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
-- (void)_willChangeValueForKey:(NSString *)key;
-- (void)_didChangeValueForKey:(NSString *)key;
-- (WebBasePluginPackage *)_pluginForMIMEType:(NSString *)MIMEType;
-- (WebBasePluginPackage *)_pluginForExtension:(NSString *)extension;
-- (BOOL)_isMIMETypeRegisteredAsPlugin:(NSString *)MIMEType;
-
-- (void)setCurrentNodeHighlight:(WebNodeHighlight *)nodeHighlight;
-- (WebNodeHighlight *)currentNodeHighlight;
-
-- (void)addPluginInstanceView:(NSView *)view;
-- (void)removePluginInstanceView:(NSView *)view;
-- (void)removePluginInstanceViewsFor:(WebFrame*)webFrame;
-
-- (void)_addObject:(id)object forIdentifier:(unsigned long)identifier;
-- (id)_objectForIdentifier:(unsigned long)identifier;
-- (void)_removeObjectForIdentifier:(unsigned long)identifier;
-- (BOOL)_becomingFirstResponderFromOutside;
-
-- (void)_registerForIconNotification:(BOOL)listen;
-- (void)_dispatchDidReceiveIconFromWebFrame:(WebFrame *)webFrame;
-
-- (void)_setZoomMultiplier:(float)m isTextOnly:(BOOL)isTextOnly;
-- (float)_zoomMultiplier:(BOOL)isTextOnly;
-- (float)_realZoomMultiplier;
-- (BOOL)_realZoomMultiplierIsTextOnly;
-- (BOOL)_canZoomOut:(BOOL)isTextOnly;
-- (BOOL)_canZoomIn:(BOOL)isTextOnly;
-- (IBAction)_zoomOut:(id)sender isTextOnly:(BOOL)isTextOnly;
-- (IBAction)_zoomIn:(id)sender isTextOnly:(BOOL)isTextOnly;
-- (BOOL)_canResetZoom:(BOOL)isTextOnly;
-- (IBAction)_resetZoom:(id)sender isTextOnly:(BOOL)isTextOnly;
-
-- (BOOL)_mustDrawUnionedRect:(NSRect)rect singleRects:(const NSRect *)rects count:(NSInteger)count;
-- (void)_updateFocusedAndActiveStateForFrame:(WebFrame *)webFrame;
-
-+ (BOOL)_canHandleRequest:(NSURLRequest *)request forMainFrame:(BOOL)forMainFrame;
-
-@end
-
-typedef struct _WebResourceDelegateImplementationCache {
- IMP didCancelAuthenticationChallengeFunc;
- IMP didReceiveAuthenticationChallengeFunc;
- IMP identifierForRequestFunc;
- IMP willSendRequestFunc;
- IMP didReceiveResponseFunc;
- IMP didReceiveContentLengthFunc;
- IMP didFinishLoadingFromDataSourceFunc;
- IMP didFailLoadingWithErrorFromDataSourceFunc;
- IMP didLoadResourceFromMemoryCacheFunc;
- IMP willCacheResponseFunc;
- IMP plugInFailedWithErrorFunc;
-} WebResourceDelegateImplementationCache;
-
-typedef struct _WebFrameLoadDelegateImplementationCache {
- IMP didClearWindowObjectForFrameFunc;
- IMP windowScriptObjectAvailableFunc;
- IMP didHandleOnloadEventsForFrameFunc;
- IMP didReceiveServerRedirectForProvisionalLoadForFrameFunc;
- IMP didCancelClientRedirectForFrameFunc;
- IMP willPerformClientRedirectToURLDelayFireDateForFrameFunc;
- IMP didChangeLocationWithinPageForFrameFunc;
- IMP willCloseFrameFunc;
- IMP didStartProvisionalLoadForFrameFunc;
- IMP didReceiveTitleForFrameFunc;
- IMP didCommitLoadForFrameFunc;
- IMP didFailProvisionalLoadWithErrorForFrameFunc;
- IMP didFailLoadWithErrorForFrameFunc;
- IMP didFinishLoadForFrameFunc;
- IMP didFirstLayoutInFrameFunc;
- IMP didReceiveIconForFrameFunc;
- IMP didFinishDocumentLoadForFrameFunc;
-} WebFrameLoadDelegateImplementationCache;
-
-WebResourceDelegateImplementationCache* WebViewGetResourceLoadDelegateImplementations(WebView *webView);
-WebFrameLoadDelegateImplementationCache* WebViewGetFrameLoadDelegateImplementations(WebView *webView);
-
-#ifdef __cplusplus
-
-id CallFormDelegate(WebView *, SEL, id, id);
-id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id object3, id object4, id object5);
-BOOL CallFormDelegateReturningBoolean(BOOL, WebView *, SEL, id, SEL, id);
-
-id CallUIDelegate(WebView *, SEL);
-id CallUIDelegate(WebView *, SEL, id);
-id CallUIDelegate(WebView *, SEL, NSRect);
-id CallUIDelegate(WebView *, SEL, id, id);
-id CallUIDelegate(WebView *, SEL, id, BOOL);
-id CallUIDelegate(WebView *, SEL, id, id, id);
-id CallUIDelegate(WebView *, SEL, id, NSUInteger);
-float CallUIDelegateReturningFloat(WebView *, SEL);
-BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL);
-BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id);
-BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, id);
-BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, BOOL);
-
-id CallFrameLoadDelegate(IMP, WebView *, SEL);
-id CallFrameLoadDelegate(IMP, WebView *, SEL, id);
-id CallFrameLoadDelegate(IMP, WebView *, SEL, id, id);
-id CallFrameLoadDelegate(IMP, WebView *, SEL, id, id, id);
-id CallFrameLoadDelegate(IMP, WebView *, SEL, id, id, id, id);
-id CallFrameLoadDelegate(IMP, WebView *, SEL, id, NSTimeInterval, id, id);
-
-id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id);
-id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id, id);
-id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id, id, id);
-id CallResourceLoadDelegate(IMP, WebView *, SEL, id, NSInteger, id);
-id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id, NSInteger, id);
-
-#endif
diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h
deleted file mode 100644
index 3a33bf9..0000000
--- a/WebKit/mac/WebView/WebViewPrivate.h
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebView.h>
-#import <WebKit/WebFramePrivate.h>
-
-#if !defined(ENABLE_DASHBOARD_SUPPORT)
-#define ENABLE_DASHBOARD_SUPPORT 1
-#endif
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSInteger int
-#define WebNSUInteger unsigned int
-#else
-#define WebNSInteger NSInteger
-#define WebNSUInteger NSUInteger
-#endif
-
-@class NSError;
-@class WebFrame;
-@class WebInspector;
-@class WebPreferences;
-@class WebTextIterator;
-
-@protocol WebFormDelegate;
-
-extern NSString *_WebCanGoBackKey;
-extern NSString *_WebCanGoForwardKey;
-extern NSString *_WebEstimatedProgressKey;
-extern NSString *_WebIsLoadingKey;
-extern NSString *_WebMainFrameIconKey;
-extern NSString *_WebMainFrameTitleKey;
-extern NSString *_WebMainFrameURLKey;
-extern NSString *_WebMainFrameDocumentKey;
-
-// pending public WebElementDictionary keys
-extern NSString *WebElementTitleKey; // NSString of the title of the element (used by Safari)
-extern NSString *WebElementSpellingToolTipKey; // NSString of a tooltip representing misspelling or bad grammar (used internally)
-extern NSString *WebElementIsContentEditableKey; // NSNumber indicating whether the inner non-shared node is content editable (used internally)
-
-// other WebElementDictionary keys
-extern NSString *WebElementLinkIsLiveKey; // NSNumber of BOOL indictating whether the link is live or not
-
-#if ENABLE_DASHBOARD_SUPPORT
-typedef enum {
- WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
- WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns,
- WebDashboardBehaviorAlwaysAcceptsFirstMouse,
- WebDashboardBehaviorAllowWheelScrolling,
- WebDashboardBehaviorUseBackwardCompatibilityMode
-} WebDashboardBehavior;
-#endif
-
-@interface WebController : NSTreeController {
- IBOutlet WebView *webView;
-}
-- (WebView *)webView;
-- (void)setWebView:(WebView *)newWebView;
-@end
-
-@interface WebView (WebViewEditingActionsPendingPublic)
-
-- (void)outdent:(id)sender;
-
-@end
-
-@interface WebView (WebPendingPublic)
-
-- (void)scheduleInRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
-- (void)unscheduleFromRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
-
-/*!
-@method searchFor:direction:caseSensitive:wrap:startInSelection:
- @abstract Searches a document view for a string and highlights the string if it is found.
- Starts the search from the current selection. Will search across all frames.
- @param string The string to search for.
- @param forward YES to search forward, NO to seach backwards.
- @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
- @param wrapFlag YES to wrap around, NO to avoid wrapping.
- @param startInSelection YES to begin search in the selected text (useful for incremental searching), NO to begin search after the selected text.
- @result YES if found, NO if not found.
- */
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection;
-
-- (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady;
-
-- (void)setTabKeyCyclesThroughElements:(BOOL)cyclesElements;
-- (BOOL)tabKeyCyclesThroughElements;
-
-- (void)scrollDOMRangeToVisible:(DOMRange *)range;
-
-// setHoverFeedbackSuspended: can be called by clients that want to temporarily prevent the webView
-// from displaying feedback about mouse position. Each WebDocumentView class that displays feedback
-// about mouse position should honor this setting.
-- (void)setHoverFeedbackSuspended:(BOOL)newValue;
-- (BOOL)isHoverFeedbackSuspended;
-
-/*!
-@method setScriptDebugDelegate:
-@abstract Set the WebView's WebScriptDebugDelegate delegate.
-@param delegate The WebScriptDebugDelegate to set as the delegate.
-*/
-- (void)setScriptDebugDelegate:(id)delegate;
-
-/*!
-@method scriptDebugDelegate
-@abstract Return the WebView's WebScriptDebugDelegate.
-@result The WebView's WebScriptDebugDelegate.
-*/
-- (id)scriptDebugDelegate;
-
-- (BOOL)shouldClose;
-
-/*!
- @method aeDescByEvaluatingJavaScriptFromString:
- @param script The text of the JavaScript.
- @result The result of the script, converted to an NSAppleEventDescriptor, or nil for failure.
-*/
-- (NSAppleEventDescriptor *)aeDescByEvaluatingJavaScriptFromString:(NSString *)script;
-
-// Support for displaying multiple text matches.
-// These methods might end up moving into a protocol, so different document types can specify
-// whether or not they implement the protocol. For now we'll just deal with HTML.
-// These methods are still in flux; don't rely on them yet.
-- (BOOL)canMarkAllTextMatches;
-- (WebNSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(WebNSUInteger)limit;
-- (void)unmarkAllTextMatches;
-- (NSArray *)rectsForTextMatches;
-
-// Support for disabling registration with the undo manager. This is equivalent to the methods with the same names on NSTextView.
-- (BOOL)allowsUndo;
-- (void)setAllowsUndo:(BOOL)flag;
-
-/*!
- @method setPageSizeMultiplier:
- @abstract Change the zoom factor of the page in views managed by this webView.
- @param multiplier A fractional percentage value, 1.0 is 100%.
-*/
-- (void)setPageSizeMultiplier:(float)multiplier;
-
-/*!
- @method pageSizeMultiplier
- @result The page size multipler.
-*/
-- (float)pageSizeMultiplier;
-
-// Commands for doing page zoom. Will end up in WebView (WebIBActions) <NSUserInterfaceValidations>
-- (BOOL)canZoomPageIn;
-- (IBAction)zoomPageIn:(id)sender;
-- (BOOL)canZoomPageOut;
-- (IBAction)zoomPageOut:(id)sender;
-- (BOOL)canResetPageZoom;
-- (IBAction)resetPageZoom:(id)sender;
-
-@end
-
-@interface WebView (WebPrivate)
-
-- (WebInspector *)inspector;
-
-/*!
- @method setBackgroundColor:
- @param backgroundColor Color to use as the default background.
- @abstract Sets what color the receiver draws under transparent page background colors and images.
- This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
- in a non-opaque window, since the color is drawn using NSCompositeCopy.
-*/
-- (void)setBackgroundColor:(NSColor *)backgroundColor;
-
-/*!
- @method backgroundColor
- @result Returns the background color drawn under transparent page background colors and images.
- This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
- in a non-opaque window, since the color is drawn using NSCompositeCopy.
-*/
-- (NSColor *)backgroundColor;
-
-/*!
-Could be worth adding to the API.
- @method loadItemsFromOtherView:
- @abstract Loads the view with the contents of the other view, including its backforward list.
- @param otherView The WebView from which to copy contents.
- */
-- (void)_loadBackForwardListFromOtherView:(WebView *)otherView;
-
-+ (NSArray *)_supportedFileExtensions;
-
-/*!
- @method canShowFile:
- @abstract Checks if the WebKit can show the content of the file at the specified path.
- @param path The path of the file to check
- @result YES if the WebKit can show the content of the file at the specified path.
-*/
-+ (BOOL)canShowFile:(NSString *)path;
-
-/*!
- @method suggestedFileExtensionForMIMEType:
- @param MIMEType The MIME type to check.
- @result The extension based on the MIME type
-*/
-+ (NSString *)suggestedFileExtensionForMIMEType: (NSString *)MIMEType;
-
-+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName;
-
-// May well become public
-- (void)_setFormDelegate:(id<WebFormDelegate>)delegate;
-- (id<WebFormDelegate>)_formDelegate;
-
-- (BOOL)_isClosed;
-
-// _close is now replaced by public method -close. It remains here only for backward compatibility
-// until callers can be weaned off of it.
-- (void)_close;
-
-/*!
- @method _registerViewClass:representationClass:forURLScheme:
- @discussion Register classes that implement WebDocumentView and WebDocumentRepresentation respectively.
- @param viewClass The WebDocumentView class to use to render data for a given MIME type.
- @param representationClass The WebDocumentRepresentation class to use to represent data of the given MIME type.
- @param scheme The URL scheme to represent with an object of the given class.
-*/
-+ (void)_registerViewClass:(Class)viewClass representationClass:(Class)representationClass forURLScheme:(NSString *)URLScheme;
-
-+ (void)_unregisterViewClassAndRepresentationClassForMIMEType:(NSString *)MIMEType;
-
-/*!
- @method _canHandleRequest:
- @abstract Performs a "preflight" operation that performs some
- speculative checks to see if a request can be used to create
- a WebDocumentView and WebDocumentRepresentation.
- @discussion The result of this method is valid only as long as no
- protocols or schemes are registered or unregistered, and as long as
- the request is not mutated (if the request is mutable). Hence, clients
- should be prepared to handle failures even if they have performed request
- preflighting by caling this method.
- @param request The request to preflight.
- @result YES if it is likely that a WebDocumentView and WebDocumentRepresentation
- can be created for the request, NO otherwise.
-*/
-+ (BOOL)_canHandleRequest:(NSURLRequest *)request;
-
-+ (NSString *)_decodeData:(NSData *)data;
-
-+ (void)_setAlwaysUsesComplexTextCodePath:(BOOL)f;
-// This is the old name of the above method. Needed for Safari versions that call it.
-+ (void)_setAlwaysUseATSU:(BOOL)f;
-
-- (NSCachedURLResponse *)_cachedResponseForURL:(NSURL *)URL;
-
-#if ENABLE_DASHBOARD_SUPPORT
-- (void)_addScrollerDashboardRegions:(NSMutableDictionary *)regions;
-- (NSDictionary *)_dashboardRegions;
-
-- (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag;
-- (BOOL)_dashboardBehavior:(WebDashboardBehavior)behavior;
-#endif
-
-+ (void)_setShouldUseFontSmoothing:(BOOL)f;
-+ (BOOL)_shouldUseFontSmoothing;
-
-- (void)_setCatchesDelegateExceptions:(BOOL)f;
-- (BOOL)_catchesDelegateExceptions;
-
-// These two methods are useful for a test harness that needs a consistent appearance for the focus rings
-// regardless of OS X version.
-+ (void)_setUsesTestModeFocusRingColor:(BOOL)f;
-+ (BOOL)_usesTestModeFocusRingColor;
-
-+ (NSString *)_minimumRequiredSafariBuildNumber;
-
-/*!
- @method setAlwaysShowVerticalScroller:
- @result Forces the vertical scroller to be visible if flag is YES, otherwise
- if flag is NO the scroller with automatically show and hide as needed.
- */
-- (void)setAlwaysShowVerticalScroller:(BOOL)flag;
-
-/*!
- @method alwaysShowVerticalScroller
- @result YES if the vertical scroller is always shown
- */
-- (BOOL)alwaysShowVerticalScroller;
-
-/*!
- @method setAlwaysShowHorizontalScroller:
- @result Forces the horizontal scroller to be visible if flag is YES, otherwise
- if flag is NO the scroller with automatically show and hide as needed.
- */
-- (void)setAlwaysShowHorizontalScroller:(BOOL)flag;
-
-/*!
- @method alwaysShowHorizontalScroller
- @result YES if the horizontal scroller is always shown
- */
-- (BOOL)alwaysShowHorizontalScroller;
-
-/*!
- @method setProhibitsMainFrameScrolling:
- @abstract Prohibits scrolling in the WebView's main frame. Used to "lock" a WebView
- to a specific scroll position.
- */
-- (void)setProhibitsMainFrameScrolling:(BOOL)prohibits;
-
-/*!
- @method _setAdditionalWebPlugInPaths:
- @abstract Sets additional plugin search paths for a specific WebView.
- */
-- (void)_setAdditionalWebPlugInPaths:(NSArray *)newPaths;
-
-/*!
- @method _setInViewSourceMode:
- @abstract Used to place a WebView into a special source-viewing mode.
- */
-- (void)_setInViewSourceMode:(BOOL)flag;
-
-/*!
- @method _inViewSourceMode;
- @abstract Whether or not the WebView is in source-view mode for HTML.
- */
-- (BOOL)_inViewSourceMode;
-
-/*!
- @method _attachScriptDebuggerToAllFrames
- @abstract Attaches a script debugger to all frames belonging to the receiver.
- */
-- (void)_attachScriptDebuggerToAllFrames;
-
-/*!
- @method _detachScriptDebuggerFromAllFrames
- @abstract Detaches any script debuggers from all frames belonging to the receiver.
- */
-- (void)_detachScriptDebuggerFromAllFrames;
-
-- (BOOL)defersCallbacks; // called by QuickTime plug-in
-- (void)setDefersCallbacks:(BOOL)defer; // called by QuickTime plug-in
-
-- (BOOL)usesPageCache;
-- (void)setUsesPageCache:(BOOL)usesPageCache;
-
-/*!
- @method textIteratorForRect:
- @param rectangle from which we want the WebTextIterator to load text from
- @result a WebtextIterator object.
- */
-- (WebTextIterator *)textIteratorForRect:(NSRect)rect;
-
-#if ENABLE_DASHBOARD_SUPPORT
-// <rdar://problem/5217124> Clients other than dashboard, don't use this.
-// Do not remove until Dashboard has moved off it
-- (void)handleAuthenticationForResource:(id)identifier challenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource;
-#endif
-
-- (void)_clearUndoRedoOperations;
-
-/* Used to do fast (lower quality) scaling of images so that window resize can be quick. */
-- (BOOL)_inFastImageScalingMode;
-- (void)_setUseFastImageScalingMode:(BOOL)flag;
-
-- (BOOL)_cookieEnabled;
-- (void)_setCookieEnabled:(BOOL)enable;
-
-// SPI for DumpRenderTree
-- (void)_executeCoreCommandByName:(NSString *)name value:(NSString *)value;
-- (void)_clearMainFrameName;
-
-- (void)_setCustomHTMLTokenizerTimeDelay:(double)timeDelay;
-- (void)_setCustomHTMLTokenizerChunkSize:(int)chunkSize;
-
-- (id)_initWithFrame:(NSRect)f frameName:(NSString *)frameName groupName:(NSString *)groupName usesDocumentViews:(BOOL)usesDocumentViews;
-- (BOOL)_usesDocumentViews;
-
-@end
-
-@interface WebView (WebViewPrintingPrivate)
-/*!
- @method _adjustPrintingMarginsForHeaderAndFooter:
- @abstract Increase the top and bottom margins for the current print operation to
- account for the header and footer height.
- @discussion Called by <WebDocument> implementors once when a print job begins. If the
- <WebDocument> implementor implements knowsPageRange:, this should be called from there.
- Otherwise this should be called from beginDocument. The <WebDocument> implementors need
- to also call _drawHeaderAndFooter.
-*/
-- (void)_adjustPrintingMarginsForHeaderAndFooter;
-
-/*!
- @method _drawHeaderAndFooter
- @abstract Gives the WebView's UIDelegate a chance to draw a header and footer on the
- printed page.
- @discussion This should be called by <WebDocument> implementors from an override of
- drawPageBorderWithSize:.
-*/
-- (void)_drawHeaderAndFooter;
-@end
-
-@interface WebView (WebViewGrammarChecking)
-
-// FIXME: These two methods should be merged into WebViewEditing when we're not in API freeze
-- (BOOL)isGrammarCheckingEnabled;
-#ifndef BUILDING_ON_TIGER
-- (void)setGrammarCheckingEnabled:(BOOL)flag;
-
-// FIXME: This method should be merged into WebIBActions when we're not in API freeze
-- (void)toggleGrammarChecking:(id)sender;
-#endif
-@end
-
-@interface WebView (WebViewEditingInMail)
-- (void)_insertNewlineInQuotedContent;
-- (void)_replaceSelectionWithNode:(DOMNode *)node matchStyle:(BOOL)matchStyle;
-@end
-
-@interface NSObject (WebFrameLoadDelegatePrivate)
-- (void)webView:(WebView *)sender didFirstLayoutInFrame:(WebFrame *)frame;
-
-// didFinishDocumentLoadForFrame is sent when the document has finished loading, though not necessarily all
-// of its subresources.
-// FIXME 5259339: Currently this callback is not sent for (some?) pages loaded entirely from the cache.
-- (void)webView:(WebView *)sender didFinishDocumentLoadForFrame:(WebFrame *)frame;
-
-// Addresses 4192534. SPI for now.
-- (void)webView:(WebView *)sender didHandleOnloadEventsForFrame:(WebFrame *)frame;
-
-@end
-
-@interface NSObject (WebResourceLoadDelegatePrivate)
-// Addresses <rdar://problem/5008925> - SPI for now
-- (NSCachedURLResponse *)webView:(WebView *)sender resource:(id)identifier willCacheResponse:(NSCachedURLResponse *)response fromDataSource:(WebDataSource *)dataSource;
-@end
-
-#undef WebNSInteger
-#undef WebNSUInteger