[webkit-changes] cvs commit: WebKit/WebView.subproj WebHTMLView.m
WebPDFView.h WebPDFView.m
John
sullivan at opensource.apple.com
Mon Jul 18 13:36:54 PDT 2005
sullivan 05/07/18 13:36:54
Modified: . ChangeLog
WebKit.pbproj project.pbxproj
WebView.subproj WebHTMLView.m WebPDFView.h WebPDFView.m
Added: Misc.subproj WebNSAttributedStringExtras.h
WebNSAttributedStringExtras.m
Log:
Reviewed by Richard Williamson.
- fixed <rdar://problem/4184366> WebPDFView should conform to the WebDocumentSelection protocol
* Misc.subproj/WebNSAttributedStringExtras.h: Added.
* Misc.subproj/WebNSAttributedStringExtras.m: Added.
(-[NSAttributedString _web_attributedStringByStrippingAttachmentCharacters]):
New category on NSAttributedString, initially contains this one method that had been in WebHTMLView.
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]):
now uses _web_attributedStringByStrippingAttachmentCharacters
* WebView.subproj/WebPDFView.h:
now conforms to WebDocumentSelection protocol
* WebView.subproj/WebPDFView.m:
(-[WebPDFView selectionRect]):
new, implementation of WebDocumentSelection protocol method
(-[WebPDFView pasteboardTypesForSelection]):
ditto
(-[WebPDFView writeSelectionWithPasteboardTypes:toPasteboard:]):
ditto
* WebKit.pbproj/project.pbxproj:
updated for new files
Revision Changes Path
1.3234 +28 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3233
retrieving revision 1.3234
diff -u -r1.3233 -r1.3234
--- ChangeLog 18 Jul 2005 18:02:18 -0000 1.3233
+++ ChangeLog 18 Jul 2005 20:36:49 -0000 1.3234
@@ -1,5 +1,33 @@
2005-07-18 John Sullivan <sullivan at apple.com>
+ Reviewed by Richard Williamson.
+
+ - fixed <rdar://problem/4184366> WebPDFView should conform to the WebDocumentSelection protocol
+
+ * Misc.subproj/WebNSAttributedStringExtras.h: Added.
+ * Misc.subproj/WebNSAttributedStringExtras.m: Added.
+ (-[NSAttributedString _web_attributedStringByStrippingAttachmentCharacters]):
+ New category on NSAttributedString, initially contains this one method that had been in WebHTMLView.
+
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]):
+ now uses _web_attributedStringByStrippingAttachmentCharacters
+
+ * WebView.subproj/WebPDFView.h:
+ now conforms to WebDocumentSelection protocol
+ * WebView.subproj/WebPDFView.m:
+ (-[WebPDFView selectionRect]):
+ new, implementation of WebDocumentSelection protocol method
+ (-[WebPDFView pasteboardTypesForSelection]):
+ ditto
+ (-[WebPDFView writeSelectionWithPasteboardTypes:toPasteboard:]):
+ ditto
+
+ * WebKit.pbproj/project.pbxproj:
+ updated for new files
+
+2005-07-18 John Sullivan <sullivan at apple.com>
+
Reviewed by Chris Blumenberg.
- some refactoring cleanup in the selection/searching code
1.1 WebKit/Misc.subproj/WebNSAttributedStringExtras.h
Index: WebNSAttributedStringExtras.h
===================================================================
/*
* 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.
*/
@interface NSAttributedString (WebKitExtras)
- (NSAttributedString *)_web_attributedStringByStrippingAttachmentCharacters;
@end
1.1 WebKit/Misc.subproj/WebNSAttributedStringExtras.m
Index: WebNSAttributedStringExtras.m
===================================================================
/*
* 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 "WebNSAttributedStringExtras.h"
@implementation NSAttributedString (WebKitExtras)
- (NSAttributedString *)_web_attributedStringByStrippingAttachmentCharacters
{
// This code was originally copied from NSTextView
NSRange attachmentRange;
NSString *originalString = [self string];
static NSString *attachmentCharString = nil;
if (!attachmentCharString) {
unichar chars[2];
if (!attachmentCharString) {
chars[0] = NSAttachmentCharacter;
chars[1] = 0;
attachmentCharString = [[NSString alloc] initWithCharacters:chars length:1];
}
}
attachmentRange = [originalString rangeOfString:attachmentCharString];
if (attachmentRange.location != NSNotFound && attachmentRange.length > 0) {
NSMutableAttributedString *newAttributedString = [[self mutableCopyWithZone:NULL] autorelease];
while (attachmentRange.location != NSNotFound && attachmentRange.length > 0) {
[newAttributedString replaceCharactersInRange:attachmentRange withString:@""];
attachmentRange = [[newAttributedString string] rangeOfString:attachmentCharString];
}
return newAttributedString;
}
return self;
}
@end
1.726 +32 -0 WebKit/WebKit.pbproj/project.pbxproj
Index: project.pbxproj
===================================================================
RCS file: /cvs/root/WebKit/WebKit.pbproj/project.pbxproj,v
retrieving revision 1.725
retrieving revision 1.726
diff -u -r1.725 -r1.726
--- project.pbxproj 1 Jul 2005 05:20:47 -0000 1.725
+++ project.pbxproj 18 Jul 2005 20:36:52 -0000 1.726
@@ -174,6 +174,8 @@
BEE52D4B0473032500CA289C,
BEE18F990472B73200CA289C,
BEE18F9A0472B73200CA289C,
+ ED6BE2E5088C32B50044DEDC,
+ ED6BE2E6088C32B50044DEDC,
9345DDB20365FFD0008635CE,
9345DDB30365FFD0008635CE,
65EEDE51084FFB920002DB25,
@@ -1985,6 +1987,7 @@
65EEDE57084FFC9E0002DB25,
65E0F88408500917007E5CB9,
65E0F9E608500F23007E5CB9,
+ ED6BE2E7088C32B50044DEDC,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -3267,6 +3270,7 @@
65EEDE58084FFC9E0002DB25,
65E0F88508500917007E5CB9,
65E0F9E708500F23007E5CB9,
+ ED6BE2E8088C32B50044DEDC,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -4601,6 +4605,34 @@
refType = 4;
sourceTree = "<group>";
};
+ ED6BE2E5088C32B50044DEDC = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = WebNSAttributedStringExtras.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ ED6BE2E6088C32B50044DEDC = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = WebNSAttributedStringExtras.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ ED6BE2E7088C32B50044DEDC = {
+ fileRef = ED6BE2E5088C32B50044DEDC;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ ED6BE2E8088C32B50044DEDC = {
+ fileRef = ED6BE2E6088C32B50044DEDC;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
EDD1A5C605C83987008E3150 = {
fileEncoding = 4;
isa = PBXFileReference;
1.458 +2 -31 WebKit/WebView.subproj/WebHTMLView.m
Index: WebHTMLView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebHTMLView.m,v
retrieving revision 1.457
retrieving revision 1.458
diff -u -r1.457 -r1.458
--- WebHTMLView.m 18 Jul 2005 18:02:21 -0000 1.457
+++ WebHTMLView.m 18 Jul 2005 20:36:53 -0000 1.458
@@ -48,6 +48,7 @@
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebKitNSStringExtras.h>
#import <WebKit/WebNetscapePluginEmbeddedView.h>
+#import <WebKit/WebNSAttributedStringExtras.h>
#import <WebKit/WebNSEventExtras.h>
#import <WebKit/WebNSFileManagerExtras.h>
#import <WebKit/WebNSImageExtras.h>
@@ -573,36 +574,6 @@
return hitView;
}
-// This method is copied from NSTextView
-- (NSAttributedString *)_stripAttachmentCharactersFromAttributedString:(NSAttributedString *)originalAttributedString
-{
- NSRange attachmentRange;
- NSString *originalString = [originalAttributedString string];
- static NSString *attachmentCharString = nil;
-
- if (!attachmentCharString) {
- unichar chars[2];
- if (!attachmentCharString) {
- chars[0] = NSAttachmentCharacter;
- chars[1] = 0;
- attachmentCharString = [[NSString alloc] initWithCharacters:chars length:1];
- }
- }
-
- attachmentRange = [originalString rangeOfString:attachmentCharString];
- if (attachmentRange.location != NSNotFound && attachmentRange.length > 0) {
- NSMutableAttributedString *newAttributedString = [[originalAttributedString mutableCopyWithZone:NULL] autorelease];
-
- while (attachmentRange.location != NSNotFound && attachmentRange.length > 0) {
- [newAttributedString replaceCharactersInRange:attachmentRange withString:@""];
- attachmentRange = [[newAttributedString string] rangeOfString:attachmentCharString];
- }
- return newAttributedString;
- } else {
- return originalAttributedString;
- }
-}
-
- (void)_writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard cachedAttributedString:(NSAttributedString *)attributedString
{
// Put HTML on the pasteboard.
@@ -624,7 +595,7 @@
attributedString = [self selectedAttributedString];
}
if ([attributedString containsAttachments]) {
- attributedString = [self _stripAttachmentCharactersFromAttributedString:attributedString];
+ attributedString = [attributedString _web_attributedStringByStrippingAttachmentCharacters];
}
NSData *RTFData = [attributedString RTFFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
[pasteboard setData:RTFData forType:NSRTFPboardType];
1.9 +2 -1 WebKit/WebView.subproj/WebPDFView.h
Index: WebPDFView.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFView.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebPDFView.h 15 Jul 2005 22:59:18 -0000 1.8
+++ WebPDFView.h 18 Jul 2005 20:36:53 -0000 1.9
@@ -32,8 +32,9 @@
@class WebDataSource;
@protocol _web_WebDocumentTextSizing;
+ at protocol WebDocumentSelection;
- at interface WebPDFView : NSView <WebDocumentView, WebDocumentSearching, WebDocumentText, _web_WebDocumentTextSizing>
+ at interface WebPDFView : NSView <WebDocumentView, WebDocumentSearching, WebDocumentText, _web_WebDocumentTextSizing, WebDocumentSelection>
{
PDFView *PDFSubview;
WebDataSource *dataSource;
1.21 +47 -0 WebKit/WebView.subproj/WebPDFView.m
Index: WebPDFView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFView.m,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- WebPDFView.m 15 Jul 2005 22:59:18 -0000 1.20
+++ WebPDFView.m 18 Jul 2005 20:36:53 -0000 1.21
@@ -31,10 +31,12 @@
#import <WebKit/WebAssertions.h>
#import <WebKit/WebDataSource.h>
#import <WebKit/WebDocumentInternal.h>
+#import <WebKit/WebDocumentPrivate.h>
#import <WebKit/WebFrame.h>
#import <WebKit/WebFrameInternal.h>
#import <WebKit/WebFrameView.h>
#import <WebKit/WebLocalizableStrings.h>
+#import <WebKit/WebNSAttributedStringExtras.h>
#import <WebKit/WebNSPasteboardExtras.h>
#import <WebKit/WebNSViewExtras.h>
#import <WebKit/WebPDFView.h>
@@ -554,6 +556,51 @@
[PDFSubview clearSelection];
}
+- (NSRect)selectionRect
+{
+ NSRect result = NSZeroRect;
+ PDFSelection *selection = [PDFSubview currentSelection];
+ NSEnumerator *pages = [[selection pages] objectEnumerator];
+ PDFPage *page;
+ while ((page = [pages nextObject]) != nil) {
+ NSRect selectionOnPageInViewCoordinates = [PDFSubview convertRect:[selection boundsForPage:page] fromPage:page];
+ if (NSIsEmptyRect(result)) {
+ result = selectionOnPageInViewCoordinates;
+ } else {
+ result = NSUnionRect(result, selectionOnPageInViewCoordinates);
+ }
+ }
+
+ return result;
+}
+
+- (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];
+ }
+}
+
@end
#endif // OMIT_TIGER_FEATURES
More information about the webkit-changes
mailing list