[webkit-changes] cvs commit: WebKit/WebView.subproj
WebDocumentInternal.h WebDocumentPrivate.h WebHTMLView.m
WebHTMLViewPrivate.h WebTextView.h WebTextView.m
John
sullivan at opensource.apple.com
Mon Jul 18 11:02:22 PDT 2005
sullivan 05/07/18 11:02:22
Modified: . ChangeLog
Misc.subproj WebSearchableTextView.h WebSearchableTextView.m
WebView.subproj WebDocumentInternal.h WebDocumentPrivate.h
WebHTMLView.m WebHTMLViewPrivate.h WebTextView.h
WebTextView.m
Log:
Reviewed by Chris Blumenberg.
- some refactoring cleanup in the selection/searching code
* Misc.subproj/WebSearchableTextView.h:
moved WebDocumentSelection protocol conformation to this class, was in subclass WebTextView
* Misc.subproj/WebSearchableTextView.m:
(-[WebSearchableTextView selectionRect]):
new method (moved here from Safari) to return a single rect encompassing all selected text
(-[WebSearchableTextView pasteboardTypesForSelection]):
moved here from WebTextView
(-[WebSearchableTextView writeSelectionWithPasteboardTypes:toPasteboard:]):
ditto
* WebView.subproj/WebDocumentInternal.h:
moved WebDocumentSelection protocol out of here
* WebView.subproj/WebDocumentPrivate.h:
moved WebDocumentSelection protocol into here, added selectionRect method
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView selectionRect]):
new method, calls existing bridge method formerly called by _selectionRect
(-[WebHTMLView _selectionRect]):
now calls [self selectionRect]. We can't just delete _selectionRect because it's used by Mail.
* WebView.subproj/WebHTMLViewPrivate.h:
removed _selectionRect since it's in WebDocumentSelection now
* WebView.subproj/WebTextView.h:
removed WebDocumentSelection from protocol list since it's in superclass now
* WebView.subproj/WebTextView.m:
removed old WebDocumentSelection methods because they are in superclass now
Revision Changes Path
1.3233 +37 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3232
retrieving revision 1.3233
diff -u -r1.3232 -r1.3233
--- ChangeLog 16 Jul 2005 05:53:01 -0000 1.3232
+++ ChangeLog 18 Jul 2005 18:02:18 -0000 1.3233
@@ -1,3 +1,40 @@
+2005-07-18 John Sullivan <sullivan at apple.com>
+
+ Reviewed by Chris Blumenberg.
+
+ - some refactoring cleanup in the selection/searching code
+
+ * Misc.subproj/WebSearchableTextView.h:
+ moved WebDocumentSelection protocol conformation to this class, was in subclass WebTextView
+ * Misc.subproj/WebSearchableTextView.m:
+ (-[WebSearchableTextView selectionRect]):
+ new method (moved here from Safari) to return a single rect encompassing all selected text
+ (-[WebSearchableTextView pasteboardTypesForSelection]):
+ moved here from WebTextView
+ (-[WebSearchableTextView writeSelectionWithPasteboardTypes:toPasteboard:]):
+ ditto
+
+ * WebView.subproj/WebDocumentInternal.h:
+ moved WebDocumentSelection protocol out of here
+
+ * WebView.subproj/WebDocumentPrivate.h:
+ moved WebDocumentSelection protocol into here, added selectionRect method
+
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView selectionRect]):
+ new method, calls existing bridge method formerly called by _selectionRect
+ (-[WebHTMLView _selectionRect]):
+ now calls [self selectionRect]. We can't just delete _selectionRect because it's used by Mail.
+
+ * WebView.subproj/WebHTMLViewPrivate.h:
+ removed _selectionRect since it's in WebDocumentSelection now
+
+ * WebView.subproj/WebTextView.h:
+ removed WebDocumentSelection from protocol list since it's in superclass now
+
+ * WebView.subproj/WebTextView.m:
+ removed old WebDocumentSelection methods because they are in superclass now
+
2005-07-15 Adele Peterson <adele at apple.com>
Written by Trey Matteson <trey at usa.net>
1.3 +2 -1 WebKit/Misc.subproj/WebSearchableTextView.h
Index: WebSearchableTextView.h
===================================================================
RCS file: /cvs/root/WebKit/Misc.subproj/WebSearchableTextView.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebSearchableTextView.h 5 Jun 2005 17:54:26 -0000 1.2
+++ WebSearchableTextView.h 18 Jul 2005 18:02:21 -0000 1.3
@@ -29,6 +29,7 @@
#import <Cocoa/Cocoa.h>
@protocol WebDocumentSearching;
+ at protocol WebDocumentSelection;
- at interface WebSearchableTextView : NSTextView <WebDocumentSearching>
+ at interface WebSearchableTextView : NSTextView <WebDocumentSearching, WebDocumentSelection>
@end
1.7 +42 -1 WebKit/Misc.subproj/WebSearchableTextView.m
Index: WebSearchableTextView.m
===================================================================
RCS file: /cvs/root/WebKit/Misc.subproj/WebSearchableTextView.m,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WebSearchableTextView.m 15 Jul 2005 20:35:26 -0000 1.6
+++ WebSearchableTextView.m 18 Jul 2005 18:02:21 -0000 1.7
@@ -27,7 +27,7 @@
*/
#import "WebSearchableTextView.h"
-#import "WebDocument.h"
+#import "WebDocumentPrivate.h"
@interface NSString (_Web_StringTextFinding)
- (NSRange)findString:(NSString *)string selectedRange:(NSRange)selectedRange options:(unsigned)mask wrap:(BOOL)wrapFlag;
@@ -77,6 +77,47 @@
}
}
+- (NSRect)selectionRect
+{
+ // Note that this method would work for any NSTextView; some day we might want to use it
+ // for an NSTextView that isn't a WebTextView.
+ NSRect result = NSZeroRect;
+
+ // iterate over multiple selected ranges
+ NSEnumerator *rangeEnumerator = [[self selectedRanges] objectEnumerator];
+ NSValue *rangeAsValue;
+ while ((rangeAsValue = [rangeEnumerator nextObject]) != nil) {
+ NSRange range = [rangeAsValue rangeValue];
+ unsigned rectCount;
+ NSRectArray rectArray = [[self layoutManager] rectArrayForCharacterRange:range
+ withinSelectedCharacterRange:range
+ inTextContainer:[self textContainer]
+ rectCount:&rectCount];
+ unsigned i;
+ // iterate over multiple rects in each selected range
+ for (i = 0; i < rectCount; ++i) {
+ NSRect rect = rectArray[i];
+ if (NSEqualRects(result, NSZeroRect)) {
+ result = rect;
+ } else {
+ result = NSUnionRect(result, rect);
+ }
+ }
+ }
+
+ return result;
+}
+
+- (NSArray *)pasteboardTypesForSelection
+{
+ return [self writablePasteboardTypes];
+}
+
+- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
+{
+ [self writeSelectionToPasteboard:pasteboard types:types];
+}
+
@end
@implementation NSString (_Web_StringTextFinding)
1.9 +0 -5 WebKit/WebView.subproj/WebDocumentInternal.h
Index: WebDocumentInternal.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebDocumentInternal.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebDocumentInternal.h 5 Jun 2005 17:54:46 -0000 1.8
+++ WebDocumentInternal.h 18 Jul 2005 18:02:21 -0000 1.9
@@ -50,8 +50,3 @@
@protocol WebDocumentElement <NSObject>
- (NSDictionary *)elementAtPoint:(NSPoint)point;
@end
-
- at protocol WebDocumentSelection <NSObject>
-- (NSArray *)pasteboardTypesForSelection;
-- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
- at end
1.9 +6 -0 WebKit/WebView.subproj/WebDocumentPrivate.h
Index: WebDocumentPrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebDocumentPrivate.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebDocumentPrivate.h 5 Jun 2005 17:54:46 -0000 1.8
+++ WebDocumentPrivate.h 18 Jul 2005 18:02:21 -0000 1.9
@@ -38,3 +38,9 @@
@protocol WebDocumentDOM <NSObject>
- (DOMDocument *)DOMDocument;
@end
+
+ at protocol WebDocumentSelection <NSObject>
+- (NSArray *)pasteboardTypesForSelection;
+- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
+- (NSRect)selectionRect;
+ at end
1.457 +12 -5 WebKit/WebView.subproj/WebHTMLView.m
Index: WebHTMLView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebHTMLView.m,v
retrieving revision 1.456
retrieving revision 1.457
diff -u -r1.456 -r1.457
--- WebHTMLView.m 14 Jul 2005 23:52:54 -0000 1.456
+++ WebHTMLView.m 18 Jul 2005 18:02:21 -0000 1.457
@@ -1439,11 +1439,6 @@
[super _web_layoutIfNeededRecursive:displayRect testDirtyRect:NO];
}
-- (NSRect)_selectionRect
-{
- return [[self _bridge] selectionRect];
-}
-
- (void)_startAutoscrollTimer: (NSEvent *)triggerEvent
{
if (_private->autoscrollTimer == nil) {
@@ -1453,6 +1448,13 @@
}
}
+// 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;
@@ -1867,6 +1869,11 @@
[[self _bridge] jumpToSelection];
}
+- (NSRect)selectionRect
+{
+ return [[self _bridge] selectionRect];
+}
+
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
{
SEL action = [item action];
1.94 +2 -0 WebKit/WebView.subproj/WebHTMLViewPrivate.h
Index: WebHTMLViewPrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebHTMLViewPrivate.h,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- WebHTMLViewPrivate.h 5 Jun 2005 17:54:47 -0000 1.93
+++ WebHTMLViewPrivate.h 18 Jul 2005 18:02:21 -0000 1.94
@@ -65,6 +65,8 @@
- (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;
1.19 +1 -1 WebKit/WebView.subproj/WebTextView.h
Index: WebTextView.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebTextView.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WebTextView.h 5 Jun 2005 17:54:48 -0000 1.18
+++ WebTextView.h 18 Jul 2005 18:02:21 -0000 1.19
@@ -31,7 +31,7 @@
@class WebDataSource;
- at interface WebTextView : WebSearchableTextView <WebDocumentView, WebDocumentText, WebDocumentElement, WebDocumentSelection>
+ at interface WebTextView : WebSearchableTextView <WebDocumentView, WebDocumentText, WebDocumentElement>
{
float _textSizeMultiplier;
}
1.58 +0 -10 WebKit/WebView.subproj/WebTextView.m
Index: WebTextView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebTextView.m,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- WebTextView.m 14 Jul 2005 23:06:10 -0000 1.57
+++ WebTextView.m 18 Jul 2005 18:02:21 -0000 1.58
@@ -339,16 +339,6 @@
return [webView _menuForElement:[self _elementAtWindowPoint:[event locationInWindow]] defaultItems:nil];
}
-- (NSArray *)pasteboardTypesForSelection
-{
- return [self writablePasteboardTypes];
-}
-
-- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
-{
- [self writeSelectionToPasteboard:pasteboard types:types];
-}
-
// This approach could be relaxed when dealing with 3228554
- (BOOL)resignFirstResponder
{
More information about the webkit-changes
mailing list