[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
rjw
rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:36:48 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 150f4bbc8e04ea308fb3114b84fe9c88656a3cf7
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Sep 6 20:21:37 2002 +0000
i * WebView.subproj/WebHTMLView.m:
(-[WebHTMLView mouseDragged:]):
More fun and games with dragged links.
Draw both a label and url (in a smaller font)
into the dragged image.
* Misc.subproj/WebStringTruncator.h:
* Misc.subproj/WebStringTruncator.m:
(+[WebStringTruncator rightTruncateString:toWidth:withFont:]):
Added right string truncator. Not optimized, but not used
very often. Currently just for dragged link experiment.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1984 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 5589262..de4f34b 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,19 @@
+2002-09-06 Richard Williamson (Home) <rjw at apple.com>
+
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView mouseDragged:]):
+
+ More fun and games with dragged links.
+ Draw both a label and url (in a smaller font)
+ into the dragged image.
+
+ * Misc.subproj/WebStringTruncator.h:
+ * Misc.subproj/WebStringTruncator.m:
+ (+[WebStringTruncator rightTruncateString:toWidth:withFont:]):
+
+ Added right string truncator. Not optimized, but not used
+ very often. Currently just for dragged link experiment.
+
=== Alexander-22 ===
2002-09-06 Ken Kocienda <kocienda at apple.com>
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 5589262..de4f34b 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,19 @@
+2002-09-06 Richard Williamson (Home) <rjw at apple.com>
+
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView mouseDragged:]):
+
+ More fun and games with dragged links.
+ Draw both a label and url (in a smaller font)
+ into the dragged image.
+
+ * Misc.subproj/WebStringTruncator.h:
+ * Misc.subproj/WebStringTruncator.m:
+ (+[WebStringTruncator rightTruncateString:toWidth:withFont:]):
+
+ Added right string truncator. Not optimized, but not used
+ very often. Currently just for dragged link experiment.
+
=== Alexander-22 ===
2002-09-06 Ken Kocienda <kocienda at apple.com>
diff --git a/WebKit/Misc.subproj/WebStringTruncator.h b/WebKit/Misc.subproj/WebStringTruncator.h
index efb849c..6d52ae0 100644
--- a/WebKit/Misc.subproj/WebStringTruncator.h
+++ b/WebKit/Misc.subproj/WebStringTruncator.h
@@ -19,4 +19,6 @@
// Default font is [NSFont menuFontOfSize:0].
+ (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth;
++ (NSString *)rightTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font;
+
@end
diff --git a/WebKit/Misc.subproj/WebStringTruncator.m b/WebKit/Misc.subproj/WebStringTruncator.m
index f2a4290..2956998 100644
--- a/WebKit/Misc.subproj/WebStringTruncator.m
+++ b/WebKit/Misc.subproj/WebStringTruncator.m
@@ -55,6 +55,40 @@ static float currentEllipsisWidth;
return [self centerTruncateString:string toWidth:maxWidth withFont:[NSFont menuFontOfSize:0]];
}
++ (NSString *)rightTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font
+{
+ unichar stringBuffer[STRING_BUFFER_SIZE];
+ WebTextRenderer *renderer;
+ unichar ellipsis;
+ float ellipsisWidth;
+ float width;
+ unsigned truncatedLength = [string length];
+
+ ASSERT (truncatedLength+1 < STRING_BUFFER_SIZE);
+ // FIXME: Allocate buffer is string doesn't fit in local buffer.
+
+ [string getCharacters:stringBuffer];
+ renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:font];
+ width = [renderer floatWidthForCharacters:stringBuffer
+ stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength applyRounding: NO attemptFontSubstitution: YES];
+ if (width <= maxWidth)
+ return string;
+
+ ellipsis = ELLIPSIS_CHARACTER;
+ ellipsisWidth = [renderer floatWidthForCharacters:&ellipsis stringLength:1 fromCharacterPosition: 0 numberOfCharacters: 1 applyRounding: NO attemptFontSubstitution: YES];
+
+ maxWidth -= ellipsisWidth;
+ while (width > maxWidth && truncatedLength){
+ truncatedLength--;
+ width = [renderer floatWidthForCharacters:stringBuffer
+ stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength applyRounding: NO attemptFontSubstitution: YES];
+ }
+
+ stringBuffer[truncatedLength++] = ELLIPSIS_CHARACTER;
+
+ return [NSString stringWithCharacters:stringBuffer length:truncatedLength];
+}
+
+ (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font
{
unichar stringBuffer[STRING_BUFFER_SIZE];
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 4b1932e..789b1c3 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -17,6 +17,7 @@
#import <WebKit/WebIconLoader.h>
#import <WebKit/WebKitDebug.h>
#import <WebKit/WebNSViewExtras.h>
+#import <WebKit/WebStringTruncator.h>
#import <WebKit/WebTextRenderer.h>
#import <WebKit/WebTextRendererFactory.h>
#import <WebKit/WebViewPrivate.h>
@@ -416,6 +417,8 @@
#define DragStartXHysteresis 2.0
#define DragStartYHysteresis 1.0
+#define DRAG_LABEL_BORDER 2.0
+
- (void)mouseDragged:(NSEvent *)event
{
// Ensure that we're visible wrt the event location.
@@ -442,23 +445,47 @@
[self dragPromisedFilesOfTypes: fileType fromRect: rect source: self slideBack: YES event: event];
}
else if (linkURL) {
+ BOOL drawURLString = YES;
+ BOOL clipURLString = NO;
+
_private->draggedURL = linkURL;
NSString *label = [element objectForKey: WebContextMenuElementLinkLabelKey];
+ NSString *urlString = [linkURL absoluteString];
+
+ if (!label){
+ drawURLString = NO;
+ label = urlString;
+ }
- if (!label)
- label = [linkURL absoluteString];
-
- NSFont *dragImageFont = [NSFont systemFontOfSize: 12.0];
- NSDictionary *dragImageAttributes = [NSDictionary dictionaryWithObject:dragImageFont forKey: NSFontAttributeName];
- NSSize imageSize = [label sizeWithAttributes: dragImageAttributes];
- imageSize.width += 4.0;
- imageSize.height += 4.0;
+ NSFont *labelFont = [NSFont systemFontOfSize: 12.0];
+ NSFont *urlFont = [NSFont systemFontOfSize: 8.0];
+ NSDictionary *labelAttributes = [NSDictionary dictionaryWithObject:labelFont forKey: NSFontAttributeName];
+ NSDictionary *urlAttributes = [NSDictionary dictionaryWithObject:urlFont forKey: NSFontAttributeName];
+ NSSize labelSize = [label sizeWithAttributes: labelAttributes];
+ NSSize imageSize, urlStringSize;
+ imageSize.width += labelSize.width + DRAG_LABEL_BORDER*2;
+ imageSize.height += labelSize.height + DRAG_LABEL_BORDER*2;
+ if (drawURLString){
+ urlStringSize = [urlString sizeWithAttributes: urlAttributes];
+ imageSize.height += urlStringSize.height;
+ // Clip the url string to 2.5 times the width of the label.
+ if (urlStringSize.width > 2.5 * labelSize.width){
+ imageSize.width = (labelSize.width*2.5)+DRAG_LABEL_BORDER*2;
+ clipURLString = YES;
+ }
+ else
+ imageSize.width = MAX(labelSize.width+DRAG_LABEL_BORDER*2,urlStringSize.width+DRAG_LABEL_BORDER*2);
+ }
NSImage *dragImage = [[[NSImage alloc] initWithSize: imageSize] autorelease];
[dragImage lockFocus];
- [[NSColor colorWithCalibratedRed: 0.25 green: 0.25 blue: 0.75 alpha: 0.5] set];
+ [[NSColor colorWithCalibratedRed: 0.75 green: 0.75 blue: 1.0 alpha: 0.75] set];
[NSBezierPath fillRect:NSMakeRect(0, 0, imageSize.width, imageSize.height)];
- [label drawAtPoint: NSMakePoint (2.0,2.0) withAttributes: dragImageAttributes];
+ if (drawURLString){
+ urlString = [WebStringTruncator rightTruncateString: urlString toWidth: imageSize.width-2.0 withFont: urlFont];
+ [urlString drawAtPoint: NSMakePoint (DRAG_LABEL_BORDER,DRAG_LABEL_BORDER) withAttributes: urlAttributes];
+ }
+ [label drawAtPoint: NSMakePoint (DRAG_LABEL_BORDER,DRAG_LABEL_BORDER+urlStringSize.height) withAttributes: labelAttributes];
[dragImage unlockFocus];
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list